babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. */
  1129. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1130. /**
  1131. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1132. * @param data contains the texture data
  1133. * @param texture defines the BabylonJS internal texture
  1134. * @param callback defines the method to call once ready to upload
  1135. */
  1136. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/IPipelineContext" {
  1140. /**
  1141. * Class used to store and describe the pipeline context associated with an effect
  1142. */
  1143. export interface IPipelineContext {
  1144. /**
  1145. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1146. */
  1147. isAsync: boolean;
  1148. /**
  1149. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1150. */
  1151. isReady: boolean;
  1152. /** @hidden */
  1153. _getVertexShaderCode(): string | null;
  1154. /** @hidden */
  1155. _getFragmentShaderCode(): string | null;
  1156. /** @hidden */
  1157. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1158. }
  1159. }
  1160. declare module "babylonjs/Meshes/dataBuffer" {
  1161. /**
  1162. * Class used to store gfx data (like WebGLBuffer)
  1163. */
  1164. export class DataBuffer {
  1165. /**
  1166. * Gets or sets the number of objects referencing this buffer
  1167. */
  1168. references: number;
  1169. /** Gets or sets the size of the underlying buffer */
  1170. capacity: number;
  1171. /**
  1172. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1173. */
  1174. is32Bits: boolean;
  1175. /**
  1176. * Gets the underlying buffer
  1177. */
  1178. get underlyingResource(): any;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1182. /** @hidden */
  1183. export interface IShaderProcessor {
  1184. attributeProcessor?: (attribute: string) => string;
  1185. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1186. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1187. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1188. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1189. lineProcessor?: (line: string, isFragment: boolean) => string;
  1190. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1191. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1195. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1196. /** @hidden */
  1197. export interface ProcessingOptions {
  1198. defines: string[];
  1199. indexParameters: any;
  1200. isFragment: boolean;
  1201. shouldUseHighPrecisionShader: boolean;
  1202. supportsUniformBuffers: boolean;
  1203. shadersRepository: string;
  1204. includesShadersStore: {
  1205. [key: string]: string;
  1206. };
  1207. processor?: IShaderProcessor;
  1208. version: string;
  1209. platformName: string;
  1210. lookForClosingBracketForUniformBuffer?: boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1214. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1215. /** @hidden */
  1216. export class ShaderCodeNode {
  1217. line: string;
  1218. children: ShaderCodeNode[];
  1219. additionalDefineKey?: string;
  1220. additionalDefineValue?: string;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1230. /** @hidden */
  1231. export class ShaderCodeCursor {
  1232. private _lines;
  1233. lineIndex: number;
  1234. get currentLine(): string;
  1235. get canRead(): boolean;
  1236. set lines(value: string[]);
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1240. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1241. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1242. /** @hidden */
  1243. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1244. process(preprocessors: {
  1245. [key: string]: string;
  1246. }, options: ProcessingOptions): string;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1250. /** @hidden */
  1251. export class ShaderDefineExpression {
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. private static _OperatorPriority;
  1256. private static _Stack;
  1257. static postfixToInfix(postfix: string[]): string;
  1258. static infixToPostfix(infix: string): string[];
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1262. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderCodeTestNode extends ShaderCodeNode {
  1266. testExpression: ShaderDefineExpression;
  1267. isValid(preprocessors: {
  1268. [key: string]: string;
  1269. }): boolean;
  1270. }
  1271. }
  1272. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1273. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1274. /** @hidden */
  1275. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1276. define: string;
  1277. not: boolean;
  1278. constructor(define: string, not?: boolean);
  1279. isTrue(preprocessors: {
  1280. [key: string]: string;
  1281. }): boolean;
  1282. }
  1283. }
  1284. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1285. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1286. /** @hidden */
  1287. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1288. leftOperand: ShaderDefineExpression;
  1289. rightOperand: ShaderDefineExpression;
  1290. isTrue(preprocessors: {
  1291. [key: string]: string;
  1292. }): boolean;
  1293. }
  1294. }
  1295. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1296. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1297. /** @hidden */
  1298. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1299. leftOperand: ShaderDefineExpression;
  1300. rightOperand: ShaderDefineExpression;
  1301. isTrue(preprocessors: {
  1302. [key: string]: string;
  1303. }): boolean;
  1304. }
  1305. }
  1306. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1307. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1308. /** @hidden */
  1309. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1310. define: string;
  1311. operand: string;
  1312. testValue: string;
  1313. constructor(define: string, operand: string, testValue: string);
  1314. isTrue(preprocessors: {
  1315. [key: string]: string;
  1316. }): boolean;
  1317. }
  1318. }
  1319. declare module "babylonjs/Offline/IOfflineProvider" {
  1320. /**
  1321. * Class used to enable access to offline support
  1322. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1323. */
  1324. export interface IOfflineProvider {
  1325. /**
  1326. * Gets a boolean indicating if scene must be saved in the database
  1327. */
  1328. enableSceneOffline: boolean;
  1329. /**
  1330. * Gets a boolean indicating if textures must be saved in the database
  1331. */
  1332. enableTexturesOffline: boolean;
  1333. /**
  1334. * Open the offline support and make it available
  1335. * @param successCallback defines the callback to call on success
  1336. * @param errorCallback defines the callback to call on error
  1337. */
  1338. open(successCallback: () => void, errorCallback: () => void): void;
  1339. /**
  1340. * Loads an image from the offline support
  1341. * @param url defines the url to load from
  1342. * @param image defines the target DOM image
  1343. */
  1344. loadImage(url: string, image: HTMLImageElement): void;
  1345. /**
  1346. * Loads a file from offline support
  1347. * @param url defines the URL to load from
  1348. * @param sceneLoaded defines a callback to call on success
  1349. * @param progressCallBack defines a callback to call when progress changed
  1350. * @param errorCallback defines a callback to call on error
  1351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1352. */
  1353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/filesInputStore" {
  1357. /**
  1358. * Class used to help managing file picking and drag'n'drop
  1359. * File Storage
  1360. */
  1361. export class FilesInputStore {
  1362. /**
  1363. * List of files ready to be loaded
  1364. */
  1365. static FilesToLoad: {
  1366. [key: string]: File;
  1367. };
  1368. }
  1369. }
  1370. declare module "babylonjs/Misc/retryStrategy" {
  1371. import { WebRequest } from "babylonjs/Misc/webRequest";
  1372. /**
  1373. * Class used to define a retry strategy when error happens while loading assets
  1374. */
  1375. export class RetryStrategy {
  1376. /**
  1377. * Function used to defines an exponential back off strategy
  1378. * @param maxRetries defines the maximum number of retries (3 by default)
  1379. * @param baseInterval defines the interval between retries
  1380. * @returns the strategy function to use
  1381. */
  1382. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1383. }
  1384. }
  1385. declare module "babylonjs/Misc/baseError" {
  1386. /**
  1387. * @ignore
  1388. * Application error to support additional information when loading a file
  1389. */
  1390. export abstract class BaseError extends Error {
  1391. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1392. }
  1393. }
  1394. declare module "babylonjs/Misc/fileTools" {
  1395. import { WebRequest } from "babylonjs/Misc/webRequest";
  1396. import { Nullable } from "babylonjs/types";
  1397. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1398. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1399. import { BaseError } from "babylonjs/Misc/baseError";
  1400. /** @ignore */
  1401. export class LoadFileError extends BaseError {
  1402. request?: WebRequest;
  1403. file?: File;
  1404. /**
  1405. * Creates a new LoadFileError
  1406. * @param message defines the message of the error
  1407. * @param request defines the optional web request
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, object?: WebRequest | File);
  1411. }
  1412. /** @ignore */
  1413. export class RequestFileError extends BaseError {
  1414. request: WebRequest;
  1415. /**
  1416. * Creates a new LoadFileError
  1417. * @param message defines the message of the error
  1418. * @param request defines the optional web request
  1419. */
  1420. constructor(message: string, request: WebRequest);
  1421. }
  1422. /** @ignore */
  1423. export class ReadFileError extends BaseError {
  1424. file: File;
  1425. /**
  1426. * Creates a new ReadFileError
  1427. * @param message defines the message of the error
  1428. * @param file defines the optional file
  1429. */
  1430. constructor(message: string, file: File);
  1431. }
  1432. /**
  1433. * @hidden
  1434. */
  1435. export class FileTools {
  1436. /**
  1437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1438. */
  1439. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1440. /**
  1441. * Gets or sets the base URL to use to load assets
  1442. */
  1443. static BaseUrl: string;
  1444. /**
  1445. * Default behaviour for cors in the application.
  1446. * It can be a string if the expected behavior is identical in the entire app.
  1447. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1448. */
  1449. static CorsBehavior: string | ((url: string | string[]) => string);
  1450. /**
  1451. * Gets or sets a function used to pre-process url before using them to load assets
  1452. */
  1453. static PreprocessUrl: (url: string) => string;
  1454. /**
  1455. * Removes unwanted characters from an url
  1456. * @param url defines the url to clean
  1457. * @returns the cleaned url
  1458. */
  1459. private static _CleanUrl;
  1460. /**
  1461. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1462. * @param url define the url we are trying
  1463. * @param element define the dom element where to configure the cors policy
  1464. */
  1465. static SetCorsBehavior(url: string | string[], element: {
  1466. crossOrigin: string | null;
  1467. }): void;
  1468. /**
  1469. * Loads an image as an HTMLImageElement.
  1470. * @param input url string, ArrayBuffer, or Blob to load
  1471. * @param onLoad callback called when the image successfully loads
  1472. * @param onError callback called when the image fails to load
  1473. * @param offlineProvider offline provider for caching
  1474. * @param mimeType optional mime type
  1475. * @returns the HTMLImageElement of the loaded image
  1476. */
  1477. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1478. /**
  1479. * Reads a file from a File object
  1480. * @param file defines the file to load
  1481. * @param onSuccess defines the callback to call when data is loaded
  1482. * @param onProgress defines the callback to call during loading process
  1483. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1484. * @param onError defines the callback to call when an error occurs
  1485. * @returns a file request object
  1486. */
  1487. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1488. /**
  1489. * Loads a file from a url
  1490. * @param url url to load
  1491. * @param onSuccess callback called when the file successfully loads
  1492. * @param onProgress callback called while file is loading (if the server supports this mode)
  1493. * @param offlineProvider defines the offline provider for caching
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @returns a file request object
  1497. */
  1498. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1499. /**
  1500. * Loads a file
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1505. * @param onError callback called when the file fails to load
  1506. * @param onOpened callback called when the web request is opened
  1507. * @returns a file request object
  1508. */
  1509. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1510. /**
  1511. * Checks if the loaded document was accessed via `file:`-Protocol.
  1512. * @returns boolean
  1513. */
  1514. static IsFileURL(): boolean;
  1515. }
  1516. }
  1517. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1518. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1519. import { WebRequest } from "babylonjs/Misc/webRequest";
  1520. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1521. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1522. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1523. /** @hidden */
  1524. export class ShaderProcessor {
  1525. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1526. private static _ProcessPrecision;
  1527. private static _ExtractOperation;
  1528. private static _BuildSubExpression;
  1529. private static _BuildExpression;
  1530. private static _MoveCursorWithinIf;
  1531. private static _MoveCursor;
  1532. private static _EvaluatePreProcessors;
  1533. private static _PreparePreProcessors;
  1534. private static _ProcessShaderConversion;
  1535. private static _ProcessIncludes;
  1536. /**
  1537. * Loads a file from a url
  1538. * @param url url to load
  1539. * @param onSuccess callback called when the file successfully loads
  1540. * @param onProgress callback called while file is loading (if the server supports this mode)
  1541. * @param offlineProvider defines the offline provider for caching
  1542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1543. * @param onError callback called when the file fails to load
  1544. * @returns a file request object
  1545. * @hidden
  1546. */
  1547. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1548. }
  1549. }
  1550. declare module "babylonjs/Maths/math.like" {
  1551. import { float, int, DeepImmutable } from "babylonjs/types";
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IColor4Like {
  1556. r: float;
  1557. g: float;
  1558. b: float;
  1559. a: float;
  1560. }
  1561. /**
  1562. * @hidden
  1563. */
  1564. export interface IColor3Like {
  1565. r: float;
  1566. g: float;
  1567. b: float;
  1568. }
  1569. /**
  1570. * @hidden
  1571. */
  1572. export interface IVector4Like {
  1573. x: float;
  1574. y: float;
  1575. z: float;
  1576. w: float;
  1577. }
  1578. /**
  1579. * @hidden
  1580. */
  1581. export interface IVector3Like {
  1582. x: float;
  1583. y: float;
  1584. z: float;
  1585. }
  1586. /**
  1587. * @hidden
  1588. */
  1589. export interface IVector2Like {
  1590. x: float;
  1591. y: float;
  1592. }
  1593. /**
  1594. * @hidden
  1595. */
  1596. export interface IMatrixLike {
  1597. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1598. updateFlag: int;
  1599. }
  1600. /**
  1601. * @hidden
  1602. */
  1603. export interface IViewportLike {
  1604. x: float;
  1605. y: float;
  1606. width: float;
  1607. height: float;
  1608. }
  1609. /**
  1610. * @hidden
  1611. */
  1612. export interface IPlaneLike {
  1613. normal: IVector3Like;
  1614. d: float;
  1615. normalize(): void;
  1616. }
  1617. }
  1618. declare module "babylonjs/Materials/iEffectFallbacks" {
  1619. import { Effect } from "babylonjs/Materials/effect";
  1620. /**
  1621. * Interface used to define common properties for effect fallbacks
  1622. */
  1623. export interface IEffectFallbacks {
  1624. /**
  1625. * Removes the defines that should be removed when falling back.
  1626. * @param currentDefines defines the current define statements for the shader.
  1627. * @param effect defines the current effect we try to compile
  1628. * @returns The resulting defines with defines of the current rank removed.
  1629. */
  1630. reduce(currentDefines: string, effect: Effect): string;
  1631. /**
  1632. * Removes the fallback from the bound mesh.
  1633. */
  1634. unBindMesh(): void;
  1635. /**
  1636. * Checks to see if more fallbacks are still availible.
  1637. */
  1638. hasMoreFallbacks: boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1642. /**
  1643. * Class used to evalaute queries containing `and` and `or` operators
  1644. */
  1645. export class AndOrNotEvaluator {
  1646. /**
  1647. * Evaluate a query
  1648. * @param query defines the query to evaluate
  1649. * @param evaluateCallback defines the callback used to filter result
  1650. * @returns true if the query matches
  1651. */
  1652. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1653. private static _HandleParenthesisContent;
  1654. private static _SimplifyNegation;
  1655. }
  1656. }
  1657. declare module "babylonjs/Misc/tags" {
  1658. /**
  1659. * Class used to store custom tags
  1660. */
  1661. export class Tags {
  1662. /**
  1663. * Adds support for tags on the given object
  1664. * @param obj defines the object to use
  1665. */
  1666. static EnableFor(obj: any): void;
  1667. /**
  1668. * Removes tags support
  1669. * @param obj defines the object to use
  1670. */
  1671. static DisableFor(obj: any): void;
  1672. /**
  1673. * Gets a boolean indicating if the given object has tags
  1674. * @param obj defines the object to use
  1675. * @returns a boolean
  1676. */
  1677. static HasTags(obj: any): boolean;
  1678. /**
  1679. * Gets the tags available on a given object
  1680. * @param obj defines the object to use
  1681. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1682. * @returns the tags
  1683. */
  1684. static GetTags(obj: any, asString?: boolean): any;
  1685. /**
  1686. * Adds tags to an object
  1687. * @param obj defines the object to use
  1688. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1689. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1690. */
  1691. static AddTagsTo(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _AddTagTo(obj: any, tag: string): void;
  1696. /**
  1697. * Removes specific tags from a specific object
  1698. * @param obj defines the object to use
  1699. * @param tagsString defines the tags to remove
  1700. */
  1701. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1702. /**
  1703. * @hidden
  1704. */
  1705. static _RemoveTagFrom(obj: any, tag: string): void;
  1706. /**
  1707. * Defines if tags hosted on an object match a given query
  1708. * @param obj defines the object to use
  1709. * @param tagsQuery defines the tag query
  1710. * @returns a boolean
  1711. */
  1712. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1713. }
  1714. }
  1715. declare module "babylonjs/Maths/math.scalar" {
  1716. /**
  1717. * Scalar computation library
  1718. */
  1719. export class Scalar {
  1720. /**
  1721. * Two pi constants convenient for computation.
  1722. */
  1723. static TwoPi: number;
  1724. /**
  1725. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1726. * @param a number
  1727. * @param b number
  1728. * @param epsilon (default = 1.401298E-45)
  1729. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. */
  1731. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1732. /**
  1733. * Returns a string : the upper case translation of the number i to hexadecimal.
  1734. * @param i number
  1735. * @returns the upper case translation of the number i to hexadecimal.
  1736. */
  1737. static ToHex(i: number): string;
  1738. /**
  1739. * Returns -1 if value is negative and +1 is value is positive.
  1740. * @param value the value
  1741. * @returns the value itself if it's equal to zero.
  1742. */
  1743. static Sign(value: number): number;
  1744. /**
  1745. * Returns the value itself if it's between min and max.
  1746. * Returns min if the value is lower than min.
  1747. * Returns max if the value is greater than max.
  1748. * @param value the value to clmap
  1749. * @param min the min value to clamp to (default: 0)
  1750. * @param max the max value to clamp to (default: 1)
  1751. * @returns the clamped value
  1752. */
  1753. static Clamp(value: number, min?: number, max?: number): number;
  1754. /**
  1755. * the log2 of value.
  1756. * @param value the value to compute log2 of
  1757. * @returns the log2 of value.
  1758. */
  1759. static Log2(value: number): number;
  1760. /**
  1761. * Loops the value, so that it is never larger than length and never smaller than 0.
  1762. *
  1763. * This is similar to the modulo operator but it works with floating point numbers.
  1764. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1765. * With t = 5 and length = 2.5, the result would be 0.0.
  1766. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1767. * @param value the value
  1768. * @param length the length
  1769. * @returns the looped value
  1770. */
  1771. static Repeat(value: number, length: number): number;
  1772. /**
  1773. * Normalize the value between 0.0 and 1.0 using min and max values
  1774. * @param value value to normalize
  1775. * @param min max to normalize between
  1776. * @param max min to normalize between
  1777. * @returns the normalized value
  1778. */
  1779. static Normalize(value: number, min: number, max: number): number;
  1780. /**
  1781. * Denormalize the value from 0.0 and 1.0 using min and max values
  1782. * @param normalized value to denormalize
  1783. * @param min max to denormalize between
  1784. * @param max min to denormalize between
  1785. * @returns the denormalized value
  1786. */
  1787. static Denormalize(normalized: number, min: number, max: number): number;
  1788. /**
  1789. * Calculates the shortest difference between two given angles given in degrees.
  1790. * @param current current angle in degrees
  1791. * @param target target angle in degrees
  1792. * @returns the delta
  1793. */
  1794. static DeltaAngle(current: number, target: number): number;
  1795. /**
  1796. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1797. * @param tx value
  1798. * @param length length
  1799. * @returns The returned value will move back and forth between 0 and length
  1800. */
  1801. static PingPong(tx: number, length: number): number;
  1802. /**
  1803. * Interpolates between min and max with smoothing at the limits.
  1804. *
  1805. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1806. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1807. * @param from from
  1808. * @param to to
  1809. * @param tx value
  1810. * @returns the smooth stepped value
  1811. */
  1812. static SmoothStep(from: number, to: number, tx: number): number;
  1813. /**
  1814. * Moves a value current towards target.
  1815. *
  1816. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1817. * Negative values of maxDelta pushes the value away from target.
  1818. * @param current current value
  1819. * @param target target value
  1820. * @param maxDelta max distance to move
  1821. * @returns resulting value
  1822. */
  1823. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1824. /**
  1825. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1826. *
  1827. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1828. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1829. * @param current current value
  1830. * @param target target value
  1831. * @param maxDelta max distance to move
  1832. * @returns resulting angle
  1833. */
  1834. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1835. /**
  1836. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1837. * @param start start value
  1838. * @param end target value
  1839. * @param amount amount to lerp between
  1840. * @returns the lerped value
  1841. */
  1842. static Lerp(start: number, end: number, amount: number): number;
  1843. /**
  1844. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1845. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1846. * @param start start value
  1847. * @param end target value
  1848. * @param amount amount to lerp between
  1849. * @returns the lerped value
  1850. */
  1851. static LerpAngle(start: number, end: number, amount: number): number;
  1852. /**
  1853. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1854. * @param a start value
  1855. * @param b target value
  1856. * @param value value between a and b
  1857. * @returns the inverseLerp value
  1858. */
  1859. static InverseLerp(a: number, b: number, value: number): number;
  1860. /**
  1861. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1862. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1863. * @param value1 spline value
  1864. * @param tangent1 spline value
  1865. * @param value2 spline value
  1866. * @param tangent2 spline value
  1867. * @param amount input value
  1868. * @returns hermite result
  1869. */
  1870. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1871. /**
  1872. * Returns a random float number between and min and max values
  1873. * @param min min value of random
  1874. * @param max max value of random
  1875. * @returns random value
  1876. */
  1877. static RandomRange(min: number, max: number): number;
  1878. /**
  1879. * This function returns percentage of a number in a given range.
  1880. *
  1881. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1882. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1883. * @param number to convert to percentage
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the percentage
  1887. */
  1888. static RangeToPercent(number: number, min: number, max: number): number;
  1889. /**
  1890. * This function returns number that corresponds to the percentage in a given range.
  1891. *
  1892. * PercentToRange(0.34,0,100) will return 34.
  1893. * @param percent to convert to number
  1894. * @param min min range
  1895. * @param max max range
  1896. * @returns the number
  1897. */
  1898. static PercentToRange(percent: number, min: number, max: number): number;
  1899. /**
  1900. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1901. * @param angle The angle to normalize in radian.
  1902. * @return The converted angle.
  1903. */
  1904. static NormalizeRadians(angle: number): number;
  1905. }
  1906. }
  1907. declare module "babylonjs/Maths/math.constants" {
  1908. /**
  1909. * Constant used to convert a value to gamma space
  1910. * @ignorenaming
  1911. */
  1912. export const ToGammaSpace: number;
  1913. /**
  1914. * Constant used to convert a value to linear space
  1915. * @ignorenaming
  1916. */
  1917. export const ToLinearSpace = 2.2;
  1918. /**
  1919. * Constant used to define the minimal number value in Babylon.js
  1920. * @ignorenaming
  1921. */
  1922. let Epsilon: number;
  1923. export { Epsilon };
  1924. }
  1925. declare module "babylonjs/Maths/math.viewport" {
  1926. /**
  1927. * Class used to represent a viewport on screen
  1928. */
  1929. export class Viewport {
  1930. /** viewport left coordinate */
  1931. x: number;
  1932. /** viewport top coordinate */
  1933. y: number;
  1934. /**viewport width */
  1935. width: number;
  1936. /** viewport height */
  1937. height: number;
  1938. /**
  1939. * Creates a Viewport object located at (x, y) and sized (width, height)
  1940. * @param x defines viewport left coordinate
  1941. * @param y defines viewport top coordinate
  1942. * @param width defines the viewport width
  1943. * @param height defines the viewport height
  1944. */
  1945. constructor(
  1946. /** viewport left coordinate */
  1947. x: number,
  1948. /** viewport top coordinate */
  1949. y: number,
  1950. /**viewport width */
  1951. width: number,
  1952. /** viewport height */
  1953. height: number);
  1954. /**
  1955. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1956. * @param renderWidth defines the rendering width
  1957. * @param renderHeight defines the rendering height
  1958. * @returns a new Viewport
  1959. */
  1960. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1961. /**
  1962. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1963. * @param renderWidth defines the rendering width
  1964. * @param renderHeight defines the rendering height
  1965. * @param ref defines the target viewport
  1966. * @returns the current viewport
  1967. */
  1968. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1969. /**
  1970. * Returns a new Viewport copied from the current one
  1971. * @returns a new Viewport
  1972. */
  1973. clone(): Viewport;
  1974. }
  1975. }
  1976. declare module "babylonjs/Misc/arrayTools" {
  1977. /**
  1978. * Class containing a set of static utilities functions for arrays.
  1979. */
  1980. export class ArrayTools {
  1981. /**
  1982. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1983. * @param size the number of element to construct and put in the array
  1984. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1985. * @returns a new array filled with new objects
  1986. */
  1987. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1988. }
  1989. }
  1990. declare module "babylonjs/Maths/math.plane" {
  1991. import { DeepImmutable } from "babylonjs/types";
  1992. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1993. /**
  1994. * Represents a plane by the equation ax + by + cz + d = 0
  1995. */
  1996. export class Plane {
  1997. private static _TmpMatrix;
  1998. /**
  1999. * Normal of the plane (a,b,c)
  2000. */
  2001. normal: Vector3;
  2002. /**
  2003. * d component of the plane
  2004. */
  2005. d: number;
  2006. /**
  2007. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2008. * @param a a component of the plane
  2009. * @param b b component of the plane
  2010. * @param c c component of the plane
  2011. * @param d d component of the plane
  2012. */
  2013. constructor(a: number, b: number, c: number, d: number);
  2014. /**
  2015. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2016. */
  2017. asArray(): number[];
  2018. /**
  2019. * @returns a new plane copied from the current Plane.
  2020. */
  2021. clone(): Plane;
  2022. /**
  2023. * @returns the string "Plane".
  2024. */
  2025. getClassName(): string;
  2026. /**
  2027. * @returns the Plane hash code.
  2028. */
  2029. getHashCode(): number;
  2030. /**
  2031. * Normalize the current Plane in place.
  2032. * @returns the updated Plane.
  2033. */
  2034. normalize(): Plane;
  2035. /**
  2036. * Applies a transformation the plane and returns the result
  2037. * @param transformation the transformation matrix to be applied to the plane
  2038. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2039. */
  2040. transform(transformation: DeepImmutable<Matrix>): Plane;
  2041. /**
  2042. * Compute the dot product between the point and the plane normal
  2043. * @param point point to calculate the dot product with
  2044. * @returns the dot product (float) of the point coordinates and the plane normal.
  2045. */
  2046. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2047. /**
  2048. * Updates the current Plane from the plane defined by the three given points.
  2049. * @param point1 one of the points used to contruct the plane
  2050. * @param point2 one of the points used to contruct the plane
  2051. * @param point3 one of the points used to contruct the plane
  2052. * @returns the updated Plane.
  2053. */
  2054. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2055. /**
  2056. * Checks if the plane is facing a given direction
  2057. * @param direction the direction to check if the plane is facing
  2058. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2059. * @returns True is the vector "direction" is the same side than the plane normal.
  2060. */
  2061. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2062. /**
  2063. * Calculates the distance to a point
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance (float) from the given point to the Plane.
  2066. */
  2067. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2068. /**
  2069. * Creates a plane from an array
  2070. * @param array the array to create a plane from
  2071. * @returns a new Plane from the given array.
  2072. */
  2073. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2074. /**
  2075. * Creates a plane from three points
  2076. * @param point1 point used to create the plane
  2077. * @param point2 point used to create the plane
  2078. * @param point3 point used to create the plane
  2079. * @returns a new Plane defined by the three given points.
  2080. */
  2081. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2082. /**
  2083. * Creates a plane from an origin point and a normal
  2084. * @param origin origin of the plane to be constructed
  2085. * @param normal normal of the plane to be constructed
  2086. * @returns a new Plane the normal vector to this plane at the given origin point.
  2087. * Note : the vector "normal" is updated because normalized.
  2088. */
  2089. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2090. /**
  2091. * Calculates the distance from a plane and a point
  2092. * @param origin origin of the plane to be constructed
  2093. * @param normal normal of the plane to be constructed
  2094. * @param point point to calculate distance to
  2095. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2096. */
  2097. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2098. }
  2099. }
  2100. declare module "babylonjs/Engines/performanceConfigurator" {
  2101. /** @hidden */
  2102. export class PerformanceConfigurator {
  2103. /** @hidden */
  2104. static MatrixUse64Bits: boolean;
  2105. /** @hidden */
  2106. static MatrixTrackPrecisionChange: boolean;
  2107. /** @hidden */
  2108. static MatrixCurrentType: any;
  2109. /** @hidden */
  2110. static MatrixTrackedMatrices: Array<any> | null;
  2111. /** @hidden */
  2112. static SetMatrixPrecision(use64bits: boolean): void;
  2113. }
  2114. }
  2115. declare module "babylonjs/Maths/math.vector" {
  2116. import { Viewport } from "babylonjs/Maths/math.viewport";
  2117. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2118. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2119. import { Plane } from "babylonjs/Maths/math.plane";
  2120. /**
  2121. * Class representing a vector containing 2 coordinates
  2122. */
  2123. export class Vector2 {
  2124. /** defines the first coordinate */
  2125. x: number;
  2126. /** defines the second coordinate */
  2127. y: number;
  2128. /**
  2129. * Creates a new Vector2 from the given x and y coordinates
  2130. * @param x defines the first coordinate
  2131. * @param y defines the second coordinate
  2132. */
  2133. constructor(
  2134. /** defines the first coordinate */
  2135. x?: number,
  2136. /** defines the second coordinate */
  2137. y?: number);
  2138. /**
  2139. * Gets a string with the Vector2 coordinates
  2140. * @returns a string with the Vector2 coordinates
  2141. */
  2142. toString(): string;
  2143. /**
  2144. * Gets class name
  2145. * @returns the string "Vector2"
  2146. */
  2147. getClassName(): string;
  2148. /**
  2149. * Gets current vector hash code
  2150. * @returns the Vector2 hash code as a number
  2151. */
  2152. getHashCode(): number;
  2153. /**
  2154. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2155. * @param array defines the source array
  2156. * @param index defines the offset in source array
  2157. * @returns the current Vector2
  2158. */
  2159. toArray(array: FloatArray, index?: number): Vector2;
  2160. /**
  2161. * Update the current vector from an array
  2162. * @param array defines the destination array
  2163. * @param index defines the offset in the destination array
  2164. * @returns the current Vector3
  2165. */
  2166. fromArray(array: FloatArray, index?: number): Vector2;
  2167. /**
  2168. * Copy the current vector to an array
  2169. * @returns a new array with 2 elements: the Vector2 coordinates.
  2170. */
  2171. asArray(): number[];
  2172. /**
  2173. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2174. * @param source defines the source Vector2
  2175. * @returns the current updated Vector2
  2176. */
  2177. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2178. /**
  2179. * Sets the Vector2 coordinates with the given floats
  2180. * @param x defines the first coordinate
  2181. * @param y defines the second coordinate
  2182. * @returns the current updated Vector2
  2183. */
  2184. copyFromFloats(x: number, y: number): Vector2;
  2185. /**
  2186. * Sets the Vector2 coordinates with the given floats
  2187. * @param x defines the first coordinate
  2188. * @param y defines the second coordinate
  2189. * @returns the current updated Vector2
  2190. */
  2191. set(x: number, y: number): Vector2;
  2192. /**
  2193. * Add another vector with the current one
  2194. * @param otherVector defines the other vector
  2195. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2196. */
  2197. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2198. /**
  2199. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2200. * @param otherVector defines the other vector
  2201. * @param result defines the target vector
  2202. * @returns the unmodified current Vector2
  2203. */
  2204. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2205. /**
  2206. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns the current updated Vector2
  2209. */
  2210. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2211. /**
  2212. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. addVector3(otherVector: Vector3): Vector2;
  2217. /**
  2218. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2219. * @param otherVector defines the other vector
  2220. * @returns a new Vector2
  2221. */
  2222. subtract(otherVector: Vector2): Vector2;
  2223. /**
  2224. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2225. * @param otherVector defines the other vector
  2226. * @param result defines the target vector
  2227. * @returns the unmodified current Vector2
  2228. */
  2229. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2230. /**
  2231. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Multiplies in place the current Vector2 coordinates by the given ones
  2238. * @param otherVector defines the other vector
  2239. * @returns the current updated Vector2
  2240. */
  2241. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @returns a new Vector2
  2246. */
  2247. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2250. * @param otherVector defines the other vector
  2251. * @param result defines the target vector
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2257. * @param x defines the first coordinate
  2258. * @param y defines the second coordinate
  2259. * @returns a new Vector2
  2260. */
  2261. multiplyByFloats(x: number, y: number): Vector2;
  2262. /**
  2263. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @returns a new Vector2
  2266. */
  2267. divide(otherVector: Vector2): Vector2;
  2268. /**
  2269. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2270. * @param otherVector defines the other vector
  2271. * @param result defines the target vector
  2272. * @returns the unmodified current Vector2
  2273. */
  2274. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2275. /**
  2276. * Divides the current Vector2 coordinates by the given ones
  2277. * @param otherVector defines the other vector
  2278. * @returns the current updated Vector2
  2279. */
  2280. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2281. /**
  2282. * Gets a new Vector2 with current Vector2 negated coordinates
  2283. * @returns a new Vector2
  2284. */
  2285. negate(): Vector2;
  2286. /**
  2287. * Negate this vector in place
  2288. * @returns this
  2289. */
  2290. negateInPlace(): Vector2;
  2291. /**
  2292. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2293. * @param result defines the Vector3 object where to store the result
  2294. * @returns the current Vector2
  2295. */
  2296. negateToRef(result: Vector2): Vector2;
  2297. /**
  2298. * Multiply the Vector2 coordinates by scale
  2299. * @param scale defines the scaling factor
  2300. * @returns the current updated Vector2
  2301. */
  2302. scaleInPlace(scale: number): Vector2;
  2303. /**
  2304. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2305. * @param scale defines the scaling factor
  2306. * @returns a new Vector2
  2307. */
  2308. scale(scale: number): Vector2;
  2309. /**
  2310. * Scale the current Vector2 values by a factor to a given Vector2
  2311. * @param scale defines the scale factor
  2312. * @param result defines the Vector2 object where to store the result
  2313. * @returns the unmodified current Vector2
  2314. */
  2315. scaleToRef(scale: number, result: Vector2): Vector2;
  2316. /**
  2317. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2318. * @param scale defines the scale factor
  2319. * @param result defines the Vector2 object where to store the result
  2320. * @returns the unmodified current Vector2
  2321. */
  2322. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2323. /**
  2324. * Gets a boolean if two vectors are equals
  2325. * @param otherVector defines the other vector
  2326. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2327. */
  2328. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2329. /**
  2330. * Gets a boolean if two vectors are equals (using an epsilon value)
  2331. * @param otherVector defines the other vector
  2332. * @param epsilon defines the minimal distance to consider equality
  2333. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2334. */
  2335. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2336. /**
  2337. * Gets a new Vector2 from current Vector2 floored values
  2338. * @returns a new Vector2
  2339. */
  2340. floor(): Vector2;
  2341. /**
  2342. * Gets a new Vector2 from current Vector2 floored values
  2343. * @returns a new Vector2
  2344. */
  2345. fract(): Vector2;
  2346. /**
  2347. * Gets the length of the vector
  2348. * @returns the vector length (float)
  2349. */
  2350. length(): number;
  2351. /**
  2352. * Gets the vector squared length
  2353. * @returns the vector squared length (float)
  2354. */
  2355. lengthSquared(): number;
  2356. /**
  2357. * Normalize the vector
  2358. * @returns the current updated Vector2
  2359. */
  2360. normalize(): Vector2;
  2361. /**
  2362. * Gets a new Vector2 copied from the Vector2
  2363. * @returns a new Vector2
  2364. */
  2365. clone(): Vector2;
  2366. /**
  2367. * Gets a new Vector2(0, 0)
  2368. * @returns a new Vector2
  2369. */
  2370. static Zero(): Vector2;
  2371. /**
  2372. * Gets a new Vector2(1, 1)
  2373. * @returns a new Vector2
  2374. */
  2375. static One(): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set from the given index element of the given array
  2378. * @param array defines the data source
  2379. * @param offset defines the offset in the data source
  2380. * @returns a new Vector2
  2381. */
  2382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2383. /**
  2384. * Sets "result" from the given index element of the given array
  2385. * @param array defines the data source
  2386. * @param offset defines the offset in the data source
  2387. * @param result defines the target vector
  2388. */
  2389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2390. /**
  2391. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2392. * @param value1 defines 1st point of control
  2393. * @param value2 defines 2nd point of control
  2394. * @param value3 defines 3rd point of control
  2395. * @param value4 defines 4th point of control
  2396. * @param amount defines the interpolation factor
  2397. * @returns a new Vector2
  2398. */
  2399. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2400. /**
  2401. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2402. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2403. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2404. * @param value defines the value to clamp
  2405. * @param min defines the lower limit
  2406. * @param max defines the upper limit
  2407. * @returns a new Vector2
  2408. */
  2409. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2412. * @param value1 defines the 1st control point
  2413. * @param tangent1 defines the outgoing tangent
  2414. * @param value2 defines the 2nd control point
  2415. * @param tangent2 defines the incoming tangent
  2416. * @param amount defines the interpolation factor
  2417. * @returns a new Vector2
  2418. */
  2419. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2420. /**
  2421. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2422. * @param start defines the start vector
  2423. * @param end defines the end vector
  2424. * @param amount defines the interpolation factor
  2425. * @returns a new Vector2
  2426. */
  2427. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2428. /**
  2429. * Gets the dot product of the vector "left" and the vector "right"
  2430. * @param left defines first vector
  2431. * @param right defines second vector
  2432. * @returns the dot product (float)
  2433. */
  2434. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2435. /**
  2436. * Returns a new Vector2 equal to the normalized given vector
  2437. * @param vector defines the vector to normalize
  2438. * @returns a new Vector2
  2439. */
  2440. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2441. /**
  2442. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2443. * @param left defines 1st vector
  2444. * @param right defines 2nd vector
  2445. * @returns a new Vector2
  2446. */
  2447. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2448. /**
  2449. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2450. * @param left defines 1st vector
  2451. * @param right defines 2nd vector
  2452. * @returns a new Vector2
  2453. */
  2454. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2455. /**
  2456. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2457. * @param vector defines the vector to transform
  2458. * @param transformation defines the matrix to apply
  2459. * @returns a new Vector2
  2460. */
  2461. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2462. /**
  2463. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2464. * @param vector defines the vector to transform
  2465. * @param transformation defines the matrix to apply
  2466. * @param result defines the target vector
  2467. */
  2468. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2469. /**
  2470. * Determines if a given vector is included in a triangle
  2471. * @param p defines the vector to test
  2472. * @param p0 defines 1st triangle point
  2473. * @param p1 defines 2nd triangle point
  2474. * @param p2 defines 3rd triangle point
  2475. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2476. */
  2477. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2478. /**
  2479. * Gets the distance between the vectors "value1" and "value2"
  2480. * @param value1 defines first vector
  2481. * @param value2 defines second vector
  2482. * @returns the distance between vectors
  2483. */
  2484. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2485. /**
  2486. * Returns the squared distance between the vectors "value1" and "value2"
  2487. * @param value1 defines first vector
  2488. * @param value2 defines second vector
  2489. * @returns the squared distance between vectors
  2490. */
  2491. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2492. /**
  2493. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2494. * @param value1 defines first vector
  2495. * @param value2 defines second vector
  2496. * @returns a new Vector2
  2497. */
  2498. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2499. /**
  2500. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2501. * @param p defines the middle point
  2502. * @param segA defines one point of the segment
  2503. * @param segB defines the other point of the segment
  2504. * @returns the shortest distance
  2505. */
  2506. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2507. }
  2508. /**
  2509. * Class used to store (x,y,z) vector representation
  2510. * A Vector3 is the main object used in 3D geometry
  2511. * It can represent etiher the coordinates of a point the space, either a direction
  2512. * Reminder: js uses a left handed forward facing system
  2513. */
  2514. export class Vector3 {
  2515. private static _UpReadOnly;
  2516. private static _ZeroReadOnly;
  2517. /** @hidden */
  2518. _x: number;
  2519. /** @hidden */
  2520. _y: number;
  2521. /** @hidden */
  2522. _z: number;
  2523. /** @hidden */
  2524. _isDirty: boolean;
  2525. /** Gets or sets the x coordinate */
  2526. get x(): number;
  2527. set x(value: number);
  2528. /** Gets or sets the y coordinate */
  2529. get y(): number;
  2530. set y(value: number);
  2531. /** Gets or sets the z coordinate */
  2532. get z(): number;
  2533. set z(value: number);
  2534. /**
  2535. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2536. * @param x defines the first coordinates (on X axis)
  2537. * @param y defines the second coordinates (on Y axis)
  2538. * @param z defines the third coordinates (on Z axis)
  2539. */
  2540. constructor(x?: number, y?: number, z?: number);
  2541. /**
  2542. * Creates a string representation of the Vector3
  2543. * @returns a string with the Vector3 coordinates.
  2544. */
  2545. toString(): string;
  2546. /**
  2547. * Gets the class name
  2548. * @returns the string "Vector3"
  2549. */
  2550. getClassName(): string;
  2551. /**
  2552. * Creates the Vector3 hash code
  2553. * @returns a number which tends to be unique between Vector3 instances
  2554. */
  2555. getHashCode(): number;
  2556. /**
  2557. * Creates an array containing three elements : the coordinates of the Vector3
  2558. * @returns a new array of numbers
  2559. */
  2560. asArray(): number[];
  2561. /**
  2562. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2563. * @param array defines the destination array
  2564. * @param index defines the offset in the destination array
  2565. * @returns the current Vector3
  2566. */
  2567. toArray(array: FloatArray, index?: number): Vector3;
  2568. /**
  2569. * Update the current vector from an array
  2570. * @param array defines the destination array
  2571. * @param index defines the offset in the destination array
  2572. * @returns the current Vector3
  2573. */
  2574. fromArray(array: FloatArray, index?: number): Vector3;
  2575. /**
  2576. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2577. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2578. */
  2579. toQuaternion(): Quaternion;
  2580. /**
  2581. * Adds the given vector to the current Vector3
  2582. * @param otherVector defines the second operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2586. /**
  2587. * Adds the given coordinates to the current Vector3
  2588. * @param x defines the x coordinate of the operand
  2589. * @param y defines the y coordinate of the operand
  2590. * @param z defines the z coordinate of the operand
  2591. * @returns the current updated Vector3
  2592. */
  2593. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2594. /**
  2595. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2596. * @param otherVector defines the second operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2600. /**
  2601. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2602. * @param otherVector defines the second operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2607. /**
  2608. * Subtract the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the current updated Vector3
  2611. */
  2612. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2615. * @param otherVector defines the second operand
  2616. * @returns the resulting Vector3
  2617. */
  2618. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2619. /**
  2620. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2621. * @param otherVector defines the second operand
  2622. * @param result defines the Vector3 object where to store the result
  2623. * @returns the current Vector3
  2624. */
  2625. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2626. /**
  2627. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2628. * @param x defines the x coordinate of the operand
  2629. * @param y defines the y coordinate of the operand
  2630. * @param z defines the z coordinate of the operand
  2631. * @returns the resulting Vector3
  2632. */
  2633. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2634. /**
  2635. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the current Vector3
  2641. */
  2642. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2643. /**
  2644. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2645. * @returns a new Vector3
  2646. */
  2647. negate(): Vector3;
  2648. /**
  2649. * Negate this vector in place
  2650. * @returns this
  2651. */
  2652. negateInPlace(): Vector3;
  2653. /**
  2654. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2655. * @param result defines the Vector3 object where to store the result
  2656. * @returns the current Vector3
  2657. */
  2658. negateToRef(result: Vector3): Vector3;
  2659. /**
  2660. * Multiplies the Vector3 coordinates by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns the current updated Vector3
  2663. */
  2664. scaleInPlace(scale: number): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2667. * @param scale defines the multiplier factor
  2668. * @returns a new Vector3
  2669. */
  2670. scale(scale: number): Vector3;
  2671. /**
  2672. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2673. * @param scale defines the multiplier factor
  2674. * @param result defines the Vector3 object where to store the result
  2675. * @returns the current Vector3
  2676. */
  2677. scaleToRef(scale: number, result: Vector3): Vector3;
  2678. /**
  2679. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2680. * @param scale defines the scale factor
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the unmodified current Vector3
  2683. */
  2684. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2685. /**
  2686. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2687. * @param origin defines the origin of the projection ray
  2688. * @param plane defines the plane to project to
  2689. * @returns the projected vector3
  2690. */
  2691. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2692. /**
  2693. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2694. * @param origin defines the origin of the projection ray
  2695. * @param plane defines the plane to project to
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2701. * @param otherVector defines the second operand
  2702. * @returns true if both vectors are equals
  2703. */
  2704. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2705. /**
  2706. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2707. * @param otherVector defines the second operand
  2708. * @param epsilon defines the minimal distance to define values as equals
  2709. * @returns true if both vectors are distant less than epsilon
  2710. */
  2711. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2712. /**
  2713. * Returns true if the current Vector3 coordinates equals the given floats
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns true if both vectors are equals
  2718. */
  2719. equalsToFloats(x: number, y: number, z: number): boolean;
  2720. /**
  2721. * Multiplies the current Vector3 coordinates by the given ones
  2722. * @param otherVector defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2728. * @param otherVector defines the second operand
  2729. * @returns the new Vector3
  2730. */
  2731. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2734. * @param otherVector defines the second operand
  2735. * @param result defines the Vector3 object where to store the result
  2736. * @returns the current Vector3
  2737. */
  2738. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2741. * @param x defines the x coordinate of the operand
  2742. * @param y defines the y coordinate of the operand
  2743. * @param z defines the z coordinate of the operand
  2744. * @returns the new Vector3
  2745. */
  2746. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2749. * @param otherVector defines the second operand
  2750. * @returns the new Vector3
  2751. */
  2752. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2753. /**
  2754. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2755. * @param otherVector defines the second operand
  2756. * @param result defines the Vector3 object where to store the result
  2757. * @returns the current Vector3
  2758. */
  2759. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2760. /**
  2761. * Divides the current Vector3 coordinates by the given ones.
  2762. * @param otherVector defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. divideInPlace(otherVector: Vector3): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2774. * @param other defines the second operand
  2775. * @returns the current updated Vector3
  2776. */
  2777. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2778. /**
  2779. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2780. * @param x defines the x coordinate of the operand
  2781. * @param y defines the y coordinate of the operand
  2782. * @param z defines the z coordinate of the operand
  2783. * @returns the current updated Vector3
  2784. */
  2785. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2786. /**
  2787. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2788. * @param x defines the x coordinate of the operand
  2789. * @param y defines the y coordinate of the operand
  2790. * @param z defines the z coordinate of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2794. /**
  2795. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2796. * Check if is non uniform within a certain amount of decimal places to account for this
  2797. * @param epsilon the amount the values can differ
  2798. * @returns if the the vector is non uniform to a certain number of decimal places
  2799. */
  2800. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2801. /**
  2802. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2803. */
  2804. get isNonUniform(): boolean;
  2805. /**
  2806. * Gets a new Vector3 from current Vector3 floored values
  2807. * @returns a new Vector3
  2808. */
  2809. floor(): Vector3;
  2810. /**
  2811. * Gets a new Vector3 from current Vector3 floored values
  2812. * @returns a new Vector3
  2813. */
  2814. fract(): Vector3;
  2815. /**
  2816. * Gets the length of the Vector3
  2817. * @returns the length of the Vector3
  2818. */
  2819. length(): number;
  2820. /**
  2821. * Gets the squared length of the Vector3
  2822. * @returns squared length of the Vector3
  2823. */
  2824. lengthSquared(): number;
  2825. /**
  2826. * Normalize the current Vector3.
  2827. * Please note that this is an in place operation.
  2828. * @returns the current updated Vector3
  2829. */
  2830. normalize(): Vector3;
  2831. /**
  2832. * Reorders the x y z properties of the vector in place
  2833. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2834. * @returns the current updated vector
  2835. */
  2836. reorderInPlace(order: string): this;
  2837. /**
  2838. * Rotates the vector around 0,0,0 by a quaternion
  2839. * @param quaternion the rotation quaternion
  2840. * @param result vector to store the result
  2841. * @returns the resulting vector
  2842. */
  2843. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2844. /**
  2845. * Rotates a vector around a given point
  2846. * @param quaternion the rotation quaternion
  2847. * @param point the point to rotate around
  2848. * @param result vector to store the result
  2849. * @returns the resulting vector
  2850. */
  2851. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2852. /**
  2853. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2854. * The cross product is then orthogonal to both current and "other"
  2855. * @param other defines the right operand
  2856. * @returns the cross product
  2857. */
  2858. cross(other: Vector3): Vector3;
  2859. /**
  2860. * Normalize the current Vector3 with the given input length.
  2861. * Please note that this is an in place operation.
  2862. * @param len the length of the vector
  2863. * @returns the current updated Vector3
  2864. */
  2865. normalizeFromLength(len: number): Vector3;
  2866. /**
  2867. * Normalize the current Vector3 to a new vector
  2868. * @returns the new Vector3
  2869. */
  2870. normalizeToNew(): Vector3;
  2871. /**
  2872. * Normalize the current Vector3 to the reference
  2873. * @param reference define the Vector3 to update
  2874. * @returns the updated Vector3
  2875. */
  2876. normalizeToRef(reference: Vector3): Vector3;
  2877. /**
  2878. * Creates a new Vector3 copied from the current Vector3
  2879. * @returns the new Vector3
  2880. */
  2881. clone(): Vector3;
  2882. /**
  2883. * Copies the given vector coordinates to the current Vector3 ones
  2884. * @param source defines the source Vector3
  2885. * @returns the current updated Vector3
  2886. */
  2887. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2888. /**
  2889. * Copies the given floats to the current Vector3 coordinates
  2890. * @param x defines the x coordinate of the operand
  2891. * @param y defines the y coordinate of the operand
  2892. * @param z defines the z coordinate of the operand
  2893. * @returns the current updated Vector3
  2894. */
  2895. copyFromFloats(x: number, y: number, z: number): Vector3;
  2896. /**
  2897. * Copies the given floats to the current Vector3 coordinates
  2898. * @param x defines the x coordinate of the operand
  2899. * @param y defines the y coordinate of the operand
  2900. * @param z defines the z coordinate of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. set(x: number, y: number, z: number): Vector3;
  2904. /**
  2905. * Copies the given float to the current Vector3 coordinates
  2906. * @param v defines the x, y and z coordinates of the operand
  2907. * @returns the current updated Vector3
  2908. */
  2909. setAll(v: number): Vector3;
  2910. /**
  2911. * Get the clip factor between two vectors
  2912. * @param vector0 defines the first operand
  2913. * @param vector1 defines the second operand
  2914. * @param axis defines the axis to use
  2915. * @param size defines the size along the axis
  2916. * @returns the clip factor
  2917. */
  2918. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2919. /**
  2920. * Get angle between two vectors
  2921. * @param vector0 angle between vector0 and vector1
  2922. * @param vector1 angle between vector0 and vector1
  2923. * @param normal direction of the normal
  2924. * @return the angle between vector0 and vector1
  2925. */
  2926. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 set from the index "offset" of the given array
  2929. * @param array defines the source array
  2930. * @param offset defines the offset in the source array
  2931. * @returns the new Vector3
  2932. */
  2933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2936. * @param array defines the source array
  2937. * @param offset defines the offset in the source array
  2938. * @returns the new Vector3
  2939. * @deprecated Please use FromArray instead.
  2940. */
  2941. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2944. * @param array defines the source array
  2945. * @param offset defines the offset in the source array
  2946. * @param result defines the Vector3 where to store the result
  2947. */
  2948. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2949. /**
  2950. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2951. * @param array defines the source array
  2952. * @param offset defines the offset in the source array
  2953. * @param result defines the Vector3 where to store the result
  2954. * @deprecated Please use FromArrayToRef instead.
  2955. */
  2956. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" with the given floats.
  2959. * @param x defines the x coordinate of the source
  2960. * @param y defines the y coordinate of the source
  2961. * @param z defines the z coordinate of the source
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2967. * @returns a new empty Vector3
  2968. */
  2969. static Zero(): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2972. * @returns a new unit Vector3
  2973. */
  2974. static One(): Vector3;
  2975. /**
  2976. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2977. * @returns a new up Vector3
  2978. */
  2979. static Up(): Vector3;
  2980. /**
  2981. * Gets a up Vector3 that must not be updated
  2982. */
  2983. static get UpReadOnly(): DeepImmutable<Vector3>;
  2984. /**
  2985. * Gets a zero Vector3 that must not be updated
  2986. */
  2987. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2990. * @returns a new down Vector3
  2991. */
  2992. static Down(): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Forward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3001. * @param rightHandedSystem is the scene right-handed (negative-z)
  3002. * @returns a new forward Vector3
  3003. */
  3004. static Backward(rightHandedSystem?: boolean): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3007. * @returns a new right Vector3
  3008. */
  3009. static Right(): Vector3;
  3010. /**
  3011. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3012. * @returns a new left Vector3
  3013. */
  3014. static Left(): Vector3;
  3015. /**
  3016. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3017. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @returns the transformed Vector3
  3021. */
  3022. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3023. /**
  3024. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3025. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3026. * @param vector defines the Vector3 to transform
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3033. * This method computes tranformed coordinates only, not transformed direction vectors
  3034. * @param x define the x coordinate of the source vector
  3035. * @param y define the y coordinate of the source vector
  3036. * @param z define the z coordinate of the source vector
  3037. * @param transformation defines the transformation matrix
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3043. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3044. * @param vector defines the Vector3 to transform
  3045. * @param transformation defines the transformation matrix
  3046. * @returns the new Vector3
  3047. */
  3048. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3049. /**
  3050. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3051. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3052. * @param vector defines the Vector3 to transform
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3059. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3060. * @param x define the x coordinate of the source vector
  3061. * @param y define the y coordinate of the source vector
  3062. * @param z define the z coordinate of the source vector
  3063. * @param transformation defines the transformation matrix
  3064. * @param result defines the Vector3 where to store the result
  3065. */
  3066. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3067. /**
  3068. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3069. * @param value1 defines the first control point
  3070. * @param value2 defines the second control point
  3071. * @param value3 defines the third control point
  3072. * @param value4 defines the fourth control point
  3073. * @param amount defines the amount on the spline to use
  3074. * @returns the new Vector3
  3075. */
  3076. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3077. /**
  3078. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @returns the new Vector3
  3085. */
  3086. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3087. /**
  3088. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3089. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3090. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3091. * @param value defines the current value
  3092. * @param min defines the lower range value
  3093. * @param max defines the upper range value
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Checks if a given vector is inside a specific range
  3099. * @param v defines the vector to test
  3100. * @param min defines the minimum range
  3101. * @param max defines the maximum range
  3102. */
  3103. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3106. * @param value1 defines the first control point
  3107. * @param tangent1 defines the first tangent vector
  3108. * @param value2 defines the second control point
  3109. * @param tangent2 defines the second tangent vector
  3110. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3111. * @returns the new Vector3
  3112. */
  3113. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3114. /**
  3115. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3116. * @param start defines the start value
  3117. * @param end defines the end value
  3118. * @param amount max defines amount between both (between 0 and 1)
  3119. * @returns the new Vector3
  3120. */
  3121. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3122. /**
  3123. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3124. * @param start defines the start value
  3125. * @param end defines the end value
  3126. * @param amount max defines amount between both (between 0 and 1)
  3127. * @param result defines the Vector3 where to store the result
  3128. */
  3129. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3130. /**
  3131. * Returns the dot product (float) between the vectors "left" and "right"
  3132. * @param left defines the left operand
  3133. * @param right defines the right operand
  3134. * @returns the dot product
  3135. */
  3136. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3139. * The cross product is then orthogonal to both "left" and "right"
  3140. * @param left defines the left operand
  3141. * @param right defines the right operand
  3142. * @returns the cross product
  3143. */
  3144. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Sets the given vector "result" with the cross product of "left" and "right"
  3147. * The cross product is then orthogonal to both "left" and "right"
  3148. * @param left defines the left operand
  3149. * @param right defines the right operand
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3153. /**
  3154. * Returns a new Vector3 as the normalization of the given vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @returns the new Vector3
  3157. */
  3158. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Sets the given vector "result" with the normalization of the given first vector
  3161. * @param vector defines the Vector3 to normalize
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3165. /**
  3166. * Project a Vector3 onto screen space
  3167. * @param vector defines the Vector3 to project
  3168. * @param world defines the world matrix to use
  3169. * @param transform defines the transform (view x projection) matrix to use
  3170. * @param viewport defines the screen viewport to use
  3171. * @returns the new Vector3
  3172. */
  3173. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3174. /** @hidden */
  3175. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @returns the new Vector3
  3184. */
  3185. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3186. /**
  3187. * Unproject from screen space to object space
  3188. * @param source defines the screen space Vector3 to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @returns the new Vector3
  3195. */
  3196. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3197. /**
  3198. * Unproject from screen space to object space
  3199. * @param source defines the screen space Vector3 to use
  3200. * @param viewportWidth defines the current width of the viewport
  3201. * @param viewportHeight defines the current height of the viewport
  3202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3203. * @param view defines the view matrix to use
  3204. * @param projection defines the projection matrix to use
  3205. * @param result defines the Vector3 where to store the result
  3206. */
  3207. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3208. /**
  3209. * Unproject from screen space to object space
  3210. * @param sourceX defines the screen space x coordinate to use
  3211. * @param sourceY defines the screen space y coordinate to use
  3212. * @param sourceZ defines the screen space z coordinate to use
  3213. * @param viewportWidth defines the current width of the viewport
  3214. * @param viewportHeight defines the current height of the viewport
  3215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3216. * @param view defines the view matrix to use
  3217. * @param projection defines the projection matrix to use
  3218. * @param result defines the Vector3 where to store the result
  3219. */
  3220. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3221. /**
  3222. * Gets the minimal coordinate values between two Vector3
  3223. * @param left defines the first operand
  3224. * @param right defines the second operand
  3225. * @returns the new Vector3
  3226. */
  3227. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3228. /**
  3229. * Gets the maximal coordinate values between two Vector3
  3230. * @param left defines the first operand
  3231. * @param right defines the second operand
  3232. * @returns the new Vector3
  3233. */
  3234. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3235. /**
  3236. * Returns the distance between the vectors "value1" and "value2"
  3237. * @param value1 defines the first operand
  3238. * @param value2 defines the second operand
  3239. * @returns the distance
  3240. */
  3241. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3242. /**
  3243. * Returns the squared distance between the vectors "value1" and "value2"
  3244. * @param value1 defines the first operand
  3245. * @param value2 defines the second operand
  3246. * @returns the squared distance
  3247. */
  3248. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3249. /**
  3250. * Returns a new Vector3 located at the center between "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the new Vector3
  3254. */
  3255. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3256. /**
  3257. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3258. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3259. * to something in order to rotate it from its local system to the given target system
  3260. * Note: axis1, axis2 and axis3 are normalized during this operation
  3261. * @param axis1 defines the first axis
  3262. * @param axis2 defines the second axis
  3263. * @param axis3 defines the third axis
  3264. * @returns a new Vector3
  3265. */
  3266. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3267. /**
  3268. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3269. * @param axis1 defines the first axis
  3270. * @param axis2 defines the second axis
  3271. * @param axis3 defines the third axis
  3272. * @param ref defines the Vector3 where to store the result
  3273. */
  3274. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3275. }
  3276. /**
  3277. * Vector4 class created for EulerAngle class conversion to Quaternion
  3278. */
  3279. export class Vector4 {
  3280. /** x value of the vector */
  3281. x: number;
  3282. /** y value of the vector */
  3283. y: number;
  3284. /** z value of the vector */
  3285. z: number;
  3286. /** w value of the vector */
  3287. w: number;
  3288. /**
  3289. * Creates a Vector4 object from the given floats.
  3290. * @param x x value of the vector
  3291. * @param y y value of the vector
  3292. * @param z z value of the vector
  3293. * @param w w value of the vector
  3294. */
  3295. constructor(
  3296. /** x value of the vector */
  3297. x: number,
  3298. /** y value of the vector */
  3299. y: number,
  3300. /** z value of the vector */
  3301. z: number,
  3302. /** w value of the vector */
  3303. w: number);
  3304. /**
  3305. * Returns the string with the Vector4 coordinates.
  3306. * @returns a string containing all the vector values
  3307. */
  3308. toString(): string;
  3309. /**
  3310. * Returns the string "Vector4".
  3311. * @returns "Vector4"
  3312. */
  3313. getClassName(): string;
  3314. /**
  3315. * Returns the Vector4 hash code.
  3316. * @returns a unique hash code
  3317. */
  3318. getHashCode(): number;
  3319. /**
  3320. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3321. * @returns the resulting array
  3322. */
  3323. asArray(): number[];
  3324. /**
  3325. * Populates the given array from the given index with the Vector4 coordinates.
  3326. * @param array array to populate
  3327. * @param index index of the array to start at (default: 0)
  3328. * @returns the Vector4.
  3329. */
  3330. toArray(array: FloatArray, index?: number): Vector4;
  3331. /**
  3332. * Update the current vector from an array
  3333. * @param array defines the destination array
  3334. * @param index defines the offset in the destination array
  3335. * @returns the current Vector3
  3336. */
  3337. fromArray(array: FloatArray, index?: number): Vector4;
  3338. /**
  3339. * Adds the given vector to the current Vector4.
  3340. * @param otherVector the vector to add
  3341. * @returns the updated Vector4.
  3342. */
  3343. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @returns the resulting vector
  3348. */
  3349. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3352. * @param otherVector the vector to add
  3353. * @param result the vector to store the result
  3354. * @returns the current Vector4.
  3355. */
  3356. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3357. /**
  3358. * Subtract in place the given vector from the current Vector4.
  3359. * @param otherVector the vector to subtract
  3360. * @returns the updated Vector4.
  3361. */
  3362. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to add
  3366. * @returns the new vector with the result
  3367. */
  3368. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3371. * @param otherVector the vector to subtract
  3372. * @param result the vector to store the result
  3373. * @returns the current Vector4.
  3374. */
  3375. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3378. */
  3379. /**
  3380. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3381. * @param x value to subtract
  3382. * @param y value to subtract
  3383. * @param z value to subtract
  3384. * @param w value to subtract
  3385. * @returns new vector containing the result
  3386. */
  3387. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3388. /**
  3389. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3390. * @param x value to subtract
  3391. * @param y value to subtract
  3392. * @param z value to subtract
  3393. * @param w value to subtract
  3394. * @param result the vector to store the result in
  3395. * @returns the current Vector4.
  3396. */
  3397. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3400. * @returns a new vector with the negated values
  3401. */
  3402. negate(): Vector4;
  3403. /**
  3404. * Negate this vector in place
  3405. * @returns this
  3406. */
  3407. negateInPlace(): Vector4;
  3408. /**
  3409. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3410. * @param result defines the Vector3 object where to store the result
  3411. * @returns the current Vector4
  3412. */
  3413. negateToRef(result: Vector4): Vector4;
  3414. /**
  3415. * Multiplies the current Vector4 coordinates by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns the updated Vector4.
  3418. */
  3419. scaleInPlace(scale: number): Vector4;
  3420. /**
  3421. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @returns a new vector with the result
  3424. */
  3425. scale(scale: number): Vector4;
  3426. /**
  3427. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3428. * @param scale the number to scale with
  3429. * @param result a vector to store the result in
  3430. * @returns the current Vector4.
  3431. */
  3432. scaleToRef(scale: number, result: Vector4): Vector4;
  3433. /**
  3434. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3435. * @param scale defines the scale factor
  3436. * @param result defines the Vector4 object where to store the result
  3437. * @returns the unmodified current Vector4
  3438. */
  3439. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3442. * @param otherVector the vector to compare against
  3443. * @returns true if they are equal
  3444. */
  3445. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3446. /**
  3447. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3448. * @param otherVector vector to compare against
  3449. * @param epsilon (Default: very small number)
  3450. * @returns true if they are equal
  3451. */
  3452. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3453. /**
  3454. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3455. * @param x x value to compare against
  3456. * @param y y value to compare against
  3457. * @param z z value to compare against
  3458. * @param w w value to compare against
  3459. * @returns true if equal
  3460. */
  3461. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3462. /**
  3463. * Multiplies in place the current Vector4 by the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns the updated Vector4.
  3466. */
  3467. multiplyInPlace(otherVector: Vector4): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @returns resulting new vector
  3472. */
  3473. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3474. /**
  3475. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3476. * @param otherVector vector to multiple with
  3477. * @param result vector to store the result
  3478. * @returns the current Vector4.
  3479. */
  3480. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3481. /**
  3482. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3483. * @param x x value multiply with
  3484. * @param y y value multiply with
  3485. * @param z z value multiply with
  3486. * @param w w value multiply with
  3487. * @returns resulting new vector
  3488. */
  3489. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @returns resulting new vector
  3494. */
  3495. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3496. /**
  3497. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3498. * @param otherVector vector to devide with
  3499. * @param result vector to store the result
  3500. * @returns the current Vector4.
  3501. */
  3502. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3503. /**
  3504. * Divides the current Vector3 coordinates by the given ones.
  3505. * @param otherVector vector to devide with
  3506. * @returns the updated Vector3.
  3507. */
  3508. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3517. * @param other defines the second operand
  3518. * @returns the current updated Vector4
  3519. */
  3520. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Gets a new Vector4 from current Vector4 floored values
  3523. * @returns a new Vector4
  3524. */
  3525. floor(): Vector4;
  3526. /**
  3527. * Gets a new Vector4 from current Vector3 floored values
  3528. * @returns a new Vector4
  3529. */
  3530. fract(): Vector4;
  3531. /**
  3532. * Returns the Vector4 length (float).
  3533. * @returns the length
  3534. */
  3535. length(): number;
  3536. /**
  3537. * Returns the Vector4 squared length (float).
  3538. * @returns the length squared
  3539. */
  3540. lengthSquared(): number;
  3541. /**
  3542. * Normalizes in place the Vector4.
  3543. * @returns the updated Vector4.
  3544. */
  3545. normalize(): Vector4;
  3546. /**
  3547. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3548. * @returns this converted to a new vector3
  3549. */
  3550. toVector3(): Vector3;
  3551. /**
  3552. * Returns a new Vector4 copied from the current one.
  3553. * @returns the new cloned vector
  3554. */
  3555. clone(): Vector4;
  3556. /**
  3557. * Updates the current Vector4 with the given one coordinates.
  3558. * @param source the source vector to copy from
  3559. * @returns the updated Vector4.
  3560. */
  3561. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Updates the current Vector4 coordinates with the given floats.
  3564. * @param x float to copy from
  3565. * @param y float to copy from
  3566. * @param z float to copy from
  3567. * @param w float to copy from
  3568. * @returns the updated Vector4.
  3569. */
  3570. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3571. /**
  3572. * Updates the current Vector4 coordinates with the given floats.
  3573. * @param x float to set from
  3574. * @param y float to set from
  3575. * @param z float to set from
  3576. * @param w float to set from
  3577. * @returns the updated Vector4.
  3578. */
  3579. set(x: number, y: number, z: number, w: number): Vector4;
  3580. /**
  3581. * Copies the given float to the current Vector3 coordinates
  3582. * @param v defines the x, y, z and w coordinates of the operand
  3583. * @returns the current updated Vector3
  3584. */
  3585. setAll(v: number): Vector4;
  3586. /**
  3587. * Returns a new Vector4 set from the starting index of the given array.
  3588. * @param array the array to pull values from
  3589. * @param offset the offset into the array to start at
  3590. * @returns the new vector
  3591. */
  3592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3593. /**
  3594. * Updates the given vector "result" from the starting index of the given array.
  3595. * @param array the array to pull values from
  3596. * @param offset the offset into the array to start at
  3597. * @param result the vector to store the result in
  3598. */
  3599. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3600. /**
  3601. * Updates the given vector "result" from the starting index of the given Float32Array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @param result the vector to store the result in
  3605. */
  3606. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3607. /**
  3608. * Updates the given vector "result" coordinates from the given floats.
  3609. * @param x float to set from
  3610. * @param y float to set from
  3611. * @param z float to set from
  3612. * @param w float to set from
  3613. * @param result the vector to the floats in
  3614. */
  3615. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3616. /**
  3617. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3618. * @returns the new vector
  3619. */
  3620. static Zero(): Vector4;
  3621. /**
  3622. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3623. * @returns the new vector
  3624. */
  3625. static One(): Vector4;
  3626. /**
  3627. * Returns a new normalized Vector4 from the given one.
  3628. * @param vector the vector to normalize
  3629. * @returns the vector
  3630. */
  3631. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3632. /**
  3633. * Updates the given vector "result" from the normalization of the given one.
  3634. * @param vector the vector to normalize
  3635. * @param result the vector to store the result in
  3636. */
  3637. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3638. /**
  3639. * Returns a vector with the minimum values from the left and right vectors
  3640. * @param left left vector to minimize
  3641. * @param right right vector to minimize
  3642. * @returns a new vector with the minimum of the left and right vector values
  3643. */
  3644. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3645. /**
  3646. * Returns a vector with the maximum values from the left and right vectors
  3647. * @param left left vector to maximize
  3648. * @param right right vector to maximize
  3649. * @returns a new vector with the maximum of the left and right vector values
  3650. */
  3651. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3652. /**
  3653. * Returns the distance (float) between the vectors "value1" and "value2".
  3654. * @param value1 value to calulate the distance between
  3655. * @param value2 value to calulate the distance between
  3656. * @return the distance between the two vectors
  3657. */
  3658. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3659. /**
  3660. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3661. * @param value1 value to calulate the distance between
  3662. * @param value2 value to calulate the distance between
  3663. * @return the distance between the two vectors squared
  3664. */
  3665. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3666. /**
  3667. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the center between
  3669. * @param value2 value to calulate the center between
  3670. * @return the center between the two vectors
  3671. */
  3672. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3673. /**
  3674. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3675. * This methods computes transformed normalized direction vectors only.
  3676. * @param vector the vector to transform
  3677. * @param transformation the transformation matrix to apply
  3678. * @returns the new vector
  3679. */
  3680. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3681. /**
  3682. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3683. * This methods computes transformed normalized direction vectors only.
  3684. * @param vector the vector to transform
  3685. * @param transformation the transformation matrix to apply
  3686. * @param result the vector to store the result in
  3687. */
  3688. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3689. /**
  3690. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3691. * This methods computes transformed normalized direction vectors only.
  3692. * @param x value to transform
  3693. * @param y value to transform
  3694. * @param z value to transform
  3695. * @param w value to transform
  3696. * @param transformation the transformation matrix to apply
  3697. * @param result the vector to store the results in
  3698. */
  3699. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3700. /**
  3701. * Creates a new Vector4 from a Vector3
  3702. * @param source defines the source data
  3703. * @param w defines the 4th component (default is 0)
  3704. * @returns a new Vector4
  3705. */
  3706. static FromVector3(source: Vector3, w?: number): Vector4;
  3707. }
  3708. /**
  3709. * Class used to store quaternion data
  3710. * @see https://en.wikipedia.org/wiki/Quaternion
  3711. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3712. */
  3713. export class Quaternion {
  3714. /** @hidden */
  3715. _x: number;
  3716. /** @hidden */
  3717. _y: number;
  3718. /** @hidden */
  3719. _z: number;
  3720. /** @hidden */
  3721. _w: number;
  3722. /** @hidden */
  3723. _isDirty: boolean;
  3724. /** Gets or sets the x coordinate */
  3725. get x(): number;
  3726. set x(value: number);
  3727. /** Gets or sets the y coordinate */
  3728. get y(): number;
  3729. set y(value: number);
  3730. /** Gets or sets the z coordinate */
  3731. get z(): number;
  3732. set z(value: number);
  3733. /** Gets or sets the w coordinate */
  3734. get w(): number;
  3735. set w(value: number);
  3736. /**
  3737. * Creates a new Quaternion from the given floats
  3738. * @param x defines the first component (0 by default)
  3739. * @param y defines the second component (0 by default)
  3740. * @param z defines the third component (0 by default)
  3741. * @param w defines the fourth component (1.0 by default)
  3742. */
  3743. constructor(x?: number, y?: number, z?: number, w?: number);
  3744. /**
  3745. * Gets a string representation for the current quaternion
  3746. * @returns a string with the Quaternion coordinates
  3747. */
  3748. toString(): string;
  3749. /**
  3750. * Gets the class name of the quaternion
  3751. * @returns the string "Quaternion"
  3752. */
  3753. getClassName(): string;
  3754. /**
  3755. * Gets a hash code for this quaternion
  3756. * @returns the quaternion hash code
  3757. */
  3758. getHashCode(): number;
  3759. /**
  3760. * Copy the quaternion to an array
  3761. * @returns a new array populated with 4 elements from the quaternion coordinates
  3762. */
  3763. asArray(): number[];
  3764. /**
  3765. * Check if two quaternions are equals
  3766. * @param otherQuaternion defines the second operand
  3767. * @return true if the current quaternion and the given one coordinates are strictly equals
  3768. */
  3769. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3770. /**
  3771. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3772. * @param otherQuaternion defines the other quaternion
  3773. * @param epsilon defines the minimal distance to consider equality
  3774. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3775. */
  3776. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3777. /**
  3778. * Clone the current quaternion
  3779. * @returns a new quaternion copied from the current one
  3780. */
  3781. clone(): Quaternion;
  3782. /**
  3783. * Copy a quaternion to the current one
  3784. * @param other defines the other quaternion
  3785. * @returns the updated current quaternion
  3786. */
  3787. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Updates the current quaternion with the given float coordinates
  3790. * @param x defines the x coordinate
  3791. * @param y defines the y coordinate
  3792. * @param z defines the z coordinate
  3793. * @param w defines the w coordinate
  3794. * @returns the updated current quaternion
  3795. */
  3796. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given float coordinates
  3799. * @param x defines the x coordinate
  3800. * @param y defines the y coordinate
  3801. * @param z defines the z coordinate
  3802. * @param w defines the w coordinate
  3803. * @returns the updated current quaternion
  3804. */
  3805. set(x: number, y: number, z: number, w: number): Quaternion;
  3806. /**
  3807. * Adds two quaternions
  3808. * @param other defines the second operand
  3809. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3810. */
  3811. add(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Add a quaternion to the current one
  3814. * @param other defines the quaternion to add
  3815. * @returns the current quaternion
  3816. */
  3817. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3818. /**
  3819. * Subtract two quaternions
  3820. * @param other defines the second operand
  3821. * @returns a new quaternion as the subtraction result of the given one from the current one
  3822. */
  3823. subtract(other: Quaternion): Quaternion;
  3824. /**
  3825. * Multiplies the current quaternion by a scale factor
  3826. * @param value defines the scale factor
  3827. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3828. */
  3829. scale(value: number): Quaternion;
  3830. /**
  3831. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3832. * @param scale defines the scale factor
  3833. * @param result defines the Quaternion object where to store the result
  3834. * @returns the unmodified current quaternion
  3835. */
  3836. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3837. /**
  3838. * Multiplies in place the current quaternion by a scale factor
  3839. * @param value defines the scale factor
  3840. * @returns the current modified quaternion
  3841. */
  3842. scaleInPlace(value: number): Quaternion;
  3843. /**
  3844. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3845. * @param scale defines the scale factor
  3846. * @param result defines the Quaternion object where to store the result
  3847. * @returns the unmodified current quaternion
  3848. */
  3849. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3850. /**
  3851. * Multiplies two quaternions
  3852. * @param q1 defines the second operand
  3853. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3854. */
  3855. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3856. /**
  3857. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3858. * @param q1 defines the second operand
  3859. * @param result defines the target quaternion
  3860. * @returns the current quaternion
  3861. */
  3862. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3863. /**
  3864. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3865. * @param q1 defines the second operand
  3866. * @returns the currentupdated quaternion
  3867. */
  3868. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3869. /**
  3870. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3871. * @param ref defines the target quaternion
  3872. * @returns the current quaternion
  3873. */
  3874. conjugateToRef(ref: Quaternion): Quaternion;
  3875. /**
  3876. * Conjugates in place (1-q) the current quaternion
  3877. * @returns the current updated quaternion
  3878. */
  3879. conjugateInPlace(): Quaternion;
  3880. /**
  3881. * Conjugates in place (1-q) the current quaternion
  3882. * @returns a new quaternion
  3883. */
  3884. conjugate(): Quaternion;
  3885. /**
  3886. * Gets length of current quaternion
  3887. * @returns the quaternion length (float)
  3888. */
  3889. length(): number;
  3890. /**
  3891. * Normalize in place the current quaternion
  3892. * @returns the current updated quaternion
  3893. */
  3894. normalize(): Quaternion;
  3895. /**
  3896. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3897. * @param order is a reserved parameter and is ignored for now
  3898. * @returns a new Vector3 containing the Euler angles
  3899. */
  3900. toEulerAngles(order?: string): Vector3;
  3901. /**
  3902. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3903. * @param result defines the vector which will be filled with the Euler angles
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toEulerAnglesToRef(result: Vector3): Quaternion;
  3907. /**
  3908. * Updates the given rotation matrix with the current quaternion values
  3909. * @param result defines the target matrix
  3910. * @returns the current unchanged quaternion
  3911. */
  3912. toRotationMatrix(result: Matrix): Quaternion;
  3913. /**
  3914. * Updates the current quaternion from the given rotation matrix values
  3915. * @param matrix defines the source matrix
  3916. * @returns the current updated quaternion
  3917. */
  3918. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Creates a new quaternion from a rotation matrix
  3921. * @param matrix defines the source matrix
  3922. * @returns a new quaternion created from the given rotation matrix values
  3923. */
  3924. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3925. /**
  3926. * Updates the given quaternion with the given rotation matrix values
  3927. * @param matrix defines the source matrix
  3928. * @param result defines the target quaternion
  3929. */
  3930. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3931. /**
  3932. * Returns the dot product (float) between the quaternions "left" and "right"
  3933. * @param left defines the left operand
  3934. * @param right defines the right operand
  3935. * @returns the dot product
  3936. */
  3937. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3938. /**
  3939. * Checks if the two quaternions are close to each other
  3940. * @param quat0 defines the first quaternion to check
  3941. * @param quat1 defines the second quaternion to check
  3942. * @returns true if the two quaternions are close to each other
  3943. */
  3944. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3945. /**
  3946. * Creates an empty quaternion
  3947. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3948. */
  3949. static Zero(): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @returns a new quaternion as the inverted current quaternion
  3954. */
  3955. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3956. /**
  3957. * Inverse a given quaternion
  3958. * @param q defines the source quaternion
  3959. * @param result the quaternion the result will be stored in
  3960. * @returns the result quaternion
  3961. */
  3962. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3963. /**
  3964. * Creates an identity quaternion
  3965. * @returns the identity quaternion
  3966. */
  3967. static Identity(): Quaternion;
  3968. /**
  3969. * Gets a boolean indicating if the given quaternion is identity
  3970. * @param quaternion defines the quaternion to check
  3971. * @returns true if the quaternion is identity
  3972. */
  3973. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3974. /**
  3975. * Creates a quaternion from a rotation around an axis
  3976. * @param axis defines the axis to use
  3977. * @param angle defines the angle to use
  3978. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3979. */
  3980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3981. /**
  3982. * Creates a rotation around an axis and stores it into the given quaternion
  3983. * @param axis defines the axis to use
  3984. * @param angle defines the angle to use
  3985. * @param result defines the target quaternion
  3986. * @returns the target quaternion
  3987. */
  3988. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3989. /**
  3990. * Creates a new quaternion from data stored into an array
  3991. * @param array defines the data source
  3992. * @param offset defines the offset in the source array where the data starts
  3993. * @returns a new quaternion
  3994. */
  3995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3996. /**
  3997. * Updates the given quaternion "result" from the starting index of the given array.
  3998. * @param array the array to pull values from
  3999. * @param offset the offset into the array to start at
  4000. * @param result the quaternion to store the result in
  4001. */
  4002. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4003. /**
  4004. * Create a quaternion from Euler rotation angles
  4005. * @param x Pitch
  4006. * @param y Yaw
  4007. * @param z Roll
  4008. * @returns the new Quaternion
  4009. */
  4010. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4011. /**
  4012. * Updates a quaternion from Euler rotation angles
  4013. * @param x Pitch
  4014. * @param y Yaw
  4015. * @param z Roll
  4016. * @param result the quaternion to store the result
  4017. * @returns the updated quaternion
  4018. */
  4019. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4020. /**
  4021. * Create a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @returns the new Quaternion
  4024. */
  4025. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4026. /**
  4027. * Updates a quaternion from Euler rotation vector
  4028. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4029. * @param result the quaternion to store the result
  4030. * @returns the updated quaternion
  4031. */
  4032. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4035. * @param yaw defines the rotation around Y axis
  4036. * @param pitch defines the rotation around X axis
  4037. * @param roll defines the rotation around Z axis
  4038. * @returns the new quaternion
  4039. */
  4040. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4041. /**
  4042. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4043. * @param yaw defines the rotation around Y axis
  4044. * @param pitch defines the rotation around X axis
  4045. * @param roll defines the rotation around Z axis
  4046. * @param result defines the target quaternion
  4047. */
  4048. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4049. /**
  4050. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4051. * @param alpha defines the rotation around first axis
  4052. * @param beta defines the rotation around second axis
  4053. * @param gamma defines the rotation around third axis
  4054. * @returns the new quaternion
  4055. */
  4056. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4057. /**
  4058. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4059. * @param alpha defines the rotation around first axis
  4060. * @param beta defines the rotation around second axis
  4061. * @param gamma defines the rotation around third axis
  4062. * @param result defines the target quaternion
  4063. */
  4064. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4065. /**
  4066. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4067. * @param axis1 defines the first axis
  4068. * @param axis2 defines the second axis
  4069. * @param axis3 defines the third axis
  4070. * @returns the new quaternion
  4071. */
  4072. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4073. /**
  4074. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4075. * @param axis1 defines the first axis
  4076. * @param axis2 defines the second axis
  4077. * @param axis3 defines the third axis
  4078. * @param ref defines the target quaternion
  4079. */
  4080. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4081. /**
  4082. * Interpolates between two quaternions
  4083. * @param left defines first quaternion
  4084. * @param right defines second quaternion
  4085. * @param amount defines the gradient to use
  4086. * @returns the new interpolated quaternion
  4087. */
  4088. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4089. /**
  4090. * Interpolates between two quaternions and stores it into a target quaternion
  4091. * @param left defines first quaternion
  4092. * @param right defines second quaternion
  4093. * @param amount defines the gradient to use
  4094. * @param result defines the target quaternion
  4095. */
  4096. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4097. /**
  4098. * Interpolate between two quaternions using Hermite interpolation
  4099. * @param value1 defines first quaternion
  4100. * @param tangent1 defines the incoming tangent
  4101. * @param value2 defines second quaternion
  4102. * @param tangent2 defines the outgoing tangent
  4103. * @param amount defines the target quaternion
  4104. * @returns the new interpolated quaternion
  4105. */
  4106. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4107. }
  4108. /**
  4109. * Class used to store matrix data (4x4)
  4110. */
  4111. export class Matrix {
  4112. /**
  4113. * Gets the precision of matrix computations
  4114. */
  4115. static get Use64Bits(): boolean;
  4116. private static _updateFlagSeed;
  4117. private static _identityReadOnly;
  4118. private _isIdentity;
  4119. private _isIdentityDirty;
  4120. private _isIdentity3x2;
  4121. private _isIdentity3x2Dirty;
  4122. /**
  4123. * Gets the update flag of the matrix which is an unique number for the matrix.
  4124. * It will be incremented every time the matrix data change.
  4125. * You can use it to speed the comparison between two versions of the same matrix.
  4126. */
  4127. updateFlag: number;
  4128. private readonly _m;
  4129. /**
  4130. * Gets the internal data of the matrix
  4131. */
  4132. get m(): DeepImmutable<Float32Array | Array<number>>;
  4133. /** @hidden */
  4134. _markAsUpdated(): void;
  4135. /** @hidden */
  4136. private _updateIdentityStatus;
  4137. /**
  4138. * Creates an empty matrix (filled with zeros)
  4139. */
  4140. constructor();
  4141. /**
  4142. * Check if the current matrix is identity
  4143. * @returns true is the matrix is the identity matrix
  4144. */
  4145. isIdentity(): boolean;
  4146. /**
  4147. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4148. * @returns true is the matrix is the identity matrix
  4149. */
  4150. isIdentityAs3x2(): boolean;
  4151. /**
  4152. * Gets the determinant of the matrix
  4153. * @returns the matrix determinant
  4154. */
  4155. determinant(): number;
  4156. /**
  4157. * Returns the matrix as a Float32Array or Array<number>
  4158. * @returns the matrix underlying array
  4159. */
  4160. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4161. /**
  4162. * Returns the matrix as a Float32Array or Array<number>
  4163. * @returns the matrix underlying array.
  4164. */
  4165. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4166. /**
  4167. * Inverts the current matrix in place
  4168. * @returns the current inverted matrix
  4169. */
  4170. invert(): Matrix;
  4171. /**
  4172. * Sets all the matrix elements to zero
  4173. * @returns the current matrix
  4174. */
  4175. reset(): Matrix;
  4176. /**
  4177. * Adds the current matrix with a second one
  4178. * @param other defines the matrix to add
  4179. * @returns a new matrix as the addition of the current matrix and the given one
  4180. */
  4181. add(other: DeepImmutable<Matrix>): Matrix;
  4182. /**
  4183. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4184. * @param other defines the matrix to add
  4185. * @param result defines the target matrix
  4186. * @returns the current matrix
  4187. */
  4188. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4189. /**
  4190. * Adds in place the given matrix to the current matrix
  4191. * @param other defines the second operand
  4192. * @returns the current updated matrix
  4193. */
  4194. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Sets the given matrix to the current inverted Matrix
  4197. * @param other defines the target matrix
  4198. * @returns the unmodified current matrix
  4199. */
  4200. invertToRef(other: Matrix): Matrix;
  4201. /**
  4202. * add a value at the specified position in the current Matrix
  4203. * @param index the index of the value within the matrix. between 0 and 15.
  4204. * @param value the value to be added
  4205. * @returns the current updated matrix
  4206. */
  4207. addAtIndex(index: number, value: number): Matrix;
  4208. /**
  4209. * mutiply the specified position in the current Matrix by a value
  4210. * @param index the index of the value within the matrix. between 0 and 15.
  4211. * @param value the value to be added
  4212. * @returns the current updated matrix
  4213. */
  4214. multiplyAtIndex(index: number, value: number): Matrix;
  4215. /**
  4216. * Inserts the translation vector (using 3 floats) in the current matrix
  4217. * @param x defines the 1st component of the translation
  4218. * @param y defines the 2nd component of the translation
  4219. * @param z defines the 3rd component of the translation
  4220. * @returns the current updated matrix
  4221. */
  4222. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4223. /**
  4224. * Adds the translation vector (using 3 floats) in the current matrix
  4225. * @param x defines the 1st component of the translation
  4226. * @param y defines the 2nd component of the translation
  4227. * @param z defines the 3rd component of the translation
  4228. * @returns the current updated matrix
  4229. */
  4230. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4231. /**
  4232. * Inserts the translation vector in the current matrix
  4233. * @param vector3 defines the translation to insert
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4237. /**
  4238. * Gets the translation value of the current matrix
  4239. * @returns a new Vector3 as the extracted translation from the matrix
  4240. */
  4241. getTranslation(): Vector3;
  4242. /**
  4243. * Fill a Vector3 with the extracted translation from the matrix
  4244. * @param result defines the Vector3 where to store the translation
  4245. * @returns the current matrix
  4246. */
  4247. getTranslationToRef(result: Vector3): Matrix;
  4248. /**
  4249. * Remove rotation and scaling part from the matrix
  4250. * @returns the updated matrix
  4251. */
  4252. removeRotationAndScaling(): Matrix;
  4253. /**
  4254. * Multiply two matrices
  4255. * @param other defines the second operand
  4256. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4257. */
  4258. multiply(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Copy the current matrix from the given one
  4261. * @param other defines the source matrix
  4262. * @returns the current updated matrix
  4263. */
  4264. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4265. /**
  4266. * Populates the given array from the starting index with the current matrix values
  4267. * @param array defines the target array
  4268. * @param offset defines the offset in the target array where to start storing values
  4269. * @returns the current matrix
  4270. */
  4271. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4272. /**
  4273. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4274. * @param other defines the second operand
  4275. * @param result defines the matrix where to store the multiplication
  4276. * @returns the current matrix
  4277. */
  4278. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4279. /**
  4280. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4281. * @param other defines the second operand
  4282. * @param result defines the array where to store the multiplication
  4283. * @param offset defines the offset in the target array where to start storing values
  4284. * @returns the current matrix
  4285. */
  4286. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4287. /**
  4288. * Check equality between this matrix and a second one
  4289. * @param value defines the second matrix to compare
  4290. * @returns true is the current matrix and the given one values are strictly equal
  4291. */
  4292. equals(value: DeepImmutable<Matrix>): boolean;
  4293. /**
  4294. * Clone the current matrix
  4295. * @returns a new matrix from the current matrix
  4296. */
  4297. clone(): Matrix;
  4298. /**
  4299. * Returns the name of the current matrix class
  4300. * @returns the string "Matrix"
  4301. */
  4302. getClassName(): string;
  4303. /**
  4304. * Gets the hash code of the current matrix
  4305. * @returns the hash code
  4306. */
  4307. getHashCode(): number;
  4308. /**
  4309. * Decomposes the current Matrix into a translation, rotation and scaling components
  4310. * @param scale defines the scale vector3 given as a reference to update
  4311. * @param rotation defines the rotation quaternion given as a reference to update
  4312. * @param translation defines the translation vector3 given as a reference to update
  4313. * @returns true if operation was successful
  4314. */
  4315. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4316. /**
  4317. * Gets specific row of the matrix
  4318. * @param index defines the number of the row to get
  4319. * @returns the index-th row of the current matrix as a new Vector4
  4320. */
  4321. getRow(index: number): Nullable<Vector4>;
  4322. /**
  4323. * Sets the index-th row of the current matrix to the vector4 values
  4324. * @param index defines the number of the row to set
  4325. * @param row defines the target vector4
  4326. * @returns the updated current matrix
  4327. */
  4328. setRow(index: number, row: Vector4): Matrix;
  4329. /**
  4330. * Compute the transpose of the matrix
  4331. * @returns the new transposed matrix
  4332. */
  4333. transpose(): Matrix;
  4334. /**
  4335. * Compute the transpose of the matrix and store it in a given matrix
  4336. * @param result defines the target matrix
  4337. * @returns the current matrix
  4338. */
  4339. transposeToRef(result: Matrix): Matrix;
  4340. /**
  4341. * Sets the index-th row of the current matrix with the given 4 x float values
  4342. * @param index defines the row index
  4343. * @param x defines the x component to set
  4344. * @param y defines the y component to set
  4345. * @param z defines the z component to set
  4346. * @param w defines the w component to set
  4347. * @returns the updated current matrix
  4348. */
  4349. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4350. /**
  4351. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4352. * @param scale defines the scale factor
  4353. * @returns a new matrix
  4354. */
  4355. scale(scale: number): Matrix;
  4356. /**
  4357. * Scale the current matrix values by a factor to a given result matrix
  4358. * @param scale defines the scale factor
  4359. * @param result defines the matrix to store the result
  4360. * @returns the current matrix
  4361. */
  4362. scaleToRef(scale: number, result: Matrix): Matrix;
  4363. /**
  4364. * Scale the current matrix values by a factor and add the result to a given matrix
  4365. * @param scale defines the scale factor
  4366. * @param result defines the Matrix to store the result
  4367. * @returns the current matrix
  4368. */
  4369. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4370. /**
  4371. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4372. * @param ref matrix to store the result
  4373. */
  4374. toNormalMatrix(ref: Matrix): void;
  4375. /**
  4376. * Gets only rotation part of the current matrix
  4377. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4378. */
  4379. getRotationMatrix(): Matrix;
  4380. /**
  4381. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4382. * @param result defines the target matrix to store data to
  4383. * @returns the current matrix
  4384. */
  4385. getRotationMatrixToRef(result: Matrix): Matrix;
  4386. /**
  4387. * Toggles model matrix from being right handed to left handed in place and vice versa
  4388. */
  4389. toggleModelMatrixHandInPlace(): void;
  4390. /**
  4391. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4392. */
  4393. toggleProjectionMatrixHandInPlace(): void;
  4394. /**
  4395. * Creates a matrix from an array
  4396. * @param array defines the source array
  4397. * @param offset defines an offset in the source array
  4398. * @returns a new Matrix set from the starting index of the given array
  4399. */
  4400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4401. /**
  4402. * Copy the content of an array into a given matrix
  4403. * @param array defines the source array
  4404. * @param offset defines an offset in the source array
  4405. * @param result defines the target matrix
  4406. */
  4407. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4408. /**
  4409. * Stores an array into a matrix after having multiplied each component by a given factor
  4410. * @param array defines the source array
  4411. * @param offset defines the offset in the source array
  4412. * @param scale defines the scaling factor
  4413. * @param result defines the target matrix
  4414. */
  4415. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4416. /**
  4417. * Gets an identity matrix that must not be updated
  4418. */
  4419. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4420. /**
  4421. * Stores a list of values (16) inside a given matrix
  4422. * @param initialM11 defines 1st value of 1st row
  4423. * @param initialM12 defines 2nd value of 1st row
  4424. * @param initialM13 defines 3rd value of 1st row
  4425. * @param initialM14 defines 4th value of 1st row
  4426. * @param initialM21 defines 1st value of 2nd row
  4427. * @param initialM22 defines 2nd value of 2nd row
  4428. * @param initialM23 defines 3rd value of 2nd row
  4429. * @param initialM24 defines 4th value of 2nd row
  4430. * @param initialM31 defines 1st value of 3rd row
  4431. * @param initialM32 defines 2nd value of 3rd row
  4432. * @param initialM33 defines 3rd value of 3rd row
  4433. * @param initialM34 defines 4th value of 3rd row
  4434. * @param initialM41 defines 1st value of 4th row
  4435. * @param initialM42 defines 2nd value of 4th row
  4436. * @param initialM43 defines 3rd value of 4th row
  4437. * @param initialM44 defines 4th value of 4th row
  4438. * @param result defines the target matrix
  4439. */
  4440. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4441. /**
  4442. * Creates new matrix from a list of values (16)
  4443. * @param initialM11 defines 1st value of 1st row
  4444. * @param initialM12 defines 2nd value of 1st row
  4445. * @param initialM13 defines 3rd value of 1st row
  4446. * @param initialM14 defines 4th value of 1st row
  4447. * @param initialM21 defines 1st value of 2nd row
  4448. * @param initialM22 defines 2nd value of 2nd row
  4449. * @param initialM23 defines 3rd value of 2nd row
  4450. * @param initialM24 defines 4th value of 2nd row
  4451. * @param initialM31 defines 1st value of 3rd row
  4452. * @param initialM32 defines 2nd value of 3rd row
  4453. * @param initialM33 defines 3rd value of 3rd row
  4454. * @param initialM34 defines 4th value of 3rd row
  4455. * @param initialM41 defines 1st value of 4th row
  4456. * @param initialM42 defines 2nd value of 4th row
  4457. * @param initialM43 defines 3rd value of 4th row
  4458. * @param initialM44 defines 4th value of 4th row
  4459. * @returns the new matrix
  4460. */
  4461. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4462. /**
  4463. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4464. * @param scale defines the scale vector3
  4465. * @param rotation defines the rotation quaternion
  4466. * @param translation defines the translation vector3
  4467. * @returns a new matrix
  4468. */
  4469. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4470. /**
  4471. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4472. * @param scale defines the scale vector3
  4473. * @param rotation defines the rotation quaternion
  4474. * @param translation defines the translation vector3
  4475. * @param result defines the target matrix
  4476. */
  4477. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4478. /**
  4479. * Creates a new identity matrix
  4480. * @returns a new identity matrix
  4481. */
  4482. static Identity(): Matrix;
  4483. /**
  4484. * Creates a new identity matrix and stores the result in a given matrix
  4485. * @param result defines the target matrix
  4486. */
  4487. static IdentityToRef(result: Matrix): void;
  4488. /**
  4489. * Creates a new zero matrix
  4490. * @returns a new zero matrix
  4491. */
  4492. static Zero(): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the X axis
  4495. * @param angle defines the angle (in radians) to use
  4496. * @return the new matrix
  4497. */
  4498. static RotationX(angle: number): Matrix;
  4499. /**
  4500. * Creates a new matrix as the invert of a given matrix
  4501. * @param source defines the source matrix
  4502. * @returns the new matrix
  4503. */
  4504. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationXToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis
  4513. * @param angle defines the angle (in radians) to use
  4514. * @return the new matrix
  4515. */
  4516. static RotationY(angle: number): Matrix;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationYToRef(angle: number, result: Matrix): void;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis
  4525. * @param angle defines the angle (in radians) to use
  4526. * @return the new matrix
  4527. */
  4528. static RotationZ(angle: number): Matrix;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4531. * @param angle defines the angle (in radians) to use
  4532. * @param result defines the target matrix
  4533. */
  4534. static RotationZToRef(angle: number, result: Matrix): void;
  4535. /**
  4536. * Creates a new rotation matrix for "angle" radians around the given axis
  4537. * @param axis defines the axis to use
  4538. * @param angle defines the angle (in radians) to use
  4539. * @return the new matrix
  4540. */
  4541. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4542. /**
  4543. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4544. * @param axis defines the axis to use
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4549. /**
  4550. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4551. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4552. * @param from defines the vector to align
  4553. * @param to defines the vector to align to
  4554. * @param result defines the target matrix
  4555. */
  4556. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4557. /**
  4558. * Creates a rotation matrix
  4559. * @param yaw defines the yaw angle in radians (Y axis)
  4560. * @param pitch defines the pitch angle in radians (X axis)
  4561. * @param roll defines the roll angle in radians (Z axis)
  4562. * @returns the new rotation matrix
  4563. */
  4564. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4565. /**
  4566. * Creates a rotation matrix and stores it in a given matrix
  4567. * @param yaw defines the yaw angle in radians (Y axis)
  4568. * @param pitch defines the pitch angle in radians (X axis)
  4569. * @param roll defines the roll angle in radians (Z axis)
  4570. * @param result defines the target matrix
  4571. */
  4572. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4573. /**
  4574. * Creates a scaling matrix
  4575. * @param x defines the scale factor on X axis
  4576. * @param y defines the scale factor on Y axis
  4577. * @param z defines the scale factor on Z axis
  4578. * @returns the new matrix
  4579. */
  4580. static Scaling(x: number, y: number, z: number): Matrix;
  4581. /**
  4582. * Creates a scaling matrix and stores it in a given matrix
  4583. * @param x defines the scale factor on X axis
  4584. * @param y defines the scale factor on Y axis
  4585. * @param z defines the scale factor on Z axis
  4586. * @param result defines the target matrix
  4587. */
  4588. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4589. /**
  4590. * Creates a translation matrix
  4591. * @param x defines the translation on X axis
  4592. * @param y defines the translation on Y axis
  4593. * @param z defines the translationon Z axis
  4594. * @returns the new matrix
  4595. */
  4596. static Translation(x: number, y: number, z: number): Matrix;
  4597. /**
  4598. * Creates a translation matrix and stores it in a given matrix
  4599. * @param x defines the translation on X axis
  4600. * @param y defines the translation on Y axis
  4601. * @param z defines the translationon Z axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4605. /**
  4606. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4607. * @param startValue defines the start value
  4608. * @param endValue defines the end value
  4609. * @param gradient defines the gradient factor
  4610. * @returns the new matrix
  4611. */
  4612. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4613. /**
  4614. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4615. * @param startValue defines the start value
  4616. * @param endValue defines the end value
  4617. * @param gradient defines the gradient factor
  4618. * @param result defines the Matrix object where to store data
  4619. */
  4620. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4621. /**
  4622. * Builds a new matrix whose values are computed by:
  4623. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4624. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4625. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4626. * @param startValue defines the first matrix
  4627. * @param endValue defines the second matrix
  4628. * @param gradient defines the gradient between the two matrices
  4629. * @returns the new matrix
  4630. */
  4631. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4632. /**
  4633. * Update a matrix to values which are computed by:
  4634. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4635. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4636. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4637. * @param startValue defines the first matrix
  4638. * @param endValue defines the second matrix
  4639. * @param gradient defines the gradient between the two matrices
  4640. * @param result defines the target matrix
  4641. */
  4642. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4643. /**
  4644. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4645. * This function works in left handed mode
  4646. * @param eye defines the final position of the entity
  4647. * @param target defines where the entity should look at
  4648. * @param up defines the up vector for the entity
  4649. * @returns the new matrix
  4650. */
  4651. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4652. /**
  4653. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4654. * This function works in left handed mode
  4655. * @param eye defines the final position of the entity
  4656. * @param target defines where the entity should look at
  4657. * @param up defines the up vector for the entity
  4658. * @param result defines the target matrix
  4659. */
  4660. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4661. /**
  4662. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4663. * This function works in right handed mode
  4664. * @param eye defines the final position of the entity
  4665. * @param target defines where the entity should look at
  4666. * @param up defines the up vector for the entity
  4667. * @returns the new matrix
  4668. */
  4669. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4670. /**
  4671. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4672. * This function works in right handed mode
  4673. * @param eye defines the final position of the entity
  4674. * @param target defines where the entity should look at
  4675. * @param up defines the up vector for the entity
  4676. * @param result defines the target matrix
  4677. */
  4678. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4679. /**
  4680. * Create a left-handed orthographic projection matrix
  4681. * @param width defines the viewport width
  4682. * @param height defines the viewport height
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @returns a new matrix as a left-handed orthographic projection matrix
  4686. */
  4687. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4688. /**
  4689. * Store a left-handed orthographic projection to a given matrix
  4690. * @param width defines the viewport width
  4691. * @param height defines the viewport height
  4692. * @param znear defines the near clip plane
  4693. * @param zfar defines the far clip plane
  4694. * @param result defines the target matrix
  4695. */
  4696. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4697. /**
  4698. * Create a left-handed orthographic projection matrix
  4699. * @param left defines the viewport left coordinate
  4700. * @param right defines the viewport right coordinate
  4701. * @param bottom defines the viewport bottom coordinate
  4702. * @param top defines the viewport top coordinate
  4703. * @param znear defines the near clip plane
  4704. * @param zfar defines the far clip plane
  4705. * @returns a new matrix as a left-handed orthographic projection matrix
  4706. */
  4707. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4708. /**
  4709. * Stores a left-handed orthographic projection into a given matrix
  4710. * @param left defines the viewport left coordinate
  4711. * @param right defines the viewport right coordinate
  4712. * @param bottom defines the viewport bottom coordinate
  4713. * @param top defines the viewport top coordinate
  4714. * @param znear defines the near clip plane
  4715. * @param zfar defines the far clip plane
  4716. * @param result defines the target matrix
  4717. */
  4718. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4719. /**
  4720. * Creates a right-handed orthographic projection matrix
  4721. * @param left defines the viewport left coordinate
  4722. * @param right defines the viewport right coordinate
  4723. * @param bottom defines the viewport bottom coordinate
  4724. * @param top defines the viewport top coordinate
  4725. * @param znear defines the near clip plane
  4726. * @param zfar defines the far clip plane
  4727. * @returns a new matrix as a right-handed orthographic projection matrix
  4728. */
  4729. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4730. /**
  4731. * Stores a right-handed orthographic projection into a given matrix
  4732. * @param left defines the viewport left coordinate
  4733. * @param right defines the viewport right coordinate
  4734. * @param bottom defines the viewport bottom coordinate
  4735. * @param top defines the viewport top coordinate
  4736. * @param znear defines the near clip plane
  4737. * @param zfar defines the far clip plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4741. /**
  4742. * Creates a left-handed perspective projection matrix
  4743. * @param width defines the viewport width
  4744. * @param height defines the viewport height
  4745. * @param znear defines the near clip plane
  4746. * @param zfar defines the far clip plane
  4747. * @returns a new matrix as a left-handed perspective projection matrix
  4748. */
  4749. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4750. /**
  4751. * Creates a left-handed perspective projection matrix
  4752. * @param fov defines the horizontal field of view
  4753. * @param aspect defines the aspect ratio
  4754. * @param znear defines the near clip plane
  4755. * @param zfar defines the far clip plane
  4756. * @returns a new matrix as a left-handed perspective projection matrix
  4757. */
  4758. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar defines the far clip plane
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar not used as infinity is used as far clip
  4775. * @param result defines the target matrix
  4776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4777. */
  4778. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4779. /**
  4780. * Creates a right-handed perspective projection matrix
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @returns a new matrix as a right-handed perspective projection matrix
  4786. */
  4787. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar defines the far clip plane
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a right-handed perspective projection into a given matrix
  4800. * @param fov defines the horizontal field of view
  4801. * @param aspect defines the aspect ratio
  4802. * @param znear defines the near clip plane
  4803. * @param zfar not used as infinity is used as far clip
  4804. * @param result defines the target matrix
  4805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4806. */
  4807. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4808. /**
  4809. * Stores a perspective projection for WebVR info a given matrix
  4810. * @param fov defines the field of view
  4811. * @param znear defines the near clip plane
  4812. * @param zfar defines the far clip plane
  4813. * @param result defines the target matrix
  4814. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4815. */
  4816. static PerspectiveFovWebVRToRef(fov: {
  4817. upDegrees: number;
  4818. downDegrees: number;
  4819. leftDegrees: number;
  4820. rightDegrees: number;
  4821. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4822. /**
  4823. * Computes a complete transformation matrix
  4824. * @param viewport defines the viewport to use
  4825. * @param world defines the world matrix
  4826. * @param view defines the view matrix
  4827. * @param projection defines the projection matrix
  4828. * @param zmin defines the near clip plane
  4829. * @param zmax defines the far clip plane
  4830. * @returns the transformation matrix
  4831. */
  4832. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4833. /**
  4834. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4841. * @param matrix defines the matrix to use
  4842. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4843. */
  4844. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4845. /**
  4846. * Compute the transpose of a given matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @returns the new matrix
  4849. */
  4850. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4851. /**
  4852. * Compute the transpose of a matrix and store it in a target matrix
  4853. * @param matrix defines the matrix to transpose
  4854. * @param result defines the target matrix
  4855. */
  4856. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @returns a new matrix
  4861. */
  4862. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4863. /**
  4864. * Computes a reflection matrix from a plane
  4865. * @param plane defines the reflection plane
  4866. * @param result defines the target matrix
  4867. */
  4868. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4869. /**
  4870. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4871. * @param xaxis defines the value of the 1st axis
  4872. * @param yaxis defines the value of the 2nd axis
  4873. * @param zaxis defines the value of the 3rd axis
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4877. /**
  4878. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4879. * @param quat defines the quaternion to use
  4880. * @param result defines the target matrix
  4881. */
  4882. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4883. }
  4884. /**
  4885. * @hidden
  4886. */
  4887. export class TmpVectors {
  4888. static Vector2: Vector2[];
  4889. static Vector3: Vector3[];
  4890. static Vector4: Vector4[];
  4891. static Quaternion: Quaternion[];
  4892. static Matrix: Matrix[];
  4893. }
  4894. }
  4895. declare module "babylonjs/Maths/math.path" {
  4896. import { DeepImmutable, Nullable } from "babylonjs/types";
  4897. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4898. /**
  4899. * Defines potential orientation for back face culling
  4900. */
  4901. export enum Orientation {
  4902. /**
  4903. * Clockwise
  4904. */
  4905. CW = 0,
  4906. /** Counter clockwise */
  4907. CCW = 1
  4908. }
  4909. /** Class used to represent a Bezier curve */
  4910. export class BezierCurve {
  4911. /**
  4912. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4913. * @param t defines the time
  4914. * @param x1 defines the left coordinate on X axis
  4915. * @param y1 defines the left coordinate on Y axis
  4916. * @param x2 defines the right coordinate on X axis
  4917. * @param y2 defines the right coordinate on Y axis
  4918. * @returns the interpolated value
  4919. */
  4920. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4921. }
  4922. /**
  4923. * Defines angle representation
  4924. */
  4925. export class Angle {
  4926. private _radians;
  4927. /**
  4928. * Creates an Angle object of "radians" radians (float).
  4929. * @param radians the angle in radians
  4930. */
  4931. constructor(radians: number);
  4932. /**
  4933. * Get value in degrees
  4934. * @returns the Angle value in degrees (float)
  4935. */
  4936. degrees(): number;
  4937. /**
  4938. * Get value in radians
  4939. * @returns the Angle value in radians (float)
  4940. */
  4941. radians(): number;
  4942. /**
  4943. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4944. * @param a defines first point as the origin
  4945. * @param b defines point
  4946. * @returns a new Angle
  4947. */
  4948. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in radians
  4951. * @param radians defines the angle value in radians
  4952. * @returns a new Angle
  4953. */
  4954. static FromRadians(radians: number): Angle;
  4955. /**
  4956. * Gets a new Angle object from the given float in degrees
  4957. * @param degrees defines the angle value in degrees
  4958. * @returns a new Angle
  4959. */
  4960. static FromDegrees(degrees: number): Angle;
  4961. }
  4962. /**
  4963. * This represents an arc in a 2d space.
  4964. */
  4965. export class Arc2 {
  4966. /** Defines the start point of the arc */
  4967. startPoint: Vector2;
  4968. /** Defines the mid point of the arc */
  4969. midPoint: Vector2;
  4970. /** Defines the end point of the arc */
  4971. endPoint: Vector2;
  4972. /**
  4973. * Defines the center point of the arc.
  4974. */
  4975. centerPoint: Vector2;
  4976. /**
  4977. * Defines the radius of the arc.
  4978. */
  4979. radius: number;
  4980. /**
  4981. * Defines the angle of the arc (from mid point to end point).
  4982. */
  4983. angle: Angle;
  4984. /**
  4985. * Defines the start angle of the arc (from start point to middle point).
  4986. */
  4987. startAngle: Angle;
  4988. /**
  4989. * Defines the orientation of the arc (clock wise/counter clock wise).
  4990. */
  4991. orientation: Orientation;
  4992. /**
  4993. * Creates an Arc object from the three given points : start, middle and end.
  4994. * @param startPoint Defines the start point of the arc
  4995. * @param midPoint Defines the midlle point of the arc
  4996. * @param endPoint Defines the end point of the arc
  4997. */
  4998. constructor(
  4999. /** Defines the start point of the arc */
  5000. startPoint: Vector2,
  5001. /** Defines the mid point of the arc */
  5002. midPoint: Vector2,
  5003. /** Defines the end point of the arc */
  5004. endPoint: Vector2);
  5005. }
  5006. /**
  5007. * Represents a 2D path made up of multiple 2D points
  5008. */
  5009. export class Path2 {
  5010. private _points;
  5011. private _length;
  5012. /**
  5013. * If the path start and end point are the same
  5014. */
  5015. closed: boolean;
  5016. /**
  5017. * Creates a Path2 object from the starting 2D coordinates x and y.
  5018. * @param x the starting points x value
  5019. * @param y the starting points y value
  5020. */
  5021. constructor(x: number, y: number);
  5022. /**
  5023. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5024. * @param x the added points x value
  5025. * @param y the added points y value
  5026. * @returns the updated Path2.
  5027. */
  5028. addLineTo(x: number, y: number): Path2;
  5029. /**
  5030. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5031. * @param midX middle point x value
  5032. * @param midY middle point y value
  5033. * @param endX end point x value
  5034. * @param endY end point y value
  5035. * @param numberOfSegments (default: 36)
  5036. * @returns the updated Path2.
  5037. */
  5038. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5039. /**
  5040. * Closes the Path2.
  5041. * @returns the Path2.
  5042. */
  5043. close(): Path2;
  5044. /**
  5045. * Gets the sum of the distance between each sequential point in the path
  5046. * @returns the Path2 total length (float).
  5047. */
  5048. length(): number;
  5049. /**
  5050. * Gets the points which construct the path
  5051. * @returns the Path2 internal array of points.
  5052. */
  5053. getPoints(): Vector2[];
  5054. /**
  5055. * Retreives the point at the distance aways from the starting point
  5056. * @param normalizedLengthPosition the length along the path to retreive the point from
  5057. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5058. */
  5059. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5060. /**
  5061. * Creates a new path starting from an x and y position
  5062. * @param x starting x value
  5063. * @param y starting y value
  5064. * @returns a new Path2 starting at the coordinates (x, y).
  5065. */
  5066. static StartingAt(x: number, y: number): Path2;
  5067. }
  5068. /**
  5069. * Represents a 3D path made up of multiple 3D points
  5070. */
  5071. export class Path3D {
  5072. /**
  5073. * an array of Vector3, the curve axis of the Path3D
  5074. */
  5075. path: Vector3[];
  5076. private _curve;
  5077. private _distances;
  5078. private _tangents;
  5079. private _normals;
  5080. private _binormals;
  5081. private _raw;
  5082. private _alignTangentsWithPath;
  5083. private readonly _pointAtData;
  5084. /**
  5085. * new Path3D(path, normal, raw)
  5086. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5087. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5088. * @param path an array of Vector3, the curve axis of the Path3D
  5089. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5090. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5091. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5092. */
  5093. constructor(
  5094. /**
  5095. * an array of Vector3, the curve axis of the Path3D
  5096. */
  5097. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5098. /**
  5099. * Returns the Path3D array of successive Vector3 designing its curve.
  5100. * @returns the Path3D array of successive Vector3 designing its curve.
  5101. */
  5102. getCurve(): Vector3[];
  5103. /**
  5104. * Returns the Path3D array of successive Vector3 designing its curve.
  5105. * @returns the Path3D array of successive Vector3 designing its curve.
  5106. */
  5107. getPoints(): Vector3[];
  5108. /**
  5109. * @returns the computed length (float) of the path.
  5110. */
  5111. length(): number;
  5112. /**
  5113. * Returns an array populated with tangent vectors on each Path3D curve point.
  5114. * @returns an array populated with tangent vectors on each Path3D curve point.
  5115. */
  5116. getTangents(): Vector3[];
  5117. /**
  5118. * Returns an array populated with normal vectors on each Path3D curve point.
  5119. * @returns an array populated with normal vectors on each Path3D curve point.
  5120. */
  5121. getNormals(): Vector3[];
  5122. /**
  5123. * Returns an array populated with binormal vectors on each Path3D curve point.
  5124. * @returns an array populated with binormal vectors on each Path3D curve point.
  5125. */
  5126. getBinormals(): Vector3[];
  5127. /**
  5128. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5129. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5130. */
  5131. getDistances(): number[];
  5132. /**
  5133. * Returns an interpolated point along this path
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @returns a new Vector3 as the point
  5136. */
  5137. getPointAt(position: number): Vector3;
  5138. /**
  5139. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5140. * @param position the position of the point along this path, from 0.0 to 1.0
  5141. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5142. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5143. */
  5144. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5145. /**
  5146. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5147. * @param position the position of the point along this path, from 0.0 to 1.0
  5148. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5149. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5150. */
  5151. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5152. /**
  5153. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5156. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5157. */
  5158. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5163. */
  5164. getDistanceAt(position: number): number;
  5165. /**
  5166. * Returns the array index of the previous point of an interpolated point along this path
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the array index
  5169. */
  5170. getPreviousPointIndexAt(position: number): number;
  5171. /**
  5172. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5173. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5174. * @returns the sub position
  5175. */
  5176. getSubPositionAt(position: number): number;
  5177. /**
  5178. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5179. * @param target the vector of which to get the closest position to
  5180. * @returns the position of the closest virtual point on this path to the target vector
  5181. */
  5182. getClosestPositionTo(target: Vector3): number;
  5183. /**
  5184. * Returns a sub path (slice) of this path
  5185. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5186. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5187. * @returns a sub path (slice) of this path
  5188. */
  5189. slice(start?: number, end?: number): Path3D;
  5190. /**
  5191. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5192. * @param path path which all values are copied into the curves points
  5193. * @param firstNormal which should be projected onto the curve
  5194. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5195. * @returns the same object updated.
  5196. */
  5197. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5198. private _compute;
  5199. private _getFirstNonNullVector;
  5200. private _getLastNonNullVector;
  5201. private _normalVector;
  5202. /**
  5203. * Updates the point at data for an interpolated point along this curve
  5204. * @param position the position of the point along this curve, from 0.0 to 1.0
  5205. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5206. * @returns the (updated) point at data
  5207. */
  5208. private _updatePointAtData;
  5209. /**
  5210. * Updates the point at data from the specified parameters
  5211. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5212. * @param point the interpolated point
  5213. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5214. */
  5215. private _setPointAtData;
  5216. /**
  5217. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5218. */
  5219. private _updateInterpolationMatrix;
  5220. }
  5221. /**
  5222. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5223. * A Curve3 is designed from a series of successive Vector3.
  5224. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5225. */
  5226. export class Curve3 {
  5227. private _points;
  5228. private _length;
  5229. /**
  5230. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5231. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5232. * @param v1 (Vector3) the control point
  5233. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5240. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5241. * @param v1 (Vector3) the first control point
  5242. * @param v2 (Vector3) the second control point
  5243. * @param v3 (Vector3) the end point of the Cubic Bezier
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5250. * @param p1 (Vector3) the origin point of the Hermite Spline
  5251. * @param t1 (Vector3) the tangent vector at the origin point
  5252. * @param p2 (Vector3) the end point of the Hermite Spline
  5253. * @param t2 (Vector3) the tangent vector at the end point
  5254. * @param nbPoints (integer) the wanted number of points in the curve
  5255. * @returns the created Curve3
  5256. */
  5257. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5258. /**
  5259. * Returns a Curve3 object along a CatmullRom Spline curve :
  5260. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5261. * @param nbPoints (integer) the wanted number of points between each curve control points
  5262. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5263. * @returns the created Curve3
  5264. */
  5265. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5266. /**
  5267. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5268. * A Curve3 is designed from a series of successive Vector3.
  5269. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5270. * @param points points which make up the curve
  5271. */
  5272. constructor(points: Vector3[]);
  5273. /**
  5274. * @returns the Curve3 stored array of successive Vector3
  5275. */
  5276. getPoints(): Vector3[];
  5277. /**
  5278. * @returns the computed length (float) of the curve.
  5279. */
  5280. length(): number;
  5281. /**
  5282. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5283. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5284. * curveA and curveB keep unchanged.
  5285. * @param curve the curve to continue from this curve
  5286. * @returns the newly constructed curve
  5287. */
  5288. continue(curve: DeepImmutable<Curve3>): Curve3;
  5289. private _computeLength;
  5290. }
  5291. }
  5292. declare module "babylonjs/Animations/easing" {
  5293. /**
  5294. * This represents the main contract an easing function should follow.
  5295. * Easing functions are used throughout the animation system.
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export interface IEasingFunction {
  5299. /**
  5300. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5301. * of the easing function.
  5302. * The link below provides some of the most common examples of easing functions.
  5303. * @see https://easings.net/
  5304. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5305. * @returns the corresponding value on the curve defined by the easing function
  5306. */
  5307. ease(gradient: number): number;
  5308. }
  5309. /**
  5310. * Base class used for every default easing function.
  5311. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5312. */
  5313. export class EasingFunction implements IEasingFunction {
  5314. /**
  5315. * Interpolation follows the mathematical formula associated with the easing function.
  5316. */
  5317. static readonly EASINGMODE_EASEIN: number;
  5318. /**
  5319. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5320. */
  5321. static readonly EASINGMODE_EASEOUT: number;
  5322. /**
  5323. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5324. */
  5325. static readonly EASINGMODE_EASEINOUT: number;
  5326. private _easingMode;
  5327. /**
  5328. * Sets the easing mode of the current function.
  5329. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5330. */
  5331. setEasingMode(easingMode: number): void;
  5332. /**
  5333. * Gets the current easing mode.
  5334. * @returns the easing mode
  5335. */
  5336. getEasingMode(): number;
  5337. /**
  5338. * @hidden
  5339. */
  5340. easeInCore(gradient: number): number;
  5341. /**
  5342. * Given an input gradient between 0 and 1, this returns the corresponding value
  5343. * of the easing function.
  5344. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5345. * @returns the corresponding value on the curve defined by the easing function
  5346. */
  5347. ease(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a circle shape (see link below).
  5351. * @see https://easings.net/#easeInCirc
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class CircleEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a ease back shape (see link below).
  5360. * @see https://easings.net/#easeInBack
  5361. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class BackEase extends EasingFunction implements IEasingFunction {
  5364. /** Defines the amplitude of the function */
  5365. amplitude: number;
  5366. /**
  5367. * Instantiates a back ease easing
  5368. * @see https://easings.net/#easeInBack
  5369. * @param amplitude Defines the amplitude of the function
  5370. */
  5371. constructor(
  5372. /** Defines the amplitude of the function */
  5373. amplitude?: number);
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a bouncing shape (see link below).
  5379. * @see https://easings.net/#easeInBounce
  5380. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class BounceEase extends EasingFunction implements IEasingFunction {
  5383. /** Defines the number of bounces */
  5384. bounces: number;
  5385. /** Defines the amplitude of the bounce */
  5386. bounciness: number;
  5387. /**
  5388. * Instantiates a bounce easing
  5389. * @see https://easings.net/#easeInBounce
  5390. * @param bounces Defines the number of bounces
  5391. * @param bounciness Defines the amplitude of the bounce
  5392. */
  5393. constructor(
  5394. /** Defines the number of bounces */
  5395. bounces?: number,
  5396. /** Defines the amplitude of the bounce */
  5397. bounciness?: number);
  5398. /** @hidden */
  5399. easeInCore(gradient: number): number;
  5400. }
  5401. /**
  5402. * Easing function with a power of 3 shape (see link below).
  5403. * @see https://easings.net/#easeInCubic
  5404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. export class CubicEase extends EasingFunction implements IEasingFunction {
  5407. /** @hidden */
  5408. easeInCore(gradient: number): number;
  5409. }
  5410. /**
  5411. * Easing function with an elastic shape (see link below).
  5412. * @see https://easings.net/#easeInElastic
  5413. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5414. */
  5415. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5416. /** Defines the number of oscillations*/
  5417. oscillations: number;
  5418. /** Defines the amplitude of the oscillations*/
  5419. springiness: number;
  5420. /**
  5421. * Instantiates an elastic easing function
  5422. * @see https://easings.net/#easeInElastic
  5423. * @param oscillations Defines the number of oscillations
  5424. * @param springiness Defines the amplitude of the oscillations
  5425. */
  5426. constructor(
  5427. /** Defines the number of oscillations*/
  5428. oscillations?: number,
  5429. /** Defines the amplitude of the oscillations*/
  5430. springiness?: number);
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with an exponential shape (see link below).
  5436. * @see https://easings.net/#easeInExpo
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5440. /** Defines the exponent of the function */
  5441. exponent: number;
  5442. /**
  5443. * Instantiates an exponential easing function
  5444. * @see https://easings.net/#easeInExpo
  5445. * @param exponent Defines the exponent of the function
  5446. */
  5447. constructor(
  5448. /** Defines the exponent of the function */
  5449. exponent?: number);
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power shape (see link below).
  5455. * @see https://easings.net/#easeInQuad
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class PowerEase extends EasingFunction implements IEasingFunction {
  5459. /** Defines the power of the function */
  5460. power: number;
  5461. /**
  5462. * Instantiates an power base easing function
  5463. * @see https://easings.net/#easeInQuad
  5464. * @param power Defines the power of the function
  5465. */
  5466. constructor(
  5467. /** Defines the power of the function */
  5468. power?: number);
  5469. /** @hidden */
  5470. easeInCore(gradient: number): number;
  5471. }
  5472. /**
  5473. * Easing function with a power of 2 shape (see link below).
  5474. * @see https://easings.net/#easeInQuad
  5475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5476. */
  5477. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5478. /** @hidden */
  5479. easeInCore(gradient: number): number;
  5480. }
  5481. /**
  5482. * Easing function with a power of 4 shape (see link below).
  5483. * @see https://easings.net/#easeInQuart
  5484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5485. */
  5486. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5487. /** @hidden */
  5488. easeInCore(gradient: number): number;
  5489. }
  5490. /**
  5491. * Easing function with a power of 5 shape (see link below).
  5492. * @see https://easings.net/#easeInQuint
  5493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5494. */
  5495. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5496. /** @hidden */
  5497. easeInCore(gradient: number): number;
  5498. }
  5499. /**
  5500. * Easing function with a sin shape (see link below).
  5501. * @see https://easings.net/#easeInSine
  5502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5503. */
  5504. export class SineEase extends EasingFunction implements IEasingFunction {
  5505. /** @hidden */
  5506. easeInCore(gradient: number): number;
  5507. }
  5508. /**
  5509. * Easing function with a bezier shape (see link below).
  5510. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5511. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5512. */
  5513. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5514. /** Defines the x component of the start tangent in the bezier curve */
  5515. x1: number;
  5516. /** Defines the y component of the start tangent in the bezier curve */
  5517. y1: number;
  5518. /** Defines the x component of the end tangent in the bezier curve */
  5519. x2: number;
  5520. /** Defines the y component of the end tangent in the bezier curve */
  5521. y2: number;
  5522. /**
  5523. * Instantiates a bezier function
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @param x1 Defines the x component of the start tangent in the bezier curve
  5526. * @param y1 Defines the y component of the start tangent in the bezier curve
  5527. * @param x2 Defines the x component of the end tangent in the bezier curve
  5528. * @param y2 Defines the y component of the end tangent in the bezier curve
  5529. */
  5530. constructor(
  5531. /** Defines the x component of the start tangent in the bezier curve */
  5532. x1?: number,
  5533. /** Defines the y component of the start tangent in the bezier curve */
  5534. y1?: number,
  5535. /** Defines the x component of the end tangent in the bezier curve */
  5536. x2?: number,
  5537. /** Defines the y component of the end tangent in the bezier curve */
  5538. y2?: number);
  5539. /** @hidden */
  5540. easeInCore(gradient: number): number;
  5541. }
  5542. }
  5543. declare module "babylonjs/Maths/math.color" {
  5544. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5545. /**
  5546. * Class used to hold a RBG color
  5547. */
  5548. export class Color3 {
  5549. /**
  5550. * Defines the red component (between 0 and 1, default is 0)
  5551. */
  5552. r: number;
  5553. /**
  5554. * Defines the green component (between 0 and 1, default is 0)
  5555. */
  5556. g: number;
  5557. /**
  5558. * Defines the blue component (between 0 and 1, default is 0)
  5559. */
  5560. b: number;
  5561. /**
  5562. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5563. * @param r defines the red component (between 0 and 1, default is 0)
  5564. * @param g defines the green component (between 0 and 1, default is 0)
  5565. * @param b defines the blue component (between 0 and 1, default is 0)
  5566. */
  5567. constructor(
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r?: number,
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g?: number,
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b?: number);
  5580. /**
  5581. * Creates a string with the Color3 current values
  5582. * @returns the string representation of the Color3 object
  5583. */
  5584. toString(): string;
  5585. /**
  5586. * Returns the string "Color3"
  5587. * @returns "Color3"
  5588. */
  5589. getClassName(): string;
  5590. /**
  5591. * Compute the Color3 hash code
  5592. * @returns an unique number that can be used to hash Color3 objects
  5593. */
  5594. getHashCode(): number;
  5595. /**
  5596. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5597. * @param array defines the array where to store the r,g,b components
  5598. * @param index defines an optional index in the target array to define where to start storing values
  5599. * @returns the current Color3 object
  5600. */
  5601. toArray(array: FloatArray, index?: number): Color3;
  5602. /**
  5603. * Update the current color with values stored in an array from the starting index of the given array
  5604. * @param array defines the source array
  5605. * @param offset defines an offset in the source array
  5606. * @returns the current Color3 object
  5607. */
  5608. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5609. /**
  5610. * Returns a new Color4 object from the current Color3 and the given alpha
  5611. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5612. * @returns a new Color4 object
  5613. */
  5614. toColor4(alpha?: number): Color4;
  5615. /**
  5616. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5617. * @returns the new array
  5618. */
  5619. asArray(): number[];
  5620. /**
  5621. * Returns the luminance value
  5622. * @returns a float value
  5623. */
  5624. toLuminance(): number;
  5625. /**
  5626. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5627. * @param otherColor defines the second operand
  5628. * @returns the new Color3 object
  5629. */
  5630. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5631. /**
  5632. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5633. * @param otherColor defines the second operand
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the current Color3
  5636. */
  5637. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5638. /**
  5639. * Determines equality between Color3 objects
  5640. * @param otherColor defines the second operand
  5641. * @returns true if the rgb values are equal to the given ones
  5642. */
  5643. equals(otherColor: DeepImmutable<Color3>): boolean;
  5644. /**
  5645. * Determines equality between the current Color3 object and a set of r,b,g values
  5646. * @param r defines the red component to check
  5647. * @param g defines the green component to check
  5648. * @param b defines the blue component to check
  5649. * @returns true if the rgb values are equal to the given ones
  5650. */
  5651. equalsFloats(r: number, g: number, b: number): boolean;
  5652. /**
  5653. * Multiplies in place each rgb value by scale
  5654. * @param scale defines the scaling factor
  5655. * @returns the updated Color3
  5656. */
  5657. scale(scale: number): Color3;
  5658. /**
  5659. * Multiplies the rgb values by scale and stores the result into "result"
  5660. * @param scale defines the scaling factor
  5661. * @param result defines the Color3 object where to store the result
  5662. * @returns the unmodified current Color3
  5663. */
  5664. scaleToRef(scale: number, result: Color3): Color3;
  5665. /**
  5666. * Scale the current Color3 values by a factor and add the result to a given Color3
  5667. * @param scale defines the scale factor
  5668. * @param result defines color to store the result into
  5669. * @returns the unmodified current Color3
  5670. */
  5671. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5672. /**
  5673. * Clamps the rgb values by the min and max values and stores the result into "result"
  5674. * @param min defines minimum clamping value (default is 0)
  5675. * @param max defines maximum clamping value (default is 1)
  5676. * @param result defines color to store the result into
  5677. * @returns the original Color3
  5678. */
  5679. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5680. /**
  5681. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5682. * @param otherColor defines the second operand
  5683. * @returns the new Color3
  5684. */
  5685. add(otherColor: DeepImmutable<Color3>): Color3;
  5686. /**
  5687. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5688. * @param otherColor defines the second operand
  5689. * @param result defines Color3 object to store the result into
  5690. * @returns the unmodified current Color3
  5691. */
  5692. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5693. /**
  5694. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5695. * @param otherColor defines the second operand
  5696. * @returns the new Color3
  5697. */
  5698. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5699. /**
  5700. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5701. * @param otherColor defines the second operand
  5702. * @param result defines Color3 object to store the result into
  5703. * @returns the unmodified current Color3
  5704. */
  5705. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5706. /**
  5707. * Copy the current object
  5708. * @returns a new Color3 copied the current one
  5709. */
  5710. clone(): Color3;
  5711. /**
  5712. * Copies the rgb values from the source in the current Color3
  5713. * @param source defines the source Color3 object
  5714. * @returns the updated Color3 object
  5715. */
  5716. copyFrom(source: DeepImmutable<Color3>): Color3;
  5717. /**
  5718. * Updates the Color3 rgb values from the given floats
  5719. * @param r defines the red component to read from
  5720. * @param g defines the green component to read from
  5721. * @param b defines the blue component to read from
  5722. * @returns the current Color3 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number): Color3;
  5725. /**
  5726. * Updates the Color3 rgb values from the given floats
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @returns the current Color3 object
  5731. */
  5732. set(r: number, g: number, b: number): Color3;
  5733. /**
  5734. * Compute the Color3 hexadecimal code as a string
  5735. * @returns a string containing the hexadecimal representation of the Color3 object
  5736. */
  5737. toHexString(): string;
  5738. /**
  5739. * Computes a new Color3 converted from the current one to linear space
  5740. * @returns a new Color3 object
  5741. */
  5742. toLinearSpace(): Color3;
  5743. /**
  5744. * Converts current color in rgb space to HSV values
  5745. * @returns a new color3 representing the HSV values
  5746. */
  5747. toHSV(): Color3;
  5748. /**
  5749. * Converts current color in rgb space to HSV values
  5750. * @param result defines the Color3 where to store the HSV values
  5751. */
  5752. toHSVToRef(result: Color3): void;
  5753. /**
  5754. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5755. * @param convertedColor defines the Color3 object where to store the linear space version
  5756. * @returns the unmodified Color3
  5757. */
  5758. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5759. /**
  5760. * Computes a new Color3 converted from the current one to gamma space
  5761. * @returns a new Color3 object
  5762. */
  5763. toGammaSpace(): Color3;
  5764. /**
  5765. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5766. * @param convertedColor defines the Color3 object where to store the gamma space version
  5767. * @returns the unmodified Color3
  5768. */
  5769. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5770. private static _BlackReadOnly;
  5771. /**
  5772. * Convert Hue, saturation and value to a Color3 (RGB)
  5773. * @param hue defines the hue
  5774. * @param saturation defines the saturation
  5775. * @param value defines the value
  5776. * @param result defines the Color3 where to store the RGB values
  5777. */
  5778. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5779. /**
  5780. * Creates a new Color3 from the string containing valid hexadecimal values
  5781. * @param hex defines a string containing valid hexadecimal values
  5782. * @returns a new Color3 object
  5783. */
  5784. static FromHexString(hex: string): Color3;
  5785. /**
  5786. * Creates a new Color3 from the starting index of the given array
  5787. * @param array defines the source array
  5788. * @param offset defines an offset in the source array
  5789. * @returns a new Color3 object
  5790. */
  5791. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5792. /**
  5793. * Creates a new Color3 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @param result defines the target Color3 object
  5797. */
  5798. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @returns a new Color3 object
  5805. */
  5806. static FromInts(r: number, g: number, b: number): Color3;
  5807. /**
  5808. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5809. * @param start defines the start Color3 value
  5810. * @param end defines the end Color3 value
  5811. * @param amount defines the gradient value between start and end
  5812. * @returns a new Color3 object
  5813. */
  5814. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5815. /**
  5816. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @param result defines the Color3 object where to store the result
  5821. */
  5822. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5823. /**
  5824. * Returns a Color3 value containing a red color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Red(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a green color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Green(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a blue color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Blue(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a black color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Black(): Color3;
  5843. /**
  5844. * Gets a Color3 value containing a black color that must not be updated
  5845. */
  5846. static get BlackReadOnly(): DeepImmutable<Color3>;
  5847. /**
  5848. * Returns a Color3 value containing a white color
  5849. * @returns a new Color3 object
  5850. */
  5851. static White(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a purple color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Purple(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a magenta color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Magenta(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a yellow color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Yellow(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a gray color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Gray(): Color3;
  5872. /**
  5873. * Returns a Color3 value containing a teal color
  5874. * @returns a new Color3 object
  5875. */
  5876. static Teal(): Color3;
  5877. /**
  5878. * Returns a Color3 value containing a random color
  5879. * @returns a new Color3 object
  5880. */
  5881. static Random(): Color3;
  5882. }
  5883. /**
  5884. * Class used to hold a RBGA color
  5885. */
  5886. export class Color4 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Defines the alpha component (between 0 and 1, default is 1)
  5901. */
  5902. a: number;
  5903. /**
  5904. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5905. * @param r defines the red component (between 0 and 1, default is 0)
  5906. * @param g defines the green component (between 0 and 1, default is 0)
  5907. * @param b defines the blue component (between 0 and 1, default is 0)
  5908. * @param a defines the alpha component (between 0 and 1, default is 1)
  5909. */
  5910. constructor(
  5911. /**
  5912. * Defines the red component (between 0 and 1, default is 0)
  5913. */
  5914. r?: number,
  5915. /**
  5916. * Defines the green component (between 0 and 1, default is 0)
  5917. */
  5918. g?: number,
  5919. /**
  5920. * Defines the blue component (between 0 and 1, default is 0)
  5921. */
  5922. b?: number,
  5923. /**
  5924. * Defines the alpha component (between 0 and 1, default is 1)
  5925. */
  5926. a?: number);
  5927. /**
  5928. * Adds in place the given Color4 values to the current Color4 object
  5929. * @param right defines the second operand
  5930. * @returns the current updated Color4 object
  5931. */
  5932. addInPlace(right: DeepImmutable<Color4>): Color4;
  5933. /**
  5934. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5935. * @returns the new array
  5936. */
  5937. asArray(): number[];
  5938. /**
  5939. * Stores from the starting index in the given array the Color4 successive values
  5940. * @param array defines the array where to store the r,g,b components
  5941. * @param index defines an optional index in the target array to define where to start storing values
  5942. * @returns the current Color4 object
  5943. */
  5944. toArray(array: number[], index?: number): Color4;
  5945. /**
  5946. * Update the current color with values stored in an array from the starting index of the given array
  5947. * @param array defines the source array
  5948. * @param offset defines an offset in the source array
  5949. * @returns the current Color4 object
  5950. */
  5951. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5952. /**
  5953. * Determines equality between Color4 objects
  5954. * @param otherColor defines the second operand
  5955. * @returns true if the rgba values are equal to the given ones
  5956. */
  5957. equals(otherColor: DeepImmutable<Color4>): boolean;
  5958. /**
  5959. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. add(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5966. * @param right defines the second operand
  5967. * @returns a new Color4 object
  5968. */
  5969. subtract(right: DeepImmutable<Color4>): Color4;
  5970. /**
  5971. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5972. * @param right defines the second operand
  5973. * @param result defines the Color4 object where to store the result
  5974. * @returns the current Color4 object
  5975. */
  5976. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 with the current Color4 values multiplied by scale
  5979. * @param scale defines the scaling factor to apply
  5980. * @returns a new Color4 object
  5981. */
  5982. scale(scale: number): Color4;
  5983. /**
  5984. * Multiplies the current Color4 values by scale and stores the result in "result"
  5985. * @param scale defines the scaling factor to apply
  5986. * @param result defines the Color4 object where to store the result
  5987. * @returns the current unmodified Color4
  5988. */
  5989. scaleToRef(scale: number, result: Color4): Color4;
  5990. /**
  5991. * Scale the current Color4 values by a factor and add the result to a given Color4
  5992. * @param scale defines the scale factor
  5993. * @param result defines the Color4 object where to store the result
  5994. * @returns the unmodified current Color4
  5995. */
  5996. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5997. /**
  5998. * Clamps the rgb values by the min and max values and stores the result into "result"
  5999. * @param min defines minimum clamping value (default is 0)
  6000. * @param max defines maximum clamping value (default is 1)
  6001. * @param result defines color to store the result into.
  6002. * @returns the cuurent Color4
  6003. */
  6004. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6005. /**
  6006. * Multipy an Color4 value by another and return a new Color4 object
  6007. * @param color defines the Color4 value to multiply by
  6008. * @returns a new Color4 object
  6009. */
  6010. multiply(color: Color4): Color4;
  6011. /**
  6012. * Multipy a Color4 value by another and push the result in a reference value
  6013. * @param color defines the Color4 value to multiply by
  6014. * @param result defines the Color4 to fill the result in
  6015. * @returns the result Color4
  6016. */
  6017. multiplyToRef(color: Color4, result: Color4): Color4;
  6018. /**
  6019. * Creates a string with the Color4 current values
  6020. * @returns the string representation of the Color4 object
  6021. */
  6022. toString(): string;
  6023. /**
  6024. * Returns the string "Color4"
  6025. * @returns "Color4"
  6026. */
  6027. getClassName(): string;
  6028. /**
  6029. * Compute the Color4 hash code
  6030. * @returns an unique number that can be used to hash Color4 objects
  6031. */
  6032. getHashCode(): number;
  6033. /**
  6034. * Creates a new Color4 copied from the current one
  6035. * @returns a new Color4 object
  6036. */
  6037. clone(): Color4;
  6038. /**
  6039. * Copies the given Color4 values into the current one
  6040. * @param source defines the source Color4 object
  6041. * @returns the current updated Color4 object
  6042. */
  6043. copyFrom(source: Color4): Color4;
  6044. /**
  6045. * Copies the given float values into the current one
  6046. * @param r defines the red component to read from
  6047. * @param g defines the green component to read from
  6048. * @param b defines the blue component to read from
  6049. * @param a defines the alpha component to read from
  6050. * @returns the current updated Color4 object
  6051. */
  6052. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6053. /**
  6054. * Copies the given float values into the current one
  6055. * @param r defines the red component to read from
  6056. * @param g defines the green component to read from
  6057. * @param b defines the blue component to read from
  6058. * @param a defines the alpha component to read from
  6059. * @returns the current updated Color4 object
  6060. */
  6061. set(r: number, g: number, b: number, a: number): Color4;
  6062. /**
  6063. * Compute the Color4 hexadecimal code as a string
  6064. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6065. * @returns a string containing the hexadecimal representation of the Color4 object
  6066. */
  6067. toHexString(returnAsColor3?: boolean): string;
  6068. /**
  6069. * Computes a new Color4 converted from the current one to linear space
  6070. * @returns a new Color4 object
  6071. */
  6072. toLinearSpace(): Color4;
  6073. /**
  6074. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6075. * @param convertedColor defines the Color4 object where to store the linear space version
  6076. * @returns the unmodified Color4
  6077. */
  6078. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6079. /**
  6080. * Computes a new Color4 converted from the current one to gamma space
  6081. * @returns a new Color4 object
  6082. */
  6083. toGammaSpace(): Color4;
  6084. /**
  6085. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6086. * @param convertedColor defines the Color4 object where to store the gamma space version
  6087. * @returns the unmodified Color4
  6088. */
  6089. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6090. /**
  6091. * Creates a new Color4 from the string containing valid hexadecimal values
  6092. * @param hex defines a string containing valid hexadecimal values
  6093. * @returns a new Color4 object
  6094. */
  6095. static FromHexString(hex: string): Color4;
  6096. /**
  6097. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6098. * @param left defines the start value
  6099. * @param right defines the end value
  6100. * @param amount defines the gradient factor
  6101. * @returns a new Color4 object
  6102. */
  6103. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6104. /**
  6105. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6106. * @param left defines the start value
  6107. * @param right defines the end value
  6108. * @param amount defines the gradient factor
  6109. * @param result defines the Color4 object where to store data
  6110. */
  6111. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6112. /**
  6113. * Creates a new Color4 from a Color3 and an alpha value
  6114. * @param color3 defines the source Color3 to read from
  6115. * @param alpha defines the alpha component (1.0 by default)
  6116. * @returns a new Color4 object
  6117. */
  6118. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6119. /**
  6120. * Creates a new Color4 from the starting index element of the given array
  6121. * @param array defines the source array to read from
  6122. * @param offset defines the offset in the source array
  6123. * @returns a new Color4 object
  6124. */
  6125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6126. /**
  6127. * Creates a new Color4 from the starting index element of the given array
  6128. * @param array defines the source array to read from
  6129. * @param offset defines the offset in the source array
  6130. * @param result defines the target Color4 object
  6131. */
  6132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6133. /**
  6134. * Creates a new Color3 from integer values (< 256)
  6135. * @param r defines the red component to read from (value between 0 and 255)
  6136. * @param g defines the green component to read from (value between 0 and 255)
  6137. * @param b defines the blue component to read from (value between 0 and 255)
  6138. * @param a defines the alpha component to read from (value between 0 and 255)
  6139. * @returns a new Color3 object
  6140. */
  6141. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6142. /**
  6143. * Check the content of a given array and convert it to an array containing RGBA data
  6144. * If the original array was already containing count * 4 values then it is returned directly
  6145. * @param colors defines the array to check
  6146. * @param count defines the number of RGBA data to expect
  6147. * @returns an array containing count * 4 values (RGBA)
  6148. */
  6149. static CheckColors4(colors: number[], count: number): number[];
  6150. }
  6151. /**
  6152. * @hidden
  6153. */
  6154. export class TmpColors {
  6155. static Color3: Color3[];
  6156. static Color4: Color4[];
  6157. }
  6158. }
  6159. declare module "babylonjs/Animations/animationKey" {
  6160. /**
  6161. * Defines an interface which represents an animation key frame
  6162. */
  6163. export interface IAnimationKey {
  6164. /**
  6165. * Frame of the key frame
  6166. */
  6167. frame: number;
  6168. /**
  6169. * Value at the specifies key frame
  6170. */
  6171. value: any;
  6172. /**
  6173. * The input tangent for the cubic hermite spline
  6174. */
  6175. inTangent?: any;
  6176. /**
  6177. * The output tangent for the cubic hermite spline
  6178. */
  6179. outTangent?: any;
  6180. /**
  6181. * The animation interpolation type
  6182. */
  6183. interpolation?: AnimationKeyInterpolation;
  6184. }
  6185. /**
  6186. * Enum for the animation key frame interpolation type
  6187. */
  6188. export enum AnimationKeyInterpolation {
  6189. /**
  6190. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6191. */
  6192. STEP = 1
  6193. }
  6194. }
  6195. declare module "babylonjs/Animations/animationRange" {
  6196. /**
  6197. * Represents the range of an animation
  6198. */
  6199. export class AnimationRange {
  6200. /**The name of the animation range**/
  6201. name: string;
  6202. /**The starting frame of the animation */
  6203. from: number;
  6204. /**The ending frame of the animation*/
  6205. to: number;
  6206. /**
  6207. * Initializes the range of an animation
  6208. * @param name The name of the animation range
  6209. * @param from The starting frame of the animation
  6210. * @param to The ending frame of the animation
  6211. */
  6212. constructor(
  6213. /**The name of the animation range**/
  6214. name: string,
  6215. /**The starting frame of the animation */
  6216. from: number,
  6217. /**The ending frame of the animation*/
  6218. to: number);
  6219. /**
  6220. * Makes a copy of the animation range
  6221. * @returns A copy of the animation range
  6222. */
  6223. clone(): AnimationRange;
  6224. }
  6225. }
  6226. declare module "babylonjs/Animations/animationEvent" {
  6227. /**
  6228. * Composed of a frame, and an action function
  6229. */
  6230. export class AnimationEvent {
  6231. /** The frame for which the event is triggered **/
  6232. frame: number;
  6233. /** The event to perform when triggered **/
  6234. action: (currentFrame: number) => void;
  6235. /** Specifies if the event should be triggered only once**/
  6236. onlyOnce?: boolean | undefined;
  6237. /**
  6238. * Specifies if the animation event is done
  6239. */
  6240. isDone: boolean;
  6241. /**
  6242. * Initializes the animation event
  6243. * @param frame The frame for which the event is triggered
  6244. * @param action The event to perform when triggered
  6245. * @param onlyOnce Specifies if the event should be triggered only once
  6246. */
  6247. constructor(
  6248. /** The frame for which the event is triggered **/
  6249. frame: number,
  6250. /** The event to perform when triggered **/
  6251. action: (currentFrame: number) => void,
  6252. /** Specifies if the event should be triggered only once**/
  6253. onlyOnce?: boolean | undefined);
  6254. /** @hidden */
  6255. _clone(): AnimationEvent;
  6256. }
  6257. }
  6258. declare module "babylonjs/Behaviors/behavior" {
  6259. import { Nullable } from "babylonjs/types";
  6260. /**
  6261. * Interface used to define a behavior
  6262. */
  6263. export interface Behavior<T> {
  6264. /** gets or sets behavior's name */
  6265. name: string;
  6266. /**
  6267. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6268. */
  6269. init(): void;
  6270. /**
  6271. * Called when the behavior is attached to a target
  6272. * @param target defines the target where the behavior is attached to
  6273. */
  6274. attach(target: T): void;
  6275. /**
  6276. * Called when the behavior is detached from its target
  6277. */
  6278. detach(): void;
  6279. }
  6280. /**
  6281. * Interface implemented by classes supporting behaviors
  6282. */
  6283. export interface IBehaviorAware<T> {
  6284. /**
  6285. * Attach a behavior
  6286. * @param behavior defines the behavior to attach
  6287. * @returns the current host
  6288. */
  6289. addBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Remove a behavior from the current object
  6292. * @param behavior defines the behavior to detach
  6293. * @returns the current host
  6294. */
  6295. removeBehavior(behavior: Behavior<T>): T;
  6296. /**
  6297. * Gets a behavior using its name to search
  6298. * @param name defines the name to search
  6299. * @returns the behavior or null if not found
  6300. */
  6301. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6302. }
  6303. }
  6304. declare module "babylonjs/Misc/smartArray" {
  6305. /**
  6306. * Defines an array and its length.
  6307. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6308. */
  6309. export interface ISmartArrayLike<T> {
  6310. /**
  6311. * The data of the array.
  6312. */
  6313. data: Array<T>;
  6314. /**
  6315. * The active length of the array.
  6316. */
  6317. length: number;
  6318. }
  6319. /**
  6320. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6321. */
  6322. export class SmartArray<T> implements ISmartArrayLike<T> {
  6323. /**
  6324. * The full set of data from the array.
  6325. */
  6326. data: Array<T>;
  6327. /**
  6328. * The active length of the array.
  6329. */
  6330. length: number;
  6331. protected _id: number;
  6332. /**
  6333. * Instantiates a Smart Array.
  6334. * @param capacity defines the default capacity of the array.
  6335. */
  6336. constructor(capacity: number);
  6337. /**
  6338. * Pushes a value at the end of the active data.
  6339. * @param value defines the object to push in the array.
  6340. */
  6341. push(value: T): void;
  6342. /**
  6343. * Iterates over the active data and apply the lambda to them.
  6344. * @param func defines the action to apply on each value.
  6345. */
  6346. forEach(func: (content: T) => void): void;
  6347. /**
  6348. * Sorts the full sets of data.
  6349. * @param compareFn defines the comparison function to apply.
  6350. */
  6351. sort(compareFn: (a: T, b: T) => number): void;
  6352. /**
  6353. * Resets the active data to an empty array.
  6354. */
  6355. reset(): void;
  6356. /**
  6357. * Releases all the data from the array as well as the array.
  6358. */
  6359. dispose(): void;
  6360. /**
  6361. * Concats the active data with a given array.
  6362. * @param array defines the data to concatenate with.
  6363. */
  6364. concat(array: any): void;
  6365. /**
  6366. * Returns the position of a value in the active data.
  6367. * @param value defines the value to find the index for
  6368. * @returns the index if found in the active data otherwise -1
  6369. */
  6370. indexOf(value: T): number;
  6371. /**
  6372. * Returns whether an element is part of the active data.
  6373. * @param value defines the value to look for
  6374. * @returns true if found in the active data otherwise false
  6375. */
  6376. contains(value: T): boolean;
  6377. private static _GlobalId;
  6378. }
  6379. /**
  6380. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6381. * The data in this array can only be present once
  6382. */
  6383. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6384. private _duplicateId;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6388. * @param value defines the object to push in the array.
  6389. */
  6390. push(value: T): void;
  6391. /**
  6392. * Pushes a value at the end of the active data.
  6393. * If the data is already present, it won t be added again
  6394. * @param value defines the object to push in the array.
  6395. * @returns true if added false if it was already present
  6396. */
  6397. pushNoDuplicate(value: T): boolean;
  6398. /**
  6399. * Resets the active data to an empty array.
  6400. */
  6401. reset(): void;
  6402. /**
  6403. * Concats the active data with a given array.
  6404. * This ensures no dupplicate will be present in the result.
  6405. * @param array defines the data to concatenate with.
  6406. */
  6407. concatWithNoDuplicate(array: any): void;
  6408. }
  6409. }
  6410. declare module "babylonjs/Cameras/cameraInputsManager" {
  6411. import { Nullable } from "babylonjs/types";
  6412. import { Camera } from "babylonjs/Cameras/camera";
  6413. /**
  6414. * @ignore
  6415. * This is a list of all the different input types that are available in the application.
  6416. * Fo instance: ArcRotateCameraGamepadInput...
  6417. */
  6418. export var CameraInputTypes: {};
  6419. /**
  6420. * This is the contract to implement in order to create a new input class.
  6421. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6422. */
  6423. export interface ICameraInput<TCamera extends Camera> {
  6424. /**
  6425. * Defines the camera the input is attached to.
  6426. */
  6427. camera: Nullable<TCamera>;
  6428. /**
  6429. * Gets the class name of the current intput.
  6430. * @returns the class name
  6431. */
  6432. getClassName(): string;
  6433. /**
  6434. * Get the friendly name associated with the input class.
  6435. * @returns the input friendly name
  6436. */
  6437. getSimpleName(): string;
  6438. /**
  6439. * Attach the input controls to a specific dom element to get the input from.
  6440. * @param element Defines the element the controls should be listened from
  6441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6442. */
  6443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6444. /**
  6445. * Detach the current controls from the specified dom element.
  6446. * @param element Defines the element to stop listening the inputs from
  6447. */
  6448. detachControl(element: Nullable<HTMLElement>): void;
  6449. /**
  6450. * Update the current camera state depending on the inputs that have been used this frame.
  6451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6452. */
  6453. checkInputs?: () => void;
  6454. }
  6455. /**
  6456. * Represents a map of input types to input instance or input index to input instance.
  6457. */
  6458. export interface CameraInputsMap<TCamera extends Camera> {
  6459. /**
  6460. * Accessor to the input by input type.
  6461. */
  6462. [name: string]: ICameraInput<TCamera>;
  6463. /**
  6464. * Accessor to the input by input index.
  6465. */
  6466. [idx: number]: ICameraInput<TCamera>;
  6467. }
  6468. /**
  6469. * This represents the input manager used within a camera.
  6470. * It helps dealing with all the different kind of input attached to a camera.
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. */
  6473. export class CameraInputsManager<TCamera extends Camera> {
  6474. /**
  6475. * Defines the list of inputs attahed to the camera.
  6476. */
  6477. attached: CameraInputsMap<TCamera>;
  6478. /**
  6479. * Defines the dom element the camera is collecting inputs from.
  6480. * This is null if the controls have not been attached.
  6481. */
  6482. attachedElement: Nullable<HTMLElement>;
  6483. /**
  6484. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6485. */
  6486. noPreventDefault: boolean;
  6487. /**
  6488. * Defined the camera the input manager belongs to.
  6489. */
  6490. camera: TCamera;
  6491. /**
  6492. * Update the current camera state depending on the inputs that have been used this frame.
  6493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6494. */
  6495. checkInputs: () => void;
  6496. /**
  6497. * Instantiate a new Camera Input Manager.
  6498. * @param camera Defines the camera the input manager blongs to
  6499. */
  6500. constructor(camera: TCamera);
  6501. /**
  6502. * Add an input method to a camera
  6503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6504. * @param input camera input method
  6505. */
  6506. add(input: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input method from a camera
  6509. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6510. * @param inputToRemove camera input method
  6511. */
  6512. remove(inputToRemove: ICameraInput<TCamera>): void;
  6513. /**
  6514. * Remove a specific input type from a camera
  6515. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6516. * @param inputType the type of the input to remove
  6517. */
  6518. removeByType(inputType: string): void;
  6519. private _addCheckInputs;
  6520. /**
  6521. * Attach the input controls to the currently attached dom element to listen the events from.
  6522. * @param input Defines the input to attach
  6523. */
  6524. attachInput(input: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6529. */
  6530. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6531. /**
  6532. * Detach the current manager inputs controls from a specific dom element.
  6533. * @param element Defines the dom element to collect the events from
  6534. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6535. */
  6536. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6537. /**
  6538. * Rebuild the dynamic inputCheck function from the current list of
  6539. * defined inputs in the manager.
  6540. */
  6541. rebuildInputCheck(): void;
  6542. /**
  6543. * Remove all attached input methods from a camera
  6544. */
  6545. clear(): void;
  6546. /**
  6547. * Serialize the current input manager attached to a camera.
  6548. * This ensures than once parsed,
  6549. * the input associated to the camera will be identical to the current ones
  6550. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6551. */
  6552. serialize(serializedCamera: any): void;
  6553. /**
  6554. * Parses an input manager serialized JSON to restore the previous list of inputs
  6555. * and states associated to a camera.
  6556. * @param parsedCamera Defines the JSON to parse
  6557. */
  6558. parse(parsedCamera: any): void;
  6559. }
  6560. }
  6561. declare module "babylonjs/Meshes/buffer" {
  6562. import { Nullable, DataArray } from "babylonjs/types";
  6563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6564. /**
  6565. * Class used to store data that will be store in GPU memory
  6566. */
  6567. export class Buffer {
  6568. private _engine;
  6569. private _buffer;
  6570. /** @hidden */
  6571. _data: Nullable<DataArray>;
  6572. private _updatable;
  6573. private _instanced;
  6574. private _divisor;
  6575. /**
  6576. * Gets the byte stride.
  6577. */
  6578. readonly byteStride: number;
  6579. /**
  6580. * Constructor
  6581. * @param engine the engine
  6582. * @param data the data to use for this buffer
  6583. * @param updatable whether the data is updatable
  6584. * @param stride the stride (optional)
  6585. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6586. * @param instanced whether the buffer is instanced (optional)
  6587. * @param useBytes set to true if the stride in in bytes (optional)
  6588. * @param divisor sets an optional divisor for instances (1 by default)
  6589. */
  6590. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6591. /**
  6592. * Create a new VertexBuffer based on the current buffer
  6593. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6594. * @param offset defines offset in the buffer (0 by default)
  6595. * @param size defines the size in floats of attributes (position is 3 for instance)
  6596. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6597. * @param instanced defines if the vertex buffer contains indexed data
  6598. * @param useBytes defines if the offset and stride are in bytes *
  6599. * @param divisor sets an optional divisor for instances (1 by default)
  6600. * @returns the new vertex buffer
  6601. */
  6602. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6603. /**
  6604. * Gets a boolean indicating if the Buffer is updatable?
  6605. * @returns true if the buffer is updatable
  6606. */
  6607. isUpdatable(): boolean;
  6608. /**
  6609. * Gets current buffer's data
  6610. * @returns a DataArray or null
  6611. */
  6612. getData(): Nullable<DataArray>;
  6613. /**
  6614. * Gets underlying native buffer
  6615. * @returns underlying native buffer
  6616. */
  6617. getBuffer(): Nullable<DataBuffer>;
  6618. /**
  6619. * Gets the stride in float32 units (i.e. byte stride / 4).
  6620. * May not be an integer if the byte stride is not divisible by 4.
  6621. * @returns the stride in float32 units
  6622. * @deprecated Please use byteStride instead.
  6623. */
  6624. getStrideSize(): number;
  6625. /**
  6626. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6627. * @param data defines the data to store
  6628. */
  6629. create(data?: Nullable<DataArray>): void;
  6630. /** @hidden */
  6631. _rebuild(): void;
  6632. /**
  6633. * Update current buffer data
  6634. * @param data defines the data to store
  6635. */
  6636. update(data: DataArray): void;
  6637. /**
  6638. * Updates the data directly.
  6639. * @param data the new data
  6640. * @param offset the new offset
  6641. * @param vertexCount the vertex count (optional)
  6642. * @param useBytes set to true if the offset is in bytes
  6643. */
  6644. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6645. /**
  6646. * Release all resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. /**
  6651. * Specialized buffer used to store vertex data
  6652. */
  6653. export class VertexBuffer {
  6654. /** @hidden */
  6655. _buffer: Buffer;
  6656. private _kind;
  6657. private _size;
  6658. private _ownsBuffer;
  6659. private _instanced;
  6660. private _instanceDivisor;
  6661. /**
  6662. * The byte type.
  6663. */
  6664. static readonly BYTE: number;
  6665. /**
  6666. * The unsigned byte type.
  6667. */
  6668. static readonly UNSIGNED_BYTE: number;
  6669. /**
  6670. * The short type.
  6671. */
  6672. static readonly SHORT: number;
  6673. /**
  6674. * The unsigned short type.
  6675. */
  6676. static readonly UNSIGNED_SHORT: number;
  6677. /**
  6678. * The integer type.
  6679. */
  6680. static readonly INT: number;
  6681. /**
  6682. * The unsigned integer type.
  6683. */
  6684. static readonly UNSIGNED_INT: number;
  6685. /**
  6686. * The float type.
  6687. */
  6688. static readonly FLOAT: number;
  6689. /**
  6690. * Gets or sets the instance divisor when in instanced mode
  6691. */
  6692. get instanceDivisor(): number;
  6693. set instanceDivisor(value: number);
  6694. /**
  6695. * Gets the byte stride.
  6696. */
  6697. readonly byteStride: number;
  6698. /**
  6699. * Gets the byte offset.
  6700. */
  6701. readonly byteOffset: number;
  6702. /**
  6703. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6704. */
  6705. readonly normalized: boolean;
  6706. /**
  6707. * Gets the data type of each component in the array.
  6708. */
  6709. readonly type: number;
  6710. /**
  6711. * Constructor
  6712. * @param engine the engine
  6713. * @param data the data to use for this vertex buffer
  6714. * @param kind the vertex buffer kind
  6715. * @param updatable whether the data is updatable
  6716. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6717. * @param stride the stride (optional)
  6718. * @param instanced whether the buffer is instanced (optional)
  6719. * @param offset the offset of the data (optional)
  6720. * @param size the number of components (optional)
  6721. * @param type the type of the component (optional)
  6722. * @param normalized whether the data contains normalized data (optional)
  6723. * @param useBytes set to true if stride and offset are in bytes (optional)
  6724. * @param divisor defines the instance divisor to use (1 by default)
  6725. */
  6726. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6727. /** @hidden */
  6728. _rebuild(): void;
  6729. /**
  6730. * Returns the kind of the VertexBuffer (string)
  6731. * @returns a string
  6732. */
  6733. getKind(): string;
  6734. /**
  6735. * Gets a boolean indicating if the VertexBuffer is updatable?
  6736. * @returns true if the buffer is updatable
  6737. */
  6738. isUpdatable(): boolean;
  6739. /**
  6740. * Gets current buffer's data
  6741. * @returns a DataArray or null
  6742. */
  6743. getData(): Nullable<DataArray>;
  6744. /**
  6745. * Gets underlying native buffer
  6746. * @returns underlying native buffer
  6747. */
  6748. getBuffer(): Nullable<DataBuffer>;
  6749. /**
  6750. * Gets the stride in float32 units (i.e. byte stride / 4).
  6751. * May not be an integer if the byte stride is not divisible by 4.
  6752. * @returns the stride in float32 units
  6753. * @deprecated Please use byteStride instead.
  6754. */
  6755. getStrideSize(): number;
  6756. /**
  6757. * Returns the offset as a multiple of the type byte length.
  6758. * @returns the offset in bytes
  6759. * @deprecated Please use byteOffset instead.
  6760. */
  6761. getOffset(): number;
  6762. /**
  6763. * Returns the number of components per vertex attribute (integer)
  6764. * @returns the size in float
  6765. */
  6766. getSize(): number;
  6767. /**
  6768. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6769. * @returns true if this buffer is instanced
  6770. */
  6771. getIsInstanced(): boolean;
  6772. /**
  6773. * Returns the instancing divisor, zero for non-instanced (integer).
  6774. * @returns a number
  6775. */
  6776. getInstanceDivisor(): number;
  6777. /**
  6778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6779. * @param data defines the data to store
  6780. */
  6781. create(data?: DataArray): void;
  6782. /**
  6783. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6784. * This function will create a new buffer if the current one is not updatable
  6785. * @param data defines the data to store
  6786. */
  6787. update(data: DataArray): void;
  6788. /**
  6789. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6790. * Returns the directly updated WebGLBuffer.
  6791. * @param data the new data
  6792. * @param offset the new offset
  6793. * @param useBytes set to true if the offset is in bytes
  6794. */
  6795. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6796. /**
  6797. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6798. */
  6799. dispose(): void;
  6800. /**
  6801. * Enumerates each value of this vertex buffer as numbers.
  6802. * @param count the number of values to enumerate
  6803. * @param callback the callback function called for each value
  6804. */
  6805. forEach(count: number, callback: (value: number, index: number) => void): void;
  6806. /**
  6807. * Positions
  6808. */
  6809. static readonly PositionKind: string;
  6810. /**
  6811. * Normals
  6812. */
  6813. static readonly NormalKind: string;
  6814. /**
  6815. * Tangents
  6816. */
  6817. static readonly TangentKind: string;
  6818. /**
  6819. * Texture coordinates
  6820. */
  6821. static readonly UVKind: string;
  6822. /**
  6823. * Texture coordinates 2
  6824. */
  6825. static readonly UV2Kind: string;
  6826. /**
  6827. * Texture coordinates 3
  6828. */
  6829. static readonly UV3Kind: string;
  6830. /**
  6831. * Texture coordinates 4
  6832. */
  6833. static readonly UV4Kind: string;
  6834. /**
  6835. * Texture coordinates 5
  6836. */
  6837. static readonly UV5Kind: string;
  6838. /**
  6839. * Texture coordinates 6
  6840. */
  6841. static readonly UV6Kind: string;
  6842. /**
  6843. * Colors
  6844. */
  6845. static readonly ColorKind: string;
  6846. /**
  6847. * Matrix indices (for bones)
  6848. */
  6849. static readonly MatricesIndicesKind: string;
  6850. /**
  6851. * Matrix weights (for bones)
  6852. */
  6853. static readonly MatricesWeightsKind: string;
  6854. /**
  6855. * Additional matrix indices (for bones)
  6856. */
  6857. static readonly MatricesIndicesExtraKind: string;
  6858. /**
  6859. * Additional matrix weights (for bones)
  6860. */
  6861. static readonly MatricesWeightsExtraKind: string;
  6862. /**
  6863. * Deduces the stride given a kind.
  6864. * @param kind The kind string to deduce
  6865. * @returns The deduced stride
  6866. */
  6867. static DeduceStride(kind: string): number;
  6868. /**
  6869. * Gets the byte length of the given type.
  6870. * @param type the type
  6871. * @returns the number of bytes
  6872. */
  6873. static GetTypeByteLength(type: number): number;
  6874. /**
  6875. * Enumerates each value of the given parameters as numbers.
  6876. * @param data the data to enumerate
  6877. * @param byteOffset the byte offset of the data
  6878. * @param byteStride the byte stride of the data
  6879. * @param componentCount the number of components per element
  6880. * @param componentType the type of the component
  6881. * @param count the number of values to enumerate
  6882. * @param normalized whether the data is normalized
  6883. * @param callback the callback function called for each value
  6884. */
  6885. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6886. private static _GetFloatValue;
  6887. }
  6888. }
  6889. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6890. import { Vector3 } from "babylonjs/Maths/math.vector";
  6891. import { Mesh } from "babylonjs/Meshes/mesh";
  6892. /**
  6893. * The options Interface for creating a Capsule Mesh
  6894. */
  6895. export interface ICreateCapsuleOptions {
  6896. /** The Orientation of the capsule. Default : Vector3.Up() */
  6897. orientation?: Vector3;
  6898. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6899. subdivisions: number;
  6900. /** Number of cylindrical segments on the capsule. */
  6901. tessellation: number;
  6902. /** Height or Length of the capsule. */
  6903. height: number;
  6904. /** Radius of the capsule. */
  6905. radius: number;
  6906. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6907. capSubdivisions: number;
  6908. /** Overwrite for the top radius. */
  6909. radiusTop?: number;
  6910. /** Overwrite for the bottom radius. */
  6911. radiusBottom?: number;
  6912. /** Overwrite for the top capSubdivisions. */
  6913. topCapSubdivisions?: number;
  6914. /** Overwrite for the bottom capSubdivisions. */
  6915. bottomCapSubdivisions?: number;
  6916. }
  6917. /**
  6918. * Class containing static functions to help procedurally build meshes
  6919. */
  6920. export class CapsuleBuilder {
  6921. /**
  6922. * Creates a capsule or a pill mesh
  6923. * @param name defines the name of the mesh
  6924. * @param options The constructors options.
  6925. * @param scene The scene the mesh is scoped to.
  6926. * @returns Capsule Mesh
  6927. */
  6928. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6929. }
  6930. }
  6931. declare module "babylonjs/Collisions/intersectionInfo" {
  6932. import { Nullable } from "babylonjs/types";
  6933. /**
  6934. * @hidden
  6935. */
  6936. export class IntersectionInfo {
  6937. bu: Nullable<number>;
  6938. bv: Nullable<number>;
  6939. distance: number;
  6940. faceId: number;
  6941. subMeshId: number;
  6942. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6943. }
  6944. }
  6945. declare module "babylonjs/Culling/boundingSphere" {
  6946. import { DeepImmutable } from "babylonjs/types";
  6947. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6948. import { Plane } from "babylonjs/Maths/math.plane";
  6949. /**
  6950. * Class used to store bounding sphere information
  6951. */
  6952. export class BoundingSphere {
  6953. /**
  6954. * Gets the center of the bounding sphere in local space
  6955. */
  6956. readonly center: Vector3;
  6957. /**
  6958. * Radius of the bounding sphere in local space
  6959. */
  6960. radius: number;
  6961. /**
  6962. * Gets the center of the bounding sphere in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Radius of the bounding sphere in world space
  6967. */
  6968. radiusWorld: number;
  6969. /**
  6970. * Gets the minimum vector in local space
  6971. */
  6972. readonly minimum: Vector3;
  6973. /**
  6974. * Gets the maximum vector in local space
  6975. */
  6976. readonly maximum: Vector3;
  6977. private _worldMatrix;
  6978. private static readonly TmpVector3;
  6979. /**
  6980. * Creates a new bounding sphere
  6981. * @param min defines the minimum vector (in local space)
  6982. * @param max defines the maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6986. /**
  6987. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6988. * @param min defines the new minimum vector (in local space)
  6989. * @param max defines the new maximum vector (in local space)
  6990. * @param worldMatrix defines the new world matrix
  6991. */
  6992. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6993. /**
  6994. * Scale the current bounding sphere by applying a scale factor
  6995. * @param factor defines the scale factor to apply
  6996. * @returns the current bounding box
  6997. */
  6998. scale(factor: number): BoundingSphere;
  6999. /**
  7000. * Gets the world matrix of the bounding box
  7001. * @returns a matrix
  7002. */
  7003. getWorldMatrix(): DeepImmutable<Matrix>;
  7004. /** @hidden */
  7005. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Tests if the bounding sphere is intersecting the frustum planes
  7008. * @param frustumPlanes defines the frustum planes to test
  7009. * @returns true if there is an intersection
  7010. */
  7011. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /**
  7013. * Tests if the bounding sphere center is in between the frustum planes.
  7014. * Used for optimistic fast inclusion.
  7015. * @param frustumPlanes defines the frustum planes to test
  7016. * @returns true if the sphere center is in between the frustum planes
  7017. */
  7018. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7019. /**
  7020. * Tests if a point is inside the bounding sphere
  7021. * @param point defines the point to test
  7022. * @returns true if the point is inside the bounding sphere
  7023. */
  7024. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7025. /**
  7026. * Checks if two sphere intersct
  7027. * @param sphere0 sphere 0
  7028. * @param sphere1 sphere 1
  7029. * @returns true if the speres intersect
  7030. */
  7031. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7032. }
  7033. }
  7034. declare module "babylonjs/Culling/boundingBox" {
  7035. import { DeepImmutable } from "babylonjs/types";
  7036. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7037. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7038. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7039. import { Plane } from "babylonjs/Maths/math.plane";
  7040. /**
  7041. * Class used to store bounding box information
  7042. */
  7043. export class BoundingBox implements ICullable {
  7044. /**
  7045. * Gets the 8 vectors representing the bounding box in local space
  7046. */
  7047. readonly vectors: Vector3[];
  7048. /**
  7049. * Gets the center of the bounding box in local space
  7050. */
  7051. readonly center: Vector3;
  7052. /**
  7053. * Gets the center of the bounding box in world space
  7054. */
  7055. readonly centerWorld: Vector3;
  7056. /**
  7057. * Gets the extend size in local space
  7058. */
  7059. readonly extendSize: Vector3;
  7060. /**
  7061. * Gets the extend size in world space
  7062. */
  7063. readonly extendSizeWorld: Vector3;
  7064. /**
  7065. * Gets the OBB (object bounding box) directions
  7066. */
  7067. readonly directions: Vector3[];
  7068. /**
  7069. * Gets the 8 vectors representing the bounding box in world space
  7070. */
  7071. readonly vectorsWorld: Vector3[];
  7072. /**
  7073. * Gets the minimum vector in world space
  7074. */
  7075. readonly minimumWorld: Vector3;
  7076. /**
  7077. * Gets the maximum vector in world space
  7078. */
  7079. readonly maximumWorld: Vector3;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * @hidden
  7092. */
  7093. _tag: number;
  7094. /**
  7095. * Creates a new bounding box
  7096. * @param min defines the minimum vector (in local space)
  7097. * @param max defines the maximum vector (in local space)
  7098. * @param worldMatrix defines the new world matrix
  7099. */
  7100. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7101. /**
  7102. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7103. * @param min defines the new minimum vector (in local space)
  7104. * @param max defines the new maximum vector (in local space)
  7105. * @param worldMatrix defines the new world matrix
  7106. */
  7107. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7108. /**
  7109. * Scale the current bounding box by applying a scale factor
  7110. * @param factor defines the scale factor to apply
  7111. * @returns the current bounding box
  7112. */
  7113. scale(factor: number): BoundingBox;
  7114. /**
  7115. * Gets the world matrix of the bounding box
  7116. * @returns a matrix
  7117. */
  7118. getWorldMatrix(): DeepImmutable<Matrix>;
  7119. /** @hidden */
  7120. _update(world: DeepImmutable<Matrix>): void;
  7121. /**
  7122. * Tests if the bounding box is intersecting the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an intersection
  7125. */
  7126. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if the bounding box is entirely inside the frustum planes
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @returns true if there is an inclusion
  7131. */
  7132. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if a point is inside the bounding box
  7135. * @param point defines the point to test
  7136. * @returns true if the point is inside the bounding box
  7137. */
  7138. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a bounding sphere
  7141. * @param sphere defines the sphere to test
  7142. * @returns true if there is an intersection
  7143. */
  7144. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7145. /**
  7146. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7147. * @param min defines the min vector to use
  7148. * @param max defines the max vector to use
  7149. * @returns true if there is an intersection
  7150. */
  7151. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7152. /**
  7153. * Tests if two bounding boxes are intersections
  7154. * @param box0 defines the first box to test
  7155. * @param box1 defines the second box to test
  7156. * @returns true if there is an intersection
  7157. */
  7158. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7159. /**
  7160. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7161. * @param minPoint defines the minimum vector of the bounding box
  7162. * @param maxPoint defines the maximum vector of the bounding box
  7163. * @param sphereCenter defines the sphere center
  7164. * @param sphereRadius defines the sphere radius
  7165. * @returns true if there is an intersection
  7166. */
  7167. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7168. /**
  7169. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7170. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7171. * @param frustumPlanes defines the frustum planes to test
  7172. * @return true if there is an inclusion
  7173. */
  7174. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7175. /**
  7176. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7177. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7178. * @param frustumPlanes defines the frustum planes to test
  7179. * @return true if there is an intersection
  7180. */
  7181. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Collisions/collider" {
  7185. import { Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7188. import { Plane } from "babylonjs/Maths/math.plane";
  7189. /** @hidden */
  7190. export class Collider {
  7191. /** Define if a collision was found */
  7192. collisionFound: boolean;
  7193. /**
  7194. * Define last intersection point in local space
  7195. */
  7196. intersectionPoint: Vector3;
  7197. /**
  7198. * Define last collided mesh
  7199. */
  7200. collidedMesh: Nullable<AbstractMesh>;
  7201. private _collisionPoint;
  7202. private _planeIntersectionPoint;
  7203. private _tempVector;
  7204. private _tempVector2;
  7205. private _tempVector3;
  7206. private _tempVector4;
  7207. private _edge;
  7208. private _baseToVertex;
  7209. private _destinationPoint;
  7210. private _slidePlaneNormal;
  7211. private _displacementVector;
  7212. /** @hidden */
  7213. _radius: Vector3;
  7214. /** @hidden */
  7215. _retry: number;
  7216. private _velocity;
  7217. private _basePoint;
  7218. private _epsilon;
  7219. /** @hidden */
  7220. _velocityWorldLength: number;
  7221. /** @hidden */
  7222. _basePointWorld: Vector3;
  7223. private _velocityWorld;
  7224. private _normalizedVelocity;
  7225. /** @hidden */
  7226. _initialVelocity: Vector3;
  7227. /** @hidden */
  7228. _initialPosition: Vector3;
  7229. private _nearestDistance;
  7230. private _collisionMask;
  7231. get collisionMask(): number;
  7232. set collisionMask(mask: number);
  7233. /**
  7234. * Gets the plane normal used to compute the sliding response (in local space)
  7235. */
  7236. get slidePlaneNormal(): Vector3;
  7237. /** @hidden */
  7238. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7239. /** @hidden */
  7240. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7241. /** @hidden */
  7242. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7243. /** @hidden */
  7244. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7245. /** @hidden */
  7246. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7247. /** @hidden */
  7248. _getResponse(pos: Vector3, vel: Vector3): void;
  7249. }
  7250. }
  7251. declare module "babylonjs/Culling/boundingInfo" {
  7252. import { DeepImmutable } from "babylonjs/types";
  7253. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7254. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7255. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7256. import { Plane } from "babylonjs/Maths/math.plane";
  7257. import { Collider } from "babylonjs/Collisions/collider";
  7258. /**
  7259. * Interface for cullable objects
  7260. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7261. */
  7262. export interface ICullable {
  7263. /**
  7264. * Checks if the object or part of the object is in the frustum
  7265. * @param frustumPlanes Camera near/planes
  7266. * @returns true if the object is in frustum otherwise false
  7267. */
  7268. isInFrustum(frustumPlanes: Plane[]): boolean;
  7269. /**
  7270. * Checks if a cullable object (mesh...) is in the camera frustum
  7271. * Unlike isInFrustum this cheks the full bounding box
  7272. * @param frustumPlanes Camera near/planes
  7273. * @returns true if the object is in frustum otherwise false
  7274. */
  7275. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7276. }
  7277. /**
  7278. * Info for a bounding data of a mesh
  7279. */
  7280. export class BoundingInfo implements ICullable {
  7281. /**
  7282. * Bounding box for the mesh
  7283. */
  7284. readonly boundingBox: BoundingBox;
  7285. /**
  7286. * Bounding sphere for the mesh
  7287. */
  7288. readonly boundingSphere: BoundingSphere;
  7289. private _isLocked;
  7290. private static readonly TmpVector3;
  7291. /**
  7292. * Constructs bounding info
  7293. * @param minimum min vector of the bounding box/sphere
  7294. * @param maximum max vector of the bounding box/sphere
  7295. * @param worldMatrix defines the new world matrix
  7296. */
  7297. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7298. /**
  7299. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7300. * @param min defines the new minimum vector (in local space)
  7301. * @param max defines the new maximum vector (in local space)
  7302. * @param worldMatrix defines the new world matrix
  7303. */
  7304. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7305. /**
  7306. * min vector of the bounding box/sphere
  7307. */
  7308. get minimum(): Vector3;
  7309. /**
  7310. * max vector of the bounding box/sphere
  7311. */
  7312. get maximum(): Vector3;
  7313. /**
  7314. * If the info is locked and won't be updated to avoid perf overhead
  7315. */
  7316. get isLocked(): boolean;
  7317. set isLocked(value: boolean);
  7318. /**
  7319. * Updates the bounding sphere and box
  7320. * @param world world matrix to be used to update
  7321. */
  7322. update(world: DeepImmutable<Matrix>): void;
  7323. /**
  7324. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7325. * @param center New center of the bounding info
  7326. * @param extend New extend of the bounding info
  7327. * @returns the current bounding info
  7328. */
  7329. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7330. /**
  7331. * Scale the current bounding info by applying a scale factor
  7332. * @param factor defines the scale factor to apply
  7333. * @returns the current bounding info
  7334. */
  7335. scale(factor: number): BoundingInfo;
  7336. /**
  7337. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7338. * @param frustumPlanes defines the frustum to test
  7339. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7340. * @returns true if the bounding info is in the frustum planes
  7341. */
  7342. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7343. /**
  7344. * Gets the world distance between the min and max points of the bounding box
  7345. */
  7346. get diagonalLength(): number;
  7347. /**
  7348. * Checks if a cullable object (mesh...) is in the camera frustum
  7349. * Unlike isInFrustum this cheks the full bounding box
  7350. * @param frustumPlanes Camera near/planes
  7351. * @returns true if the object is in frustum otherwise false
  7352. */
  7353. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7354. /** @hidden */
  7355. _checkCollision(collider: Collider): boolean;
  7356. /**
  7357. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7358. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7359. * @param point the point to check intersection with
  7360. * @returns if the point intersects
  7361. */
  7362. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7363. /**
  7364. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7365. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7366. * @param boundingInfo the bounding info to check intersection with
  7367. * @param precise if the intersection should be done using OBB
  7368. * @returns if the bounding info intersects
  7369. */
  7370. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7371. }
  7372. }
  7373. declare module "babylonjs/Maths/math.functions" {
  7374. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7375. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7376. /**
  7377. * Extracts minimum and maximum values from a list of indexed positions
  7378. * @param positions defines the positions to use
  7379. * @param indices defines the indices to the positions
  7380. * @param indexStart defines the start index
  7381. * @param indexCount defines the end index
  7382. * @param bias defines bias value to add to the result
  7383. * @return minimum and maximum values
  7384. */
  7385. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7386. minimum: Vector3;
  7387. maximum: Vector3;
  7388. };
  7389. /**
  7390. * Extracts minimum and maximum values from a list of positions
  7391. * @param positions defines the positions to use
  7392. * @param start defines the start index in the positions array
  7393. * @param count defines the number of positions to handle
  7394. * @param bias defines bias value to add to the result
  7395. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7396. * @return minimum and maximum values
  7397. */
  7398. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7399. minimum: Vector3;
  7400. maximum: Vector3;
  7401. };
  7402. }
  7403. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7404. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7405. /** @hidden */
  7406. export class WebGLDataBuffer extends DataBuffer {
  7407. private _buffer;
  7408. constructor(resource: WebGLBuffer);
  7409. get underlyingResource(): any;
  7410. }
  7411. }
  7412. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7414. import { Nullable } from "babylonjs/types";
  7415. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7416. /** @hidden */
  7417. export class WebGLPipelineContext implements IPipelineContext {
  7418. engine: ThinEngine;
  7419. program: Nullable<WebGLProgram>;
  7420. context?: WebGLRenderingContext;
  7421. vertexShader?: WebGLShader;
  7422. fragmentShader?: WebGLShader;
  7423. isParallelCompiled: boolean;
  7424. onCompiled?: () => void;
  7425. transformFeedback?: WebGLTransformFeedback | null;
  7426. vertexCompilationError: Nullable<string>;
  7427. fragmentCompilationError: Nullable<string>;
  7428. programLinkError: Nullable<string>;
  7429. programValidationError: Nullable<string>;
  7430. get isAsync(): boolean;
  7431. get isReady(): boolean;
  7432. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7433. _getVertexShaderCode(): string | null;
  7434. _getFragmentShaderCode(): string | null;
  7435. }
  7436. }
  7437. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7438. import { FloatArray, Nullable } from "babylonjs/types";
  7439. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7440. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7441. module "babylonjs/Engines/thinEngine" {
  7442. interface ThinEngine {
  7443. /**
  7444. * Create an uniform buffer
  7445. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7446. * @param elements defines the content of the uniform buffer
  7447. * @returns the webGL uniform buffer
  7448. */
  7449. createUniformBuffer(elements: FloatArray): DataBuffer;
  7450. /**
  7451. * Create a dynamic uniform buffer
  7452. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7453. * @param elements defines the content of the uniform buffer
  7454. * @returns the webGL uniform buffer
  7455. */
  7456. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7457. /**
  7458. * Update an existing uniform buffer
  7459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. * @param uniformBuffer defines the target uniform buffer
  7461. * @param elements defines the content to update
  7462. * @param offset defines the offset in the uniform buffer where update should start
  7463. * @param count defines the size of the data to update
  7464. */
  7465. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7466. /**
  7467. * Bind an uniform buffer to the current webGL context
  7468. * @param buffer defines the buffer to bind
  7469. */
  7470. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7471. /**
  7472. * Bind a buffer to the current webGL context at a given location
  7473. * @param buffer defines the buffer to bind
  7474. * @param location defines the index where to bind the buffer
  7475. */
  7476. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7477. /**
  7478. * Bind a specific block at a given index in a specific shader program
  7479. * @param pipelineContext defines the pipeline context to use
  7480. * @param blockName defines the block name
  7481. * @param index defines the index where to bind the block
  7482. */
  7483. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7484. }
  7485. }
  7486. }
  7487. declare module "babylonjs/Materials/uniformBuffer" {
  7488. import { Nullable, FloatArray } from "babylonjs/types";
  7489. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7490. import { Engine } from "babylonjs/Engines/engine";
  7491. import { Effect } from "babylonjs/Materials/effect";
  7492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7494. import { Color3 } from "babylonjs/Maths/math.color";
  7495. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7496. /**
  7497. * Uniform buffer objects.
  7498. *
  7499. * Handles blocks of uniform on the GPU.
  7500. *
  7501. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7502. *
  7503. * For more information, please refer to :
  7504. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7505. */
  7506. export class UniformBuffer {
  7507. private _engine;
  7508. private _buffer;
  7509. private _data;
  7510. private _bufferData;
  7511. private _dynamic?;
  7512. private _uniformLocations;
  7513. private _uniformSizes;
  7514. private _uniformLocationPointer;
  7515. private _needSync;
  7516. private _noUBO;
  7517. private _currentEffect;
  7518. /** @hidden */
  7519. _alreadyBound: boolean;
  7520. private static _MAX_UNIFORM_SIZE;
  7521. private static _tempBuffer;
  7522. /**
  7523. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7534. /**
  7535. * Lambda to Update a single float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat: (name: string, x: number) => void;
  7540. /**
  7541. * Lambda to Update a vec2 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec3 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a vec4 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateMatrix: (name: string, mat: Matrix) => void;
  7564. /**
  7565. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector3: (name: string, vector: Vector3) => void;
  7570. /**
  7571. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateVector4: (name: string, vector: Vector4) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7588. /**
  7589. * Instantiates a new Uniform buffer objects.
  7590. *
  7591. * Handles blocks of uniform on the GPU.
  7592. *
  7593. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7594. *
  7595. * For more information, please refer to :
  7596. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7597. * @param engine Define the engine the buffer is associated with
  7598. * @param data Define the data contained in the buffer
  7599. * @param dynamic Define if the buffer is updatable
  7600. */
  7601. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7602. /**
  7603. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7604. * or just falling back on setUniformXXX calls.
  7605. */
  7606. get useUbo(): boolean;
  7607. /**
  7608. * Indicates if the WebGL underlying uniform buffer is in sync
  7609. * with the javascript cache data.
  7610. */
  7611. get isSync(): boolean;
  7612. /**
  7613. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7614. * Also, a dynamic UniformBuffer will disable cache verification and always
  7615. * update the underlying WebGL uniform buffer to the GPU.
  7616. * @returns if Dynamic, otherwise false
  7617. */
  7618. isDynamic(): boolean;
  7619. /**
  7620. * The data cache on JS side.
  7621. * @returns the underlying data as a float array
  7622. */
  7623. getData(): Float32Array;
  7624. /**
  7625. * The underlying WebGL Uniform buffer.
  7626. * @returns the webgl buffer
  7627. */
  7628. getBuffer(): Nullable<DataBuffer>;
  7629. /**
  7630. * std140 layout specifies how to align data within an UBO structure.
  7631. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7632. * for specs.
  7633. */
  7634. private _fillAlignment;
  7635. /**
  7636. * Adds an uniform in the buffer.
  7637. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7638. * for the layout to be correct !
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param size Data size, or data directly.
  7641. */
  7642. addUniform(name: string, size: number | number[]): void;
  7643. /**
  7644. * Adds a Matrix 4x4 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param mat A 4x4 matrix.
  7647. */
  7648. addMatrix(name: string, mat: Matrix): void;
  7649. /**
  7650. * Adds a vec2 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param x Define the x component value of the vec2
  7653. * @param y Define the y component value of the vec2
  7654. */
  7655. addFloat2(name: string, x: number, y: number): void;
  7656. /**
  7657. * Adds a vec3 to the uniform buffer.
  7658. * @param name Name of the uniform, as used in the uniform block in the shader.
  7659. * @param x Define the x component value of the vec3
  7660. * @param y Define the y component value of the vec3
  7661. * @param z Define the z component value of the vec3
  7662. */
  7663. addFloat3(name: string, x: number, y: number, z: number): void;
  7664. /**
  7665. * Adds a vec3 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the vec3 from a Color
  7668. */
  7669. addColor3(name: string, color: Color3): void;
  7670. /**
  7671. * Adds a vec4 to the uniform buffer.
  7672. * @param name Name of the uniform, as used in the uniform block in the shader.
  7673. * @param color Define the rgb components from a Color
  7674. * @param alpha Define the a component of the vec4
  7675. */
  7676. addColor4(name: string, color: Color3, alpha: number): void;
  7677. /**
  7678. * Adds a vec3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. * @param vector Define the vec3 components from a Vector
  7681. */
  7682. addVector3(name: string, vector: Vector3): void;
  7683. /**
  7684. * Adds a Matrix 3x3 to the uniform buffer.
  7685. * @param name Name of the uniform, as used in the uniform block in the shader.
  7686. */
  7687. addMatrix3x3(name: string): void;
  7688. /**
  7689. * Adds a Matrix 2x2 to the uniform buffer.
  7690. * @param name Name of the uniform, as used in the uniform block in the shader.
  7691. */
  7692. addMatrix2x2(name: string): void;
  7693. /**
  7694. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7695. */
  7696. create(): void;
  7697. /** @hidden */
  7698. _rebuild(): void;
  7699. /**
  7700. * Updates the WebGL Uniform Buffer on the GPU.
  7701. * If the `dynamic` flag is set to true, no cache comparison is done.
  7702. * Otherwise, the buffer will be updated only if the cache differs.
  7703. */
  7704. update(): void;
  7705. /**
  7706. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7707. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7708. * @param data Define the flattened data
  7709. * @param size Define the size of the data.
  7710. */
  7711. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7712. private _valueCache;
  7713. private _cacheMatrix;
  7714. private _updateMatrix3x3ForUniform;
  7715. private _updateMatrix3x3ForEffect;
  7716. private _updateMatrix2x2ForEffect;
  7717. private _updateMatrix2x2ForUniform;
  7718. private _updateFloatForEffect;
  7719. private _updateFloatForUniform;
  7720. private _updateFloat2ForEffect;
  7721. private _updateFloat2ForUniform;
  7722. private _updateFloat3ForEffect;
  7723. private _updateFloat3ForUniform;
  7724. private _updateFloat4ForEffect;
  7725. private _updateFloat4ForUniform;
  7726. private _updateMatrixForEffect;
  7727. private _updateMatrixForUniform;
  7728. private _updateVector3ForEffect;
  7729. private _updateVector3ForUniform;
  7730. private _updateVector4ForEffect;
  7731. private _updateVector4ForUniform;
  7732. private _updateColor3ForEffect;
  7733. private _updateColor3ForUniform;
  7734. private _updateColor4ForEffect;
  7735. private _updateColor4ForUniform;
  7736. /**
  7737. * Sets a sampler uniform on the effect.
  7738. * @param name Define the name of the sampler.
  7739. * @param texture Define the texture to set in the sampler
  7740. */
  7741. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7742. /**
  7743. * Directly updates the value of the uniform in the cache AND on the GPU.
  7744. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7745. * @param data Define the flattened data
  7746. */
  7747. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7748. /**
  7749. * Binds this uniform buffer to an effect.
  7750. * @param effect Define the effect to bind the buffer to
  7751. * @param name Name of the uniform block in the shader.
  7752. */
  7753. bindToEffect(effect: Effect, name: string): void;
  7754. /**
  7755. * Disposes the uniform buffer.
  7756. */
  7757. dispose(): void;
  7758. }
  7759. }
  7760. declare module "babylonjs/Misc/iInspectable" {
  7761. /**
  7762. * Enum that determines the text-wrapping mode to use.
  7763. */
  7764. export enum InspectableType {
  7765. /**
  7766. * Checkbox for booleans
  7767. */
  7768. Checkbox = 0,
  7769. /**
  7770. * Sliders for numbers
  7771. */
  7772. Slider = 1,
  7773. /**
  7774. * Vector3
  7775. */
  7776. Vector3 = 2,
  7777. /**
  7778. * Quaternions
  7779. */
  7780. Quaternion = 3,
  7781. /**
  7782. * Color3
  7783. */
  7784. Color3 = 4,
  7785. /**
  7786. * String
  7787. */
  7788. String = 5
  7789. }
  7790. /**
  7791. * Interface used to define custom inspectable properties.
  7792. * This interface is used by the inspector to display custom property grids
  7793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7794. */
  7795. export interface IInspectable {
  7796. /**
  7797. * Gets the label to display
  7798. */
  7799. label: string;
  7800. /**
  7801. * Gets the name of the property to edit
  7802. */
  7803. propertyName: string;
  7804. /**
  7805. * Gets the type of the editor to use
  7806. */
  7807. type: InspectableType;
  7808. /**
  7809. * Gets the minimum value of the property when using in "slider" mode
  7810. */
  7811. min?: number;
  7812. /**
  7813. * Gets the maximum value of the property when using in "slider" mode
  7814. */
  7815. max?: number;
  7816. /**
  7817. * Gets the setp to use when using in "slider" mode
  7818. */
  7819. step?: number;
  7820. }
  7821. }
  7822. declare module "babylonjs/Misc/timingTools" {
  7823. /**
  7824. * Class used to provide helper for timing
  7825. */
  7826. export class TimingTools {
  7827. /**
  7828. * Polyfill for setImmediate
  7829. * @param action defines the action to execute after the current execution block
  7830. */
  7831. static SetImmediate(action: () => void): void;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/instantiationTools" {
  7835. /**
  7836. * Class used to enable instatition of objects by class name
  7837. */
  7838. export class InstantiationTools {
  7839. /**
  7840. * Use this object to register external classes like custom textures or material
  7841. * to allow the laoders to instantiate them
  7842. */
  7843. static RegisteredExternalClasses: {
  7844. [key: string]: Object;
  7845. };
  7846. /**
  7847. * Tries to instantiate a new object from a given class name
  7848. * @param className defines the class name to instantiate
  7849. * @returns the new object or null if the system was not able to do the instantiation
  7850. */
  7851. static Instantiate(className: string): any;
  7852. }
  7853. }
  7854. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7855. /**
  7856. * Define options used to create a depth texture
  7857. */
  7858. export class DepthTextureCreationOptions {
  7859. /** Specifies whether or not a stencil should be allocated in the texture */
  7860. generateStencil?: boolean;
  7861. /** Specifies whether or not bilinear filtering is enable on the texture */
  7862. bilinearFiltering?: boolean;
  7863. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7864. comparisonFunction?: number;
  7865. /** Specifies if the created texture is a cube texture */
  7866. isCube?: boolean;
  7867. }
  7868. }
  7869. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7871. import { Nullable } from "babylonjs/types";
  7872. import { Scene } from "babylonjs/scene";
  7873. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7874. module "babylonjs/Engines/thinEngine" {
  7875. interface ThinEngine {
  7876. /**
  7877. * Creates a depth stencil cube texture.
  7878. * This is only available in WebGL 2.
  7879. * @param size The size of face edge in the cube texture.
  7880. * @param options The options defining the cube texture.
  7881. * @returns The cube texture
  7882. */
  7883. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7884. /**
  7885. * Creates a cube texture
  7886. * @param rootUrl defines the url where the files to load is located
  7887. * @param scene defines the current scene
  7888. * @param files defines the list of files to load (1 per face)
  7889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7890. * @param onLoad defines an optional callback raised when the texture is loaded
  7891. * @param onError defines an optional callback raised if there is an issue to load the texture
  7892. * @param format defines the format of the data
  7893. * @param forcedExtension defines the extension to use to pick the right loader
  7894. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7897. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7898. * @returns the cube texture as an InternalTexture
  7899. */
  7900. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7901. /**
  7902. * Creates a cube texture
  7903. * @param rootUrl defines the url where the files to load is located
  7904. * @param scene defines the current scene
  7905. * @param files defines the list of files to load (1 per face)
  7906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7907. * @param onLoad defines an optional callback raised when the texture is loaded
  7908. * @param onError defines an optional callback raised if there is an issue to load the texture
  7909. * @param format defines the format of the data
  7910. * @param forcedExtension defines the extension to use to pick the right loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7927. * @returns the cube texture as an InternalTexture
  7928. */
  7929. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7930. /** @hidden */
  7931. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7932. /** @hidden */
  7933. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7934. /** @hidden */
  7935. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7936. /** @hidden */
  7937. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7938. /**
  7939. * @hidden
  7940. */
  7941. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7942. }
  7943. }
  7944. }
  7945. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7946. import { Nullable } from "babylonjs/types";
  7947. import { Scene } from "babylonjs/scene";
  7948. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7950. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7951. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7952. import { Observable } from "babylonjs/Misc/observable";
  7953. /**
  7954. * Class for creating a cube texture
  7955. */
  7956. export class CubeTexture extends BaseTexture {
  7957. private _delayedOnLoad;
  7958. /**
  7959. * Observable triggered once the texture has been loaded.
  7960. */
  7961. onLoadObservable: Observable<CubeTexture>;
  7962. /**
  7963. * The url of the texture
  7964. */
  7965. url: string;
  7966. /**
  7967. * Gets or sets the center of the bounding box associated with the cube texture.
  7968. * It must define where the camera used to render the texture was set
  7969. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7970. */
  7971. boundingBoxPosition: Vector3;
  7972. private _boundingBoxSize;
  7973. /**
  7974. * Gets or sets the size of the bounding box associated with the cube texture
  7975. * When defined, the cubemap will switch to local mode
  7976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7977. * @example https://www.babylonjs-playground.com/#RNASML
  7978. */
  7979. set boundingBoxSize(value: Vector3);
  7980. /**
  7981. * Returns the bounding box size
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. get boundingBoxSize(): Vector3;
  7985. protected _rotationY: number;
  7986. /**
  7987. * Sets texture matrix rotation angle around Y axis in radians.
  7988. */
  7989. set rotationY(value: number);
  7990. /**
  7991. * Gets texture matrix rotation angle around Y axis radians.
  7992. */
  7993. get rotationY(): number;
  7994. /**
  7995. * Are mip maps generated for this texture or not.
  7996. */
  7997. get noMipmap(): boolean;
  7998. private _noMipmap;
  7999. private _files;
  8000. protected _forcedExtension: Nullable<string>;
  8001. private _extensions;
  8002. private _textureMatrix;
  8003. private _format;
  8004. private _createPolynomials;
  8005. /**
  8006. * Creates a cube texture from an array of image urls
  8007. * @param files defines an array of image urls
  8008. * @param scene defines the hosting scene
  8009. * @param noMipmap specifies if mip maps are not used
  8010. * @returns a cube texture
  8011. */
  8012. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8013. /**
  8014. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8015. * @param url defines the url of the prefiltered texture
  8016. * @param scene defines the scene the texture is attached to
  8017. * @param forcedExtension defines the extension of the file if different from the url
  8018. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8019. * @return the prefiltered texture
  8020. */
  8021. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8022. /**
  8023. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8024. * as prefiltered data.
  8025. * @param rootUrl defines the url of the texture or the root name of the six images
  8026. * @param null defines the scene or engine the texture is attached to
  8027. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8028. * @param noMipmap defines if mipmaps should be created or not
  8029. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8030. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8031. * @param onError defines a callback triggered in case of error during load
  8032. * @param format defines the internal format to use for the texture once loaded
  8033. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8034. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8035. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8036. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8037. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8038. * @return the cube texture
  8039. */
  8040. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8041. /**
  8042. * Get the current class name of the texture useful for serialization or dynamic coding.
  8043. * @returns "CubeTexture"
  8044. */
  8045. getClassName(): string;
  8046. /**
  8047. * Update the url (and optional buffer) of this texture if url was null during construction.
  8048. * @param url the url of the texture
  8049. * @param forcedExtension defines the extension to use
  8050. * @param onLoad callback called when the texture is loaded (defaults to null)
  8051. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8052. */
  8053. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8054. /**
  8055. * Delays loading of the cube texture
  8056. * @param forcedExtension defines the extension to use
  8057. */
  8058. delayLoad(forcedExtension?: string): void;
  8059. /**
  8060. * Returns the reflection texture matrix
  8061. * @returns the reflection texture matrix
  8062. */
  8063. getReflectionTextureMatrix(): Matrix;
  8064. /**
  8065. * Sets the reflection texture matrix
  8066. * @param value Reflection texture matrix
  8067. */
  8068. setReflectionTextureMatrix(value: Matrix): void;
  8069. /**
  8070. * Parses text to create a cube texture
  8071. * @param parsedTexture define the serialized text to read from
  8072. * @param scene defines the hosting scene
  8073. * @param rootUrl defines the root url of the cube texture
  8074. * @returns a cube texture
  8075. */
  8076. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8077. /**
  8078. * Makes a clone, or deep copy, of the cube texture
  8079. * @returns a new cube texture
  8080. */
  8081. clone(): CubeTexture;
  8082. }
  8083. }
  8084. declare module "babylonjs/Materials/materialDefines" {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module "babylonjs/Materials/colorCurves" {
  8191. import { Effect } from "babylonjs/Materials/effect";
  8192. /**
  8193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8195. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8197. */
  8198. export class ColorCurves {
  8199. private _dirty;
  8200. private _tempColor;
  8201. private _globalCurve;
  8202. private _highlightsCurve;
  8203. private _midtonesCurve;
  8204. private _shadowsCurve;
  8205. private _positiveCurve;
  8206. private _negativeCurve;
  8207. private _globalHue;
  8208. private _globalDensity;
  8209. private _globalSaturation;
  8210. private _globalExposure;
  8211. /**
  8212. * Gets the global Hue value.
  8213. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8214. */
  8215. get globalHue(): number;
  8216. /**
  8217. * Sets the global Hue value.
  8218. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8219. */
  8220. set globalHue(value: number);
  8221. /**
  8222. * Gets the global Density value.
  8223. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. get globalDensity(): number;
  8227. /**
  8228. * Sets the global Density value.
  8229. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. set globalDensity(value: number);
  8233. /**
  8234. * Gets the global Saturation value.
  8235. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8236. */
  8237. get globalSaturation(): number;
  8238. /**
  8239. * Sets the global Saturation value.
  8240. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8241. */
  8242. set globalSaturation(value: number);
  8243. /**
  8244. * Gets the global Exposure value.
  8245. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8246. */
  8247. get globalExposure(): number;
  8248. /**
  8249. * Sets the global Exposure value.
  8250. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8251. */
  8252. set globalExposure(value: number);
  8253. private _highlightsHue;
  8254. private _highlightsDensity;
  8255. private _highlightsSaturation;
  8256. private _highlightsExposure;
  8257. /**
  8258. * Gets the highlights Hue value.
  8259. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8260. */
  8261. get highlightsHue(): number;
  8262. /**
  8263. * Sets the highlights Hue value.
  8264. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8265. */
  8266. set highlightsHue(value: number);
  8267. /**
  8268. * Gets the highlights Density value.
  8269. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. get highlightsDensity(): number;
  8273. /**
  8274. * Sets the highlights Density value.
  8275. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8276. * Values less than zero provide a filter of opposite hue.
  8277. */
  8278. set highlightsDensity(value: number);
  8279. /**
  8280. * Gets the highlights Saturation value.
  8281. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8282. */
  8283. get highlightsSaturation(): number;
  8284. /**
  8285. * Sets the highlights Saturation value.
  8286. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8287. */
  8288. set highlightsSaturation(value: number);
  8289. /**
  8290. * Gets the highlights Exposure value.
  8291. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8292. */
  8293. get highlightsExposure(): number;
  8294. /**
  8295. * Sets the highlights Exposure value.
  8296. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8297. */
  8298. set highlightsExposure(value: number);
  8299. private _midtonesHue;
  8300. private _midtonesDensity;
  8301. private _midtonesSaturation;
  8302. private _midtonesExposure;
  8303. /**
  8304. * Gets the midtones Hue value.
  8305. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8306. */
  8307. get midtonesHue(): number;
  8308. /**
  8309. * Sets the midtones Hue value.
  8310. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8311. */
  8312. set midtonesHue(value: number);
  8313. /**
  8314. * Gets the midtones Density value.
  8315. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. get midtonesDensity(): number;
  8319. /**
  8320. * Sets the midtones Density value.
  8321. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8322. * Values less than zero provide a filter of opposite hue.
  8323. */
  8324. set midtonesDensity(value: number);
  8325. /**
  8326. * Gets the midtones Saturation value.
  8327. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8328. */
  8329. get midtonesSaturation(): number;
  8330. /**
  8331. * Sets the midtones Saturation value.
  8332. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8333. */
  8334. set midtonesSaturation(value: number);
  8335. /**
  8336. * Gets the midtones Exposure value.
  8337. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8338. */
  8339. get midtonesExposure(): number;
  8340. /**
  8341. * Sets the midtones Exposure value.
  8342. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8343. */
  8344. set midtonesExposure(value: number);
  8345. private _shadowsHue;
  8346. private _shadowsDensity;
  8347. private _shadowsSaturation;
  8348. private _shadowsExposure;
  8349. /**
  8350. * Gets the shadows Hue value.
  8351. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8352. */
  8353. get shadowsHue(): number;
  8354. /**
  8355. * Sets the shadows Hue value.
  8356. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8357. */
  8358. set shadowsHue(value: number);
  8359. /**
  8360. * Gets the shadows Density value.
  8361. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. get shadowsDensity(): number;
  8365. /**
  8366. * Sets the shadows Density value.
  8367. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8368. * Values less than zero provide a filter of opposite hue.
  8369. */
  8370. set shadowsDensity(value: number);
  8371. /**
  8372. * Gets the shadows Saturation value.
  8373. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8374. */
  8375. get shadowsSaturation(): number;
  8376. /**
  8377. * Sets the shadows Saturation value.
  8378. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8379. */
  8380. set shadowsSaturation(value: number);
  8381. /**
  8382. * Gets the shadows Exposure value.
  8383. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8384. */
  8385. get shadowsExposure(): number;
  8386. /**
  8387. * Sets the shadows Exposure value.
  8388. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8389. */
  8390. set shadowsExposure(value: number);
  8391. /**
  8392. * Returns the class name
  8393. * @returns The class name
  8394. */
  8395. getClassName(): string;
  8396. /**
  8397. * Binds the color curves to the shader.
  8398. * @param colorCurves The color curve to bind
  8399. * @param effect The effect to bind to
  8400. * @param positiveUniform The positive uniform shader parameter
  8401. * @param neutralUniform The neutral uniform shader parameter
  8402. * @param negativeUniform The negative uniform shader parameter
  8403. */
  8404. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8405. /**
  8406. * Prepare the list of uniforms associated with the ColorCurves effects.
  8407. * @param uniformsList The list of uniforms used in the effect
  8408. */
  8409. static PrepareUniforms(uniformsList: string[]): void;
  8410. /**
  8411. * Returns color grading data based on a hue, density, saturation and exposure value.
  8412. * @param filterHue The hue of the color filter.
  8413. * @param filterDensity The density of the color filter.
  8414. * @param saturation The saturation.
  8415. * @param exposure The exposure.
  8416. * @param result The result data container.
  8417. */
  8418. private getColorGradingDataToRef;
  8419. /**
  8420. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8421. * @param value The input slider value in range [-100,100].
  8422. * @returns Adjusted value.
  8423. */
  8424. private static applyColorGradingSliderNonlinear;
  8425. /**
  8426. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8427. * @param hue The hue (H) input.
  8428. * @param saturation The saturation (S) input.
  8429. * @param brightness The brightness (B) input.
  8430. * @result An RGBA color represented as Vector4.
  8431. */
  8432. private static fromHSBToRef;
  8433. /**
  8434. * Returns a value clamped between min and max
  8435. * @param value The value to clamp
  8436. * @param min The minimum of value
  8437. * @param max The maximum of value
  8438. * @returns The clamped value.
  8439. */
  8440. private static clamp;
  8441. /**
  8442. * Clones the current color curve instance.
  8443. * @return The cloned curves
  8444. */
  8445. clone(): ColorCurves;
  8446. /**
  8447. * Serializes the current color curve instance to a json representation.
  8448. * @return a JSON representation
  8449. */
  8450. serialize(): any;
  8451. /**
  8452. * Parses the color curve from a json representation.
  8453. * @param source the JSON source to parse
  8454. * @return The parsed curves
  8455. */
  8456. static Parse(source: any): ColorCurves;
  8457. }
  8458. }
  8459. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8460. import { Observable } from "babylonjs/Misc/observable";
  8461. import { Nullable } from "babylonjs/types";
  8462. import { Color4 } from "babylonjs/Maths/math.color";
  8463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8464. import { Effect } from "babylonjs/Materials/effect";
  8465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8466. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8467. /**
  8468. * Interface to follow in your material defines to integrate easily the
  8469. * Image proccessing functions.
  8470. * @hidden
  8471. */
  8472. export interface IImageProcessingConfigurationDefines {
  8473. IMAGEPROCESSING: boolean;
  8474. VIGNETTE: boolean;
  8475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8476. VIGNETTEBLENDMODEOPAQUE: boolean;
  8477. TONEMAPPING: boolean;
  8478. TONEMAPPING_ACES: boolean;
  8479. CONTRAST: boolean;
  8480. EXPOSURE: boolean;
  8481. COLORCURVES: boolean;
  8482. COLORGRADING: boolean;
  8483. COLORGRADING3D: boolean;
  8484. SAMPLER3DGREENDEPTH: boolean;
  8485. SAMPLER3DBGRMAP: boolean;
  8486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8487. }
  8488. /**
  8489. * @hidden
  8490. */
  8491. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8492. IMAGEPROCESSING: boolean;
  8493. VIGNETTE: boolean;
  8494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8495. VIGNETTEBLENDMODEOPAQUE: boolean;
  8496. TONEMAPPING: boolean;
  8497. TONEMAPPING_ACES: boolean;
  8498. CONTRAST: boolean;
  8499. COLORCURVES: boolean;
  8500. COLORGRADING: boolean;
  8501. COLORGRADING3D: boolean;
  8502. SAMPLER3DGREENDEPTH: boolean;
  8503. SAMPLER3DBGRMAP: boolean;
  8504. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8505. EXPOSURE: boolean;
  8506. constructor();
  8507. }
  8508. /**
  8509. * This groups together the common properties used for image processing either in direct forward pass
  8510. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8511. * or not.
  8512. */
  8513. export class ImageProcessingConfiguration {
  8514. /**
  8515. * Default tone mapping applied in BabylonJS.
  8516. */
  8517. static readonly TONEMAPPING_STANDARD: number;
  8518. /**
  8519. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8520. * to other engines rendering to increase portability.
  8521. */
  8522. static readonly TONEMAPPING_ACES: number;
  8523. /**
  8524. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8525. */
  8526. colorCurves: Nullable<ColorCurves>;
  8527. private _colorCurvesEnabled;
  8528. /**
  8529. * Gets wether the color curves effect is enabled.
  8530. */
  8531. get colorCurvesEnabled(): boolean;
  8532. /**
  8533. * Sets wether the color curves effect is enabled.
  8534. */
  8535. set colorCurvesEnabled(value: boolean);
  8536. private _colorGradingTexture;
  8537. /**
  8538. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8539. */
  8540. get colorGradingTexture(): Nullable<BaseTexture>;
  8541. /**
  8542. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8543. */
  8544. set colorGradingTexture(value: Nullable<BaseTexture>);
  8545. private _colorGradingEnabled;
  8546. /**
  8547. * Gets wether the color grading effect is enabled.
  8548. */
  8549. get colorGradingEnabled(): boolean;
  8550. /**
  8551. * Sets wether the color grading effect is enabled.
  8552. */
  8553. set colorGradingEnabled(value: boolean);
  8554. private _colorGradingWithGreenDepth;
  8555. /**
  8556. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8557. */
  8558. get colorGradingWithGreenDepth(): boolean;
  8559. /**
  8560. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8561. */
  8562. set colorGradingWithGreenDepth(value: boolean);
  8563. private _colorGradingBGR;
  8564. /**
  8565. * Gets wether the color grading texture contains BGR values.
  8566. */
  8567. get colorGradingBGR(): boolean;
  8568. /**
  8569. * Sets wether the color grading texture contains BGR values.
  8570. */
  8571. set colorGradingBGR(value: boolean);
  8572. /** @hidden */
  8573. _exposure: number;
  8574. /**
  8575. * Gets the Exposure used in the effect.
  8576. */
  8577. get exposure(): number;
  8578. /**
  8579. * Sets the Exposure used in the effect.
  8580. */
  8581. set exposure(value: number);
  8582. private _toneMappingEnabled;
  8583. /**
  8584. * Gets wether the tone mapping effect is enabled.
  8585. */
  8586. get toneMappingEnabled(): boolean;
  8587. /**
  8588. * Sets wether the tone mapping effect is enabled.
  8589. */
  8590. set toneMappingEnabled(value: boolean);
  8591. private _toneMappingType;
  8592. /**
  8593. * Gets the type of tone mapping effect.
  8594. */
  8595. get toneMappingType(): number;
  8596. /**
  8597. * Sets the type of tone mapping effect used in BabylonJS.
  8598. */
  8599. set toneMappingType(value: number);
  8600. protected _contrast: number;
  8601. /**
  8602. * Gets the contrast used in the effect.
  8603. */
  8604. get contrast(): number;
  8605. /**
  8606. * Sets the contrast used in the effect.
  8607. */
  8608. set contrast(value: number);
  8609. /**
  8610. * Vignette stretch size.
  8611. */
  8612. vignetteStretch: number;
  8613. /**
  8614. * Vignette centre X Offset.
  8615. */
  8616. vignetteCentreX: number;
  8617. /**
  8618. * Vignette centre Y Offset.
  8619. */
  8620. vignetteCentreY: number;
  8621. /**
  8622. * Vignette weight or intensity of the vignette effect.
  8623. */
  8624. vignetteWeight: number;
  8625. /**
  8626. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8627. * if vignetteEnabled is set to true.
  8628. */
  8629. vignetteColor: Color4;
  8630. /**
  8631. * Camera field of view used by the Vignette effect.
  8632. */
  8633. vignetteCameraFov: number;
  8634. private _vignetteBlendMode;
  8635. /**
  8636. * Gets the vignette blend mode allowing different kind of effect.
  8637. */
  8638. get vignetteBlendMode(): number;
  8639. /**
  8640. * Sets the vignette blend mode allowing different kind of effect.
  8641. */
  8642. set vignetteBlendMode(value: number);
  8643. private _vignetteEnabled;
  8644. /**
  8645. * Gets wether the vignette effect is enabled.
  8646. */
  8647. get vignetteEnabled(): boolean;
  8648. /**
  8649. * Sets wether the vignette effect is enabled.
  8650. */
  8651. set vignetteEnabled(value: boolean);
  8652. private _applyByPostProcess;
  8653. /**
  8654. * Gets wether the image processing is applied through a post process or not.
  8655. */
  8656. get applyByPostProcess(): boolean;
  8657. /**
  8658. * Sets wether the image processing is applied through a post process or not.
  8659. */
  8660. set applyByPostProcess(value: boolean);
  8661. private _isEnabled;
  8662. /**
  8663. * Gets wether the image processing is enabled or not.
  8664. */
  8665. get isEnabled(): boolean;
  8666. /**
  8667. * Sets wether the image processing is enabled or not.
  8668. */
  8669. set isEnabled(value: boolean);
  8670. /**
  8671. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8672. */
  8673. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8674. /**
  8675. * Method called each time the image processing information changes requires to recompile the effect.
  8676. */
  8677. protected _updateParameters(): void;
  8678. /**
  8679. * Gets the current class name.
  8680. * @return "ImageProcessingConfiguration"
  8681. */
  8682. getClassName(): string;
  8683. /**
  8684. * Prepare the list of uniforms associated with the Image Processing effects.
  8685. * @param uniforms The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of samplers associated with the Image Processing effects.
  8691. * @param samplersList The list of uniforms used in the effect
  8692. * @param defines the list of defines currently in use
  8693. */
  8694. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8695. /**
  8696. * Prepare the list of defines associated to the shader.
  8697. * @param defines the list of defines to complete
  8698. * @param forPostProcess Define if we are currently in post process mode or not
  8699. */
  8700. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8701. /**
  8702. * Returns true if all the image processing information are ready.
  8703. * @returns True if ready, otherwise, false
  8704. */
  8705. isReady(): boolean;
  8706. /**
  8707. * Binds the image processing to the shader.
  8708. * @param effect The effect to bind to
  8709. * @param overrideAspectRatio Override the aspect ratio of the effect
  8710. */
  8711. bind(effect: Effect, overrideAspectRatio?: number): void;
  8712. /**
  8713. * Clones the current image processing instance.
  8714. * @return The cloned image processing
  8715. */
  8716. clone(): ImageProcessingConfiguration;
  8717. /**
  8718. * Serializes the current image processing instance to a json representation.
  8719. * @return a JSON representation
  8720. */
  8721. serialize(): any;
  8722. /**
  8723. * Parses the image processing from a json representation.
  8724. * @param source the JSON source to parse
  8725. * @return The parsed image processing
  8726. */
  8727. static Parse(source: any): ImageProcessingConfiguration;
  8728. private static _VIGNETTEMODE_MULTIPLY;
  8729. private static _VIGNETTEMODE_OPAQUE;
  8730. /**
  8731. * Used to apply the vignette as a mix with the pixel color.
  8732. */
  8733. static get VIGNETTEMODE_MULTIPLY(): number;
  8734. /**
  8735. * Used to apply the vignette as a replacement of the pixel color.
  8736. */
  8737. static get VIGNETTEMODE_OPAQUE(): number;
  8738. }
  8739. }
  8740. declare module "babylonjs/Shaders/postprocess.vertex" {
  8741. /** @hidden */
  8742. export var postprocessVertexShader: {
  8743. name: string;
  8744. shader: string;
  8745. };
  8746. }
  8747. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8749. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8750. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8751. /**
  8752. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8753. */
  8754. export type RenderTargetTextureSize = number | {
  8755. width: number;
  8756. height: number;
  8757. layers?: number;
  8758. };
  8759. module "babylonjs/Engines/thinEngine" {
  8760. interface ThinEngine {
  8761. /**
  8762. * Creates a new render target texture
  8763. * @param size defines the size of the texture
  8764. * @param options defines the options used to create the texture
  8765. * @returns a new render target texture stored in an InternalTexture
  8766. */
  8767. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8768. /**
  8769. * Creates a depth stencil texture.
  8770. * This is only available in WebGL 2 or with the depth texture extension available.
  8771. * @param size The size of face edge in the texture.
  8772. * @param options The options defining the texture.
  8773. * @returns The texture
  8774. */
  8775. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8776. /** @hidden */
  8777. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8778. }
  8779. }
  8780. }
  8781. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8782. /**
  8783. * Defines the kind of connection point for node based material
  8784. */
  8785. export enum NodeMaterialBlockConnectionPointTypes {
  8786. /** Float */
  8787. Float = 1,
  8788. /** Int */
  8789. Int = 2,
  8790. /** Vector2 */
  8791. Vector2 = 4,
  8792. /** Vector3 */
  8793. Vector3 = 8,
  8794. /** Vector4 */
  8795. Vector4 = 16,
  8796. /** Color3 */
  8797. Color3 = 32,
  8798. /** Color4 */
  8799. Color4 = 64,
  8800. /** Matrix */
  8801. Matrix = 128,
  8802. /** Custom object */
  8803. Object = 256,
  8804. /** Detect type based on connection */
  8805. AutoDetect = 1024,
  8806. /** Output type that will be defined by input type */
  8807. BasedOnInput = 2048
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8811. /**
  8812. * Enum used to define the target of a block
  8813. */
  8814. export enum NodeMaterialBlockTargets {
  8815. /** Vertex shader */
  8816. Vertex = 1,
  8817. /** Fragment shader */
  8818. Fragment = 2,
  8819. /** Neutral */
  8820. Neutral = 4,
  8821. /** Vertex and Fragment */
  8822. VertexAndFragment = 3
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8826. /**
  8827. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8828. */
  8829. export enum NodeMaterialBlockConnectionPointMode {
  8830. /** Value is an uniform */
  8831. Uniform = 0,
  8832. /** Value is a mesh attribute */
  8833. Attribute = 1,
  8834. /** Value is a varying between vertex and fragment shaders */
  8835. Varying = 2,
  8836. /** Mode is undefined */
  8837. Undefined = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8841. /**
  8842. * Enum used to define system values e.g. values automatically provided by the system
  8843. */
  8844. export enum NodeMaterialSystemValues {
  8845. /** World */
  8846. World = 1,
  8847. /** View */
  8848. View = 2,
  8849. /** Projection */
  8850. Projection = 3,
  8851. /** ViewProjection */
  8852. ViewProjection = 4,
  8853. /** WorldView */
  8854. WorldView = 5,
  8855. /** WorldViewProjection */
  8856. WorldViewProjection = 6,
  8857. /** CameraPosition */
  8858. CameraPosition = 7,
  8859. /** Fog Color */
  8860. FogColor = 8,
  8861. /** Delta time */
  8862. DeltaTime = 9
  8863. }
  8864. }
  8865. declare module "babylonjs/Maths/math.axis" {
  8866. import { Vector3 } from "babylonjs/Maths/math.vector";
  8867. /** Defines supported spaces */
  8868. export enum Space {
  8869. /** Local (object) space */
  8870. LOCAL = 0,
  8871. /** World space */
  8872. WORLD = 1,
  8873. /** Bone space */
  8874. BONE = 2
  8875. }
  8876. /** Defines the 3 main axes */
  8877. export class Axis {
  8878. /** X axis */
  8879. static X: Vector3;
  8880. /** Y axis */
  8881. static Y: Vector3;
  8882. /** Z axis */
  8883. static Z: Vector3;
  8884. }
  8885. }
  8886. declare module "babylonjs/Maths/math.frustum" {
  8887. import { Matrix } from "babylonjs/Maths/math.vector";
  8888. import { DeepImmutable } from "babylonjs/types";
  8889. import { Plane } from "babylonjs/Maths/math.plane";
  8890. /**
  8891. * Represents a camera frustum
  8892. */
  8893. export class Frustum {
  8894. /**
  8895. * Gets the planes representing the frustum
  8896. * @param transform matrix to be applied to the returned planes
  8897. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8898. */
  8899. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8900. /**
  8901. * Gets the near frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the far frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the left frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the right frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the top frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Gets the bottom frustum plane transformed by the transform matrix
  8932. * @param transform transformation matrix to be applied to the resulting frustum plane
  8933. * @param frustumPlane the resuling frustum plane
  8934. */
  8935. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8936. /**
  8937. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8938. * @param transform transformation matrix to be applied to the resulting frustum planes
  8939. * @param frustumPlanes the resuling frustum planes
  8940. */
  8941. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8942. }
  8943. }
  8944. declare module "babylonjs/Maths/math.size" {
  8945. /**
  8946. * Interface for the size containing width and height
  8947. */
  8948. export interface ISize {
  8949. /**
  8950. * Width
  8951. */
  8952. width: number;
  8953. /**
  8954. * Heighht
  8955. */
  8956. height: number;
  8957. }
  8958. /**
  8959. * Size containing widht and height
  8960. */
  8961. export class Size implements ISize {
  8962. /**
  8963. * Width
  8964. */
  8965. width: number;
  8966. /**
  8967. * Height
  8968. */
  8969. height: number;
  8970. /**
  8971. * Creates a Size object from the given width and height (floats).
  8972. * @param width width of the new size
  8973. * @param height height of the new size
  8974. */
  8975. constructor(width: number, height: number);
  8976. /**
  8977. * Returns a string with the Size width and height
  8978. * @returns a string with the Size width and height
  8979. */
  8980. toString(): string;
  8981. /**
  8982. * "Size"
  8983. * @returns the string "Size"
  8984. */
  8985. getClassName(): string;
  8986. /**
  8987. * Returns the Size hash code.
  8988. * @returns a hash code for a unique width and height
  8989. */
  8990. getHashCode(): number;
  8991. /**
  8992. * Updates the current size from the given one.
  8993. * @param src the given size
  8994. */
  8995. copyFrom(src: Size): void;
  8996. /**
  8997. * Updates in place the current Size from the given floats.
  8998. * @param width width of the new size
  8999. * @param height height of the new size
  9000. * @returns the updated Size.
  9001. */
  9002. copyFromFloats(width: number, height: number): Size;
  9003. /**
  9004. * Updates in place the current Size from the given floats.
  9005. * @param width width to set
  9006. * @param height height to set
  9007. * @returns the updated Size.
  9008. */
  9009. set(width: number, height: number): Size;
  9010. /**
  9011. * Multiplies the width and height by numbers
  9012. * @param w factor to multiple the width by
  9013. * @param h factor to multiple the height by
  9014. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9015. */
  9016. multiplyByFloats(w: number, h: number): Size;
  9017. /**
  9018. * Clones the size
  9019. * @returns a new Size copied from the given one.
  9020. */
  9021. clone(): Size;
  9022. /**
  9023. * True if the current Size and the given one width and height are strictly equal.
  9024. * @param other the other size to compare against
  9025. * @returns True if the current Size and the given one width and height are strictly equal.
  9026. */
  9027. equals(other: Size): boolean;
  9028. /**
  9029. * The surface of the Size : width * height (float).
  9030. */
  9031. get surface(): number;
  9032. /**
  9033. * Create a new size of zero
  9034. * @returns a new Size set to (0.0, 0.0)
  9035. */
  9036. static Zero(): Size;
  9037. /**
  9038. * Sums the width and height of two sizes
  9039. * @param otherSize size to add to this size
  9040. * @returns a new Size set as the addition result of the current Size and the given one.
  9041. */
  9042. add(otherSize: Size): Size;
  9043. /**
  9044. * Subtracts the width and height of two
  9045. * @param otherSize size to subtract to this size
  9046. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9047. */
  9048. subtract(otherSize: Size): Size;
  9049. /**
  9050. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9051. * @param start starting size to lerp between
  9052. * @param end end size to lerp between
  9053. * @param amount amount to lerp between the start and end values
  9054. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9055. */
  9056. static Lerp(start: Size, end: Size, amount: number): Size;
  9057. }
  9058. }
  9059. declare module "babylonjs/Maths/math.vertexFormat" {
  9060. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9061. /**
  9062. * Contains position and normal vectors for a vertex
  9063. */
  9064. export class PositionNormalVertex {
  9065. /** the position of the vertex (defaut: 0,0,0) */
  9066. position: Vector3;
  9067. /** the normal of the vertex (defaut: 0,1,0) */
  9068. normal: Vector3;
  9069. /**
  9070. * Creates a PositionNormalVertex
  9071. * @param position the position of the vertex (defaut: 0,0,0)
  9072. * @param normal the normal of the vertex (defaut: 0,1,0)
  9073. */
  9074. constructor(
  9075. /** the position of the vertex (defaut: 0,0,0) */
  9076. position?: Vector3,
  9077. /** the normal of the vertex (defaut: 0,1,0) */
  9078. normal?: Vector3);
  9079. /**
  9080. * Clones the PositionNormalVertex
  9081. * @returns the cloned PositionNormalVertex
  9082. */
  9083. clone(): PositionNormalVertex;
  9084. }
  9085. /**
  9086. * Contains position, normal and uv vectors for a vertex
  9087. */
  9088. export class PositionNormalTextureVertex {
  9089. /** the position of the vertex (defaut: 0,0,0) */
  9090. position: Vector3;
  9091. /** the normal of the vertex (defaut: 0,1,0) */
  9092. normal: Vector3;
  9093. /** the uv of the vertex (default: 0,0) */
  9094. uv: Vector2;
  9095. /**
  9096. * Creates a PositionNormalTextureVertex
  9097. * @param position the position of the vertex (defaut: 0,0,0)
  9098. * @param normal the normal of the vertex (defaut: 0,1,0)
  9099. * @param uv the uv of the vertex (default: 0,0)
  9100. */
  9101. constructor(
  9102. /** the position of the vertex (defaut: 0,0,0) */
  9103. position?: Vector3,
  9104. /** the normal of the vertex (defaut: 0,1,0) */
  9105. normal?: Vector3,
  9106. /** the uv of the vertex (default: 0,0) */
  9107. uv?: Vector2);
  9108. /**
  9109. * Clones the PositionNormalTextureVertex
  9110. * @returns the cloned PositionNormalTextureVertex
  9111. */
  9112. clone(): PositionNormalTextureVertex;
  9113. }
  9114. }
  9115. declare module "babylonjs/Maths/math" {
  9116. export * from "babylonjs/Maths/math.axis";
  9117. export * from "babylonjs/Maths/math.color";
  9118. export * from "babylonjs/Maths/math.constants";
  9119. export * from "babylonjs/Maths/math.frustum";
  9120. export * from "babylonjs/Maths/math.path";
  9121. export * from "babylonjs/Maths/math.plane";
  9122. export * from "babylonjs/Maths/math.size";
  9123. export * from "babylonjs/Maths/math.vector";
  9124. export * from "babylonjs/Maths/math.vertexFormat";
  9125. export * from "babylonjs/Maths/math.viewport";
  9126. }
  9127. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9128. /**
  9129. * Enum defining the type of animations supported by InputBlock
  9130. */
  9131. export enum AnimatedInputBlockTypes {
  9132. /** No animation */
  9133. None = 0,
  9134. /** Time based animation. Will only work for floats */
  9135. Time = 1
  9136. }
  9137. }
  9138. declare module "babylonjs/Lights/shadowLight" {
  9139. import { Camera } from "babylonjs/Cameras/camera";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. /**
  9145. * Interface describing all the common properties and methods a shadow light needs to implement.
  9146. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9147. * as well as binding the different shadow properties to the effects.
  9148. */
  9149. export interface IShadowLight extends Light {
  9150. /**
  9151. * The light id in the scene (used in scene.findLighById for instance)
  9152. */
  9153. id: string;
  9154. /**
  9155. * The position the shdow will be casted from.
  9156. */
  9157. position: Vector3;
  9158. /**
  9159. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9160. */
  9161. direction: Vector3;
  9162. /**
  9163. * The transformed position. Position of the light in world space taking parenting in account.
  9164. */
  9165. transformedPosition: Vector3;
  9166. /**
  9167. * The transformed direction. Direction of the light in world space taking parenting in account.
  9168. */
  9169. transformedDirection: Vector3;
  9170. /**
  9171. * The friendly name of the light in the scene.
  9172. */
  9173. name: string;
  9174. /**
  9175. * Defines the shadow projection clipping minimum z value.
  9176. */
  9177. shadowMinZ: number;
  9178. /**
  9179. * Defines the shadow projection clipping maximum z value.
  9180. */
  9181. shadowMaxZ: number;
  9182. /**
  9183. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9184. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9185. */
  9186. computeTransformedInformation(): boolean;
  9187. /**
  9188. * Gets the scene the light belongs to.
  9189. * @returns The scene
  9190. */
  9191. getScene(): Scene;
  9192. /**
  9193. * Callback defining a custom Projection Matrix Builder.
  9194. * This can be used to override the default projection matrix computation.
  9195. */
  9196. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. /**
  9206. * Gets the current depth scale used in ESM.
  9207. * @returns The scale
  9208. */
  9209. getDepthScale(): number;
  9210. /**
  9211. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9212. * @returns true if a cube texture needs to be use
  9213. */
  9214. needCube(): boolean;
  9215. /**
  9216. * Detects if the projection matrix requires to be recomputed this frame.
  9217. * @returns true if it requires to be recomputed otherwise, false.
  9218. */
  9219. needProjectionMatrixCompute(): boolean;
  9220. /**
  9221. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9222. */
  9223. forceProjectionMatrixCompute(): void;
  9224. /**
  9225. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9226. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9227. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9228. */
  9229. getShadowDirection(faceIndex?: number): Vector3;
  9230. /**
  9231. * Gets the minZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the min for
  9233. * @returns the depth min z
  9234. */
  9235. getDepthMinZ(activeCamera: Camera): number;
  9236. /**
  9237. * Gets the maxZ used for shadow according to both the scene and the light.
  9238. * @param activeCamera The camera we are returning the max for
  9239. * @returns the depth max z
  9240. */
  9241. getDepthMaxZ(activeCamera: Camera): number;
  9242. }
  9243. /**
  9244. * Base implementation IShadowLight
  9245. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9246. */
  9247. export abstract class ShadowLight extends Light implements IShadowLight {
  9248. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9249. protected _position: Vector3;
  9250. protected _setPosition(value: Vector3): void;
  9251. /**
  9252. * Sets the position the shadow will be casted from. Also use as the light position for both
  9253. * point and spot lights.
  9254. */
  9255. get position(): Vector3;
  9256. /**
  9257. * Sets the position the shadow will be casted from. Also use as the light position for both
  9258. * point and spot lights.
  9259. */
  9260. set position(value: Vector3);
  9261. protected _direction: Vector3;
  9262. protected _setDirection(value: Vector3): void;
  9263. /**
  9264. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9265. * Also use as the light direction on spot and directional lights.
  9266. */
  9267. get direction(): Vector3;
  9268. /**
  9269. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9270. * Also use as the light direction on spot and directional lights.
  9271. */
  9272. set direction(value: Vector3);
  9273. protected _shadowMinZ: number;
  9274. /**
  9275. * Gets the shadow projection clipping minimum z value.
  9276. */
  9277. get shadowMinZ(): number;
  9278. /**
  9279. * Sets the shadow projection clipping minimum z value.
  9280. */
  9281. set shadowMinZ(value: number);
  9282. protected _shadowMaxZ: number;
  9283. /**
  9284. * Sets the shadow projection clipping maximum z value.
  9285. */
  9286. get shadowMaxZ(): number;
  9287. /**
  9288. * Gets the shadow projection clipping maximum z value.
  9289. */
  9290. set shadowMaxZ(value: number);
  9291. /**
  9292. * Callback defining a custom Projection Matrix Builder.
  9293. * This can be used to override the default projection matrix computation.
  9294. */
  9295. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9296. /**
  9297. * The transformed position. Position of the light in world space taking parenting in account.
  9298. */
  9299. transformedPosition: Vector3;
  9300. /**
  9301. * The transformed direction. Direction of the light in world space taking parenting in account.
  9302. */
  9303. transformedDirection: Vector3;
  9304. private _needProjectionMatrixCompute;
  9305. /**
  9306. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9307. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9308. */
  9309. computeTransformedInformation(): boolean;
  9310. /**
  9311. * Return the depth scale used for the shadow map.
  9312. * @returns the depth scale.
  9313. */
  9314. getDepthScale(): number;
  9315. /**
  9316. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9317. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9318. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9319. */
  9320. getShadowDirection(faceIndex?: number): Vector3;
  9321. /**
  9322. * Returns the ShadowLight absolute position in the World.
  9323. * @returns the position vector in world space
  9324. */
  9325. getAbsolutePosition(): Vector3;
  9326. /**
  9327. * Sets the ShadowLight direction toward the passed target.
  9328. * @param target The point to target in local space
  9329. * @returns the updated ShadowLight direction
  9330. */
  9331. setDirectionToTarget(target: Vector3): Vector3;
  9332. /**
  9333. * Returns the light rotation in euler definition.
  9334. * @returns the x y z rotation in local space.
  9335. */
  9336. getRotation(): Vector3;
  9337. /**
  9338. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9339. * @returns true if a cube texture needs to be use
  9340. */
  9341. needCube(): boolean;
  9342. /**
  9343. * Detects if the projection matrix requires to be recomputed this frame.
  9344. * @returns true if it requires to be recomputed otherwise, false.
  9345. */
  9346. needProjectionMatrixCompute(): boolean;
  9347. /**
  9348. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9349. */
  9350. forceProjectionMatrixCompute(): void;
  9351. /** @hidden */
  9352. _initCache(): void;
  9353. /** @hidden */
  9354. _isSynchronized(): boolean;
  9355. /**
  9356. * Computes the world matrix of the node
  9357. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9358. * @returns the world matrix
  9359. */
  9360. computeWorldMatrix(force?: boolean): Matrix;
  9361. /**
  9362. * Gets the minZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the min for
  9364. * @returns the depth min z
  9365. */
  9366. getDepthMinZ(activeCamera: Camera): number;
  9367. /**
  9368. * Gets the maxZ used for shadow according to both the scene and the light.
  9369. * @param activeCamera The camera we are returning the max for
  9370. * @returns the depth max z
  9371. */
  9372. getDepthMaxZ(activeCamera: Camera): number;
  9373. /**
  9374. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9375. * @param matrix The materix to updated with the projection information
  9376. * @param viewMatrix The transform matrix of the light
  9377. * @param renderList The list of mesh to render in the map
  9378. * @returns The current light
  9379. */
  9380. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9381. }
  9382. }
  9383. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9384. /** @hidden */
  9385. export var packingFunctions: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9391. /** @hidden */
  9392. export var bayerDitherFunctions: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9398. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9399. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9400. /** @hidden */
  9401. export var shadowMapFragmentDeclaration: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9407. /** @hidden */
  9408. export var clipPlaneFragmentDeclaration: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9414. /** @hidden */
  9415. export var clipPlaneFragment: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9421. /** @hidden */
  9422. export var shadowMapFragment: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9428. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9430. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9431. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9432. /** @hidden */
  9433. export var shadowMapPixelShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9439. /** @hidden */
  9440. export var bonesDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9446. /** @hidden */
  9447. export var morphTargetsVertexGlobalDeclaration: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9453. /** @hidden */
  9454. export var morphTargetsVertexDeclaration: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9460. /** @hidden */
  9461. export var instancesDeclaration: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9467. /** @hidden */
  9468. export var helperFunctions: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9474. /** @hidden */
  9475. export var shadowMapVertexDeclaration: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9481. /** @hidden */
  9482. export var clipPlaneVertexDeclaration: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9488. /** @hidden */
  9489. export var morphTargetsVertex: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9495. /** @hidden */
  9496. export var instancesVertex: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9502. /** @hidden */
  9503. export var bonesVertex: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9509. /** @hidden */
  9510. export var shadowMapVertexNormalBias: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9516. /** @hidden */
  9517. export var shadowMapVertexMetric: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9523. /** @hidden */
  9524. export var clipPlaneVertex: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9540. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9541. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9542. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9543. /** @hidden */
  9544. export var shadowMapVertexShader: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9550. /** @hidden */
  9551. export var depthBoxBlurPixelShader: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9557. /** @hidden */
  9558. export var shadowMapFragmentSoftTransparentShadow: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Materials/effectFallbacks" {
  9564. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9565. import { Effect } from "babylonjs/Materials/effect";
  9566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9567. /**
  9568. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9569. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9570. */
  9571. export class EffectFallbacks implements IEffectFallbacks {
  9572. private _defines;
  9573. private _currentRank;
  9574. private _maxRank;
  9575. private _mesh;
  9576. /**
  9577. * Removes the fallback from the bound mesh.
  9578. */
  9579. unBindMesh(): void;
  9580. /**
  9581. * Adds a fallback on the specified property.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param define The name of the define in the shader
  9584. */
  9585. addFallback(rank: number, define: string): void;
  9586. /**
  9587. * Sets the mesh to use CPU skinning when needing to fallback.
  9588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9589. * @param mesh The mesh to use the fallbacks.
  9590. */
  9591. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9592. /**
  9593. * Checks to see if more fallbacks are still availible.
  9594. */
  9595. get hasMoreFallbacks(): boolean;
  9596. /**
  9597. * Removes the defines that should be removed when falling back.
  9598. * @param currentDefines defines the current define statements for the shader.
  9599. * @param effect defines the current effect we try to compile
  9600. * @returns The resulting defines with defines of the current rank removed.
  9601. */
  9602. reduce(currentDefines: string, effect: Effect): string;
  9603. }
  9604. }
  9605. declare module "babylonjs/Actions/action" {
  9606. import { Observable } from "babylonjs/Misc/observable";
  9607. import { Condition } from "babylonjs/Actions/condition";
  9608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9609. import { Nullable } from "babylonjs/types";
  9610. import { Scene } from "babylonjs/scene";
  9611. import { ActionManager } from "babylonjs/Actions/actionManager";
  9612. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9613. import { Node } from "babylonjs/node";
  9614. /**
  9615. * Interface used to define Action
  9616. */
  9617. export interface IAction {
  9618. /**
  9619. * Trigger for the action
  9620. */
  9621. trigger: number;
  9622. /** Options of the trigger */
  9623. triggerOptions: any;
  9624. /**
  9625. * Gets the trigger parameters
  9626. * @returns the trigger parameters
  9627. */
  9628. getTriggerParameter(): any;
  9629. /**
  9630. * Internal only - executes current action event
  9631. * @hidden
  9632. */
  9633. _executeCurrent(evt?: ActionEvent): void;
  9634. /**
  9635. * Serialize placeholder for child classes
  9636. * @param parent of child
  9637. * @returns the serialized object
  9638. */
  9639. serialize(parent: any): any;
  9640. /**
  9641. * Internal only
  9642. * @hidden
  9643. */
  9644. _prepare(): void;
  9645. /**
  9646. * Internal only - manager for action
  9647. * @hidden
  9648. */
  9649. _actionManager: Nullable<AbstractActionManager>;
  9650. /**
  9651. * Adds action to chain of actions, may be a DoNothingAction
  9652. * @param action defines the next action to execute
  9653. * @returns The action passed in
  9654. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9655. */
  9656. then(action: IAction): IAction;
  9657. }
  9658. /**
  9659. * The action to be carried out following a trigger
  9660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9661. */
  9662. export class Action implements IAction {
  9663. /** the trigger, with or without parameters, for the action */
  9664. triggerOptions: any;
  9665. /**
  9666. * Trigger for the action
  9667. */
  9668. trigger: number;
  9669. /**
  9670. * Internal only - manager for action
  9671. * @hidden
  9672. */
  9673. _actionManager: ActionManager;
  9674. private _nextActiveAction;
  9675. private _child;
  9676. private _condition?;
  9677. private _triggerParameter;
  9678. /**
  9679. * An event triggered prior to action being executed.
  9680. */
  9681. onBeforeExecuteObservable: Observable<Action>;
  9682. /**
  9683. * Creates a new Action
  9684. * @param triggerOptions the trigger, with or without parameters, for the action
  9685. * @param condition an optional determinant of action
  9686. */
  9687. constructor(
  9688. /** the trigger, with or without parameters, for the action */
  9689. triggerOptions: any, condition?: Condition);
  9690. /**
  9691. * Internal only
  9692. * @hidden
  9693. */
  9694. _prepare(): void;
  9695. /**
  9696. * Gets the trigger parameters
  9697. * @returns the trigger parameters
  9698. */
  9699. getTriggerParameter(): any;
  9700. /**
  9701. * Internal only - executes current action event
  9702. * @hidden
  9703. */
  9704. _executeCurrent(evt?: ActionEvent): void;
  9705. /**
  9706. * Execute placeholder for child classes
  9707. * @param evt optional action event
  9708. */
  9709. execute(evt?: ActionEvent): void;
  9710. /**
  9711. * Skips to next active action
  9712. */
  9713. skipToNextActiveAction(): void;
  9714. /**
  9715. * Adds action to chain of actions, may be a DoNothingAction
  9716. * @param action defines the next action to execute
  9717. * @returns The action passed in
  9718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9719. */
  9720. then(action: Action): Action;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getProperty(propertyPath: string): string;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. _getEffectiveTarget(target: any, propertyPath: string): any;
  9731. /**
  9732. * Serialize placeholder for child classes
  9733. * @param parent of child
  9734. * @returns the serialized object
  9735. */
  9736. serialize(parent: any): any;
  9737. /**
  9738. * Internal only called by serialize
  9739. * @hidden
  9740. */
  9741. protected _serialize(serializedAction: any, parent?: any): any;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. static _SerializeValueAsString: (value: any) => string;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. static _GetTargetProperty: (target: Scene | Node) => {
  9752. name: string;
  9753. targetType: string;
  9754. value: string;
  9755. };
  9756. }
  9757. }
  9758. declare module "babylonjs/Actions/condition" {
  9759. import { ActionManager } from "babylonjs/Actions/actionManager";
  9760. /**
  9761. * A Condition applied to an Action
  9762. */
  9763. export class Condition {
  9764. /**
  9765. * Internal only - manager for action
  9766. * @hidden
  9767. */
  9768. _actionManager: ActionManager;
  9769. /**
  9770. * Internal only
  9771. * @hidden
  9772. */
  9773. _evaluationId: number;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. _currentResult: boolean;
  9779. /**
  9780. * Creates a new Condition
  9781. * @param actionManager the manager of the action the condition is applied to
  9782. */
  9783. constructor(actionManager: ActionManager);
  9784. /**
  9785. * Check if the current condition is valid
  9786. * @returns a boolean
  9787. */
  9788. isValid(): boolean;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. _getProperty(propertyPath: string): string;
  9794. /**
  9795. * Internal only
  9796. * @hidden
  9797. */
  9798. _getEffectiveTarget(target: any, propertyPath: string): any;
  9799. /**
  9800. * Serialize placeholder for child classes
  9801. * @returns the serialized object
  9802. */
  9803. serialize(): any;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. protected _serialize(serializedCondition: any): any;
  9809. }
  9810. /**
  9811. * Defines specific conditional operators as extensions of Condition
  9812. */
  9813. export class ValueCondition extends Condition {
  9814. /** path to specify the property of the target the conditional operator uses */
  9815. propertyPath: string;
  9816. /** the value compared by the conditional operator against the current value of the property */
  9817. value: any;
  9818. /** the conditional operator, default ValueCondition.IsEqual */
  9819. operator: number;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. private static _IsEqual;
  9825. /**
  9826. * Internal only
  9827. * @hidden
  9828. */
  9829. private static _IsDifferent;
  9830. /**
  9831. * Internal only
  9832. * @hidden
  9833. */
  9834. private static _IsGreater;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsLesser;
  9840. /**
  9841. * returns the number for IsEqual
  9842. */
  9843. static get IsEqual(): number;
  9844. /**
  9845. * Returns the number for IsDifferent
  9846. */
  9847. static get IsDifferent(): number;
  9848. /**
  9849. * Returns the number for IsGreater
  9850. */
  9851. static get IsGreater(): number;
  9852. /**
  9853. * Returns the number for IsLesser
  9854. */
  9855. static get IsLesser(): number;
  9856. /**
  9857. * Internal only The action manager for the condition
  9858. * @hidden
  9859. */
  9860. _actionManager: ActionManager;
  9861. /**
  9862. * Internal only
  9863. * @hidden
  9864. */
  9865. private _target;
  9866. /**
  9867. * Internal only
  9868. * @hidden
  9869. */
  9870. private _effectiveTarget;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _property;
  9876. /**
  9877. * Creates a new ValueCondition
  9878. * @param actionManager manager for the action the condition applies to
  9879. * @param target for the action
  9880. * @param propertyPath path to specify the property of the target the conditional operator uses
  9881. * @param value the value compared by the conditional operator against the current value of the property
  9882. * @param operator the conditional operator, default ValueCondition.IsEqual
  9883. */
  9884. constructor(actionManager: ActionManager, target: any,
  9885. /** path to specify the property of the target the conditional operator uses */
  9886. propertyPath: string,
  9887. /** the value compared by the conditional operator against the current value of the property */
  9888. value: any,
  9889. /** the conditional operator, default ValueCondition.IsEqual */
  9890. operator?: number);
  9891. /**
  9892. * Compares the given value with the property value for the specified conditional operator
  9893. * @returns the result of the comparison
  9894. */
  9895. isValid(): boolean;
  9896. /**
  9897. * Serialize the ValueCondition into a JSON compatible object
  9898. * @returns serialization object
  9899. */
  9900. serialize(): any;
  9901. /**
  9902. * Gets the name of the conditional operator for the ValueCondition
  9903. * @param operator the conditional operator
  9904. * @returns the name
  9905. */
  9906. static GetOperatorName(operator: number): string;
  9907. }
  9908. /**
  9909. * Defines a predicate condition as an extension of Condition
  9910. */
  9911. export class PredicateCondition extends Condition {
  9912. /** defines the predicate function used to validate the condition */
  9913. predicate: () => boolean;
  9914. /**
  9915. * Internal only - manager for action
  9916. * @hidden
  9917. */
  9918. _actionManager: ActionManager;
  9919. /**
  9920. * Creates a new PredicateCondition
  9921. * @param actionManager manager for the action the condition applies to
  9922. * @param predicate defines the predicate function used to validate the condition
  9923. */
  9924. constructor(actionManager: ActionManager,
  9925. /** defines the predicate function used to validate the condition */
  9926. predicate: () => boolean);
  9927. /**
  9928. * @returns the validity of the predicate condition
  9929. */
  9930. isValid(): boolean;
  9931. }
  9932. /**
  9933. * Defines a state condition as an extension of Condition
  9934. */
  9935. export class StateCondition extends Condition {
  9936. /** Value to compare with target state */
  9937. value: string;
  9938. /**
  9939. * Internal only - manager for action
  9940. * @hidden
  9941. */
  9942. _actionManager: ActionManager;
  9943. /**
  9944. * Internal only
  9945. * @hidden
  9946. */
  9947. private _target;
  9948. /**
  9949. * Creates a new StateCondition
  9950. * @param actionManager manager for the action the condition applies to
  9951. * @param target of the condition
  9952. * @param value to compare with target state
  9953. */
  9954. constructor(actionManager: ActionManager, target: any,
  9955. /** Value to compare with target state */
  9956. value: string);
  9957. /**
  9958. * Gets a boolean indicating if the current condition is met
  9959. * @returns the validity of the state
  9960. */
  9961. isValid(): boolean;
  9962. /**
  9963. * Serialize the StateCondition into a JSON compatible object
  9964. * @returns serialization object
  9965. */
  9966. serialize(): any;
  9967. }
  9968. }
  9969. declare module "babylonjs/Actions/directActions" {
  9970. import { Action } from "babylonjs/Actions/action";
  9971. import { Condition } from "babylonjs/Actions/condition";
  9972. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9973. /**
  9974. * This defines an action responsible to toggle a boolean once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class SwitchBooleanAction extends Action {
  9978. /**
  9979. * The path to the boolean property in the target object
  9980. */
  9981. propertyPath: string;
  9982. private _target;
  9983. private _effectiveTarget;
  9984. private _property;
  9985. /**
  9986. * Instantiate the action
  9987. * @param triggerOptions defines the trigger options
  9988. * @param target defines the object containing the boolean
  9989. * @param propertyPath defines the path to the boolean property in the target object
  9990. * @param condition defines the trigger related conditions
  9991. */
  9992. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9993. /** @hidden */
  9994. _prepare(): void;
  9995. /**
  9996. * Execute the action toggle the boolean value.
  9997. */
  9998. execute(): void;
  9999. /**
  10000. * Serializes the actions and its related information.
  10001. * @param parent defines the object to serialize in
  10002. * @returns the serialized object
  10003. */
  10004. serialize(parent: any): any;
  10005. }
  10006. /**
  10007. * This defines an action responsible to set a the state field of the target
  10008. * to a desired value once triggered.
  10009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10010. */
  10011. export class SetStateAction extends Action {
  10012. /**
  10013. * The value to store in the state field.
  10014. */
  10015. value: string;
  10016. private _target;
  10017. /**
  10018. * Instantiate the action
  10019. * @param triggerOptions defines the trigger options
  10020. * @param target defines the object containing the state property
  10021. * @param value defines the value to store in the state field
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10025. /**
  10026. * Execute the action and store the value on the target state property.
  10027. */
  10028. execute(): void;
  10029. /**
  10030. * Serializes the actions and its related information.
  10031. * @param parent defines the object to serialize in
  10032. * @returns the serialized object
  10033. */
  10034. serialize(parent: any): any;
  10035. }
  10036. /**
  10037. * This defines an action responsible to set a property of the target
  10038. * to a desired value once triggered.
  10039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10040. */
  10041. export class SetValueAction extends Action {
  10042. /**
  10043. * The path of the property to set in the target.
  10044. */
  10045. propertyPath: string;
  10046. /**
  10047. * The value to set in the property
  10048. */
  10049. value: any;
  10050. private _target;
  10051. private _effectiveTarget;
  10052. private _property;
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param target defines the object containing the property
  10057. * @param propertyPath defines the path of the property to set in the target
  10058. * @param value defines the value to set in the property
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and set the targetted property to the desired value.
  10066. */
  10067. execute(): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to increment the target value
  10077. * to a desired value once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class IncrementValueAction extends Action {
  10081. /**
  10082. * The path of the property to increment in the target.
  10083. */
  10084. propertyPath: string;
  10085. /**
  10086. * The value we should increment the property by.
  10087. */
  10088. value: any;
  10089. private _target;
  10090. private _effectiveTarget;
  10091. private _property;
  10092. /**
  10093. * Instantiate the action
  10094. * @param triggerOptions defines the trigger options
  10095. * @param target defines the object containing the property
  10096. * @param propertyPath defines the path of the property to increment in the target
  10097. * @param value defines the value value we should increment the property by
  10098. * @param condition defines the trigger related conditions
  10099. */
  10100. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10101. /** @hidden */
  10102. _prepare(): void;
  10103. /**
  10104. * Execute the action and increment the target of the value amount.
  10105. */
  10106. execute(): void;
  10107. /**
  10108. * Serializes the actions and its related information.
  10109. * @param parent defines the object to serialize in
  10110. * @returns the serialized object
  10111. */
  10112. serialize(parent: any): any;
  10113. }
  10114. /**
  10115. * This defines an action responsible to start an animation once triggered.
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10117. */
  10118. export class PlayAnimationAction extends Action {
  10119. /**
  10120. * Where the animation should start (animation frame)
  10121. */
  10122. from: number;
  10123. /**
  10124. * Where the animation should stop (animation frame)
  10125. */
  10126. to: number;
  10127. /**
  10128. * Define if the animation should loop or stop after the first play.
  10129. */
  10130. loop?: boolean;
  10131. private _target;
  10132. /**
  10133. * Instantiate the action
  10134. * @param triggerOptions defines the trigger options
  10135. * @param target defines the target animation or animation name
  10136. * @param from defines from where the animation should start (animation frame)
  10137. * @param end defines where the animation should stop (animation frame)
  10138. * @param loop defines if the animation should loop or stop after the first play
  10139. * @param condition defines the trigger related conditions
  10140. */
  10141. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10142. /** @hidden */
  10143. _prepare(): void;
  10144. /**
  10145. * Execute the action and play the animation.
  10146. */
  10147. execute(): void;
  10148. /**
  10149. * Serializes the actions and its related information.
  10150. * @param parent defines the object to serialize in
  10151. * @returns the serialized object
  10152. */
  10153. serialize(parent: any): any;
  10154. }
  10155. /**
  10156. * This defines an action responsible to stop an animation once triggered.
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10158. */
  10159. export class StopAnimationAction extends Action {
  10160. private _target;
  10161. /**
  10162. * Instantiate the action
  10163. * @param triggerOptions defines the trigger options
  10164. * @param target defines the target animation or animation name
  10165. * @param condition defines the trigger related conditions
  10166. */
  10167. constructor(triggerOptions: any, target: any, condition?: Condition);
  10168. /** @hidden */
  10169. _prepare(): void;
  10170. /**
  10171. * Execute the action and stop the animation.
  10172. */
  10173. execute(): void;
  10174. /**
  10175. * Serializes the actions and its related information.
  10176. * @param parent defines the object to serialize in
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. }
  10181. /**
  10182. * This defines an action responsible that does nothing once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class DoNothingAction extends Action {
  10186. /**
  10187. * Instantiate the action
  10188. * @param triggerOptions defines the trigger options
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions?: any, condition?: Condition);
  10192. /**
  10193. * Execute the action and do nothing.
  10194. */
  10195. execute(): void;
  10196. /**
  10197. * Serializes the actions and its related information.
  10198. * @param parent defines the object to serialize in
  10199. * @returns the serialized object
  10200. */
  10201. serialize(parent: any): any;
  10202. }
  10203. /**
  10204. * This defines an action responsible to trigger several actions once triggered.
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10206. */
  10207. export class CombineAction extends Action {
  10208. /**
  10209. * The list of aggregated animations to run.
  10210. */
  10211. children: Action[];
  10212. /**
  10213. * Instantiate the action
  10214. * @param triggerOptions defines the trigger options
  10215. * @param children defines the list of aggregated animations to run
  10216. * @param condition defines the trigger related conditions
  10217. */
  10218. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10219. /** @hidden */
  10220. _prepare(): void;
  10221. /**
  10222. * Execute the action and executes all the aggregated actions.
  10223. */
  10224. execute(evt: ActionEvent): void;
  10225. /**
  10226. * Serializes the actions and its related information.
  10227. * @param parent defines the object to serialize in
  10228. * @returns the serialized object
  10229. */
  10230. serialize(parent: any): any;
  10231. }
  10232. /**
  10233. * This defines an action responsible to run code (external event) once triggered.
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10235. */
  10236. export class ExecuteCodeAction extends Action {
  10237. /**
  10238. * The callback function to run.
  10239. */
  10240. func: (evt: ActionEvent) => void;
  10241. /**
  10242. * Instantiate the action
  10243. * @param triggerOptions defines the trigger options
  10244. * @param func defines the callback function to run
  10245. * @param condition defines the trigger related conditions
  10246. */
  10247. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10248. /**
  10249. * Execute the action and run the attached code.
  10250. */
  10251. execute(evt: ActionEvent): void;
  10252. }
  10253. /**
  10254. * This defines an action responsible to set the parent property of the target once triggered.
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10256. */
  10257. export class SetParentAction extends Action {
  10258. private _parent;
  10259. private _target;
  10260. /**
  10261. * Instantiate the action
  10262. * @param triggerOptions defines the trigger options
  10263. * @param target defines the target containing the parent property
  10264. * @param parent defines from where the animation should start (animation frame)
  10265. * @param condition defines the trigger related conditions
  10266. */
  10267. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10268. /** @hidden */
  10269. _prepare(): void;
  10270. /**
  10271. * Execute the action and set the parent property.
  10272. */
  10273. execute(): void;
  10274. /**
  10275. * Serializes the actions and its related information.
  10276. * @param parent defines the object to serialize in
  10277. * @returns the serialized object
  10278. */
  10279. serialize(parent: any): any;
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/actionManager" {
  10283. import { Nullable } from "babylonjs/types";
  10284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10285. import { Scene } from "babylonjs/scene";
  10286. import { IAction } from "babylonjs/Actions/action";
  10287. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10288. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10289. /**
  10290. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10291. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10293. */
  10294. export class ActionManager extends AbstractActionManager {
  10295. /**
  10296. * Nothing
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly NothingTrigger: number;
  10300. /**
  10301. * On pick
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnPickTrigger: number;
  10305. /**
  10306. * On left pick
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly OnLeftPickTrigger: number;
  10310. /**
  10311. * On right pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnRightPickTrigger: number;
  10315. /**
  10316. * On center pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnCenterPickTrigger: number;
  10320. /**
  10321. * On pick down
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickDownTrigger: number;
  10325. /**
  10326. * On double pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnDoublePickTrigger: number;
  10330. /**
  10331. * On pick up
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickUpTrigger: number;
  10335. /**
  10336. * On pick out.
  10337. * This trigger will only be raised if you also declared a OnPickDown
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnPickOutTrigger: number;
  10341. /**
  10342. * On long press
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnLongPressTrigger: number;
  10346. /**
  10347. * On pointer over
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnPointerOverTrigger: number;
  10351. /**
  10352. * On pointer out
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnPointerOutTrigger: number;
  10356. /**
  10357. * On every frame
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnEveryFrameTrigger: number;
  10361. /**
  10362. * On intersection enter
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnIntersectionEnterTrigger: number;
  10366. /**
  10367. * On intersection exit
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnIntersectionExitTrigger: number;
  10371. /**
  10372. * On key down
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnKeyDownTrigger: number;
  10376. /**
  10377. * On key up
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnKeyUpTrigger: number;
  10381. private _scene;
  10382. /**
  10383. * Creates a new action manager
  10384. * @param scene defines the hosting scene
  10385. */
  10386. constructor(scene: Scene);
  10387. /**
  10388. * Releases all associated resources
  10389. */
  10390. dispose(): void;
  10391. /**
  10392. * Gets hosting scene
  10393. * @returns the hosting scene
  10394. */
  10395. getScene(): Scene;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers
  10398. * @param triggers defines the triggers to be tested
  10399. * @return a boolean indicating whether one (or more) of the triggers is handled
  10400. */
  10401. hasSpecificTriggers(triggers: number[]): boolean;
  10402. /**
  10403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10404. * speed.
  10405. * @param triggerA defines the trigger to be tested
  10406. * @param triggerB defines the trigger to be tested
  10407. * @return a boolean indicating whether one (or more) of the triggers is handled
  10408. */
  10409. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10410. /**
  10411. * Does this action manager handles actions of a given trigger
  10412. * @param trigger defines the trigger to be tested
  10413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10414. * @return whether the trigger is handled
  10415. */
  10416. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10417. /**
  10418. * Does this action manager has pointer triggers
  10419. */
  10420. get hasPointerTriggers(): boolean;
  10421. /**
  10422. * Does this action manager has pick triggers
  10423. */
  10424. get hasPickTriggers(): boolean;
  10425. /**
  10426. * Registers an action to this action manager
  10427. * @param action defines the action to be registered
  10428. * @return the action amended (prepared) after registration
  10429. */
  10430. registerAction(action: IAction): Nullable<IAction>;
  10431. /**
  10432. * Unregisters an action to this action manager
  10433. * @param action defines the action to be unregistered
  10434. * @return a boolean indicating whether the action has been unregistered
  10435. */
  10436. unregisterAction(action: IAction): Boolean;
  10437. /**
  10438. * Process a specific trigger
  10439. * @param trigger defines the trigger to process
  10440. * @param evt defines the event details to be processed
  10441. */
  10442. processTrigger(trigger: number, evt?: IActionEvent): void;
  10443. /** @hidden */
  10444. _getEffectiveTarget(target: any, propertyPath: string): any;
  10445. /** @hidden */
  10446. _getProperty(propertyPath: string): string;
  10447. /**
  10448. * Serialize this manager to a JSON object
  10449. * @param name defines the property name to store this manager
  10450. * @returns a JSON representation of this manager
  10451. */
  10452. serialize(name: string): any;
  10453. /**
  10454. * Creates a new ActionManager from a JSON data
  10455. * @param parsedActions defines the JSON data to read from
  10456. * @param object defines the hosting mesh
  10457. * @param scene defines the hosting scene
  10458. */
  10459. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10460. /**
  10461. * Get a trigger name by index
  10462. * @param trigger defines the trigger index
  10463. * @returns a trigger name
  10464. */
  10465. static GetTriggerName(trigger: number): string;
  10466. }
  10467. }
  10468. declare module "babylonjs/Sprites/sprite" {
  10469. import { Vector3 } from "babylonjs/Maths/math.vector";
  10470. import { Nullable } from "babylonjs/types";
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10473. import { Color4 } from "babylonjs/Maths/math.color";
  10474. import { Observable } from "babylonjs/Misc/observable";
  10475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10476. import { Animation } from "babylonjs/Animations/animation";
  10477. /**
  10478. * Class used to represent a sprite
  10479. * @see https://doc.babylonjs.com/babylon101/sprites
  10480. */
  10481. export class Sprite implements IAnimatable {
  10482. /** defines the name */
  10483. name: string;
  10484. /** Gets or sets the current world position */
  10485. position: Vector3;
  10486. /** Gets or sets the main color */
  10487. color: Color4;
  10488. /** Gets or sets the width */
  10489. width: number;
  10490. /** Gets or sets the height */
  10491. height: number;
  10492. /** Gets or sets rotation angle */
  10493. angle: number;
  10494. /** Gets or sets the cell index in the sprite sheet */
  10495. cellIndex: number;
  10496. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10497. cellRef: string;
  10498. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10499. invertU: boolean;
  10500. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10501. invertV: boolean;
  10502. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10503. disposeWhenFinishedAnimating: boolean;
  10504. /** Gets the list of attached animations */
  10505. animations: Nullable<Array<Animation>>;
  10506. /** Gets or sets a boolean indicating if the sprite can be picked */
  10507. isPickable: boolean;
  10508. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10509. useAlphaForPicking: boolean;
  10510. /** @hidden */
  10511. _xOffset: number;
  10512. /** @hidden */
  10513. _yOffset: number;
  10514. /** @hidden */
  10515. _xSize: number;
  10516. /** @hidden */
  10517. _ySize: number;
  10518. /**
  10519. * Gets or sets the associated action manager
  10520. */
  10521. actionManager: Nullable<ActionManager>;
  10522. /**
  10523. * An event triggered when the control has been disposed
  10524. */
  10525. onDisposeObservable: Observable<Sprite>;
  10526. private _animationStarted;
  10527. private _loopAnimation;
  10528. private _fromIndex;
  10529. private _toIndex;
  10530. private _delay;
  10531. private _direction;
  10532. private _manager;
  10533. private _time;
  10534. private _onAnimationEnd;
  10535. /**
  10536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10537. */
  10538. isVisible: boolean;
  10539. /**
  10540. * Gets or sets the sprite size
  10541. */
  10542. get size(): number;
  10543. set size(value: number);
  10544. /**
  10545. * Returns a boolean indicating if the animation is started
  10546. */
  10547. get animationStarted(): boolean;
  10548. /**
  10549. * Gets or sets the unique id of the sprite
  10550. */
  10551. uniqueId: number;
  10552. /**
  10553. * Gets the manager of this sprite
  10554. */
  10555. get manager(): ISpriteManager;
  10556. /**
  10557. * Creates a new Sprite
  10558. * @param name defines the name
  10559. * @param manager defines the manager
  10560. */
  10561. constructor(
  10562. /** defines the name */
  10563. name: string, manager: ISpriteManager);
  10564. /**
  10565. * Returns the string "Sprite"
  10566. * @returns "Sprite"
  10567. */
  10568. getClassName(): string;
  10569. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10570. get fromIndex(): number;
  10571. set fromIndex(value: number);
  10572. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10573. get toIndex(): number;
  10574. set toIndex(value: number);
  10575. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10576. get loopAnimation(): boolean;
  10577. set loopAnimation(value: boolean);
  10578. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10579. get delay(): number;
  10580. set delay(value: number);
  10581. /**
  10582. * Starts an animation
  10583. * @param from defines the initial key
  10584. * @param to defines the end key
  10585. * @param loop defines if the animation must loop
  10586. * @param delay defines the start delay (in ms)
  10587. * @param onAnimationEnd defines a callback to call when animation ends
  10588. */
  10589. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10590. /** Stops current animation (if any) */
  10591. stopAnimation(): void;
  10592. /** @hidden */
  10593. _animate(deltaTime: number): void;
  10594. /** Release associated resources */
  10595. dispose(): void;
  10596. /**
  10597. * Serializes the sprite to a JSON object
  10598. * @returns the JSON object
  10599. */
  10600. serialize(): any;
  10601. /**
  10602. * Parses a JSON object to create a new sprite
  10603. * @param parsedSprite The JSON object to parse
  10604. * @param manager defines the hosting manager
  10605. * @returns the new sprite
  10606. */
  10607. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10608. }
  10609. }
  10610. declare module "babylonjs/Collisions/pickingInfo" {
  10611. import { Nullable } from "babylonjs/types";
  10612. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10614. import { Sprite } from "babylonjs/Sprites/sprite";
  10615. import { Ray } from "babylonjs/Culling/ray";
  10616. /**
  10617. * Information about the result of picking within a scene
  10618. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10619. */
  10620. export class PickingInfo {
  10621. /** @hidden */
  10622. _pickingUnavailable: boolean;
  10623. /**
  10624. * If the pick collided with an object
  10625. */
  10626. hit: boolean;
  10627. /**
  10628. * Distance away where the pick collided
  10629. */
  10630. distance: number;
  10631. /**
  10632. * The location of pick collision
  10633. */
  10634. pickedPoint: Nullable<Vector3>;
  10635. /**
  10636. * The mesh corresponding the the pick collision
  10637. */
  10638. pickedMesh: Nullable<AbstractMesh>;
  10639. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10640. bu: number;
  10641. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10642. bv: number;
  10643. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10644. faceId: number;
  10645. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10646. subMeshFaceId: number;
  10647. /** Id of the the submesh that was picked */
  10648. subMeshId: number;
  10649. /** If a sprite was picked, this will be the sprite the pick collided with */
  10650. pickedSprite: Nullable<Sprite>;
  10651. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10652. thinInstanceIndex: number;
  10653. /**
  10654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10655. */
  10656. originMesh: Nullable<AbstractMesh>;
  10657. /**
  10658. * The ray that was used to perform the picking.
  10659. */
  10660. ray: Nullable<Ray>;
  10661. /**
  10662. * Gets the normal correspodning to the face the pick collided with
  10663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10665. * @returns The normal correspodning to the face the pick collided with
  10666. */
  10667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10668. /**
  10669. * Gets the texture coordinates of where the pick occured
  10670. * @returns the vector containing the coordnates of the texture
  10671. */
  10672. getTextureCoordinates(): Nullable<Vector2>;
  10673. }
  10674. }
  10675. declare module "babylonjs/Culling/ray" {
  10676. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10679. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10680. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10681. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10682. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10683. import { Plane } from "babylonjs/Maths/math.plane";
  10684. /**
  10685. * Class representing a ray with position and direction
  10686. */
  10687. export class Ray {
  10688. /** origin point */
  10689. origin: Vector3;
  10690. /** direction */
  10691. direction: Vector3;
  10692. /** length of the ray */
  10693. length: number;
  10694. private static readonly _TmpVector3;
  10695. private _tmpRay;
  10696. /**
  10697. * Creates a new ray
  10698. * @param origin origin point
  10699. * @param direction direction
  10700. * @param length length of the ray
  10701. */
  10702. constructor(
  10703. /** origin point */
  10704. origin: Vector3,
  10705. /** direction */
  10706. direction: Vector3,
  10707. /** length of the ray */
  10708. length?: number);
  10709. /**
  10710. * Checks if the ray intersects a box
  10711. * This does not account for the ray lenght by design to improve perfs.
  10712. * @param minimum bound of the box
  10713. * @param maximum bound of the box
  10714. * @param intersectionTreshold extra extend to be added to the box in all direction
  10715. * @returns if the box was hit
  10716. */
  10717. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10718. /**
  10719. * Checks if the ray intersects a box
  10720. * This does not account for the ray lenght by design to improve perfs.
  10721. * @param box the bounding box to check
  10722. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10723. * @returns if the box was hit
  10724. */
  10725. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10726. /**
  10727. * If the ray hits a sphere
  10728. * @param sphere the bounding sphere to check
  10729. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10730. * @returns true if it hits the sphere
  10731. */
  10732. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10733. /**
  10734. * If the ray hits a triange
  10735. * @param vertex0 triangle vertex
  10736. * @param vertex1 triangle vertex
  10737. * @param vertex2 triangle vertex
  10738. * @returns intersection information if hit
  10739. */
  10740. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10741. /**
  10742. * Checks if ray intersects a plane
  10743. * @param plane the plane to check
  10744. * @returns the distance away it was hit
  10745. */
  10746. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10747. /**
  10748. * Calculate the intercept of a ray on a given axis
  10749. * @param axis to check 'x' | 'y' | 'z'
  10750. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10751. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10752. */
  10753. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10754. /**
  10755. * Checks if ray intersects a mesh
  10756. * @param mesh the mesh to check
  10757. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10758. * @returns picking info of the intersecton
  10759. */
  10760. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10761. /**
  10762. * Checks if ray intersects a mesh
  10763. * @param meshes the meshes to check
  10764. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10765. * @param results array to store result in
  10766. * @returns Array of picking infos
  10767. */
  10768. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10769. private _comparePickingInfo;
  10770. private static smallnum;
  10771. private static rayl;
  10772. /**
  10773. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10774. * @param sega the first point of the segment to test the intersection against
  10775. * @param segb the second point of the segment to test the intersection against
  10776. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10777. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10778. */
  10779. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10780. /**
  10781. * Update the ray from viewport position
  10782. * @param x position
  10783. * @param y y position
  10784. * @param viewportWidth viewport width
  10785. * @param viewportHeight viewport height
  10786. * @param world world matrix
  10787. * @param view view matrix
  10788. * @param projection projection matrix
  10789. * @returns this ray updated
  10790. */
  10791. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10792. /**
  10793. * Creates a ray with origin and direction of 0,0,0
  10794. * @returns the new ray
  10795. */
  10796. static Zero(): Ray;
  10797. /**
  10798. * Creates a new ray from screen space and viewport
  10799. * @param x position
  10800. * @param y y position
  10801. * @param viewportWidth viewport width
  10802. * @param viewportHeight viewport height
  10803. * @param world world matrix
  10804. * @param view view matrix
  10805. * @param projection projection matrix
  10806. * @returns new ray
  10807. */
  10808. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10811. * transformed to the given world matrix.
  10812. * @param origin The origin point
  10813. * @param end The end point
  10814. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10815. * @returns the new ray
  10816. */
  10817. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10818. /**
  10819. * Transforms a ray by a matrix
  10820. * @param ray ray to transform
  10821. * @param matrix matrix to apply
  10822. * @returns the resulting new ray
  10823. */
  10824. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10825. /**
  10826. * Transforms a ray by a matrix
  10827. * @param ray ray to transform
  10828. * @param matrix matrix to apply
  10829. * @param result ray to store result in
  10830. */
  10831. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10832. /**
  10833. * Unproject a ray from screen space to object space
  10834. * @param sourceX defines the screen space x coordinate to use
  10835. * @param sourceY defines the screen space y coordinate to use
  10836. * @param viewportWidth defines the current width of the viewport
  10837. * @param viewportHeight defines the current height of the viewport
  10838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10839. * @param view defines the view matrix to use
  10840. * @param projection defines the projection matrix to use
  10841. */
  10842. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10843. }
  10844. /**
  10845. * Type used to define predicate used to select faces when a mesh intersection is detected
  10846. */
  10847. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10848. module "babylonjs/scene" {
  10849. interface Scene {
  10850. /** @hidden */
  10851. _tempPickingRay: Nullable<Ray>;
  10852. /** @hidden */
  10853. _cachedRayForTransform: Ray;
  10854. /** @hidden */
  10855. _pickWithRayInverseMatrix: Matrix;
  10856. /** @hidden */
  10857. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10858. /** @hidden */
  10859. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10860. /** @hidden */
  10861. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10862. }
  10863. }
  10864. }
  10865. declare module "babylonjs/sceneComponent" {
  10866. import { Scene } from "babylonjs/scene";
  10867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10869. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10870. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10871. import { Nullable } from "babylonjs/types";
  10872. import { Camera } from "babylonjs/Cameras/camera";
  10873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10874. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10875. import { AbstractScene } from "babylonjs/abstractScene";
  10876. import { Mesh } from "babylonjs/Meshes/mesh";
  10877. /**
  10878. * Groups all the scene component constants in one place to ease maintenance.
  10879. * @hidden
  10880. */
  10881. export class SceneComponentConstants {
  10882. static readonly NAME_EFFECTLAYER: string;
  10883. static readonly NAME_LAYER: string;
  10884. static readonly NAME_LENSFLARESYSTEM: string;
  10885. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10886. static readonly NAME_PARTICLESYSTEM: string;
  10887. static readonly NAME_GAMEPAD: string;
  10888. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10889. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10890. static readonly NAME_PREPASSRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_SUBSURFACE: string;
  10895. static readonly NAME_OUTLINERENDERER: string;
  10896. static readonly NAME_PROCEDURALTEXTURE: string;
  10897. static readonly NAME_SHADOWGENERATOR: string;
  10898. static readonly NAME_OCTREE: string;
  10899. static readonly NAME_PHYSICSENGINE: string;
  10900. static readonly NAME_AUDIO: string;
  10901. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10902. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10905. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10907. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10908. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10909. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10910. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10911. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10912. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10913. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10914. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10915. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10916. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10917. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10920. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10921. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10922. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10923. static readonly STEP_AFTERRENDER_AUDIO: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10925. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10926. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10927. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10928. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10929. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10930. static readonly STEP_POINTERMOVE_SPRITE: number;
  10931. static readonly STEP_POINTERDOWN_SPRITE: number;
  10932. static readonly STEP_POINTERUP_SPRITE: number;
  10933. }
  10934. /**
  10935. * This represents a scene component.
  10936. *
  10937. * This is used to decouple the dependency the scene is having on the different workloads like
  10938. * layers, post processes...
  10939. */
  10940. export interface ISceneComponent {
  10941. /**
  10942. * The name of the component. Each component must have a unique name.
  10943. */
  10944. name: string;
  10945. /**
  10946. * The scene the component belongs to.
  10947. */
  10948. scene: Scene;
  10949. /**
  10950. * Register the component to one instance of a scene.
  10951. */
  10952. register(): void;
  10953. /**
  10954. * Rebuilds the elements related to this component in case of
  10955. * context lost for instance.
  10956. */
  10957. rebuild(): void;
  10958. /**
  10959. * Disposes the component and the associated ressources.
  10960. */
  10961. dispose(): void;
  10962. }
  10963. /**
  10964. * This represents a SERIALIZABLE scene component.
  10965. *
  10966. * This extends Scene Component to add Serialization methods on top.
  10967. */
  10968. export interface ISceneSerializableComponent extends ISceneComponent {
  10969. /**
  10970. * Adds all the elements from the container to the scene
  10971. * @param container the container holding the elements
  10972. */
  10973. addFromContainer(container: AbstractScene): void;
  10974. /**
  10975. * Removes all the elements in the container from the scene
  10976. * @param container contains the elements to remove
  10977. * @param dispose if the removed element should be disposed (default: false)
  10978. */
  10979. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10980. /**
  10981. * Serializes the component data to the specified json object
  10982. * @param serializationObject The object to serialize to
  10983. */
  10984. serialize(serializationObject: any): void;
  10985. }
  10986. /**
  10987. * Strong typing of a Mesh related stage step action
  10988. */
  10989. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10990. /**
  10991. * Strong typing of a Evaluate Sub Mesh related stage step action
  10992. */
  10993. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10994. /**
  10995. * Strong typing of a Active Mesh related stage step action
  10996. */
  10997. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10998. /**
  10999. * Strong typing of a Camera related stage step action
  11000. */
  11001. export type CameraStageAction = (camera: Camera) => void;
  11002. /**
  11003. * Strong typing of a Camera Frame buffer related stage step action
  11004. */
  11005. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11006. /**
  11007. * Strong typing of a Render Target related stage step action
  11008. */
  11009. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11010. /**
  11011. * Strong typing of a RenderingGroup related stage step action
  11012. */
  11013. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11014. /**
  11015. * Strong typing of a Mesh Render related stage step action
  11016. */
  11017. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11018. /**
  11019. * Strong typing of a simple stage step action
  11020. */
  11021. export type SimpleStageAction = () => void;
  11022. /**
  11023. * Strong typing of a render target action.
  11024. */
  11025. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11026. /**
  11027. * Strong typing of a pointer move action.
  11028. */
  11029. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11030. /**
  11031. * Strong typing of a pointer up/down action.
  11032. */
  11033. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11034. /**
  11035. * Representation of a stage in the scene (Basically a list of ordered steps)
  11036. * @hidden
  11037. */
  11038. export class Stage<T extends Function> extends Array<{
  11039. index: number;
  11040. component: ISceneComponent;
  11041. action: T;
  11042. }> {
  11043. /**
  11044. * Hide ctor from the rest of the world.
  11045. * @param items The items to add.
  11046. */
  11047. private constructor();
  11048. /**
  11049. * Creates a new Stage.
  11050. * @returns A new instance of a Stage
  11051. */
  11052. static Create<T extends Function>(): Stage<T>;
  11053. /**
  11054. * Registers a step in an ordered way in the targeted stage.
  11055. * @param index Defines the position to register the step in
  11056. * @param component Defines the component attached to the step
  11057. * @param action Defines the action to launch during the step
  11058. */
  11059. registerStep(index: number, component: ISceneComponent, action: T): void;
  11060. /**
  11061. * Clears all the steps from the stage.
  11062. */
  11063. clear(): void;
  11064. }
  11065. }
  11066. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11067. import { Nullable } from "babylonjs/types";
  11068. import { Observable } from "babylonjs/Misc/observable";
  11069. import { Scene } from "babylonjs/scene";
  11070. import { Sprite } from "babylonjs/Sprites/sprite";
  11071. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. import { Camera } from "babylonjs/Cameras/camera";
  11074. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11075. import { ISceneComponent } from "babylonjs/sceneComponent";
  11076. module "babylonjs/scene" {
  11077. interface Scene {
  11078. /** @hidden */
  11079. _pointerOverSprite: Nullable<Sprite>;
  11080. /** @hidden */
  11081. _pickedDownSprite: Nullable<Sprite>;
  11082. /** @hidden */
  11083. _tempSpritePickingRay: Nullable<Ray>;
  11084. /**
  11085. * All of the sprite managers added to this scene
  11086. * @see https://doc.babylonjs.com/babylon101/sprites
  11087. */
  11088. spriteManagers: Array<ISpriteManager>;
  11089. /**
  11090. * An event triggered when sprites rendering is about to start
  11091. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11092. */
  11093. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11094. /**
  11095. * An event triggered when sprites rendering is done
  11096. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11097. */
  11098. onAfterSpritesRenderingObservable: Observable<Scene>;
  11099. /** @hidden */
  11100. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11101. /** Launch a ray to try to pick a sprite in the scene
  11102. * @param x position on screen
  11103. * @param y position on screen
  11104. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11105. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11107. * @returns a PickingInfo
  11108. */
  11109. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11110. /** Use the given ray to pick a sprite in the scene
  11111. * @param ray The ray (in world space) to use to pick meshes
  11112. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11113. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11115. * @returns a PickingInfo
  11116. */
  11117. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11118. /** @hidden */
  11119. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11120. /** Launch a ray to try to pick sprites in the scene
  11121. * @param x position on screen
  11122. * @param y position on screen
  11123. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11124. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11125. * @returns a PickingInfo array
  11126. */
  11127. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11128. /** Use the given ray to pick sprites in the scene
  11129. * @param ray The ray (in world space) to use to pick meshes
  11130. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11132. * @returns a PickingInfo array
  11133. */
  11134. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11135. /**
  11136. * Force the sprite under the pointer
  11137. * @param sprite defines the sprite to use
  11138. */
  11139. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11140. /**
  11141. * Gets the sprite under the pointer
  11142. * @returns a Sprite or null if no sprite is under the pointer
  11143. */
  11144. getPointerOverSprite(): Nullable<Sprite>;
  11145. }
  11146. }
  11147. /**
  11148. * Defines the sprite scene component responsible to manage sprites
  11149. * in a given scene.
  11150. */
  11151. export class SpriteSceneComponent implements ISceneComponent {
  11152. /**
  11153. * The component name helpfull to identify the component in the list of scene components.
  11154. */
  11155. readonly name: string;
  11156. /**
  11157. * The scene the component belongs to.
  11158. */
  11159. scene: Scene;
  11160. /** @hidden */
  11161. private _spritePredicate;
  11162. /**
  11163. * Creates a new instance of the component for the given scene
  11164. * @param scene Defines the scene to register the component in
  11165. */
  11166. constructor(scene: Scene);
  11167. /**
  11168. * Registers the component in a given scene
  11169. */
  11170. register(): void;
  11171. /**
  11172. * Rebuilds the elements related to this component in case of
  11173. * context lost for instance.
  11174. */
  11175. rebuild(): void;
  11176. /**
  11177. * Disposes the component and the associated ressources.
  11178. */
  11179. dispose(): void;
  11180. private _pickSpriteButKeepRay;
  11181. private _pointerMove;
  11182. private _pointerDown;
  11183. private _pointerUp;
  11184. }
  11185. }
  11186. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11187. /** @hidden */
  11188. export var fogFragmentDeclaration: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11194. /** @hidden */
  11195. export var fogFragment: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11201. /** @hidden */
  11202. export var imageProcessingCompatibility: {
  11203. name: string;
  11204. shader: string;
  11205. };
  11206. }
  11207. declare module "babylonjs/Shaders/sprites.fragment" {
  11208. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11209. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11210. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11211. /** @hidden */
  11212. export var spritesPixelShader: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11218. /** @hidden */
  11219. export var fogVertexDeclaration: {
  11220. name: string;
  11221. shader: string;
  11222. };
  11223. }
  11224. declare module "babylonjs/Shaders/sprites.vertex" {
  11225. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11226. /** @hidden */
  11227. export var spritesVertexShader: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Sprites/spriteManager" {
  11233. import { IDisposable, Scene } from "babylonjs/scene";
  11234. import { Nullable } from "babylonjs/types";
  11235. import { Observable } from "babylonjs/Misc/observable";
  11236. import { Sprite } from "babylonjs/Sprites/sprite";
  11237. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11238. import { Camera } from "babylonjs/Cameras/camera";
  11239. import { Texture } from "babylonjs/Materials/Textures/texture";
  11240. import "babylonjs/Shaders/sprites.fragment";
  11241. import "babylonjs/Shaders/sprites.vertex";
  11242. import { Ray } from "babylonjs/Culling/ray";
  11243. /**
  11244. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11245. */
  11246. export interface ISpriteManager extends IDisposable {
  11247. /**
  11248. * Gets manager's name
  11249. */
  11250. name: string;
  11251. /**
  11252. * Restricts the camera to viewing objects with the same layerMask.
  11253. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11254. */
  11255. layerMask: number;
  11256. /**
  11257. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11258. */
  11259. isPickable: boolean;
  11260. /**
  11261. * Gets the hosting scene
  11262. */
  11263. scene: Scene;
  11264. /**
  11265. * Specifies the rendering group id for this mesh (0 by default)
  11266. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11267. */
  11268. renderingGroupId: number;
  11269. /**
  11270. * Defines the list of sprites managed by the manager.
  11271. */
  11272. sprites: Array<Sprite>;
  11273. /**
  11274. * Gets or sets the spritesheet texture
  11275. */
  11276. texture: Texture;
  11277. /** Defines the default width of a cell in the spritesheet */
  11278. cellWidth: number;
  11279. /** Defines the default height of a cell in the spritesheet */
  11280. cellHeight: number;
  11281. /**
  11282. * Tests the intersection of a sprite with a specific ray.
  11283. * @param ray The ray we are sending to test the collision
  11284. * @param camera The camera space we are sending rays in
  11285. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11286. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11287. * @returns picking info or null.
  11288. */
  11289. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @returns null if no hit or a PickingInfo array
  11296. */
  11297. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11298. /**
  11299. * Renders the list of sprites on screen.
  11300. */
  11301. render(): void;
  11302. }
  11303. /**
  11304. * Class used to manage multiple sprites on the same spritesheet
  11305. * @see https://doc.babylonjs.com/babylon101/sprites
  11306. */
  11307. export class SpriteManager implements ISpriteManager {
  11308. /** defines the manager's name */
  11309. name: string;
  11310. /** Define the Url to load snippets */
  11311. static SnippetUrl: string;
  11312. /** Snippet ID if the manager was created from the snippet server */
  11313. snippetId: string;
  11314. /** Gets the list of sprites */
  11315. sprites: Sprite[];
  11316. /** Gets or sets the rendering group id (0 by default) */
  11317. renderingGroupId: number;
  11318. /** Gets or sets camera layer mask */
  11319. layerMask: number;
  11320. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11321. fogEnabled: boolean;
  11322. /** Gets or sets a boolean indicating if the sprites are pickable */
  11323. isPickable: boolean;
  11324. /** Defines the default width of a cell in the spritesheet */
  11325. cellWidth: number;
  11326. /** Defines the default height of a cell in the spritesheet */
  11327. cellHeight: number;
  11328. /** Associative array from JSON sprite data file */
  11329. private _cellData;
  11330. /** Array of sprite names from JSON sprite data file */
  11331. private _spriteMap;
  11332. /** True when packed cell data from JSON file is ready*/
  11333. private _packedAndReady;
  11334. private _textureContent;
  11335. private _useInstancing;
  11336. /**
  11337. * An event triggered when the manager is disposed.
  11338. */
  11339. onDisposeObservable: Observable<SpriteManager>;
  11340. private _onDisposeObserver;
  11341. /**
  11342. * Callback called when the manager is disposed
  11343. */
  11344. set onDispose(callback: () => void);
  11345. private _capacity;
  11346. private _fromPacked;
  11347. private _spriteTexture;
  11348. private _epsilon;
  11349. private _scene;
  11350. private _vertexData;
  11351. private _buffer;
  11352. private _vertexBuffers;
  11353. private _spriteBuffer;
  11354. private _indexBuffer;
  11355. private _effectBase;
  11356. private _effectFog;
  11357. private _vertexBufferSize;
  11358. /**
  11359. * Gets or sets the unique id of the sprite
  11360. */
  11361. uniqueId: number;
  11362. /**
  11363. * Gets the array of sprites
  11364. */
  11365. get children(): Sprite[];
  11366. /**
  11367. * Gets the hosting scene
  11368. */
  11369. get scene(): Scene;
  11370. /**
  11371. * Gets the capacity of the manager
  11372. */
  11373. get capacity(): number;
  11374. /**
  11375. * Gets or sets the spritesheet texture
  11376. */
  11377. get texture(): Texture;
  11378. set texture(value: Texture);
  11379. private _blendMode;
  11380. /**
  11381. * Blend mode use to render the particle, it can be any of
  11382. * the static Constants.ALPHA_x properties provided in this class.
  11383. * Default value is Constants.ALPHA_COMBINE
  11384. */
  11385. get blendMode(): number;
  11386. set blendMode(blendMode: number);
  11387. /** Disables writing to the depth buffer when rendering the sprites.
  11388. * It can be handy to disable depth writing when using textures without alpha channel
  11389. * and setting some specific blend modes.
  11390. */
  11391. disableDepthWrite: boolean;
  11392. /**
  11393. * Creates a new sprite manager
  11394. * @param name defines the manager's name
  11395. * @param imgUrl defines the sprite sheet url
  11396. * @param capacity defines the maximum allowed number of sprites
  11397. * @param cellSize defines the size of a sprite cell
  11398. * @param scene defines the hosting scene
  11399. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11400. * @param samplingMode defines the smapling mode to use with spritesheet
  11401. * @param fromPacked set to false; do not alter
  11402. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11403. */
  11404. constructor(
  11405. /** defines the manager's name */
  11406. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11407. /**
  11408. * Returns the string "SpriteManager"
  11409. * @returns "SpriteManager"
  11410. */
  11411. getClassName(): string;
  11412. private _makePacked;
  11413. private _appendSpriteVertex;
  11414. private _checkTextureAlpha;
  11415. /**
  11416. * Intersects the sprites with a ray
  11417. * @param ray defines the ray to intersect with
  11418. * @param camera defines the current active camera
  11419. * @param predicate defines a predicate used to select candidate sprites
  11420. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11421. * @returns null if no hit or a PickingInfo
  11422. */
  11423. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11424. /**
  11425. * Intersects the sprites with a ray
  11426. * @param ray defines the ray to intersect with
  11427. * @param camera defines the current active camera
  11428. * @param predicate defines a predicate used to select candidate sprites
  11429. * @returns null if no hit or a PickingInfo array
  11430. */
  11431. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11432. /**
  11433. * Render all child sprites
  11434. */
  11435. render(): void;
  11436. /**
  11437. * Release associated resources
  11438. */
  11439. dispose(): void;
  11440. /**
  11441. * Serializes the sprite manager to a JSON object
  11442. * @param serializeTexture defines if the texture must be serialized as well
  11443. * @returns the JSON object
  11444. */
  11445. serialize(serializeTexture?: boolean): any;
  11446. /**
  11447. * Parses a JSON object to create a new sprite manager.
  11448. * @param parsedManager The JSON object to parse
  11449. * @param scene The scene to create the sprite managerin
  11450. * @param rootUrl The root url to use to load external dependencies like texture
  11451. * @returns the new sprite manager
  11452. */
  11453. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11454. /**
  11455. * Creates a sprite manager from a snippet saved in a remote file
  11456. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11457. * @param url defines the url to load from
  11458. * @param scene defines the hosting scene
  11459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11460. * @returns a promise that will resolve to the new sprite manager
  11461. */
  11462. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11463. /**
  11464. * Creates a sprite manager from a snippet saved by the sprite editor
  11465. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11466. * @param scene defines the hosting scene
  11467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11468. * @returns a promise that will resolve to the new sprite manager
  11469. */
  11470. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11471. }
  11472. }
  11473. declare module "babylonjs/Misc/gradients" {
  11474. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11475. /** Interface used by value gradients (color, factor, ...) */
  11476. export interface IValueGradient {
  11477. /**
  11478. * Gets or sets the gradient value (between 0 and 1)
  11479. */
  11480. gradient: number;
  11481. }
  11482. /** Class used to store color4 gradient */
  11483. export class ColorGradient implements IValueGradient {
  11484. /**
  11485. * Gets or sets the gradient value (between 0 and 1)
  11486. */
  11487. gradient: number;
  11488. /**
  11489. * Gets or sets first associated color
  11490. */
  11491. color1: Color4;
  11492. /**
  11493. * Gets or sets second associated color
  11494. */
  11495. color2?: Color4 | undefined;
  11496. /**
  11497. * Creates a new color4 gradient
  11498. * @param gradient gets or sets the gradient value (between 0 and 1)
  11499. * @param color1 gets or sets first associated color
  11500. * @param color2 gets or sets first second color
  11501. */
  11502. constructor(
  11503. /**
  11504. * Gets or sets the gradient value (between 0 and 1)
  11505. */
  11506. gradient: number,
  11507. /**
  11508. * Gets or sets first associated color
  11509. */
  11510. color1: Color4,
  11511. /**
  11512. * Gets or sets second associated color
  11513. */
  11514. color2?: Color4 | undefined);
  11515. /**
  11516. * Will get a color picked randomly between color1 and color2.
  11517. * If color2 is undefined then color1 will be used
  11518. * @param result defines the target Color4 to store the result in
  11519. */
  11520. getColorToRef(result: Color4): void;
  11521. }
  11522. /** Class used to store color 3 gradient */
  11523. export class Color3Gradient implements IValueGradient {
  11524. /**
  11525. * Gets or sets the gradient value (between 0 and 1)
  11526. */
  11527. gradient: number;
  11528. /**
  11529. * Gets or sets the associated color
  11530. */
  11531. color: Color3;
  11532. /**
  11533. * Creates a new color3 gradient
  11534. * @param gradient gets or sets the gradient value (between 0 and 1)
  11535. * @param color gets or sets associated color
  11536. */
  11537. constructor(
  11538. /**
  11539. * Gets or sets the gradient value (between 0 and 1)
  11540. */
  11541. gradient: number,
  11542. /**
  11543. * Gets or sets the associated color
  11544. */
  11545. color: Color3);
  11546. }
  11547. /** Class used to store factor gradient */
  11548. export class FactorGradient implements IValueGradient {
  11549. /**
  11550. * Gets or sets the gradient value (between 0 and 1)
  11551. */
  11552. gradient: number;
  11553. /**
  11554. * Gets or sets first associated factor
  11555. */
  11556. factor1: number;
  11557. /**
  11558. * Gets or sets second associated factor
  11559. */
  11560. factor2?: number | undefined;
  11561. /**
  11562. * Creates a new factor gradient
  11563. * @param gradient gets or sets the gradient value (between 0 and 1)
  11564. * @param factor1 gets or sets first associated factor
  11565. * @param factor2 gets or sets second associated factor
  11566. */
  11567. constructor(
  11568. /**
  11569. * Gets or sets the gradient value (between 0 and 1)
  11570. */
  11571. gradient: number,
  11572. /**
  11573. * Gets or sets first associated factor
  11574. */
  11575. factor1: number,
  11576. /**
  11577. * Gets or sets second associated factor
  11578. */
  11579. factor2?: number | undefined);
  11580. /**
  11581. * Will get a number picked randomly between factor1 and factor2.
  11582. * If factor2 is undefined then factor1 will be used
  11583. * @returns the picked number
  11584. */
  11585. getFactor(): number;
  11586. }
  11587. /**
  11588. * Helper used to simplify some generic gradient tasks
  11589. */
  11590. export class GradientHelper {
  11591. /**
  11592. * Gets the current gradient from an array of IValueGradient
  11593. * @param ratio defines the current ratio to get
  11594. * @param gradients defines the array of IValueGradient
  11595. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11596. */
  11597. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11598. }
  11599. }
  11600. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11601. import { Nullable } from "babylonjs/types";
  11602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11603. import { Scene } from "babylonjs/scene";
  11604. module "babylonjs/Engines/thinEngine" {
  11605. interface ThinEngine {
  11606. /**
  11607. * Creates a raw texture
  11608. * @param data defines the data to store in the texture
  11609. * @param width defines the width of the texture
  11610. * @param height defines the height of the texture
  11611. * @param format defines the format of the data
  11612. * @param generateMipMaps defines if the engine should generate the mip levels
  11613. * @param invertY defines if data must be stored with Y axis inverted
  11614. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11615. * @param compression defines the compression used (null by default)
  11616. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11617. * @returns the raw texture inside an InternalTexture
  11618. */
  11619. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11620. /**
  11621. * Update a raw texture
  11622. * @param texture defines the texture to update
  11623. * @param data defines the data to store in the texture
  11624. * @param format defines the format of the data
  11625. * @param invertY defines if data must be stored with Y axis inverted
  11626. */
  11627. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11628. /**
  11629. * Update a raw texture
  11630. * @param texture defines the texture to update
  11631. * @param data defines the data to store in the texture
  11632. * @param format defines the format of the data
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. * @param compression defines the compression used (null by default)
  11635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11636. */
  11637. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11638. /**
  11639. * Creates a new raw cube texture
  11640. * @param data defines the array of data to use to create each face
  11641. * @param size defines the size of the textures
  11642. * @param format defines the format of the data
  11643. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11644. * @param generateMipMaps defines if the engine should generate the mip levels
  11645. * @param invertY defines if data must be stored with Y axis inverted
  11646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11647. * @param compression defines the compression used (null by default)
  11648. * @returns the cube texture as an InternalTexture
  11649. */
  11650. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11651. /**
  11652. * Update a raw cube texture
  11653. * @param texture defines the texture to udpdate
  11654. * @param data defines the data to store
  11655. * @param format defines the data format
  11656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11657. * @param invertY defines if data must be stored with Y axis inverted
  11658. */
  11659. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11660. /**
  11661. * Update a raw cube texture
  11662. * @param texture defines the texture to udpdate
  11663. * @param data defines the data to store
  11664. * @param format defines the data format
  11665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @param invertY defines if data must be stored with Y axis inverted
  11667. * @param compression defines the compression used (null by default)
  11668. */
  11669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11670. /**
  11671. * Update a raw cube texture
  11672. * @param texture defines the texture to udpdate
  11673. * @param data defines the data to store
  11674. * @param format defines the data format
  11675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. * @param level defines which level of the texture to update
  11679. */
  11680. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11681. /**
  11682. * Creates a new raw cube texture from a specified url
  11683. * @param url defines the url where the data is located
  11684. * @param scene defines the current scene
  11685. * @param size defines the size of the textures
  11686. * @param format defines the format of the data
  11687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11688. * @param noMipmap defines if the engine should avoid generating the mip levels
  11689. * @param callback defines a callback used to extract texture data from loaded data
  11690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11691. * @param onLoad defines a callback called when texture is loaded
  11692. * @param onError defines a callback called if there is an error
  11693. * @returns the cube texture as an InternalTexture
  11694. */
  11695. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11696. /**
  11697. * Creates a new raw cube texture from a specified url
  11698. * @param url defines the url where the data is located
  11699. * @param scene defines the current scene
  11700. * @param size defines the size of the textures
  11701. * @param format defines the format of the data
  11702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11703. * @param noMipmap defines if the engine should avoid generating the mip levels
  11704. * @param callback defines a callback used to extract texture data from loaded data
  11705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11706. * @param onLoad defines a callback called when texture is loaded
  11707. * @param onError defines a callback called if there is an error
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @returns the cube texture as an InternalTexture
  11711. */
  11712. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11713. /**
  11714. * Creates a new raw 3D texture
  11715. * @param data defines the data used to create the texture
  11716. * @param width defines the width of the texture
  11717. * @param height defines the height of the texture
  11718. * @param depth defines the depth of the texture
  11719. * @param format defines the format of the texture
  11720. * @param generateMipMaps defines if the engine must generate mip levels
  11721. * @param invertY defines if data must be stored with Y axis inverted
  11722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11723. * @param compression defines the compressed used (can be null)
  11724. * @param textureType defines the compressed used (can be null)
  11725. * @returns a new raw 3D texture (stored in an InternalTexture)
  11726. */
  11727. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11728. /**
  11729. * Update a raw 3D texture
  11730. * @param texture defines the texture to update
  11731. * @param data defines the data to store
  11732. * @param format defines the data format
  11733. * @param invertY defines if data must be stored with Y axis inverted
  11734. */
  11735. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11736. /**
  11737. * Update a raw 3D texture
  11738. * @param texture defines the texture to update
  11739. * @param data defines the data to store
  11740. * @param format defines the data format
  11741. * @param invertY defines if data must be stored with Y axis inverted
  11742. * @param compression defines the used compression (can be null)
  11743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11744. */
  11745. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11746. /**
  11747. * Creates a new raw 2D array texture
  11748. * @param data defines the data used to create the texture
  11749. * @param width defines the width of the texture
  11750. * @param height defines the height of the texture
  11751. * @param depth defines the number of layers of the texture
  11752. * @param format defines the format of the texture
  11753. * @param generateMipMaps defines if the engine must generate mip levels
  11754. * @param invertY defines if data must be stored with Y axis inverted
  11755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11756. * @param compression defines the compressed used (can be null)
  11757. * @param textureType defines the compressed used (can be null)
  11758. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11759. */
  11760. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11761. /**
  11762. * Update a raw 2D array texture
  11763. * @param texture defines the texture to update
  11764. * @param data defines the data to store
  11765. * @param format defines the data format
  11766. * @param invertY defines if data must be stored with Y axis inverted
  11767. */
  11768. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11769. /**
  11770. * Update a raw 2D array texture
  11771. * @param texture defines the texture to update
  11772. * @param data defines the data to store
  11773. * @param format defines the data format
  11774. * @param invertY defines if data must be stored with Y axis inverted
  11775. * @param compression defines the used compression (can be null)
  11776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11777. */
  11778. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11779. }
  11780. }
  11781. }
  11782. declare module "babylonjs/Materials/Textures/rawTexture" {
  11783. import { Texture } from "babylonjs/Materials/Textures/texture";
  11784. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11787. import { Scene } from "babylonjs/scene";
  11788. /**
  11789. * Raw texture can help creating a texture directly from an array of data.
  11790. * This can be super useful if you either get the data from an uncompressed source or
  11791. * if you wish to create your texture pixel by pixel.
  11792. */
  11793. export class RawTexture extends Texture {
  11794. /**
  11795. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11796. */
  11797. format: number;
  11798. /**
  11799. * Instantiates a new RawTexture.
  11800. * Raw texture can help creating a texture directly from an array of data.
  11801. * This can be super useful if you either get the data from an uncompressed source or
  11802. * if you wish to create your texture pixel by pixel.
  11803. * @param data define the array of data to use to create the texture
  11804. * @param width define the width of the texture
  11805. * @param height define the height of the texture
  11806. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11807. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11808. * @param generateMipMaps define whether mip maps should be generated or not
  11809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11811. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11812. */
  11813. constructor(data: ArrayBufferView, width: number, height: number,
  11814. /**
  11815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11816. */
  11817. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11818. /**
  11819. * Updates the texture underlying data.
  11820. * @param data Define the new data of the texture
  11821. */
  11822. update(data: ArrayBufferView): void;
  11823. /**
  11824. * Creates a luminance texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the luminance texture
  11833. */
  11834. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a luminance alpha texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @returns the luminance alpha texture
  11845. */
  11846. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11847. /**
  11848. * Creates an alpha texture from some data.
  11849. * @param data Define the texture data
  11850. * @param width Define the width of the texture
  11851. * @param height Define the height of the texture
  11852. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11856. * @returns the alpha texture
  11857. */
  11858. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11859. /**
  11860. * Creates a RGB texture from some data.
  11861. * @param data Define the texture data
  11862. * @param width Define the width of the texture
  11863. * @param height Define the height of the texture
  11864. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11869. * @returns the RGB alpha texture
  11870. */
  11871. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11872. /**
  11873. * Creates a RGBA texture from some data.
  11874. * @param data Define the texture data
  11875. * @param width Define the width of the texture
  11876. * @param height Define the height of the texture
  11877. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11882. * @returns the RGBA texture
  11883. */
  11884. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11885. /**
  11886. * Creates a R texture from some data.
  11887. * @param data Define the texture data
  11888. * @param width Define the width of the texture
  11889. * @param height Define the height of the texture
  11890. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11895. * @returns the R texture
  11896. */
  11897. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11898. }
  11899. }
  11900. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11901. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11902. import { IndicesArray, DataArray } from "babylonjs/types";
  11903. module "babylonjs/Engines/thinEngine" {
  11904. interface ThinEngine {
  11905. /**
  11906. * Update a dynamic index buffer
  11907. * @param indexBuffer defines the target index buffer
  11908. * @param indices defines the data to update
  11909. * @param offset defines the offset in the target index buffer where update should start
  11910. */
  11911. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11912. /**
  11913. * Updates a dynamic vertex buffer.
  11914. * @param vertexBuffer the vertex buffer to update
  11915. * @param data the data used to update the vertex buffer
  11916. * @param byteOffset the byte offset of the data
  11917. * @param byteLength the byte length of the data
  11918. */
  11919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11920. }
  11921. }
  11922. }
  11923. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11924. import { Scene } from "babylonjs/scene";
  11925. import { ISceneComponent } from "babylonjs/sceneComponent";
  11926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11927. module "babylonjs/abstractScene" {
  11928. interface AbstractScene {
  11929. /**
  11930. * The list of procedural textures added to the scene
  11931. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11932. */
  11933. proceduralTextures: Array<ProceduralTexture>;
  11934. }
  11935. }
  11936. /**
  11937. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11938. * in a given scene.
  11939. */
  11940. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11941. /**
  11942. * The component name helpfull to identify the component in the list of scene components.
  11943. */
  11944. readonly name: string;
  11945. /**
  11946. * The scene the component belongs to.
  11947. */
  11948. scene: Scene;
  11949. /**
  11950. * Creates a new instance of the component for the given scene
  11951. * @param scene Defines the scene to register the component in
  11952. */
  11953. constructor(scene: Scene);
  11954. /**
  11955. * Registers the component in a given scene
  11956. */
  11957. register(): void;
  11958. /**
  11959. * Rebuilds the elements related to this component in case of
  11960. * context lost for instance.
  11961. */
  11962. rebuild(): void;
  11963. /**
  11964. * Disposes the component and the associated ressources.
  11965. */
  11966. dispose(): void;
  11967. private _beforeClear;
  11968. }
  11969. }
  11970. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11972. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11973. module "babylonjs/Engines/thinEngine" {
  11974. interface ThinEngine {
  11975. /**
  11976. * Creates a new render target cube texture
  11977. * @param size defines the size of the texture
  11978. * @param options defines the options used to create the texture
  11979. * @returns a new render target cube texture stored in an InternalTexture
  11980. */
  11981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11982. }
  11983. }
  11984. }
  11985. declare module "babylonjs/Shaders/procedural.vertex" {
  11986. /** @hidden */
  11987. export var proceduralVertexShader: {
  11988. name: string;
  11989. shader: string;
  11990. };
  11991. }
  11992. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { Scene } from "babylonjs/scene";
  11996. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11997. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11998. import { Effect } from "babylonjs/Materials/effect";
  11999. import { Texture } from "babylonjs/Materials/Textures/texture";
  12000. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12001. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12002. import "babylonjs/Shaders/procedural.vertex";
  12003. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12004. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12005. /**
  12006. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  12007. * This is the base class of any Procedural texture and contains most of the shareable code.
  12008. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12009. */
  12010. export class ProceduralTexture extends Texture {
  12011. /**
  12012. * Define if the texture is enabled or not (disabled texture will not render)
  12013. */
  12014. isEnabled: boolean;
  12015. /**
  12016. * Define if the texture must be cleared before rendering (default is true)
  12017. */
  12018. autoClear: boolean;
  12019. /**
  12020. * Callback called when the texture is generated
  12021. */
  12022. onGenerated: () => void;
  12023. /**
  12024. * Event raised when the texture is generated
  12025. */
  12026. onGeneratedObservable: Observable<ProceduralTexture>;
  12027. /**
  12028. * Event raised before the texture is generated
  12029. */
  12030. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12031. /**
  12032. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12033. */
  12034. nodeMaterialSource: Nullable<NodeMaterial>;
  12035. /** @hidden */
  12036. _generateMipMaps: boolean;
  12037. /** @hidden **/
  12038. _effect: Effect;
  12039. /** @hidden */
  12040. _textures: {
  12041. [key: string]: Texture;
  12042. };
  12043. /** @hidden */
  12044. protected _fallbackTexture: Nullable<Texture>;
  12045. private _size;
  12046. private _currentRefreshId;
  12047. private _frameId;
  12048. private _refreshRate;
  12049. private _vertexBuffers;
  12050. private _indexBuffer;
  12051. private _uniforms;
  12052. private _samplers;
  12053. private _fragment;
  12054. private _floats;
  12055. private _ints;
  12056. private _floatsArrays;
  12057. private _colors3;
  12058. private _colors4;
  12059. private _vectors2;
  12060. private _vectors3;
  12061. private _matrices;
  12062. private _fallbackTextureUsed;
  12063. private _fullEngine;
  12064. private _cachedDefines;
  12065. private _contentUpdateId;
  12066. private _contentData;
  12067. /**
  12068. * Instantiates a new procedural texture.
  12069. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  12070. * This is the base class of any Procedural texture and contains most of the shareable code.
  12071. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12072. * @param name Define the name of the texture
  12073. * @param size Define the size of the texture to create
  12074. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12075. * @param scene Define the scene the texture belongs to
  12076. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12077. * @param generateMipMaps Define if the texture should creates mip maps or not
  12078. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12079. * @param textureType The FBO internal texture type
  12080. */
  12081. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12082. /**
  12083. * The effect that is created when initializing the post process.
  12084. * @returns The created effect corresponding the the postprocess.
  12085. */
  12086. getEffect(): Effect;
  12087. /**
  12088. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12089. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12090. */
  12091. getContent(): Nullable<ArrayBufferView>;
  12092. private _createIndexBuffer;
  12093. /** @hidden */
  12094. _rebuild(): void;
  12095. /**
  12096. * Resets the texture in order to recreate its associated resources.
  12097. * This can be called in case of context loss
  12098. */
  12099. reset(): void;
  12100. protected _getDefines(): string;
  12101. /**
  12102. * Is the texture ready to be used ? (rendered at least once)
  12103. * @returns true if ready, otherwise, false.
  12104. */
  12105. isReady(): boolean;
  12106. /**
  12107. * Resets the refresh counter of the texture and start bak from scratch.
  12108. * Could be useful to regenerate the texture if it is setup to render only once.
  12109. */
  12110. resetRefreshCounter(): void;
  12111. /**
  12112. * Set the fragment shader to use in order to render the texture.
  12113. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12114. */
  12115. setFragment(fragment: any): void;
  12116. /**
  12117. * Define the refresh rate of the texture or the rendering frequency.
  12118. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12119. */
  12120. get refreshRate(): number;
  12121. set refreshRate(value: number);
  12122. /** @hidden */
  12123. _shouldRender(): boolean;
  12124. /**
  12125. * Get the size the texture is rendering at.
  12126. * @returns the size (on cube texture it is always squared)
  12127. */
  12128. getRenderSize(): RenderTargetTextureSize;
  12129. /**
  12130. * Resize the texture to new value.
  12131. * @param size Define the new size the texture should have
  12132. * @param generateMipMaps Define whether the new texture should create mip maps
  12133. */
  12134. resize(size: number, generateMipMaps: boolean): void;
  12135. private _checkUniform;
  12136. /**
  12137. * Set a texture in the shader program used to render.
  12138. * @param name Define the name of the uniform samplers as defined in the shader
  12139. * @param texture Define the texture to bind to this sampler
  12140. * @return the texture itself allowing "fluent" like uniform updates
  12141. */
  12142. setTexture(name: string, texture: Texture): ProceduralTexture;
  12143. /**
  12144. * Set a float in the shader.
  12145. * @param name Define the name of the uniform as defined in the shader
  12146. * @param value Define the value to give to the uniform
  12147. * @return the texture itself allowing "fluent" like uniform updates
  12148. */
  12149. setFloat(name: string, value: number): ProceduralTexture;
  12150. /**
  12151. * Set a int in the shader.
  12152. * @param name Define the name of the uniform as defined in the shader
  12153. * @param value Define the value to give to the uniform
  12154. * @return the texture itself allowing "fluent" like uniform updates
  12155. */
  12156. setInt(name: string, value: number): ProceduralTexture;
  12157. /**
  12158. * Set an array of floats in the shader.
  12159. * @param name Define the name of the uniform as defined in the shader
  12160. * @param value Define the value to give to the uniform
  12161. * @return the texture itself allowing "fluent" like uniform updates
  12162. */
  12163. setFloats(name: string, value: number[]): ProceduralTexture;
  12164. /**
  12165. * Set a vec3 in the shader from a Color3.
  12166. * @param name Define the name of the uniform as defined in the shader
  12167. * @param value Define the value to give to the uniform
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setColor3(name: string, value: Color3): ProceduralTexture;
  12171. /**
  12172. * Set a vec4 in the shader from a Color4.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setColor4(name: string, value: Color4): ProceduralTexture;
  12178. /**
  12179. * Set a vec2 in the shader from a Vector2.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setVector2(name: string, value: Vector2): ProceduralTexture;
  12185. /**
  12186. * Set a vec3 in the shader from a Vector3.
  12187. * @param name Define the name of the uniform as defined in the shader
  12188. * @param value Define the value to give to the uniform
  12189. * @return the texture itself allowing "fluent" like uniform updates
  12190. */
  12191. setVector3(name: string, value: Vector3): ProceduralTexture;
  12192. /**
  12193. * Set a mat4 in the shader from a MAtrix.
  12194. * @param name Define the name of the uniform as defined in the shader
  12195. * @param value Define the value to give to the uniform
  12196. * @return the texture itself allowing "fluent" like uniform updates
  12197. */
  12198. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12199. /**
  12200. * Render the texture to its associated render target.
  12201. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12202. */
  12203. render(useCameraPostProcess?: boolean): void;
  12204. /**
  12205. * Clone the texture.
  12206. * @returns the cloned texture
  12207. */
  12208. clone(): ProceduralTexture;
  12209. /**
  12210. * Dispose the texture and release its asoociated resources.
  12211. */
  12212. dispose(): void;
  12213. }
  12214. }
  12215. declare module "babylonjs/Particles/baseParticleSystem" {
  12216. import { Nullable } from "babylonjs/types";
  12217. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12219. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12220. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12221. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12223. import { Color4 } from "babylonjs/Maths/math.color";
  12224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12225. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12226. import { Animation } from "babylonjs/Animations/animation";
  12227. import { Scene } from "babylonjs/scene";
  12228. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12230. /**
  12231. * This represents the base class for particle system in Babylon.
  12232. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12233. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12234. * @example https://doc.babylonjs.com/babylon101/particles
  12235. */
  12236. export class BaseParticleSystem {
  12237. /**
  12238. * Source color is added to the destination color without alpha affecting the result
  12239. */
  12240. static BLENDMODE_ONEONE: number;
  12241. /**
  12242. * Blend current color and particle color using particle’s alpha
  12243. */
  12244. static BLENDMODE_STANDARD: number;
  12245. /**
  12246. * Add current color and particle color multiplied by particle’s alpha
  12247. */
  12248. static BLENDMODE_ADD: number;
  12249. /**
  12250. * Multiply current color with particle color
  12251. */
  12252. static BLENDMODE_MULTIPLY: number;
  12253. /**
  12254. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12255. */
  12256. static BLENDMODE_MULTIPLYADD: number;
  12257. /**
  12258. * List of animations used by the particle system.
  12259. */
  12260. animations: Animation[];
  12261. /**
  12262. * Gets or sets the unique id of the particle system
  12263. */
  12264. uniqueId: number;
  12265. /**
  12266. * The id of the Particle system.
  12267. */
  12268. id: string;
  12269. /**
  12270. * The friendly name of the Particle system.
  12271. */
  12272. name: string;
  12273. /**
  12274. * Snippet ID if the particle system was created from the snippet server
  12275. */
  12276. snippetId: string;
  12277. /**
  12278. * The rendering group used by the Particle system to chose when to render.
  12279. */
  12280. renderingGroupId: number;
  12281. /**
  12282. * The emitter represents the Mesh or position we are attaching the particle system to.
  12283. */
  12284. emitter: Nullable<AbstractMesh | Vector3>;
  12285. /**
  12286. * The maximum number of particles to emit per frame
  12287. */
  12288. emitRate: number;
  12289. /**
  12290. * If you want to launch only a few particles at once, that can be done, as well.
  12291. */
  12292. manualEmitCount: number;
  12293. /**
  12294. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12295. */
  12296. updateSpeed: number;
  12297. /**
  12298. * The amount of time the particle system is running (depends of the overall update speed).
  12299. */
  12300. targetStopDuration: number;
  12301. /**
  12302. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12303. */
  12304. disposeOnStop: boolean;
  12305. /**
  12306. * Minimum power of emitting particles.
  12307. */
  12308. minEmitPower: number;
  12309. /**
  12310. * Maximum power of emitting particles.
  12311. */
  12312. maxEmitPower: number;
  12313. /**
  12314. * Minimum life time of emitting particles.
  12315. */
  12316. minLifeTime: number;
  12317. /**
  12318. * Maximum life time of emitting particles.
  12319. */
  12320. maxLifeTime: number;
  12321. /**
  12322. * Minimum Size of emitting particles.
  12323. */
  12324. minSize: number;
  12325. /**
  12326. * Maximum Size of emitting particles.
  12327. */
  12328. maxSize: number;
  12329. /**
  12330. * Minimum scale of emitting particles on X axis.
  12331. */
  12332. minScaleX: number;
  12333. /**
  12334. * Maximum scale of emitting particles on X axis.
  12335. */
  12336. maxScaleX: number;
  12337. /**
  12338. * Minimum scale of emitting particles on Y axis.
  12339. */
  12340. minScaleY: number;
  12341. /**
  12342. * Maximum scale of emitting particles on Y axis.
  12343. */
  12344. maxScaleY: number;
  12345. /**
  12346. * Gets or sets the minimal initial rotation in radians.
  12347. */
  12348. minInitialRotation: number;
  12349. /**
  12350. * Gets or sets the maximal initial rotation in radians.
  12351. */
  12352. maxInitialRotation: number;
  12353. /**
  12354. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12355. */
  12356. minAngularSpeed: number;
  12357. /**
  12358. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12359. */
  12360. maxAngularSpeed: number;
  12361. /**
  12362. * The texture used to render each particle. (this can be a spritesheet)
  12363. */
  12364. particleTexture: Nullable<BaseTexture>;
  12365. /**
  12366. * The layer mask we are rendering the particles through.
  12367. */
  12368. layerMask: number;
  12369. /**
  12370. * This can help using your own shader to render the particle system.
  12371. * The according effect will be created
  12372. */
  12373. customShader: any;
  12374. /**
  12375. * By default particle system starts as soon as they are created. This prevents the
  12376. * automatic start to happen and let you decide when to start emitting particles.
  12377. */
  12378. preventAutoStart: boolean;
  12379. private _noiseTexture;
  12380. /**
  12381. * Gets or sets a texture used to add random noise to particle positions
  12382. */
  12383. get noiseTexture(): Nullable<ProceduralTexture>;
  12384. set noiseTexture(value: Nullable<ProceduralTexture>);
  12385. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12386. noiseStrength: Vector3;
  12387. /**
  12388. * Callback triggered when the particle animation is ending.
  12389. */
  12390. onAnimationEnd: Nullable<() => void>;
  12391. /**
  12392. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12393. */
  12394. blendMode: number;
  12395. /**
  12396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12397. * to override the particles.
  12398. */
  12399. forceDepthWrite: boolean;
  12400. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12401. preWarmCycles: number;
  12402. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12403. preWarmStepOffset: number;
  12404. /**
  12405. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12406. */
  12407. spriteCellChangeSpeed: number;
  12408. /**
  12409. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12410. */
  12411. startSpriteCellID: number;
  12412. /**
  12413. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12414. */
  12415. endSpriteCellID: number;
  12416. /**
  12417. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12418. */
  12419. spriteCellWidth: number;
  12420. /**
  12421. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12422. */
  12423. spriteCellHeight: number;
  12424. /**
  12425. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12426. */
  12427. spriteRandomStartCell: boolean;
  12428. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12429. translationPivot: Vector2;
  12430. /** @hidden */
  12431. protected _isAnimationSheetEnabled: boolean;
  12432. /**
  12433. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12434. */
  12435. beginAnimationOnStart: boolean;
  12436. /**
  12437. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12438. */
  12439. beginAnimationFrom: number;
  12440. /**
  12441. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12442. */
  12443. beginAnimationTo: number;
  12444. /**
  12445. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12446. */
  12447. beginAnimationLoop: boolean;
  12448. /**
  12449. * Gets or sets a world offset applied to all particles
  12450. */
  12451. worldOffset: Vector3;
  12452. /**
  12453. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12454. */
  12455. get isAnimationSheetEnabled(): boolean;
  12456. set isAnimationSheetEnabled(value: boolean);
  12457. /**
  12458. * Get hosting scene
  12459. * @returns the scene
  12460. */
  12461. getScene(): Nullable<Scene>;
  12462. /**
  12463. * You can use gravity if you want to give an orientation to your particles.
  12464. */
  12465. gravity: Vector3;
  12466. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12467. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12468. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12469. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12470. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12471. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12472. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12473. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12474. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12475. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12476. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12477. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12478. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12479. /**
  12480. * Defines the delay in milliseconds before starting the system (0 by default)
  12481. */
  12482. startDelay: number;
  12483. /**
  12484. * Gets the current list of drag gradients.
  12485. * You must use addDragGradient and removeDragGradient to udpate this list
  12486. * @returns the list of drag gradients
  12487. */
  12488. getDragGradients(): Nullable<Array<FactorGradient>>;
  12489. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12490. limitVelocityDamping: number;
  12491. /**
  12492. * Gets the current list of limit velocity gradients.
  12493. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12494. * @returns the list of limit velocity gradients
  12495. */
  12496. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12497. /**
  12498. * Gets the current list of color gradients.
  12499. * You must use addColorGradient and removeColorGradient to udpate this list
  12500. * @returns the list of color gradients
  12501. */
  12502. getColorGradients(): Nullable<Array<ColorGradient>>;
  12503. /**
  12504. * Gets the current list of size gradients.
  12505. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12506. * @returns the list of size gradients
  12507. */
  12508. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of color remap gradients.
  12511. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12512. * @returns the list of color remap gradients
  12513. */
  12514. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of alpha remap gradients.
  12517. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12518. * @returns the list of alpha remap gradients
  12519. */
  12520. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of life time gradients.
  12523. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12524. * @returns the list of life time gradients
  12525. */
  12526. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Gets the current list of angular speed gradients.
  12529. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12530. * @returns the list of angular speed gradients
  12531. */
  12532. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12533. /**
  12534. * Gets the current list of velocity gradients.
  12535. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12536. * @returns the list of velocity gradients
  12537. */
  12538. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12539. /**
  12540. * Gets the current list of start size gradients.
  12541. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12542. * @returns the list of start size gradients
  12543. */
  12544. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12545. /**
  12546. * Gets the current list of emit rate gradients.
  12547. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12548. * @returns the list of emit rate gradients
  12549. */
  12550. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12551. /**
  12552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12554. */
  12555. get direction1(): Vector3;
  12556. set direction1(value: Vector3);
  12557. /**
  12558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12559. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12560. */
  12561. get direction2(): Vector3;
  12562. set direction2(value: Vector3);
  12563. /**
  12564. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12566. */
  12567. get minEmitBox(): Vector3;
  12568. set minEmitBox(value: Vector3);
  12569. /**
  12570. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12571. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12572. */
  12573. get maxEmitBox(): Vector3;
  12574. set maxEmitBox(value: Vector3);
  12575. /**
  12576. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12577. */
  12578. color1: Color4;
  12579. /**
  12580. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12581. */
  12582. color2: Color4;
  12583. /**
  12584. * Color the particle will have at the end of its lifetime
  12585. */
  12586. colorDead: Color4;
  12587. /**
  12588. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12589. */
  12590. textureMask: Color4;
  12591. /**
  12592. * The particle emitter type defines the emitter used by the particle system.
  12593. * It can be for example box, sphere, or cone...
  12594. */
  12595. particleEmitterType: IParticleEmitterType;
  12596. /** @hidden */
  12597. _isSubEmitter: boolean;
  12598. /**
  12599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12601. */
  12602. billboardMode: number;
  12603. protected _isBillboardBased: boolean;
  12604. /**
  12605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12606. */
  12607. get isBillboardBased(): boolean;
  12608. set isBillboardBased(value: boolean);
  12609. /**
  12610. * The scene the particle system belongs to.
  12611. */
  12612. protected _scene: Nullable<Scene>;
  12613. /**
  12614. * The engine the particle system belongs to.
  12615. */
  12616. protected _engine: ThinEngine;
  12617. /**
  12618. * Local cache of defines for image processing.
  12619. */
  12620. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12621. /**
  12622. * Default configuration related to image processing available in the standard Material.
  12623. */
  12624. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12625. /**
  12626. * Gets the image processing configuration used either in this material.
  12627. */
  12628. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12629. /**
  12630. * Sets the Default image processing configuration used either in the this material.
  12631. *
  12632. * If sets to null, the scene one is in use.
  12633. */
  12634. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12635. /**
  12636. * Attaches a new image processing configuration to the Standard Material.
  12637. * @param configuration
  12638. */
  12639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12640. /** @hidden */
  12641. protected _reset(): void;
  12642. /** @hidden */
  12643. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12644. /**
  12645. * Instantiates a particle system.
  12646. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12647. * @param name The name of the particle system
  12648. */
  12649. constructor(name: string);
  12650. /**
  12651. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12654. * @returns the emitter
  12655. */
  12656. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12657. /**
  12658. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12659. * @param radius The radius of the hemisphere to emit from
  12660. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12661. * @returns the emitter
  12662. */
  12663. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12664. /**
  12665. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12666. * @param radius The radius of the sphere to emit from
  12667. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12668. * @returns the emitter
  12669. */
  12670. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12671. /**
  12672. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12673. * @param radius The radius of the sphere to emit from
  12674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12676. * @returns the emitter
  12677. */
  12678. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12679. /**
  12680. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12681. * @param radius The radius of the emission cylinder
  12682. * @param height The height of the emission cylinder
  12683. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12684. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12685. * @returns the emitter
  12686. */
  12687. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12688. /**
  12689. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12690. * @param radius The radius of the cylinder to emit from
  12691. * @param height The height of the emission cylinder
  12692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12695. * @returns the emitter
  12696. */
  12697. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12698. /**
  12699. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12700. * @param radius The radius of the cone to emit from
  12701. * @param angle The base angle of the cone
  12702. * @returns the emitter
  12703. */
  12704. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12705. /**
  12706. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12709. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12710. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12711. * @returns the emitter
  12712. */
  12713. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12714. }
  12715. }
  12716. declare module "babylonjs/Particles/subEmitter" {
  12717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12718. import { Scene } from "babylonjs/scene";
  12719. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12720. /**
  12721. * Type of sub emitter
  12722. */
  12723. export enum SubEmitterType {
  12724. /**
  12725. * Attached to the particle over it's lifetime
  12726. */
  12727. ATTACHED = 0,
  12728. /**
  12729. * Created when the particle dies
  12730. */
  12731. END = 1
  12732. }
  12733. /**
  12734. * Sub emitter class used to emit particles from an existing particle
  12735. */
  12736. export class SubEmitter {
  12737. /**
  12738. * the particle system to be used by the sub emitter
  12739. */
  12740. particleSystem: ParticleSystem;
  12741. /**
  12742. * Type of the submitter (Default: END)
  12743. */
  12744. type: SubEmitterType;
  12745. /**
  12746. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12747. * Note: This only is supported when using an emitter of type Mesh
  12748. */
  12749. inheritDirection: boolean;
  12750. /**
  12751. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12752. */
  12753. inheritedVelocityAmount: number;
  12754. /**
  12755. * Creates a sub emitter
  12756. * @param particleSystem the particle system to be used by the sub emitter
  12757. */
  12758. constructor(
  12759. /**
  12760. * the particle system to be used by the sub emitter
  12761. */
  12762. particleSystem: ParticleSystem);
  12763. /**
  12764. * Clones the sub emitter
  12765. * @returns the cloned sub emitter
  12766. */
  12767. clone(): SubEmitter;
  12768. /**
  12769. * Serialize current object to a JSON object
  12770. * @returns the serialized object
  12771. */
  12772. serialize(): any;
  12773. /** @hidden */
  12774. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12775. /**
  12776. * Creates a new SubEmitter from a serialized JSON version
  12777. * @param serializationObject defines the JSON object to read from
  12778. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12779. * @param rootUrl defines the rootUrl for data loading
  12780. * @returns a new SubEmitter
  12781. */
  12782. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12783. /** Release associated resources */
  12784. dispose(): void;
  12785. }
  12786. }
  12787. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12788. /** @hidden */
  12789. export var imageProcessingDeclaration: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12795. /** @hidden */
  12796. export var imageProcessingFunctions: {
  12797. name: string;
  12798. shader: string;
  12799. };
  12800. }
  12801. declare module "babylonjs/Shaders/particles.fragment" {
  12802. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12803. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12805. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12806. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12807. /** @hidden */
  12808. export var particlesPixelShader: {
  12809. name: string;
  12810. shader: string;
  12811. };
  12812. }
  12813. declare module "babylonjs/Shaders/particles.vertex" {
  12814. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12816. /** @hidden */
  12817. export var particlesVertexShader: {
  12818. name: string;
  12819. shader: string;
  12820. };
  12821. }
  12822. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12823. import { Nullable } from "babylonjs/types";
  12824. import { Plane } from "babylonjs/Maths/math";
  12825. /**
  12826. * Interface used to define entities containing multiple clip planes
  12827. */
  12828. export interface IClipPlanesHolder {
  12829. /**
  12830. * Gets or sets the active clipplane 1
  12831. */
  12832. clipPlane: Nullable<Plane>;
  12833. /**
  12834. * Gets or sets the active clipplane 2
  12835. */
  12836. clipPlane2: Nullable<Plane>;
  12837. /**
  12838. * Gets or sets the active clipplane 3
  12839. */
  12840. clipPlane3: Nullable<Plane>;
  12841. /**
  12842. * Gets or sets the active clipplane 4
  12843. */
  12844. clipPlane4: Nullable<Plane>;
  12845. /**
  12846. * Gets or sets the active clipplane 5
  12847. */
  12848. clipPlane5: Nullable<Plane>;
  12849. /**
  12850. * Gets or sets the active clipplane 6
  12851. */
  12852. clipPlane6: Nullable<Plane>;
  12853. }
  12854. }
  12855. declare module "babylonjs/Materials/thinMaterialHelper" {
  12856. import { Effect } from "babylonjs/Materials/effect";
  12857. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12858. /**
  12859. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12860. *
  12861. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12862. *
  12863. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12864. */
  12865. export class ThinMaterialHelper {
  12866. /**
  12867. * Binds the clip plane information from the holder to the effect.
  12868. * @param effect The effect we are binding the data to
  12869. * @param holder The entity containing the clip plane information
  12870. */
  12871. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12872. }
  12873. }
  12874. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12875. module "babylonjs/Engines/thinEngine" {
  12876. interface ThinEngine {
  12877. /**
  12878. * Sets alpha constants used by some alpha blending modes
  12879. * @param r defines the red component
  12880. * @param g defines the green component
  12881. * @param b defines the blue component
  12882. * @param a defines the alpha component
  12883. */
  12884. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12885. /**
  12886. * Sets the current alpha mode
  12887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12889. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12890. */
  12891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12892. /**
  12893. * Gets the current alpha mode
  12894. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12895. * @returns the current alpha mode
  12896. */
  12897. getAlphaMode(): number;
  12898. /**
  12899. * Sets the current alpha equation
  12900. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12901. */
  12902. setAlphaEquation(equation: number): void;
  12903. /**
  12904. * Gets the current alpha equation.
  12905. * @returns the current alpha equation
  12906. */
  12907. getAlphaEquation(): number;
  12908. }
  12909. }
  12910. }
  12911. declare module "babylonjs/Particles/particleSystem" {
  12912. import { Nullable } from "babylonjs/types";
  12913. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12914. import { Observable } from "babylonjs/Misc/observable";
  12915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12916. import { Effect } from "babylonjs/Materials/effect";
  12917. import { IDisposable } from "babylonjs/scene";
  12918. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12919. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12920. import { Particle } from "babylonjs/Particles/particle";
  12921. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12923. import "babylonjs/Shaders/particles.fragment";
  12924. import "babylonjs/Shaders/particles.vertex";
  12925. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12926. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12927. import "babylonjs/Engines/Extensions/engine.alpha";
  12928. import { Scene } from "babylonjs/scene";
  12929. /**
  12930. * This represents a particle system in Babylon.
  12931. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12932. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12933. * @example https://doc.babylonjs.com/babylon101/particles
  12934. */
  12935. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12936. /**
  12937. * Billboard mode will only apply to Y axis
  12938. */
  12939. static readonly BILLBOARDMODE_Y: number;
  12940. /**
  12941. * Billboard mode will apply to all axes
  12942. */
  12943. static readonly BILLBOARDMODE_ALL: number;
  12944. /**
  12945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12946. */
  12947. static readonly BILLBOARDMODE_STRETCHED: number;
  12948. /**
  12949. * This function can be defined to provide custom update for active particles.
  12950. * This function will be called instead of regular update (age, position, color, etc.).
  12951. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12952. */
  12953. updateFunction: (particles: Particle[]) => void;
  12954. private _emitterWorldMatrix;
  12955. /**
  12956. * This function can be defined to specify initial direction for every new particle.
  12957. * It by default use the emitterType defined function
  12958. */
  12959. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12960. /**
  12961. * This function can be defined to specify initial position for every new particle.
  12962. * It by default use the emitterType defined function
  12963. */
  12964. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12965. /**
  12966. * @hidden
  12967. */
  12968. _inheritedVelocityOffset: Vector3;
  12969. /**
  12970. * An event triggered when the system is disposed
  12971. */
  12972. onDisposeObservable: Observable<IParticleSystem>;
  12973. /**
  12974. * An event triggered when the system is stopped
  12975. */
  12976. onStoppedObservable: Observable<IParticleSystem>;
  12977. private _onDisposeObserver;
  12978. /**
  12979. * Sets a callback that will be triggered when the system is disposed
  12980. */
  12981. set onDispose(callback: () => void);
  12982. private _particles;
  12983. private _epsilon;
  12984. private _capacity;
  12985. private _stockParticles;
  12986. private _newPartsExcess;
  12987. private _vertexData;
  12988. private _vertexBuffer;
  12989. private _vertexBuffers;
  12990. private _spriteBuffer;
  12991. private _indexBuffer;
  12992. private _effect;
  12993. private _customEffect;
  12994. private _cachedDefines;
  12995. private _scaledColorStep;
  12996. private _colorDiff;
  12997. private _scaledDirection;
  12998. private _scaledGravity;
  12999. private _currentRenderId;
  13000. private _alive;
  13001. private _useInstancing;
  13002. private _started;
  13003. private _stopped;
  13004. private _actualFrame;
  13005. private _scaledUpdateSpeed;
  13006. private _vertexBufferSize;
  13007. /** @hidden */
  13008. _currentEmitRateGradient: Nullable<FactorGradient>;
  13009. /** @hidden */
  13010. _currentEmitRate1: number;
  13011. /** @hidden */
  13012. _currentEmitRate2: number;
  13013. /** @hidden */
  13014. _currentStartSizeGradient: Nullable<FactorGradient>;
  13015. /** @hidden */
  13016. _currentStartSize1: number;
  13017. /** @hidden */
  13018. _currentStartSize2: number;
  13019. private readonly _rawTextureWidth;
  13020. private _rampGradientsTexture;
  13021. private _useRampGradients;
  13022. /** Gets or sets a matrix to use to compute projection */
  13023. defaultProjectionMatrix: Matrix;
  13024. /** Gets or sets a matrix to use to compute view */
  13025. defaultViewMatrix: Matrix;
  13026. /** Gets or sets a boolean indicating that ramp gradients must be used
  13027. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13028. */
  13029. get useRampGradients(): boolean;
  13030. set useRampGradients(value: boolean);
  13031. /**
  13032. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  13033. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  13034. */
  13035. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13036. private _subEmitters;
  13037. /**
  13038. * @hidden
  13039. * If the particle systems emitter should be disposed when the particle system is disposed
  13040. */
  13041. _disposeEmitterOnDispose: boolean;
  13042. /**
  13043. * The current active Sub-systems, this property is used by the root particle system only.
  13044. */
  13045. activeSubSystems: Array<ParticleSystem>;
  13046. /**
  13047. * Specifies if the particles are updated in emitter local space or world space
  13048. */
  13049. isLocal: boolean;
  13050. private _rootParticleSystem;
  13051. /**
  13052. * Gets the current list of active particles
  13053. */
  13054. get particles(): Particle[];
  13055. /**
  13056. * Gets the number of particles active at the same time.
  13057. * @returns The number of active particles.
  13058. */
  13059. getActiveCount(): number;
  13060. /**
  13061. * Returns the string "ParticleSystem"
  13062. * @returns a string containing the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Gets a boolean indicating that the system is stopping
  13067. * @returns true if the system is currently stopping
  13068. */
  13069. isStopping(): boolean;
  13070. /**
  13071. * Gets the custom effect used to render the particles
  13072. * @param blendMode Blend mode for which the effect should be retrieved
  13073. * @returns The effect
  13074. */
  13075. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13076. /**
  13077. * Sets the custom effect used to render the particles
  13078. * @param effect The effect to set
  13079. * @param blendMode Blend mode for which the effect should be set
  13080. */
  13081. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13082. /** @hidden */
  13083. private _onBeforeDrawParticlesObservable;
  13084. /**
  13085. * Observable that will be called just before the particles are drawn
  13086. */
  13087. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13088. /**
  13089. * Gets the name of the particle vertex shader
  13090. */
  13091. get vertexShaderName(): string;
  13092. /**
  13093. * Instantiates a particle system.
  13094. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  13095. * @param name The name of the particle system
  13096. * @param capacity The max number of particles alive at the same time
  13097. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13098. * @param customEffect a custom effect used to change the way particles are rendered by default
  13099. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13100. * @param epsilon Offset used to render the particles
  13101. */
  13102. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13103. private _addFactorGradient;
  13104. private _removeFactorGradient;
  13105. /**
  13106. * Adds a new life time gradient
  13107. * @param gradient defines the gradient to use (between 0 and 1)
  13108. * @param factor defines the life time factor to affect to the specified gradient
  13109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13110. * @returns the current particle system
  13111. */
  13112. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13113. /**
  13114. * Remove a specific life time gradient
  13115. * @param gradient defines the gradient to remove
  13116. * @returns the current particle system
  13117. */
  13118. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13119. /**
  13120. * Adds a new size gradient
  13121. * @param gradient defines the gradient to use (between 0 and 1)
  13122. * @param factor defines the size factor to affect to the specified gradient
  13123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13124. * @returns the current particle system
  13125. */
  13126. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13127. /**
  13128. * Remove a specific size gradient
  13129. * @param gradient defines the gradient to remove
  13130. * @returns the current particle system
  13131. */
  13132. removeSizeGradient(gradient: number): IParticleSystem;
  13133. /**
  13134. * Adds a new color remap gradient
  13135. * @param gradient defines the gradient to use (between 0 and 1)
  13136. * @param min defines the color remap minimal range
  13137. * @param max defines the color remap maximal range
  13138. * @returns the current particle system
  13139. */
  13140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13141. /**
  13142. * Remove a specific color remap gradient
  13143. * @param gradient defines the gradient to remove
  13144. * @returns the current particle system
  13145. */
  13146. removeColorRemapGradient(gradient: number): IParticleSystem;
  13147. /**
  13148. * Adds a new alpha remap gradient
  13149. * @param gradient defines the gradient to use (between 0 and 1)
  13150. * @param min defines the alpha remap minimal range
  13151. * @param max defines the alpha remap maximal range
  13152. * @returns the current particle system
  13153. */
  13154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13155. /**
  13156. * Remove a specific alpha remap gradient
  13157. * @param gradient defines the gradient to remove
  13158. * @returns the current particle system
  13159. */
  13160. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13161. /**
  13162. * Adds a new angular speed gradient
  13163. * @param gradient defines the gradient to use (between 0 and 1)
  13164. * @param factor defines the angular speed to affect to the specified gradient
  13165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13166. * @returns the current particle system
  13167. */
  13168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13169. /**
  13170. * Remove a specific angular speed gradient
  13171. * @param gradient defines the gradient to remove
  13172. * @returns the current particle system
  13173. */
  13174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13175. /**
  13176. * Adds a new velocity gradient
  13177. * @param gradient defines the gradient to use (between 0 and 1)
  13178. * @param factor defines the velocity to affect to the specified gradient
  13179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13180. * @returns the current particle system
  13181. */
  13182. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13183. /**
  13184. * Remove a specific velocity gradient
  13185. * @param gradient defines the gradient to remove
  13186. * @returns the current particle system
  13187. */
  13188. removeVelocityGradient(gradient: number): IParticleSystem;
  13189. /**
  13190. * Adds a new limit velocity gradient
  13191. * @param gradient defines the gradient to use (between 0 and 1)
  13192. * @param factor defines the limit velocity value to affect to the specified gradient
  13193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13194. * @returns the current particle system
  13195. */
  13196. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13197. /**
  13198. * Remove a specific limit velocity gradient
  13199. * @param gradient defines the gradient to remove
  13200. * @returns the current particle system
  13201. */
  13202. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13203. /**
  13204. * Adds a new drag gradient
  13205. * @param gradient defines the gradient to use (between 0 and 1)
  13206. * @param factor defines the drag value to affect to the specified gradient
  13207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13208. * @returns the current particle system
  13209. */
  13210. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13211. /**
  13212. * Remove a specific drag gradient
  13213. * @param gradient defines the gradient to remove
  13214. * @returns the current particle system
  13215. */
  13216. removeDragGradient(gradient: number): IParticleSystem;
  13217. /**
  13218. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13219. * @param gradient defines the gradient to use (between 0 and 1)
  13220. * @param factor defines the emit rate value to affect to the specified gradient
  13221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13222. * @returns the current particle system
  13223. */
  13224. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13225. /**
  13226. * Remove a specific emit rate gradient
  13227. * @param gradient defines the gradient to remove
  13228. * @returns the current particle system
  13229. */
  13230. removeEmitRateGradient(gradient: number): IParticleSystem;
  13231. /**
  13232. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13233. * @param gradient defines the gradient to use (between 0 and 1)
  13234. * @param factor defines the start size value to affect to the specified gradient
  13235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13236. * @returns the current particle system
  13237. */
  13238. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13239. /**
  13240. * Remove a specific start size gradient
  13241. * @param gradient defines the gradient to remove
  13242. * @returns the current particle system
  13243. */
  13244. removeStartSizeGradient(gradient: number): IParticleSystem;
  13245. private _createRampGradientTexture;
  13246. /**
  13247. * Gets the current list of ramp gradients.
  13248. * You must use addRampGradient and removeRampGradient to udpate this list
  13249. * @returns the list of ramp gradients
  13250. */
  13251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13252. /** Force the system to rebuild all gradients that need to be resync */
  13253. forceRefreshGradients(): void;
  13254. private _syncRampGradientTexture;
  13255. /**
  13256. * Adds a new ramp gradient used to remap particle colors
  13257. * @param gradient defines the gradient to use (between 0 and 1)
  13258. * @param color defines the color to affect to the specified gradient
  13259. * @returns the current particle system
  13260. */
  13261. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13262. /**
  13263. * Remove a specific ramp gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeRampGradient(gradient: number): ParticleSystem;
  13268. /**
  13269. * Adds a new color gradient
  13270. * @param gradient defines the gradient to use (between 0 and 1)
  13271. * @param color1 defines the color to affect to the specified gradient
  13272. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13273. * @returns this particle system
  13274. */
  13275. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13276. /**
  13277. * Remove a specific color gradient
  13278. * @param gradient defines the gradient to remove
  13279. * @returns this particle system
  13280. */
  13281. removeColorGradient(gradient: number): IParticleSystem;
  13282. private _fetchR;
  13283. protected _reset(): void;
  13284. private _resetEffect;
  13285. private _createVertexBuffers;
  13286. private _createIndexBuffer;
  13287. /**
  13288. * Gets the maximum number of particles active at the same time.
  13289. * @returns The max number of active particles.
  13290. */
  13291. getCapacity(): number;
  13292. /**
  13293. * Gets whether there are still active particles in the system.
  13294. * @returns True if it is alive, otherwise false.
  13295. */
  13296. isAlive(): boolean;
  13297. /**
  13298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13299. * @returns True if it has been started, otherwise false.
  13300. */
  13301. isStarted(): boolean;
  13302. private _prepareSubEmitterInternalArray;
  13303. /**
  13304. * Starts the particle system and begins to emit
  13305. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13306. */
  13307. start(delay?: number): void;
  13308. /**
  13309. * Stops the particle system.
  13310. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13311. */
  13312. stop(stopSubEmitters?: boolean): void;
  13313. /**
  13314. * Remove all active particles
  13315. */
  13316. reset(): void;
  13317. /**
  13318. * @hidden (for internal use only)
  13319. */
  13320. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13321. /**
  13322. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13323. * Its lifetime will start back at 0.
  13324. */
  13325. recycleParticle: (particle: Particle) => void;
  13326. private _stopSubEmitters;
  13327. private _createParticle;
  13328. private _removeFromRoot;
  13329. private _emitFromParticle;
  13330. private _update;
  13331. /** @hidden */
  13332. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13333. /** @hidden */
  13334. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13335. /**
  13336. * Fill the defines array according to the current settings of the particle system
  13337. * @param defines Array to be updated
  13338. * @param blendMode blend mode to take into account when updating the array
  13339. */
  13340. fillDefines(defines: Array<string>, blendMode: number): void;
  13341. /**
  13342. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13343. * @param uniforms Uniforms array to fill
  13344. * @param attributes Attributes array to fill
  13345. * @param samplers Samplers array to fill
  13346. */
  13347. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13348. /** @hidden */
  13349. private _getEffect;
  13350. /**
  13351. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13352. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13353. */
  13354. animate(preWarmOnly?: boolean): void;
  13355. private _appendParticleVertices;
  13356. /**
  13357. * Rebuilds the particle system.
  13358. */
  13359. rebuild(): void;
  13360. /**
  13361. * Is this system ready to be used/rendered
  13362. * @return true if the system is ready
  13363. */
  13364. isReady(): boolean;
  13365. private _render;
  13366. /**
  13367. * Renders the particle system in its current state.
  13368. * @returns the current number of particles
  13369. */
  13370. render(): number;
  13371. /**
  13372. * Disposes the particle system and free the associated resources
  13373. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13374. */
  13375. dispose(disposeTexture?: boolean): void;
  13376. /**
  13377. * Clones the particle system.
  13378. * @param name The name of the cloned object
  13379. * @param newEmitter The new emitter to use
  13380. * @returns the cloned particle system
  13381. */
  13382. clone(name: string, newEmitter: any): ParticleSystem;
  13383. /**
  13384. * Serializes the particle system to a JSON object
  13385. * @param serializeTexture defines if the texture must be serialized as well
  13386. * @returns the JSON object
  13387. */
  13388. serialize(serializeTexture?: boolean): any;
  13389. /** @hidden */
  13390. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13391. /** @hidden */
  13392. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13393. /**
  13394. * Parses a JSON object to create a particle system.
  13395. * @param parsedParticleSystem The JSON object to parse
  13396. * @param sceneOrEngine The scene or the engine to create the particle system in
  13397. * @param rootUrl The root url to use to load external dependencies like texture
  13398. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13399. * @returns the Parsed particle system
  13400. */
  13401. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13402. }
  13403. }
  13404. declare module "babylonjs/Particles/particle" {
  13405. import { Nullable } from "babylonjs/types";
  13406. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13407. import { Color4 } from "babylonjs/Maths/math.color";
  13408. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13409. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13410. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13411. /**
  13412. * A particle represents one of the element emitted by a particle system.
  13413. * This is mainly define by its coordinates, direction, velocity and age.
  13414. */
  13415. export class Particle {
  13416. /**
  13417. * The particle system the particle belongs to.
  13418. */
  13419. particleSystem: ParticleSystem;
  13420. private static _Count;
  13421. /**
  13422. * Unique ID of the particle
  13423. */
  13424. id: number;
  13425. /**
  13426. * The world position of the particle in the scene.
  13427. */
  13428. position: Vector3;
  13429. /**
  13430. * The world direction of the particle in the scene.
  13431. */
  13432. direction: Vector3;
  13433. /**
  13434. * The color of the particle.
  13435. */
  13436. color: Color4;
  13437. /**
  13438. * The color change of the particle per step.
  13439. */
  13440. colorStep: Color4;
  13441. /**
  13442. * Defines how long will the life of the particle be.
  13443. */
  13444. lifeTime: number;
  13445. /**
  13446. * The current age of the particle.
  13447. */
  13448. age: number;
  13449. /**
  13450. * The current size of the particle.
  13451. */
  13452. size: number;
  13453. /**
  13454. * The current scale of the particle.
  13455. */
  13456. scale: Vector2;
  13457. /**
  13458. * The current angle of the particle.
  13459. */
  13460. angle: number;
  13461. /**
  13462. * Defines how fast is the angle changing.
  13463. */
  13464. angularSpeed: number;
  13465. /**
  13466. * Defines the cell index used by the particle to be rendered from a sprite.
  13467. */
  13468. cellIndex: number;
  13469. /**
  13470. * The information required to support color remapping
  13471. */
  13472. remapData: Vector4;
  13473. /** @hidden */
  13474. _randomCellOffset?: number;
  13475. /** @hidden */
  13476. _initialDirection: Nullable<Vector3>;
  13477. /** @hidden */
  13478. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13479. /** @hidden */
  13480. _initialStartSpriteCellID: number;
  13481. /** @hidden */
  13482. _initialEndSpriteCellID: number;
  13483. /** @hidden */
  13484. _currentColorGradient: Nullable<ColorGradient>;
  13485. /** @hidden */
  13486. _currentColor1: Color4;
  13487. /** @hidden */
  13488. _currentColor2: Color4;
  13489. /** @hidden */
  13490. _currentSizeGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentSize1: number;
  13493. /** @hidden */
  13494. _currentSize2: number;
  13495. /** @hidden */
  13496. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentAngularSpeed1: number;
  13499. /** @hidden */
  13500. _currentAngularSpeed2: number;
  13501. /** @hidden */
  13502. _currentVelocityGradient: Nullable<FactorGradient>;
  13503. /** @hidden */
  13504. _currentVelocity1: number;
  13505. /** @hidden */
  13506. _currentVelocity2: number;
  13507. /** @hidden */
  13508. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13509. /** @hidden */
  13510. _currentLimitVelocity1: number;
  13511. /** @hidden */
  13512. _currentLimitVelocity2: number;
  13513. /** @hidden */
  13514. _currentDragGradient: Nullable<FactorGradient>;
  13515. /** @hidden */
  13516. _currentDrag1: number;
  13517. /** @hidden */
  13518. _currentDrag2: number;
  13519. /** @hidden */
  13520. _randomNoiseCoordinates1: Vector3;
  13521. /** @hidden */
  13522. _randomNoiseCoordinates2: Vector3;
  13523. /** @hidden */
  13524. _localPosition?: Vector3;
  13525. /**
  13526. * Creates a new instance Particle
  13527. * @param particleSystem the particle system the particle belongs to
  13528. */
  13529. constructor(
  13530. /**
  13531. * The particle system the particle belongs to.
  13532. */
  13533. particleSystem: ParticleSystem);
  13534. private updateCellInfoFromSystem;
  13535. /**
  13536. * Defines how the sprite cell index is updated for the particle
  13537. */
  13538. updateCellIndex(): void;
  13539. /** @hidden */
  13540. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13541. /** @hidden */
  13542. _inheritParticleInfoToSubEmitters(): void;
  13543. /** @hidden */
  13544. _reset(): void;
  13545. /**
  13546. * Copy the properties of particle to another one.
  13547. * @param other the particle to copy the information to.
  13548. */
  13549. copyTo(other: Particle): void;
  13550. }
  13551. }
  13552. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13553. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13554. import { Effect } from "babylonjs/Materials/effect";
  13555. import { Particle } from "babylonjs/Particles/particle";
  13556. import { Nullable } from "babylonjs/types";
  13557. import { Scene } from "babylonjs/scene";
  13558. /**
  13559. * Particle emitter represents a volume emitting particles.
  13560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13561. */
  13562. export interface IParticleEmitterType {
  13563. /**
  13564. * Called by the particle System when the direction is computed for the created particle.
  13565. * @param worldMatrix is the world matrix of the particle system
  13566. * @param directionToUpdate is the direction vector to update with the result
  13567. * @param particle is the particle we are computed the direction for
  13568. * @param isLocal defines if the direction should be set in local space
  13569. */
  13570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13571. /**
  13572. * Called by the particle System when the position is computed for the created particle.
  13573. * @param worldMatrix is the world matrix of the particle system
  13574. * @param positionToUpdate is the position vector to update with the result
  13575. * @param particle is the particle we are computed the position for
  13576. * @param isLocal defines if the position should be set in local space
  13577. */
  13578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13579. /**
  13580. * Clones the current emitter and returns a copy of it
  13581. * @returns the new emitter
  13582. */
  13583. clone(): IParticleEmitterType;
  13584. /**
  13585. * Called by the GPUParticleSystem to setup the update shader
  13586. * @param effect defines the update shader
  13587. */
  13588. applyToShader(effect: Effect): void;
  13589. /**
  13590. * Returns a string to use to update the GPU particles update shader
  13591. * @returns the effect defines string
  13592. */
  13593. getEffectDefines(): string;
  13594. /**
  13595. * Returns a string representing the class name
  13596. * @returns a string containing the class name
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Serializes the particle system to a JSON object.
  13601. * @returns the JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Parse properties from a JSON object
  13606. * @param serializationObject defines the JSON object
  13607. * @param scene defines the hosting scene
  13608. */
  13609. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13610. }
  13611. }
  13612. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13613. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13614. import { Effect } from "babylonjs/Materials/effect";
  13615. import { Particle } from "babylonjs/Particles/particle";
  13616. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13617. /**
  13618. * Particle emitter emitting particles from the inside of a box.
  13619. * It emits the particles randomly between 2 given directions.
  13620. */
  13621. export class BoxParticleEmitter implements IParticleEmitterType {
  13622. /**
  13623. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13624. */
  13625. direction1: Vector3;
  13626. /**
  13627. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13628. */
  13629. direction2: Vector3;
  13630. /**
  13631. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13632. */
  13633. minEmitBox: Vector3;
  13634. /**
  13635. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13636. */
  13637. maxEmitBox: Vector3;
  13638. /**
  13639. * Creates a new instance BoxParticleEmitter
  13640. */
  13641. constructor();
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): BoxParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "BoxParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cone.
  13697. * It emits the particles alongside the cone volume from the base to the particle.
  13698. * The emission direction might be randomized.
  13699. */
  13700. export class ConeParticleEmitter implements IParticleEmitterType {
  13701. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13702. directionRandomizer: number;
  13703. private _radius;
  13704. private _angle;
  13705. private _height;
  13706. /**
  13707. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13708. */
  13709. radiusRange: number;
  13710. /**
  13711. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13712. */
  13713. heightRange: number;
  13714. /**
  13715. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13716. */
  13717. emitFromSpawnPointOnly: boolean;
  13718. /**
  13719. * Gets or sets the radius of the emission cone
  13720. */
  13721. get radius(): number;
  13722. set radius(value: number);
  13723. /**
  13724. * Gets or sets the angle of the emission cone
  13725. */
  13726. get angle(): number;
  13727. set angle(value: number);
  13728. private _buildHeight;
  13729. /**
  13730. * Creates a new instance ConeParticleEmitter
  13731. * @param radius the radius of the emission cone (1 by default)
  13732. * @param angle the cone base angle (PI by default)
  13733. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13734. */
  13735. constructor(radius?: number, angle?: number,
  13736. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13737. directionRandomizer?: number);
  13738. /**
  13739. * Called by the particle System when the direction is computed for the created particle.
  13740. * @param worldMatrix is the world matrix of the particle system
  13741. * @param directionToUpdate is the direction vector to update with the result
  13742. * @param particle is the particle we are computed the direction for
  13743. * @param isLocal defines if the direction should be set in local space
  13744. */
  13745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13746. /**
  13747. * Called by the particle System when the position is computed for the created particle.
  13748. * @param worldMatrix is the world matrix of the particle system
  13749. * @param positionToUpdate is the position vector to update with the result
  13750. * @param particle is the particle we are computed the position for
  13751. * @param isLocal defines if the position should be set in local space
  13752. */
  13753. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13754. /**
  13755. * Clones the current emitter and returns a copy of it
  13756. * @returns the new emitter
  13757. */
  13758. clone(): ConeParticleEmitter;
  13759. /**
  13760. * Called by the GPUParticleSystem to setup the update shader
  13761. * @param effect defines the update shader
  13762. */
  13763. applyToShader(effect: Effect): void;
  13764. /**
  13765. * Returns a string to use to update the GPU particles update shader
  13766. * @returns a string containng the defines string
  13767. */
  13768. getEffectDefines(): string;
  13769. /**
  13770. * Returns the string "ConeParticleEmitter"
  13771. * @returns a string containing the class name
  13772. */
  13773. getClassName(): string;
  13774. /**
  13775. * Serializes the particle system to a JSON object.
  13776. * @returns the JSON object
  13777. */
  13778. serialize(): any;
  13779. /**
  13780. * Parse properties from a JSON object
  13781. * @param serializationObject defines the JSON object
  13782. */
  13783. parse(serializationObject: any): void;
  13784. }
  13785. }
  13786. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13788. import { Effect } from "babylonjs/Materials/effect";
  13789. import { Particle } from "babylonjs/Particles/particle";
  13790. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13791. /**
  13792. * Particle emitter emitting particles from the inside of a cylinder.
  13793. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13794. */
  13795. export class CylinderParticleEmitter implements IParticleEmitterType {
  13796. /**
  13797. * The radius of the emission cylinder.
  13798. */
  13799. radius: number;
  13800. /**
  13801. * The height of the emission cylinder.
  13802. */
  13803. height: number;
  13804. /**
  13805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13806. */
  13807. radiusRange: number;
  13808. /**
  13809. * How much to randomize the particle direction [0-1].
  13810. */
  13811. directionRandomizer: number;
  13812. /**
  13813. * Creates a new instance CylinderParticleEmitter
  13814. * @param radius the radius of the emission cylinder (1 by default)
  13815. * @param height the height of the emission cylinder (1 by default)
  13816. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13818. */
  13819. constructor(
  13820. /**
  13821. * The radius of the emission cylinder.
  13822. */
  13823. radius?: number,
  13824. /**
  13825. * The height of the emission cylinder.
  13826. */
  13827. height?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): CylinderParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "CylinderParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a cylinder.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance CylinderDirectedParticleEmitter
  13898. * @param radius the radius of the emission cylinder (1 by default)
  13899. * @param height the height of the emission cylinder (1 by default)
  13900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13901. * @param direction1 the min limit of the emission direction (up vector by default)
  13902. * @param direction2 the max limit of the emission direction (up vector by default)
  13903. */
  13904. constructor(radius?: number, height?: number, radiusRange?: number,
  13905. /**
  13906. * The min limit of the emission direction.
  13907. */
  13908. direction1?: Vector3,
  13909. /**
  13910. * The max limit of the emission direction.
  13911. */
  13912. direction2?: Vector3);
  13913. /**
  13914. * Called by the particle System when the direction is computed for the created particle.
  13915. * @param worldMatrix is the world matrix of the particle system
  13916. * @param directionToUpdate is the direction vector to update with the result
  13917. * @param particle is the particle we are computed the direction for
  13918. */
  13919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13920. /**
  13921. * Clones the current emitter and returns a copy of it
  13922. * @returns the new emitter
  13923. */
  13924. clone(): CylinderDirectedParticleEmitter;
  13925. /**
  13926. * Called by the GPUParticleSystem to setup the update shader
  13927. * @param effect defines the update shader
  13928. */
  13929. applyToShader(effect: Effect): void;
  13930. /**
  13931. * Returns a string to use to update the GPU particles update shader
  13932. * @returns a string containng the defines string
  13933. */
  13934. getEffectDefines(): string;
  13935. /**
  13936. * Returns the string "CylinderDirectedParticleEmitter"
  13937. * @returns a string containing the class name
  13938. */
  13939. getClassName(): string;
  13940. /**
  13941. * Serializes the particle system to a JSON object.
  13942. * @returns the JSON object
  13943. */
  13944. serialize(): any;
  13945. /**
  13946. * Parse properties from a JSON object
  13947. * @param serializationObject defines the JSON object
  13948. */
  13949. parse(serializationObject: any): void;
  13950. }
  13951. }
  13952. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13953. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13954. import { Effect } from "babylonjs/Materials/effect";
  13955. import { Particle } from "babylonjs/Particles/particle";
  13956. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13957. /**
  13958. * Particle emitter emitting particles from the inside of a hemisphere.
  13959. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13960. */
  13961. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * The radius of the emission hemisphere.
  13964. */
  13965. radius: number;
  13966. /**
  13967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13968. */
  13969. radiusRange: number;
  13970. /**
  13971. * How much to randomize the particle direction [0-1].
  13972. */
  13973. directionRandomizer: number;
  13974. /**
  13975. * Creates a new instance HemisphericParticleEmitter
  13976. * @param radius the radius of the emission hemisphere (1 by default)
  13977. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13978. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13979. */
  13980. constructor(
  13981. /**
  13982. * The radius of the emission hemisphere.
  13983. */
  13984. radius?: number,
  13985. /**
  13986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13987. */
  13988. radiusRange?: number,
  13989. /**
  13990. * How much to randomize the particle direction [0-1].
  13991. */
  13992. directionRandomizer?: number);
  13993. /**
  13994. * Called by the particle System when the direction is computed for the created particle.
  13995. * @param worldMatrix is the world matrix of the particle system
  13996. * @param directionToUpdate is the direction vector to update with the result
  13997. * @param particle is the particle we are computed the direction for
  13998. * @param isLocal defines if the direction should be set in local space
  13999. */
  14000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14001. /**
  14002. * Called by the particle System when the position is computed for the created particle.
  14003. * @param worldMatrix is the world matrix of the particle system
  14004. * @param positionToUpdate is the position vector to update with the result
  14005. * @param particle is the particle we are computed the position for
  14006. * @param isLocal defines if the position should be set in local space
  14007. */
  14008. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14009. /**
  14010. * Clones the current emitter and returns a copy of it
  14011. * @returns the new emitter
  14012. */
  14013. clone(): HemisphericParticleEmitter;
  14014. /**
  14015. * Called by the GPUParticleSystem to setup the update shader
  14016. * @param effect defines the update shader
  14017. */
  14018. applyToShader(effect: Effect): void;
  14019. /**
  14020. * Returns a string to use to update the GPU particles update shader
  14021. * @returns a string containng the defines string
  14022. */
  14023. getEffectDefines(): string;
  14024. /**
  14025. * Returns the string "HemisphericParticleEmitter"
  14026. * @returns a string containing the class name
  14027. */
  14028. getClassName(): string;
  14029. /**
  14030. * Serializes the particle system to a JSON object.
  14031. * @returns the JSON object
  14032. */
  14033. serialize(): any;
  14034. /**
  14035. * Parse properties from a JSON object
  14036. * @param serializationObject defines the JSON object
  14037. */
  14038. parse(serializationObject: any): void;
  14039. }
  14040. }
  14041. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14042. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14043. import { Effect } from "babylonjs/Materials/effect";
  14044. import { Particle } from "babylonjs/Particles/particle";
  14045. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14046. /**
  14047. * Particle emitter emitting particles from a point.
  14048. * It emits the particles randomly between 2 given directions.
  14049. */
  14050. export class PointParticleEmitter implements IParticleEmitterType {
  14051. /**
  14052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14053. */
  14054. direction1: Vector3;
  14055. /**
  14056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14057. */
  14058. direction2: Vector3;
  14059. /**
  14060. * Creates a new instance PointParticleEmitter
  14061. */
  14062. constructor();
  14063. /**
  14064. * Called by the particle System when the direction is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param directionToUpdate is the direction vector to update with the result
  14067. * @param particle is the particle we are computed the direction for
  14068. * @param isLocal defines if the direction should be set in local space
  14069. */
  14070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Called by the particle System when the position is computed for the created particle.
  14073. * @param worldMatrix is the world matrix of the particle system
  14074. * @param positionToUpdate is the position vector to update with the result
  14075. * @param particle is the particle we are computed the position for
  14076. * @param isLocal defines if the position should be set in local space
  14077. */
  14078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14079. /**
  14080. * Clones the current emitter and returns a copy of it
  14081. * @returns the new emitter
  14082. */
  14083. clone(): PointParticleEmitter;
  14084. /**
  14085. * Called by the GPUParticleSystem to setup the update shader
  14086. * @param effect defines the update shader
  14087. */
  14088. applyToShader(effect: Effect): void;
  14089. /**
  14090. * Returns a string to use to update the GPU particles update shader
  14091. * @returns a string containng the defines string
  14092. */
  14093. getEffectDefines(): string;
  14094. /**
  14095. * Returns the string "PointParticleEmitter"
  14096. * @returns a string containing the class name
  14097. */
  14098. getClassName(): string;
  14099. /**
  14100. * Serializes the particle system to a JSON object.
  14101. * @returns the JSON object
  14102. */
  14103. serialize(): any;
  14104. /**
  14105. * Parse properties from a JSON object
  14106. * @param serializationObject defines the JSON object
  14107. */
  14108. parse(serializationObject: any): void;
  14109. }
  14110. }
  14111. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14112. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14113. import { Effect } from "babylonjs/Materials/effect";
  14114. import { Particle } from "babylonjs/Particles/particle";
  14115. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14116. /**
  14117. * Particle emitter emitting particles from the inside of a sphere.
  14118. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14119. */
  14120. export class SphereParticleEmitter implements IParticleEmitterType {
  14121. /**
  14122. * The radius of the emission sphere.
  14123. */
  14124. radius: number;
  14125. /**
  14126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14127. */
  14128. radiusRange: number;
  14129. /**
  14130. * How much to randomize the particle direction [0-1].
  14131. */
  14132. directionRandomizer: number;
  14133. /**
  14134. * Creates a new instance SphereParticleEmitter
  14135. * @param radius the radius of the emission sphere (1 by default)
  14136. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14138. */
  14139. constructor(
  14140. /**
  14141. * The radius of the emission sphere.
  14142. */
  14143. radius?: number,
  14144. /**
  14145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14146. */
  14147. radiusRange?: number,
  14148. /**
  14149. * How much to randomize the particle direction [0-1].
  14150. */
  14151. directionRandomizer?: number);
  14152. /**
  14153. * Called by the particle System when the direction is computed for the created particle.
  14154. * @param worldMatrix is the world matrix of the particle system
  14155. * @param directionToUpdate is the direction vector to update with the result
  14156. * @param particle is the particle we are computed the direction for
  14157. * @param isLocal defines if the direction should be set in local space
  14158. */
  14159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14160. /**
  14161. * Called by the particle System when the position is computed for the created particle.
  14162. * @param worldMatrix is the world matrix of the particle system
  14163. * @param positionToUpdate is the position vector to update with the result
  14164. * @param particle is the particle we are computed the position for
  14165. * @param isLocal defines if the position should be set in local space
  14166. */
  14167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14168. /**
  14169. * Clones the current emitter and returns a copy of it
  14170. * @returns the new emitter
  14171. */
  14172. clone(): SphereParticleEmitter;
  14173. /**
  14174. * Called by the GPUParticleSystem to setup the update shader
  14175. * @param effect defines the update shader
  14176. */
  14177. applyToShader(effect: Effect): void;
  14178. /**
  14179. * Returns a string to use to update the GPU particles update shader
  14180. * @returns a string containng the defines string
  14181. */
  14182. getEffectDefines(): string;
  14183. /**
  14184. * Returns the string "SphereParticleEmitter"
  14185. * @returns a string containing the class name
  14186. */
  14187. getClassName(): string;
  14188. /**
  14189. * Serializes the particle system to a JSON object.
  14190. * @returns the JSON object
  14191. */
  14192. serialize(): any;
  14193. /**
  14194. * Parse properties from a JSON object
  14195. * @param serializationObject defines the JSON object
  14196. */
  14197. parse(serializationObject: any): void;
  14198. }
  14199. /**
  14200. * Particle emitter emitting particles from the inside of a sphere.
  14201. * It emits the particles randomly between two vectors.
  14202. */
  14203. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14204. /**
  14205. * The min limit of the emission direction.
  14206. */
  14207. direction1: Vector3;
  14208. /**
  14209. * The max limit of the emission direction.
  14210. */
  14211. direction2: Vector3;
  14212. /**
  14213. * Creates a new instance SphereDirectedParticleEmitter
  14214. * @param radius the radius of the emission sphere (1 by default)
  14215. * @param direction1 the min limit of the emission direction (up vector by default)
  14216. * @param direction2 the max limit of the emission direction (up vector by default)
  14217. */
  14218. constructor(radius?: number,
  14219. /**
  14220. * The min limit of the emission direction.
  14221. */
  14222. direction1?: Vector3,
  14223. /**
  14224. * The max limit of the emission direction.
  14225. */
  14226. direction2?: Vector3);
  14227. /**
  14228. * Called by the particle System when the direction is computed for the created particle.
  14229. * @param worldMatrix is the world matrix of the particle system
  14230. * @param directionToUpdate is the direction vector to update with the result
  14231. * @param particle is the particle we are computed the direction for
  14232. */
  14233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14234. /**
  14235. * Clones the current emitter and returns a copy of it
  14236. * @returns the new emitter
  14237. */
  14238. clone(): SphereDirectedParticleEmitter;
  14239. /**
  14240. * Called by the GPUParticleSystem to setup the update shader
  14241. * @param effect defines the update shader
  14242. */
  14243. applyToShader(effect: Effect): void;
  14244. /**
  14245. * Returns a string to use to update the GPU particles update shader
  14246. * @returns a string containng the defines string
  14247. */
  14248. getEffectDefines(): string;
  14249. /**
  14250. * Returns the string "SphereDirectedParticleEmitter"
  14251. * @returns a string containing the class name
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Serializes the particle system to a JSON object.
  14256. * @returns the JSON object
  14257. */
  14258. serialize(): any;
  14259. /**
  14260. * Parse properties from a JSON object
  14261. * @param serializationObject defines the JSON object
  14262. */
  14263. parse(serializationObject: any): void;
  14264. }
  14265. }
  14266. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14268. import { Effect } from "babylonjs/Materials/effect";
  14269. import { Particle } from "babylonjs/Particles/particle";
  14270. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14271. import { Nullable } from "babylonjs/types";
  14272. /**
  14273. * Particle emitter emitting particles from a custom list of positions.
  14274. */
  14275. export class CustomParticleEmitter implements IParticleEmitterType {
  14276. /**
  14277. * Gets or sets the position generator that will create the inital position of each particle.
  14278. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14279. */
  14280. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14281. /**
  14282. * Gets or sets the destination generator that will create the final destination of each particle.
  14283. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14284. */
  14285. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14286. /**
  14287. * Creates a new instance CustomParticleEmitter
  14288. */
  14289. constructor();
  14290. /**
  14291. * Called by the particle System when the direction is computed for the created particle.
  14292. * @param worldMatrix is the world matrix of the particle system
  14293. * @param directionToUpdate is the direction vector to update with the result
  14294. * @param particle is the particle we are computed the direction for
  14295. * @param isLocal defines if the direction should be set in local space
  14296. */
  14297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14298. /**
  14299. * Called by the particle System when the position is computed for the created particle.
  14300. * @param worldMatrix is the world matrix of the particle system
  14301. * @param positionToUpdate is the position vector to update with the result
  14302. * @param particle is the particle we are computed the position for
  14303. * @param isLocal defines if the position should be set in local space
  14304. */
  14305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14306. /**
  14307. * Clones the current emitter and returns a copy of it
  14308. * @returns the new emitter
  14309. */
  14310. clone(): CustomParticleEmitter;
  14311. /**
  14312. * Called by the GPUParticleSystem to setup the update shader
  14313. * @param effect defines the update shader
  14314. */
  14315. applyToShader(effect: Effect): void;
  14316. /**
  14317. * Returns a string to use to update the GPU particles update shader
  14318. * @returns a string containng the defines string
  14319. */
  14320. getEffectDefines(): string;
  14321. /**
  14322. * Returns the string "PointParticleEmitter"
  14323. * @returns a string containing the class name
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Serializes the particle system to a JSON object.
  14328. * @returns the JSON object
  14329. */
  14330. serialize(): any;
  14331. /**
  14332. * Parse properties from a JSON object
  14333. * @param serializationObject defines the JSON object
  14334. */
  14335. parse(serializationObject: any): void;
  14336. }
  14337. }
  14338. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14340. import { Effect } from "babylonjs/Materials/effect";
  14341. import { Particle } from "babylonjs/Particles/particle";
  14342. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14343. import { Nullable } from "babylonjs/types";
  14344. import { Scene } from "babylonjs/scene";
  14345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14346. /**
  14347. * Particle emitter emitting particles from the inside of a box.
  14348. * It emits the particles randomly between 2 given directions.
  14349. */
  14350. export class MeshParticleEmitter implements IParticleEmitterType {
  14351. private _indices;
  14352. private _positions;
  14353. private _normals;
  14354. private _storedNormal;
  14355. private _mesh;
  14356. /**
  14357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14358. */
  14359. direction1: Vector3;
  14360. /**
  14361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14362. */
  14363. direction2: Vector3;
  14364. /**
  14365. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14366. */
  14367. useMeshNormalsForDirection: boolean;
  14368. /** Defines the mesh to use as source */
  14369. get mesh(): Nullable<AbstractMesh>;
  14370. set mesh(value: Nullable<AbstractMesh>);
  14371. /**
  14372. * Creates a new instance MeshParticleEmitter
  14373. * @param mesh defines the mesh to use as source
  14374. */
  14375. constructor(mesh?: Nullable<AbstractMesh>);
  14376. /**
  14377. * Called by the particle System when the direction is computed for the created particle.
  14378. * @param worldMatrix is the world matrix of the particle system
  14379. * @param directionToUpdate is the direction vector to update with the result
  14380. * @param particle is the particle we are computed the direction for
  14381. * @param isLocal defines if the direction should be set in local space
  14382. */
  14383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14384. /**
  14385. * Called by the particle System when the position is computed for the created particle.
  14386. * @param worldMatrix is the world matrix of the particle system
  14387. * @param positionToUpdate is the position vector to update with the result
  14388. * @param particle is the particle we are computed the position for
  14389. * @param isLocal defines if the position should be set in local space
  14390. */
  14391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14392. /**
  14393. * Clones the current emitter and returns a copy of it
  14394. * @returns the new emitter
  14395. */
  14396. clone(): MeshParticleEmitter;
  14397. /**
  14398. * Called by the GPUParticleSystem to setup the update shader
  14399. * @param effect defines the update shader
  14400. */
  14401. applyToShader(effect: Effect): void;
  14402. /**
  14403. * Returns a string to use to update the GPU particles update shader
  14404. * @returns a string containng the defines string
  14405. */
  14406. getEffectDefines(): string;
  14407. /**
  14408. * Returns the string "BoxParticleEmitter"
  14409. * @returns a string containing the class name
  14410. */
  14411. getClassName(): string;
  14412. /**
  14413. * Serializes the particle system to a JSON object.
  14414. * @returns the JSON object
  14415. */
  14416. serialize(): any;
  14417. /**
  14418. * Parse properties from a JSON object
  14419. * @param serializationObject defines the JSON object
  14420. * @param scene defines the hosting scene
  14421. */
  14422. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14423. }
  14424. }
  14425. declare module "babylonjs/Particles/EmitterTypes/index" {
  14426. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14427. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14428. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14429. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14430. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14431. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14432. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14433. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14434. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14435. }
  14436. declare module "babylonjs/Particles/IParticleSystem" {
  14437. import { Nullable } from "babylonjs/types";
  14438. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14439. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14441. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14442. import { Scene } from "babylonjs/scene";
  14443. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14444. import { Effect } from "babylonjs/Materials/effect";
  14445. import { Observable } from "babylonjs/Misc/observable";
  14446. import { Animation } from "babylonjs/Animations/animation";
  14447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14448. /**
  14449. * Interface representing a particle system in Babylon.js.
  14450. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14451. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14452. */
  14453. export interface IParticleSystem {
  14454. /**
  14455. * List of animations used by the particle system.
  14456. */
  14457. animations: Animation[];
  14458. /**
  14459. * The id of the Particle system.
  14460. */
  14461. id: string;
  14462. /**
  14463. * The name of the Particle system.
  14464. */
  14465. name: string;
  14466. /**
  14467. * The emitter represents the Mesh or position we are attaching the particle system to.
  14468. */
  14469. emitter: Nullable<AbstractMesh | Vector3>;
  14470. /**
  14471. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14472. */
  14473. isBillboardBased: boolean;
  14474. /**
  14475. * The rendering group used by the Particle system to chose when to render.
  14476. */
  14477. renderingGroupId: number;
  14478. /**
  14479. * The layer mask we are rendering the particles through.
  14480. */
  14481. layerMask: number;
  14482. /**
  14483. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14484. */
  14485. updateSpeed: number;
  14486. /**
  14487. * The amount of time the particle system is running (depends of the overall update speed).
  14488. */
  14489. targetStopDuration: number;
  14490. /**
  14491. * The texture used to render each particle. (this can be a spritesheet)
  14492. */
  14493. particleTexture: Nullable<BaseTexture>;
  14494. /**
  14495. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14496. */
  14497. blendMode: number;
  14498. /**
  14499. * Minimum life time of emitting particles.
  14500. */
  14501. minLifeTime: number;
  14502. /**
  14503. * Maximum life time of emitting particles.
  14504. */
  14505. maxLifeTime: number;
  14506. /**
  14507. * Minimum Size of emitting particles.
  14508. */
  14509. minSize: number;
  14510. /**
  14511. * Maximum Size of emitting particles.
  14512. */
  14513. maxSize: number;
  14514. /**
  14515. * Minimum scale of emitting particles on X axis.
  14516. */
  14517. minScaleX: number;
  14518. /**
  14519. * Maximum scale of emitting particles on X axis.
  14520. */
  14521. maxScaleX: number;
  14522. /**
  14523. * Minimum scale of emitting particles on Y axis.
  14524. */
  14525. minScaleY: number;
  14526. /**
  14527. * Maximum scale of emitting particles on Y axis.
  14528. */
  14529. maxScaleY: number;
  14530. /**
  14531. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14532. */
  14533. color1: Color4;
  14534. /**
  14535. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14536. */
  14537. color2: Color4;
  14538. /**
  14539. * Color the particle will have at the end of its lifetime.
  14540. */
  14541. colorDead: Color4;
  14542. /**
  14543. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14544. */
  14545. emitRate: number;
  14546. /**
  14547. * You can use gravity if you want to give an orientation to your particles.
  14548. */
  14549. gravity: Vector3;
  14550. /**
  14551. * Minimum power of emitting particles.
  14552. */
  14553. minEmitPower: number;
  14554. /**
  14555. * Maximum power of emitting particles.
  14556. */
  14557. maxEmitPower: number;
  14558. /**
  14559. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14560. */
  14561. minAngularSpeed: number;
  14562. /**
  14563. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14564. */
  14565. maxAngularSpeed: number;
  14566. /**
  14567. * Gets or sets the minimal initial rotation in radians.
  14568. */
  14569. minInitialRotation: number;
  14570. /**
  14571. * Gets or sets the maximal initial rotation in radians.
  14572. */
  14573. maxInitialRotation: number;
  14574. /**
  14575. * The particle emitter type defines the emitter used by the particle system.
  14576. * It can be for example box, sphere, or cone...
  14577. */
  14578. particleEmitterType: Nullable<IParticleEmitterType>;
  14579. /**
  14580. * Defines the delay in milliseconds before starting the system (0 by default)
  14581. */
  14582. startDelay: number;
  14583. /**
  14584. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14585. */
  14586. preWarmCycles: number;
  14587. /**
  14588. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14589. */
  14590. preWarmStepOffset: number;
  14591. /**
  14592. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14593. */
  14594. spriteCellChangeSpeed: number;
  14595. /**
  14596. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14597. */
  14598. startSpriteCellID: number;
  14599. /**
  14600. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14601. */
  14602. endSpriteCellID: number;
  14603. /**
  14604. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14605. */
  14606. spriteCellWidth: number;
  14607. /**
  14608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14609. */
  14610. spriteCellHeight: number;
  14611. /**
  14612. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14613. */
  14614. spriteRandomStartCell: boolean;
  14615. /**
  14616. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14617. */
  14618. isAnimationSheetEnabled: boolean;
  14619. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14620. translationPivot: Vector2;
  14621. /**
  14622. * Gets or sets a texture used to add random noise to particle positions
  14623. */
  14624. noiseTexture: Nullable<BaseTexture>;
  14625. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14626. noiseStrength: Vector3;
  14627. /**
  14628. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14629. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14630. */
  14631. billboardMode: number;
  14632. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14633. limitVelocityDamping: number;
  14634. /**
  14635. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14636. */
  14637. beginAnimationOnStart: boolean;
  14638. /**
  14639. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14640. */
  14641. beginAnimationFrom: number;
  14642. /**
  14643. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14644. */
  14645. beginAnimationTo: number;
  14646. /**
  14647. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14648. */
  14649. beginAnimationLoop: boolean;
  14650. /**
  14651. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14652. */
  14653. disposeOnStop: boolean;
  14654. /**
  14655. * Specifies if the particles are updated in emitter local space or world space
  14656. */
  14657. isLocal: boolean;
  14658. /** Snippet ID if the particle system was created from the snippet server */
  14659. snippetId: string;
  14660. /** Gets or sets a matrix to use to compute projection */
  14661. defaultProjectionMatrix: Matrix;
  14662. /**
  14663. * Gets the maximum number of particles active at the same time.
  14664. * @returns The max number of active particles.
  14665. */
  14666. getCapacity(): number;
  14667. /**
  14668. * Gets the number of particles active at the same time.
  14669. * @returns The number of active particles.
  14670. */
  14671. getActiveCount(): number;
  14672. /**
  14673. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14674. * @returns True if it has been started, otherwise false.
  14675. */
  14676. isStarted(): boolean;
  14677. /**
  14678. * Animates the particle system for this frame.
  14679. */
  14680. animate(): void;
  14681. /**
  14682. * Renders the particle system in its current state.
  14683. * @returns the current number of particles
  14684. */
  14685. render(): number;
  14686. /**
  14687. * Dispose the particle system and frees its associated resources.
  14688. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14689. */
  14690. dispose(disposeTexture?: boolean): void;
  14691. /**
  14692. * An event triggered when the system is disposed
  14693. */
  14694. onDisposeObservable: Observable<IParticleSystem>;
  14695. /**
  14696. * An event triggered when the system is stopped
  14697. */
  14698. onStoppedObservable: Observable<IParticleSystem>;
  14699. /**
  14700. * Clones the particle system.
  14701. * @param name The name of the cloned object
  14702. * @param newEmitter The new emitter to use
  14703. * @returns the cloned particle system
  14704. */
  14705. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14706. /**
  14707. * Serializes the particle system to a JSON object
  14708. * @param serializeTexture defines if the texture must be serialized as well
  14709. * @returns the JSON object
  14710. */
  14711. serialize(serializeTexture: boolean): any;
  14712. /**
  14713. * Rebuild the particle system
  14714. */
  14715. rebuild(): void;
  14716. /** Force the system to rebuild all gradients that need to be resync */
  14717. forceRefreshGradients(): void;
  14718. /**
  14719. * Starts the particle system and begins to emit
  14720. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14721. */
  14722. start(delay?: number): void;
  14723. /**
  14724. * Stops the particle system.
  14725. */
  14726. stop(): void;
  14727. /**
  14728. * Remove all active particles
  14729. */
  14730. reset(): void;
  14731. /**
  14732. * Gets a boolean indicating that the system is stopping
  14733. * @returns true if the system is currently stopping
  14734. */
  14735. isStopping(): boolean;
  14736. /**
  14737. * Is this system ready to be used/rendered
  14738. * @return true if the system is ready
  14739. */
  14740. isReady(): boolean;
  14741. /**
  14742. * Returns the string "ParticleSystem"
  14743. * @returns a string containing the class name
  14744. */
  14745. getClassName(): string;
  14746. /**
  14747. * Gets the custom effect used to render the particles
  14748. * @param blendMode Blend mode for which the effect should be retrieved
  14749. * @returns The effect
  14750. */
  14751. getCustomEffect(blendMode: number): Nullable<Effect>;
  14752. /**
  14753. * Sets the custom effect used to render the particles
  14754. * @param effect The effect to set
  14755. * @param blendMode Blend mode for which the effect should be set
  14756. */
  14757. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14758. /**
  14759. * Fill the defines array according to the current settings of the particle system
  14760. * @param defines Array to be updated
  14761. * @param blendMode blend mode to take into account when updating the array
  14762. */
  14763. fillDefines(defines: Array<string>, blendMode: number): void;
  14764. /**
  14765. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14766. * @param uniforms Uniforms array to fill
  14767. * @param attributes Attributes array to fill
  14768. * @param samplers Samplers array to fill
  14769. */
  14770. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14771. /**
  14772. * Observable that will be called just before the particles are drawn
  14773. */
  14774. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14775. /**
  14776. * Gets the name of the particle vertex shader
  14777. */
  14778. vertexShaderName: string;
  14779. /**
  14780. * Adds a new color gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param color1 defines the color to affect to the specified gradient
  14783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14784. * @returns the current particle system
  14785. */
  14786. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14787. /**
  14788. * Remove a specific color gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeColorGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Adds a new size gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the size factor to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific size gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeSizeGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of color gradients.
  14809. * You must use addColorGradient and removeColorGradient to udpate this list
  14810. * @returns the list of color gradients
  14811. */
  14812. getColorGradients(): Nullable<Array<ColorGradient>>;
  14813. /**
  14814. * Gets the current list of size gradients.
  14815. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14816. * @returns the list of size gradients
  14817. */
  14818. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Gets the current list of angular speed gradients.
  14821. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14822. * @returns the list of angular speed gradients
  14823. */
  14824. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14825. /**
  14826. * Adds a new angular speed gradient
  14827. * @param gradient defines the gradient to use (between 0 and 1)
  14828. * @param factor defines the angular speed to affect to the specified gradient
  14829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14830. * @returns the current particle system
  14831. */
  14832. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14833. /**
  14834. * Remove a specific angular speed gradient
  14835. * @param gradient defines the gradient to remove
  14836. * @returns the current particle system
  14837. */
  14838. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14839. /**
  14840. * Gets the current list of velocity gradients.
  14841. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14842. * @returns the list of velocity gradients
  14843. */
  14844. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14845. /**
  14846. * Adds a new velocity gradient
  14847. * @param gradient defines the gradient to use (between 0 and 1)
  14848. * @param factor defines the velocity to affect to the specified gradient
  14849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14850. * @returns the current particle system
  14851. */
  14852. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14853. /**
  14854. * Remove a specific velocity gradient
  14855. * @param gradient defines the gradient to remove
  14856. * @returns the current particle system
  14857. */
  14858. removeVelocityGradient(gradient: number): IParticleSystem;
  14859. /**
  14860. * Gets the current list of limit velocity gradients.
  14861. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14862. * @returns the list of limit velocity gradients
  14863. */
  14864. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Gets the current list of drag gradients.
  14895. * You must use addDragGradient and removeDragGradient to udpate this list
  14896. * @returns the list of drag gradients
  14897. */
  14898. getDragGradients(): Nullable<Array<FactorGradient>>;
  14899. /**
  14900. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the emit rate to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific emit rate gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeEmitRateGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Gets the current list of emit rate gradients.
  14915. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14916. * @returns the list of emit rate gradients
  14917. */
  14918. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14919. /**
  14920. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the start size to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific start size gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeStartSizeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Gets the current list of start size gradients.
  14935. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14936. * @returns the list of start size gradients
  14937. */
  14938. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14939. /**
  14940. * Adds a new life time gradient
  14941. * @param gradient defines the gradient to use (between 0 and 1)
  14942. * @param factor defines the life time factor to affect to the specified gradient
  14943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14944. * @returns the current particle system
  14945. */
  14946. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14947. /**
  14948. * Remove a specific life time gradient
  14949. * @param gradient defines the gradient to remove
  14950. * @returns the current particle system
  14951. */
  14952. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14953. /**
  14954. * Gets the current list of life time gradients.
  14955. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14956. * @returns the list of life time gradients
  14957. */
  14958. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14959. /**
  14960. * Gets the current list of color gradients.
  14961. * You must use addColorGradient and removeColorGradient to udpate this list
  14962. * @returns the list of color gradients
  14963. */
  14964. getColorGradients(): Nullable<Array<ColorGradient>>;
  14965. /**
  14966. * Adds a new ramp gradient used to remap particle colors
  14967. * @param gradient defines the gradient to use (between 0 and 1)
  14968. * @param color defines the color to affect to the specified gradient
  14969. * @returns the current particle system
  14970. */
  14971. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14972. /**
  14973. * Gets the current list of ramp gradients.
  14974. * You must use addRampGradient and removeRampGradient to udpate this list
  14975. * @returns the list of ramp gradients
  14976. */
  14977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14978. /** Gets or sets a boolean indicating that ramp gradients must be used
  14979. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14980. */
  14981. useRampGradients: boolean;
  14982. /**
  14983. * Adds a new color remap gradient
  14984. * @param gradient defines the gradient to use (between 0 and 1)
  14985. * @param min defines the color remap minimal range
  14986. * @param max defines the color remap maximal range
  14987. * @returns the current particle system
  14988. */
  14989. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14990. /**
  14991. * Gets the current list of color remap gradients.
  14992. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14993. * @returns the list of color remap gradients
  14994. */
  14995. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Adds a new alpha remap gradient
  14998. * @param gradient defines the gradient to use (between 0 and 1)
  14999. * @param min defines the alpha remap minimal range
  15000. * @param max defines the alpha remap maximal range
  15001. * @returns the current particle system
  15002. */
  15003. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15004. /**
  15005. * Gets the current list of alpha remap gradients.
  15006. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15007. * @returns the list of alpha remap gradients
  15008. */
  15009. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15010. /**
  15011. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15014. * @returns the emitter
  15015. */
  15016. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15017. /**
  15018. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15019. * @param radius The radius of the hemisphere to emit from
  15020. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15021. * @returns the emitter
  15022. */
  15023. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15024. /**
  15025. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15026. * @param radius The radius of the sphere to emit from
  15027. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15028. * @returns the emitter
  15029. */
  15030. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15031. /**
  15032. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15033. * @param radius The radius of the sphere to emit from
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15036. * @returns the emitter
  15037. */
  15038. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15039. /**
  15040. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15041. * @param radius The radius of the emission cylinder
  15042. * @param height The height of the emission cylinder
  15043. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15044. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15045. * @returns the emitter
  15046. */
  15047. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15048. /**
  15049. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15050. * @param radius The radius of the cylinder to emit from
  15051. * @param height The height of the emission cylinder
  15052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15053. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15054. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15055. * @returns the emitter
  15056. */
  15057. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15058. /**
  15059. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15060. * @param radius The radius of the cone to emit from
  15061. * @param angle The base angle of the cone
  15062. * @returns the emitter
  15063. */
  15064. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15065. /**
  15066. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15067. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15068. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15069. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15070. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15071. * @returns the emitter
  15072. */
  15073. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15074. /**
  15075. * Get hosting scene
  15076. * @returns the scene
  15077. */
  15078. getScene(): Nullable<Scene>;
  15079. }
  15080. }
  15081. declare module "babylonjs/Meshes/transformNode" {
  15082. import { DeepImmutable } from "babylonjs/types";
  15083. import { Observable } from "babylonjs/Misc/observable";
  15084. import { Nullable } from "babylonjs/types";
  15085. import { Camera } from "babylonjs/Cameras/camera";
  15086. import { Scene } from "babylonjs/scene";
  15087. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15088. import { Node } from "babylonjs/node";
  15089. import { Bone } from "babylonjs/Bones/bone";
  15090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15091. import { Space } from "babylonjs/Maths/math.axis";
  15092. /**
  15093. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  15094. * @see https://doc.babylonjs.com/how_to/transformnode
  15095. */
  15096. export class TransformNode extends Node {
  15097. /**
  15098. * Object will not rotate to face the camera
  15099. */
  15100. static BILLBOARDMODE_NONE: number;
  15101. /**
  15102. * Object will rotate to face the camera but only on the x axis
  15103. */
  15104. static BILLBOARDMODE_X: number;
  15105. /**
  15106. * Object will rotate to face the camera but only on the y axis
  15107. */
  15108. static BILLBOARDMODE_Y: number;
  15109. /**
  15110. * Object will rotate to face the camera but only on the z axis
  15111. */
  15112. static BILLBOARDMODE_Z: number;
  15113. /**
  15114. * Object will rotate to face the camera
  15115. */
  15116. static BILLBOARDMODE_ALL: number;
  15117. /**
  15118. * Object will rotate to face the camera's position instead of orientation
  15119. */
  15120. static BILLBOARDMODE_USE_POSITION: number;
  15121. private static _TmpRotation;
  15122. private static _TmpScaling;
  15123. private static _TmpTranslation;
  15124. private _forward;
  15125. private _forwardInverted;
  15126. private _up;
  15127. private _right;
  15128. private _rightInverted;
  15129. private _position;
  15130. private _rotation;
  15131. private _rotationQuaternion;
  15132. protected _scaling: Vector3;
  15133. protected _isDirty: boolean;
  15134. private _transformToBoneReferal;
  15135. private _isAbsoluteSynced;
  15136. private _billboardMode;
  15137. /**
  15138. * Gets or sets the billboard mode. Default is 0.
  15139. *
  15140. * | Value | Type | Description |
  15141. * | --- | --- | --- |
  15142. * | 0 | BILLBOARDMODE_NONE | |
  15143. * | 1 | BILLBOARDMODE_X | |
  15144. * | 2 | BILLBOARDMODE_Y | |
  15145. * | 4 | BILLBOARDMODE_Z | |
  15146. * | 7 | BILLBOARDMODE_ALL | |
  15147. *
  15148. */
  15149. get billboardMode(): number;
  15150. set billboardMode(value: number);
  15151. private _preserveParentRotationForBillboard;
  15152. /**
  15153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15155. */
  15156. get preserveParentRotationForBillboard(): boolean;
  15157. set preserveParentRotationForBillboard(value: boolean);
  15158. /**
  15159. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  15160. */
  15161. scalingDeterminant: number;
  15162. private _infiniteDistance;
  15163. /**
  15164. * Gets or sets the distance of the object to max, often used by skybox
  15165. */
  15166. get infiniteDistance(): boolean;
  15167. set infiniteDistance(value: boolean);
  15168. /**
  15169. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15170. * By default the system will update normals to compensate
  15171. */
  15172. ignoreNonUniformScaling: boolean;
  15173. /**
  15174. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  15175. */
  15176. reIntegrateRotationIntoRotationQuaternion: boolean;
  15177. /** @hidden */
  15178. _poseMatrix: Nullable<Matrix>;
  15179. /** @hidden */
  15180. _localMatrix: Matrix;
  15181. private _usePivotMatrix;
  15182. private _absolutePosition;
  15183. private _absoluteScaling;
  15184. private _absoluteRotationQuaternion;
  15185. private _pivotMatrix;
  15186. private _pivotMatrixInverse;
  15187. /** @hidden */
  15188. _postMultiplyPivotMatrix: boolean;
  15189. protected _isWorldMatrixFrozen: boolean;
  15190. /** @hidden */
  15191. _indexInSceneTransformNodesArray: number;
  15192. /**
  15193. * An event triggered after the world matrix is updated
  15194. */
  15195. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15196. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15197. /**
  15198. * Gets a string identifying the name of the class
  15199. * @returns "TransformNode" string
  15200. */
  15201. getClassName(): string;
  15202. /**
  15203. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15204. */
  15205. get position(): Vector3;
  15206. set position(newPosition: Vector3);
  15207. /**
  15208. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15209. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15210. */
  15211. get rotation(): Vector3;
  15212. set rotation(newRotation: Vector3);
  15213. /**
  15214. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15215. */
  15216. get scaling(): Vector3;
  15217. set scaling(newScaling: Vector3);
  15218. /**
  15219. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  15220. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15221. */
  15222. get rotationQuaternion(): Nullable<Quaternion>;
  15223. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15224. /**
  15225. * The forward direction of that transform in world space.
  15226. */
  15227. get forward(): Vector3;
  15228. /**
  15229. * The up direction of that transform in world space.
  15230. */
  15231. get up(): Vector3;
  15232. /**
  15233. * The right direction of that transform in world space.
  15234. */
  15235. get right(): Vector3;
  15236. /**
  15237. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15238. * @param matrix the matrix to copy the pose from
  15239. * @returns this TransformNode.
  15240. */
  15241. updatePoseMatrix(matrix: Matrix): TransformNode;
  15242. /**
  15243. * Returns the mesh Pose matrix.
  15244. * @returns the pose matrix
  15245. */
  15246. getPoseMatrix(): Matrix;
  15247. /** @hidden */
  15248. _isSynchronized(): boolean;
  15249. /** @hidden */
  15250. _initCache(): void;
  15251. /**
  15252. * Flag the transform node as dirty (Forcing it to update everything)
  15253. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15254. * @returns this transform node
  15255. */
  15256. markAsDirty(property: string): TransformNode;
  15257. /**
  15258. * Returns the current mesh absolute position.
  15259. * Returns a Vector3.
  15260. */
  15261. get absolutePosition(): Vector3;
  15262. /**
  15263. * Returns the current mesh absolute scaling.
  15264. * Returns a Vector3.
  15265. */
  15266. get absoluteScaling(): Vector3;
  15267. /**
  15268. * Returns the current mesh absolute rotation.
  15269. * Returns a Quaternion.
  15270. */
  15271. get absoluteRotationQuaternion(): Quaternion;
  15272. /**
  15273. * Sets a new matrix to apply before all other transformation
  15274. * @param matrix defines the transform matrix
  15275. * @returns the current TransformNode
  15276. */
  15277. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15278. /**
  15279. * Sets a new pivot matrix to the current node
  15280. * @param matrix defines the new pivot matrix to use
  15281. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  15282. * @returns the current TransformNode
  15283. */
  15284. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15285. /**
  15286. * Returns the mesh pivot matrix.
  15287. * Default : Identity.
  15288. * @returns the matrix
  15289. */
  15290. getPivotMatrix(): Matrix;
  15291. /**
  15292. * Instantiate (when possible) or clone that node with its hierarchy
  15293. * @param newParent defines the new parent to use for the instance (or clone)
  15294. * @param options defines options to configure how copy is done
  15295. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15296. * @returns an instance (or a clone) of the current node with its hiearchy
  15297. */
  15298. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15299. doNotInstantiate: boolean;
  15300. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15301. /**
  15302. * Prevents the World matrix to be computed any longer
  15303. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15304. * @returns the TransformNode.
  15305. */
  15306. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15307. /**
  15308. * Allows back the World matrix computation.
  15309. * @returns the TransformNode.
  15310. */
  15311. unfreezeWorldMatrix(): this;
  15312. /**
  15313. * True if the World matrix has been frozen.
  15314. */
  15315. get isWorldMatrixFrozen(): boolean;
  15316. /**
  15317. * Retuns the mesh absolute position in the World.
  15318. * @returns a Vector3.
  15319. */
  15320. getAbsolutePosition(): Vector3;
  15321. /**
  15322. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15323. * @param absolutePosition the absolute position to set
  15324. * @returns the TransformNode.
  15325. */
  15326. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15327. /**
  15328. * Sets the mesh position in its local space.
  15329. * @param vector3 the position to set in localspace
  15330. * @returns the TransformNode.
  15331. */
  15332. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15333. /**
  15334. * Returns the mesh position in the local space from the current World matrix values.
  15335. * @returns a new Vector3.
  15336. */
  15337. getPositionExpressedInLocalSpace(): Vector3;
  15338. /**
  15339. * Translates the mesh along the passed Vector3 in its local space.
  15340. * @param vector3 the distance to translate in localspace
  15341. * @returns the TransformNode.
  15342. */
  15343. locallyTranslate(vector3: Vector3): TransformNode;
  15344. private static _lookAtVectorCache;
  15345. /**
  15346. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15347. * @param targetPoint the position (must be in same space as current mesh) to look at
  15348. * @param yawCor optional yaw (y-axis) correction in radians
  15349. * @param pitchCor optional pitch (x-axis) correction in radians
  15350. * @param rollCor optional roll (z-axis) correction in radians
  15351. * @param space the choosen space of the target
  15352. * @returns the TransformNode.
  15353. */
  15354. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15355. /**
  15356. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15357. * This Vector3 is expressed in the World space.
  15358. * @param localAxis axis to rotate
  15359. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15360. */
  15361. getDirection(localAxis: Vector3): Vector3;
  15362. /**
  15363. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15364. * localAxis is expressed in the mesh local space.
  15365. * result is computed in the Wordl space from the mesh World matrix.
  15366. * @param localAxis axis to rotate
  15367. * @param result the resulting transformnode
  15368. * @returns this TransformNode.
  15369. */
  15370. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15371. /**
  15372. * Sets this transform node rotation to the given local axis.
  15373. * @param localAxis the axis in local space
  15374. * @param yawCor optional yaw (y-axis) correction in radians
  15375. * @param pitchCor optional pitch (x-axis) correction in radians
  15376. * @param rollCor optional roll (z-axis) correction in radians
  15377. * @returns this TransformNode
  15378. */
  15379. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15380. /**
  15381. * Sets a new pivot point to the current node
  15382. * @param point defines the new pivot point to use
  15383. * @param space defines if the point is in world or local space (local by default)
  15384. * @returns the current TransformNode
  15385. */
  15386. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15387. /**
  15388. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15389. * @returns the pivot point
  15390. */
  15391. getPivotPoint(): Vector3;
  15392. /**
  15393. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15394. * @param result the vector3 to store the result
  15395. * @returns this TransformNode.
  15396. */
  15397. getPivotPointToRef(result: Vector3): TransformNode;
  15398. /**
  15399. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15400. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15401. */
  15402. getAbsolutePivotPoint(): Vector3;
  15403. /**
  15404. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15405. * @param result vector3 to store the result
  15406. * @returns this TransformNode.
  15407. */
  15408. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15409. /**
  15410. * Defines the passed node as the parent of the current node.
  15411. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15412. * @see https://doc.babylonjs.com/how_to/parenting
  15413. * @param node the node ot set as the parent
  15414. * @returns this TransformNode.
  15415. */
  15416. setParent(node: Nullable<Node>): TransformNode;
  15417. private _nonUniformScaling;
  15418. /**
  15419. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15420. */
  15421. get nonUniformScaling(): boolean;
  15422. /** @hidden */
  15423. _updateNonUniformScalingState(value: boolean): boolean;
  15424. /**
  15425. * Attach the current TransformNode to another TransformNode associated with a bone
  15426. * @param bone Bone affecting the TransformNode
  15427. * @param affectedTransformNode TransformNode associated with the bone
  15428. * @returns this object
  15429. */
  15430. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15431. /**
  15432. * Detach the transform node if its associated with a bone
  15433. * @returns this object
  15434. */
  15435. detachFromBone(): TransformNode;
  15436. private static _rotationAxisCache;
  15437. /**
  15438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15439. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15440. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15441. * The passed axis is also normalized.
  15442. * @param axis the axis to rotate around
  15443. * @param amount the amount to rotate in radians
  15444. * @param space Space to rotate in (Default: local)
  15445. * @returns the TransformNode.
  15446. */
  15447. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15448. /**
  15449. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15450. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15451. * The passed axis is also normalized. .
  15452. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15453. * @param point the point to rotate around
  15454. * @param axis the axis to rotate around
  15455. * @param amount the amount to rotate in radians
  15456. * @returns the TransformNode
  15457. */
  15458. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15459. /**
  15460. * Translates the mesh along the axis vector for the passed distance in the given space.
  15461. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15462. * @param axis the axis to translate in
  15463. * @param distance the distance to translate
  15464. * @param space Space to rotate in (Default: local)
  15465. * @returns the TransformNode.
  15466. */
  15467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15468. /**
  15469. * Adds a rotation step to the mesh current rotation.
  15470. * x, y, z are Euler angles expressed in radians.
  15471. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15472. * This means this rotation is made in the mesh local space only.
  15473. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15474. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15475. * ```javascript
  15476. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15477. * ```
  15478. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15479. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15480. * @param x Rotation to add
  15481. * @param y Rotation to add
  15482. * @param z Rotation to add
  15483. * @returns the TransformNode.
  15484. */
  15485. addRotation(x: number, y: number, z: number): TransformNode;
  15486. /**
  15487. * @hidden
  15488. */
  15489. protected _getEffectiveParent(): Nullable<Node>;
  15490. /**
  15491. * Computes the world matrix of the node
  15492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15493. * @returns the world matrix
  15494. */
  15495. computeWorldMatrix(force?: boolean): Matrix;
  15496. /**
  15497. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15498. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15499. */
  15500. resetLocalMatrix(independentOfChildren?: boolean): void;
  15501. protected _afterComputeWorldMatrix(): void;
  15502. /**
  15503. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15504. * @param func callback function to add
  15505. *
  15506. * @returns the TransformNode.
  15507. */
  15508. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15509. /**
  15510. * Removes a registered callback function.
  15511. * @param func callback function to remove
  15512. * @returns the TransformNode.
  15513. */
  15514. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15515. /**
  15516. * Gets the position of the current mesh in camera space
  15517. * @param camera defines the camera to use
  15518. * @returns a position
  15519. */
  15520. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15521. /**
  15522. * Returns the distance from the mesh to the active camera
  15523. * @param camera defines the camera to use
  15524. * @returns the distance
  15525. */
  15526. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15527. /**
  15528. * Clone the current transform node
  15529. * @param name Name of the new clone
  15530. * @param newParent New parent for the clone
  15531. * @param doNotCloneChildren Do not clone children hierarchy
  15532. * @returns the new transform node
  15533. */
  15534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15535. /**
  15536. * Serializes the objects information.
  15537. * @param currentSerializationObject defines the object to serialize in
  15538. * @returns the serialized object
  15539. */
  15540. serialize(currentSerializationObject?: any): any;
  15541. /**
  15542. * Returns a new TransformNode object parsed from the source provided.
  15543. * @param parsedTransformNode is the source.
  15544. * @param scene the scne the object belongs to
  15545. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15546. * @returns a new TransformNode object parsed from the source provided.
  15547. */
  15548. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15549. /**
  15550. * Get all child-transformNodes of this node
  15551. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15552. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15553. * @returns an array of TransformNode
  15554. */
  15555. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15556. /**
  15557. * Releases resources associated with this transform node.
  15558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15560. */
  15561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15562. /**
  15563. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15564. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15565. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15566. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15567. * @returns the current mesh
  15568. */
  15569. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15570. private _syncAbsoluteScalingAndRotation;
  15571. }
  15572. }
  15573. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15574. /**
  15575. * Class used to override all child animations of a given target
  15576. */
  15577. export class AnimationPropertiesOverride {
  15578. /**
  15579. * Gets or sets a value indicating if animation blending must be used
  15580. */
  15581. enableBlending: boolean;
  15582. /**
  15583. * Gets or sets the blending speed to use when enableBlending is true
  15584. */
  15585. blendingSpeed: number;
  15586. /**
  15587. * Gets or sets the default loop mode to use
  15588. */
  15589. loopMode: number;
  15590. }
  15591. }
  15592. declare module "babylonjs/Bones/bone" {
  15593. import { Skeleton } from "babylonjs/Bones/skeleton";
  15594. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15595. import { Nullable } from "babylonjs/types";
  15596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15598. import { Node } from "babylonjs/node";
  15599. import { Space } from "babylonjs/Maths/math.axis";
  15600. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15601. /**
  15602. * Class used to store bone information
  15603. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15604. */
  15605. export class Bone extends Node {
  15606. /**
  15607. * defines the bone name
  15608. */
  15609. name: string;
  15610. private static _tmpVecs;
  15611. private static _tmpQuat;
  15612. private static _tmpMats;
  15613. /**
  15614. * Gets the list of child bones
  15615. */
  15616. children: Bone[];
  15617. /** Gets the animations associated with this bone */
  15618. animations: import("babylonjs/Animations/animation").Animation[];
  15619. /**
  15620. * Gets or sets bone length
  15621. */
  15622. length: number;
  15623. /**
  15624. * @hidden Internal only
  15625. * Set this value to map this bone to a different index in the transform matrices
  15626. * Set this value to -1 to exclude the bone from the transform matrices
  15627. */
  15628. _index: Nullable<number>;
  15629. private _skeleton;
  15630. private _localMatrix;
  15631. private _restPose;
  15632. private _bindPose;
  15633. private _baseMatrix;
  15634. private _absoluteTransform;
  15635. private _invertedAbsoluteTransform;
  15636. private _parent;
  15637. private _scalingDeterminant;
  15638. private _worldTransform;
  15639. private _localScaling;
  15640. private _localRotation;
  15641. private _localPosition;
  15642. private _needToDecompose;
  15643. private _needToCompose;
  15644. /** @hidden */
  15645. _linkedTransformNode: Nullable<TransformNode>;
  15646. /** @hidden */
  15647. _waitingTransformNodeId: Nullable<string>;
  15648. /** @hidden */
  15649. get _matrix(): Matrix;
  15650. /** @hidden */
  15651. set _matrix(value: Matrix);
  15652. /**
  15653. * Create a new bone
  15654. * @param name defines the bone name
  15655. * @param skeleton defines the parent skeleton
  15656. * @param parentBone defines the parent (can be null if the bone is the root)
  15657. * @param localMatrix defines the local matrix
  15658. * @param restPose defines the rest pose matrix
  15659. * @param baseMatrix defines the base matrix
  15660. * @param index defines index of the bone in the hiearchy
  15661. */
  15662. constructor(
  15663. /**
  15664. * defines the bone name
  15665. */
  15666. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15667. /**
  15668. * Gets the current object class name.
  15669. * @return the class name
  15670. */
  15671. getClassName(): string;
  15672. /**
  15673. * Gets the parent skeleton
  15674. * @returns a skeleton
  15675. */
  15676. getSkeleton(): Skeleton;
  15677. /**
  15678. * Gets parent bone
  15679. * @returns a bone or null if the bone is the root of the bone hierarchy
  15680. */
  15681. getParent(): Nullable<Bone>;
  15682. /**
  15683. * Returns an array containing the root bones
  15684. * @returns an array containing the root bones
  15685. */
  15686. getChildren(): Array<Bone>;
  15687. /**
  15688. * Gets the node index in matrix array generated for rendering
  15689. * @returns the node index
  15690. */
  15691. getIndex(): number;
  15692. /**
  15693. * Sets the parent bone
  15694. * @param parent defines the parent (can be null if the bone is the root)
  15695. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15696. */
  15697. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15698. /**
  15699. * Gets the local matrix
  15700. * @returns a matrix
  15701. */
  15702. getLocalMatrix(): Matrix;
  15703. /**
  15704. * Gets the base matrix (initial matrix which remains unchanged)
  15705. * @returns a matrix
  15706. */
  15707. getBaseMatrix(): Matrix;
  15708. /**
  15709. * Gets the rest pose matrix
  15710. * @returns a matrix
  15711. */
  15712. getRestPose(): Matrix;
  15713. /**
  15714. * Sets the rest pose matrix
  15715. * @param matrix the local-space rest pose to set for this bone
  15716. */
  15717. setRestPose(matrix: Matrix): void;
  15718. /**
  15719. * Gets the bind pose matrix
  15720. * @returns the bind pose matrix
  15721. */
  15722. getBindPose(): Matrix;
  15723. /**
  15724. * Sets the bind pose matrix
  15725. * @param matrix the local-space bind pose to set for this bone
  15726. */
  15727. setBindPose(matrix: Matrix): void;
  15728. /**
  15729. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15730. */
  15731. getWorldMatrix(): Matrix;
  15732. /**
  15733. * Sets the local matrix to rest pose matrix
  15734. */
  15735. returnToRest(): void;
  15736. /**
  15737. * Gets the inverse of the absolute transform matrix.
  15738. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15739. * @returns a matrix
  15740. */
  15741. getInvertedAbsoluteTransform(): Matrix;
  15742. /**
  15743. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15744. * @returns a matrix
  15745. */
  15746. getAbsoluteTransform(): Matrix;
  15747. /**
  15748. * Links with the given transform node.
  15749. * The local matrix of this bone is copied from the transform node every frame.
  15750. * @param transformNode defines the transform node to link to
  15751. */
  15752. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15753. /**
  15754. * Gets the node used to drive the bone's transformation
  15755. * @returns a transform node or null
  15756. */
  15757. getTransformNode(): Nullable<TransformNode>;
  15758. /** Gets or sets current position (in local space) */
  15759. get position(): Vector3;
  15760. set position(newPosition: Vector3);
  15761. /** Gets or sets current rotation (in local space) */
  15762. get rotation(): Vector3;
  15763. set rotation(newRotation: Vector3);
  15764. /** Gets or sets current rotation quaternion (in local space) */
  15765. get rotationQuaternion(): Quaternion;
  15766. set rotationQuaternion(newRotation: Quaternion);
  15767. /** Gets or sets current scaling (in local space) */
  15768. get scaling(): Vector3;
  15769. set scaling(newScaling: Vector3);
  15770. /**
  15771. * Gets the animation properties override
  15772. */
  15773. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15774. private _decompose;
  15775. private _compose;
  15776. /**
  15777. * Update the base and local matrices
  15778. * @param matrix defines the new base or local matrix
  15779. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15780. * @param updateLocalMatrix defines if the local matrix should be updated
  15781. */
  15782. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15783. /** @hidden */
  15784. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15785. /**
  15786. * Flag the bone as dirty (Forcing it to update everything)
  15787. */
  15788. markAsDirty(): void;
  15789. /** @hidden */
  15790. _markAsDirtyAndCompose(): void;
  15791. private _markAsDirtyAndDecompose;
  15792. /**
  15793. * Translate the bone in local or world space
  15794. * @param vec The amount to translate the bone
  15795. * @param space The space that the translation is in
  15796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15797. */
  15798. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15799. /**
  15800. * Set the postion of the bone in local or world space
  15801. * @param position The position to set the bone
  15802. * @param space The space that the position is in
  15803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15804. */
  15805. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15806. /**
  15807. * Set the absolute position of the bone (world space)
  15808. * @param position The position to set the bone
  15809. * @param mesh The mesh that this bone is attached to
  15810. */
  15811. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15812. /**
  15813. * Scale the bone on the x, y and z axes (in local space)
  15814. * @param x The amount to scale the bone on the x axis
  15815. * @param y The amount to scale the bone on the y axis
  15816. * @param z The amount to scale the bone on the z axis
  15817. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15818. */
  15819. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15820. /**
  15821. * Set the bone scaling in local space
  15822. * @param scale defines the scaling vector
  15823. */
  15824. setScale(scale: Vector3): void;
  15825. /**
  15826. * Gets the current scaling in local space
  15827. * @returns the current scaling vector
  15828. */
  15829. getScale(): Vector3;
  15830. /**
  15831. * Gets the current scaling in local space and stores it in a target vector
  15832. * @param result defines the target vector
  15833. */
  15834. getScaleToRef(result: Vector3): void;
  15835. /**
  15836. * Set the yaw, pitch, and roll of the bone in local or world space
  15837. * @param yaw The rotation of the bone on the y axis
  15838. * @param pitch The rotation of the bone on the x axis
  15839. * @param roll The rotation of the bone on the z axis
  15840. * @param space The space that the axes of rotation are in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. */
  15843. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15844. /**
  15845. * Add a rotation to the bone on an axis in local or world space
  15846. * @param axis The axis to rotate the bone on
  15847. * @param amount The amount to rotate the bone
  15848. * @param space The space that the axis is in
  15849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15850. */
  15851. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15852. /**
  15853. * Set the rotation of the bone to a particular axis angle in local or world space
  15854. * @param axis The axis to rotate the bone on
  15855. * @param angle The angle that the bone should be rotated to
  15856. * @param space The space that the axis is in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. */
  15859. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15860. /**
  15861. * Set the euler rotation of the bone in local or world space
  15862. * @param rotation The euler rotation that the bone should be set to
  15863. * @param space The space that the rotation is in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. */
  15866. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15867. /**
  15868. * Set the quaternion rotation of the bone in local or world space
  15869. * @param quat The quaternion rotation that the bone should be set to
  15870. * @param space The space that the rotation is in
  15871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15872. */
  15873. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15874. /**
  15875. * Set the rotation matrix of the bone in local or world space
  15876. * @param rotMat The rotation matrix that the bone should be set to
  15877. * @param space The space that the rotation is in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. */
  15880. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15881. private _rotateWithMatrix;
  15882. private _getNegativeRotationToRef;
  15883. /**
  15884. * Get the position of the bone in local or world space
  15885. * @param space The space that the returned position is in
  15886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15887. * @returns The position of the bone
  15888. */
  15889. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15890. /**
  15891. * Copy the position of the bone to a vector3 in local or world space
  15892. * @param space The space that the returned position is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. * @param result The vector3 to copy the position to
  15895. */
  15896. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15897. /**
  15898. * Get the absolute position of the bone (world space)
  15899. * @param mesh The mesh that this bone is attached to
  15900. * @returns The absolute position of the bone
  15901. */
  15902. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15903. /**
  15904. * Copy the absolute position of the bone (world space) to the result param
  15905. * @param mesh The mesh that this bone is attached to
  15906. * @param result The vector3 to copy the absolute position to
  15907. */
  15908. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15909. /**
  15910. * Compute the absolute transforms of this bone and its children
  15911. */
  15912. computeAbsoluteTransforms(): void;
  15913. /**
  15914. * Get the world direction from an axis that is in the local space of the bone
  15915. * @param localAxis The local direction that is used to compute the world direction
  15916. * @param mesh The mesh that this bone is attached to
  15917. * @returns The world direction
  15918. */
  15919. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15920. /**
  15921. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15922. * @param localAxis The local direction that is used to compute the world direction
  15923. * @param mesh The mesh that this bone is attached to
  15924. * @param result The vector3 that the world direction will be copied to
  15925. */
  15926. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15927. /**
  15928. * Get the euler rotation of the bone in local or world space
  15929. * @param space The space that the rotation should be in
  15930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15931. * @returns The euler rotation
  15932. */
  15933. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15934. /**
  15935. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15936. * @param space The space that the rotation should be in
  15937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15938. * @param result The vector3 that the rotation should be copied to
  15939. */
  15940. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15941. /**
  15942. * Get the quaternion rotation of the bone in either local or world space
  15943. * @param space The space that the rotation should be in
  15944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15945. * @returns The quaternion rotation
  15946. */
  15947. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15948. /**
  15949. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15950. * @param space The space that the rotation should be in
  15951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15952. * @param result The quaternion that the rotation should be copied to
  15953. */
  15954. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15955. /**
  15956. * Get the rotation matrix of the bone in local or world space
  15957. * @param space The space that the rotation should be in
  15958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15959. * @returns The rotation matrix
  15960. */
  15961. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15962. /**
  15963. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15964. * @param space The space that the rotation should be in
  15965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15966. * @param result The quaternion that the rotation should be copied to
  15967. */
  15968. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15969. /**
  15970. * Get the world position of a point that is in the local space of the bone
  15971. * @param position The local position
  15972. * @param mesh The mesh that this bone is attached to
  15973. * @returns The world position
  15974. */
  15975. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15976. /**
  15977. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15978. * @param position The local position
  15979. * @param mesh The mesh that this bone is attached to
  15980. * @param result The vector3 that the world position should be copied to
  15981. */
  15982. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15983. /**
  15984. * Get the local position of a point that is in world space
  15985. * @param position The world position
  15986. * @param mesh The mesh that this bone is attached to
  15987. * @returns The local position
  15988. */
  15989. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15990. /**
  15991. * Get the local position of a point that is in world space and copy it to the result param
  15992. * @param position The world position
  15993. * @param mesh The mesh that this bone is attached to
  15994. * @param result The vector3 that the local position should be copied to
  15995. */
  15996. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15997. /**
  15998. * Set the current local matrix as the restPose for this bone.
  15999. */
  16000. setCurrentPoseAsRest(): void;
  16001. }
  16002. }
  16003. declare module "babylonjs/Animations/runtimeAnimation" {
  16004. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16005. import { Animatable } from "babylonjs/Animations/animatable";
  16006. import { Scene } from "babylonjs/scene";
  16007. /**
  16008. * Defines a runtime animation
  16009. */
  16010. export class RuntimeAnimation {
  16011. private _events;
  16012. /**
  16013. * The current frame of the runtime animation
  16014. */
  16015. private _currentFrame;
  16016. /**
  16017. * The animation used by the runtime animation
  16018. */
  16019. private _animation;
  16020. /**
  16021. * The target of the runtime animation
  16022. */
  16023. private _target;
  16024. /**
  16025. * The initiating animatable
  16026. */
  16027. private _host;
  16028. /**
  16029. * The original value of the runtime animation
  16030. */
  16031. private _originalValue;
  16032. /**
  16033. * The original blend value of the runtime animation
  16034. */
  16035. private _originalBlendValue;
  16036. /**
  16037. * The offsets cache of the runtime animation
  16038. */
  16039. private _offsetsCache;
  16040. /**
  16041. * The high limits cache of the runtime animation
  16042. */
  16043. private _highLimitsCache;
  16044. /**
  16045. * Specifies if the runtime animation has been stopped
  16046. */
  16047. private _stopped;
  16048. /**
  16049. * The blending factor of the runtime animation
  16050. */
  16051. private _blendingFactor;
  16052. /**
  16053. * The BabylonJS scene
  16054. */
  16055. private _scene;
  16056. /**
  16057. * The current value of the runtime animation
  16058. */
  16059. private _currentValue;
  16060. /** @hidden */
  16061. _animationState: _IAnimationState;
  16062. /**
  16063. * The active target of the runtime animation
  16064. */
  16065. private _activeTargets;
  16066. private _currentActiveTarget;
  16067. private _directTarget;
  16068. /**
  16069. * The target path of the runtime animation
  16070. */
  16071. private _targetPath;
  16072. /**
  16073. * The weight of the runtime animation
  16074. */
  16075. private _weight;
  16076. /**
  16077. * The ratio offset of the runtime animation
  16078. */
  16079. private _ratioOffset;
  16080. /**
  16081. * The previous delay of the runtime animation
  16082. */
  16083. private _previousDelay;
  16084. /**
  16085. * The previous ratio of the runtime animation
  16086. */
  16087. private _previousRatio;
  16088. private _enableBlending;
  16089. private _keys;
  16090. private _minFrame;
  16091. private _maxFrame;
  16092. private _minValue;
  16093. private _maxValue;
  16094. private _targetIsArray;
  16095. /**
  16096. * Gets the current frame of the runtime animation
  16097. */
  16098. get currentFrame(): number;
  16099. /**
  16100. * Gets the weight of the runtime animation
  16101. */
  16102. get weight(): number;
  16103. /**
  16104. * Gets the current value of the runtime animation
  16105. */
  16106. get currentValue(): any;
  16107. /**
  16108. * Gets the target path of the runtime animation
  16109. */
  16110. get targetPath(): string;
  16111. /**
  16112. * Gets the actual target of the runtime animation
  16113. */
  16114. get target(): any;
  16115. /**
  16116. * Gets the additive state of the runtime animation
  16117. */
  16118. get isAdditive(): boolean;
  16119. /** @hidden */
  16120. _onLoop: () => void;
  16121. /**
  16122. * Create a new RuntimeAnimation object
  16123. * @param target defines the target of the animation
  16124. * @param animation defines the source animation object
  16125. * @param scene defines the hosting scene
  16126. * @param host defines the initiating Animatable
  16127. */
  16128. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16129. private _preparePath;
  16130. /**
  16131. * Gets the animation from the runtime animation
  16132. */
  16133. get animation(): Animation;
  16134. /**
  16135. * Resets the runtime animation to the beginning
  16136. * @param restoreOriginal defines whether to restore the target property to the original value
  16137. */
  16138. reset(restoreOriginal?: boolean): void;
  16139. /**
  16140. * Specifies if the runtime animation is stopped
  16141. * @returns Boolean specifying if the runtime animation is stopped
  16142. */
  16143. isStopped(): boolean;
  16144. /**
  16145. * Disposes of the runtime animation
  16146. */
  16147. dispose(): void;
  16148. /**
  16149. * Apply the interpolated value to the target
  16150. * @param currentValue defines the value computed by the animation
  16151. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16152. */
  16153. setValue(currentValue: any, weight: number): void;
  16154. private _getOriginalValues;
  16155. private _setValue;
  16156. /**
  16157. * Gets the loop pmode of the runtime animation
  16158. * @returns Loop Mode
  16159. */
  16160. private _getCorrectLoopMode;
  16161. /**
  16162. * Move the current animation to a given frame
  16163. * @param frame defines the frame to move to
  16164. */
  16165. goToFrame(frame: number): void;
  16166. /**
  16167. * @hidden Internal use only
  16168. */
  16169. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16170. /**
  16171. * Execute the current animation
  16172. * @param delay defines the delay to add to the current frame
  16173. * @param from defines the lower bound of the animation range
  16174. * @param to defines the upper bound of the animation range
  16175. * @param loop defines if the current animation must loop
  16176. * @param speedRatio defines the current speed ratio
  16177. * @param weight defines the weight of the animation (default is -1 so no weight)
  16178. * @param onLoop optional callback called when animation loops
  16179. * @returns a boolean indicating if the animation is running
  16180. */
  16181. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16182. }
  16183. }
  16184. declare module "babylonjs/Animations/animatable" {
  16185. import { Animation } from "babylonjs/Animations/animation";
  16186. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Observable } from "babylonjs/Misc/observable";
  16189. import { Scene } from "babylonjs/scene";
  16190. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16191. import { Node } from "babylonjs/node";
  16192. /**
  16193. * Class used to store an actual running animation
  16194. */
  16195. export class Animatable {
  16196. /** defines the target object */
  16197. target: any;
  16198. /** defines the starting frame number (default is 0) */
  16199. fromFrame: number;
  16200. /** defines the ending frame number (default is 100) */
  16201. toFrame: number;
  16202. /** defines if the animation must loop (default is false) */
  16203. loopAnimation: boolean;
  16204. /** defines a callback to call when animation ends if it is not looping */
  16205. onAnimationEnd?: (() => void) | null | undefined;
  16206. /** defines a callback to call when animation loops */
  16207. onAnimationLoop?: (() => void) | null | undefined;
  16208. /** defines whether the animation should be evaluated additively */
  16209. isAdditive: boolean;
  16210. private _localDelayOffset;
  16211. private _pausedDelay;
  16212. private _runtimeAnimations;
  16213. private _paused;
  16214. private _scene;
  16215. private _speedRatio;
  16216. private _weight;
  16217. private _syncRoot;
  16218. /**
  16219. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16220. * This will only apply for non looping animation (default is true)
  16221. */
  16222. disposeOnEnd: boolean;
  16223. /**
  16224. * Gets a boolean indicating if the animation has started
  16225. */
  16226. animationStarted: boolean;
  16227. /**
  16228. * Observer raised when the animation ends
  16229. */
  16230. onAnimationEndObservable: Observable<Animatable>;
  16231. /**
  16232. * Observer raised when the animation loops
  16233. */
  16234. onAnimationLoopObservable: Observable<Animatable>;
  16235. /**
  16236. * Gets the root Animatable used to synchronize and normalize animations
  16237. */
  16238. get syncRoot(): Nullable<Animatable>;
  16239. /**
  16240. * Gets the current frame of the first RuntimeAnimation
  16241. * Used to synchronize Animatables
  16242. */
  16243. get masterFrame(): number;
  16244. /**
  16245. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16246. */
  16247. get weight(): number;
  16248. set weight(value: number);
  16249. /**
  16250. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16251. */
  16252. get speedRatio(): number;
  16253. set speedRatio(value: number);
  16254. /**
  16255. * Creates a new Animatable
  16256. * @param scene defines the hosting scene
  16257. * @param target defines the target object
  16258. * @param fromFrame defines the starting frame number (default is 0)
  16259. * @param toFrame defines the ending frame number (default is 100)
  16260. * @param loopAnimation defines if the animation must loop (default is false)
  16261. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16262. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16263. * @param animations defines a group of animation to add to the new Animatable
  16264. * @param onAnimationLoop defines a callback to call when animation loops
  16265. * @param isAdditive defines whether the animation should be evaluated additively
  16266. */
  16267. constructor(scene: Scene,
  16268. /** defines the target object */
  16269. target: any,
  16270. /** defines the starting frame number (default is 0) */
  16271. fromFrame?: number,
  16272. /** defines the ending frame number (default is 100) */
  16273. toFrame?: number,
  16274. /** defines if the animation must loop (default is false) */
  16275. loopAnimation?: boolean, speedRatio?: number,
  16276. /** defines a callback to call when animation ends if it is not looping */
  16277. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16278. /** defines a callback to call when animation loops */
  16279. onAnimationLoop?: (() => void) | null | undefined,
  16280. /** defines whether the animation should be evaluated additively */
  16281. isAdditive?: boolean);
  16282. /**
  16283. * Synchronize and normalize current Animatable with a source Animatable
  16284. * This is useful when using animation weights and when animations are not of the same length
  16285. * @param root defines the root Animatable to synchronize with
  16286. * @returns the current Animatable
  16287. */
  16288. syncWith(root: Animatable): Animatable;
  16289. /**
  16290. * Gets the list of runtime animations
  16291. * @returns an array of RuntimeAnimation
  16292. */
  16293. getAnimations(): RuntimeAnimation[];
  16294. /**
  16295. * Adds more animations to the current animatable
  16296. * @param target defines the target of the animations
  16297. * @param animations defines the new animations to add
  16298. */
  16299. appendAnimations(target: any, animations: Animation[]): void;
  16300. /**
  16301. * Gets the source animation for a specific property
  16302. * @param property defines the propertyu to look for
  16303. * @returns null or the source animation for the given property
  16304. */
  16305. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16306. /**
  16307. * Gets the runtime animation for a specific property
  16308. * @param property defines the propertyu to look for
  16309. * @returns null or the runtime animation for the given property
  16310. */
  16311. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16312. /**
  16313. * Resets the animatable to its original state
  16314. */
  16315. reset(): void;
  16316. /**
  16317. * Allows the animatable to blend with current running animations
  16318. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16319. * @param blendingSpeed defines the blending speed to use
  16320. */
  16321. enableBlending(blendingSpeed: number): void;
  16322. /**
  16323. * Disable animation blending
  16324. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16325. */
  16326. disableBlending(): void;
  16327. /**
  16328. * Jump directly to a given frame
  16329. * @param frame defines the frame to jump to
  16330. */
  16331. goToFrame(frame: number): void;
  16332. /**
  16333. * Pause the animation
  16334. */
  16335. pause(): void;
  16336. /**
  16337. * Restart the animation
  16338. */
  16339. restart(): void;
  16340. private _raiseOnAnimationEnd;
  16341. /**
  16342. * Stop and delete the current animation
  16343. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16344. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  16345. */
  16346. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16347. /**
  16348. * Wait asynchronously for the animation to end
  16349. * @returns a promise which will be fullfilled when the animation ends
  16350. */
  16351. waitAsync(): Promise<Animatable>;
  16352. /** @hidden */
  16353. _animate(delay: number): boolean;
  16354. }
  16355. module "babylonjs/scene" {
  16356. interface Scene {
  16357. /** @hidden */
  16358. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16359. /** @hidden */
  16360. _processLateAnimationBindingsForMatrices(holder: {
  16361. totalWeight: number;
  16362. totalAdditiveWeight: number;
  16363. animations: RuntimeAnimation[];
  16364. additiveAnimations: RuntimeAnimation[];
  16365. originalValue: Matrix;
  16366. }): any;
  16367. /** @hidden */
  16368. _processLateAnimationBindingsForQuaternions(holder: {
  16369. totalWeight: number;
  16370. totalAdditiveWeight: number;
  16371. animations: RuntimeAnimation[];
  16372. additiveAnimations: RuntimeAnimation[];
  16373. originalValue: Quaternion;
  16374. }, refQuaternion: Quaternion): Quaternion;
  16375. /** @hidden */
  16376. _processLateAnimationBindings(): void;
  16377. /**
  16378. * Will start the animation sequence of a given target
  16379. * @param target defines the target
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param weight defines the weight to apply to the animation (1.0 by default)
  16383. * @param loop defines if the animation loops
  16384. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16385. * @param onAnimationEnd defines the function to be executed when the animation ends
  16386. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the animatable object created for this animation
  16391. */
  16392. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16393. /**
  16394. * Will start the animation sequence of a given target
  16395. * @param target defines the target
  16396. * @param from defines from which frame should animation start
  16397. * @param to defines until which frame should animation run.
  16398. * @param loop defines if the animation loops
  16399. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16400. * @param onAnimationEnd defines the function to be executed when the animation ends
  16401. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16402. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16403. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16404. * @param onAnimationLoop defines the callback to call when an animation loops
  16405. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16406. * @returns the animatable object created for this animation
  16407. */
  16408. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16409. /**
  16410. * Will start the animation sequence of a given target and its hierarchy
  16411. * @param target defines the target
  16412. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16413. * @param from defines from which frame should animation start
  16414. * @param to defines until which frame should animation run.
  16415. * @param loop defines if the animation loops
  16416. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16417. * @param onAnimationEnd defines the function to be executed when the animation ends
  16418. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16419. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16420. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16421. * @param onAnimationLoop defines the callback to call when an animation loops
  16422. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16423. * @returns the list of created animatables
  16424. */
  16425. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16426. /**
  16427. * Begin a new animation on a given node
  16428. * @param target defines the target where the animation will take place
  16429. * @param animations defines the list of animations to start
  16430. * @param from defines the initial value
  16431. * @param to defines the final value
  16432. * @param loop defines if you want animation to loop (off by default)
  16433. * @param speedRatio defines the speed ratio to apply to all animations
  16434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16435. * @param onAnimationLoop defines the callback to call when an animation loops
  16436. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16437. * @returns the list of created animatables
  16438. */
  16439. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16440. /**
  16441. * Begin a new animation on a given node and its hierarchy
  16442. * @param target defines the root node where the animation will take place
  16443. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16444. * @param animations defines the list of animations to start
  16445. * @param from defines the initial value
  16446. * @param to defines the final value
  16447. * @param loop defines if you want animation to loop (off by default)
  16448. * @param speedRatio defines the speed ratio to apply to all animations
  16449. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16450. * @param onAnimationLoop defines the callback to call when an animation loops
  16451. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16452. * @returns the list of animatables created for all nodes
  16453. */
  16454. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16455. /**
  16456. * Gets the animatable associated with a specific target
  16457. * @param target defines the target of the animatable
  16458. * @returns the required animatable if found
  16459. */
  16460. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16461. /**
  16462. * Gets all animatables associated with a given target
  16463. * @param target defines the target to look animatables for
  16464. * @returns an array of Animatables
  16465. */
  16466. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16467. /**
  16468. * Stops and removes all animations that have been applied to the scene
  16469. */
  16470. stopAllAnimations(): void;
  16471. /**
  16472. * Gets the current delta time used by animation engine
  16473. */
  16474. deltaTime: number;
  16475. }
  16476. }
  16477. module "babylonjs/Bones/bone" {
  16478. interface Bone {
  16479. /**
  16480. * Copy an animation range from another bone
  16481. * @param source defines the source bone
  16482. * @param rangeName defines the range name to copy
  16483. * @param frameOffset defines the frame offset
  16484. * @param rescaleAsRequired defines if rescaling must be applied if required
  16485. * @param skelDimensionsRatio defines the scaling ratio
  16486. * @returns true if operation was successful
  16487. */
  16488. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16489. }
  16490. }
  16491. }
  16492. declare module "babylonjs/Bones/skeleton" {
  16493. import { Bone } from "babylonjs/Bones/bone";
  16494. import { Observable } from "babylonjs/Misc/observable";
  16495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16496. import { Scene } from "babylonjs/scene";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16499. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16500. import { Animatable } from "babylonjs/Animations/animatable";
  16501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16502. import { Animation } from "babylonjs/Animations/animation";
  16503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16505. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16506. /**
  16507. * Class used to handle skinning animations
  16508. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16509. */
  16510. export class Skeleton implements IAnimatable {
  16511. /** defines the skeleton name */
  16512. name: string;
  16513. /** defines the skeleton Id */
  16514. id: string;
  16515. /**
  16516. * Defines the list of child bones
  16517. */
  16518. bones: Bone[];
  16519. /**
  16520. * Defines an estimate of the dimension of the skeleton at rest
  16521. */
  16522. dimensionsAtRest: Vector3;
  16523. /**
  16524. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16525. */
  16526. needInitialSkinMatrix: boolean;
  16527. /**
  16528. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16529. */
  16530. overrideMesh: Nullable<AbstractMesh>;
  16531. /**
  16532. * Gets the list of animations attached to this skeleton
  16533. */
  16534. animations: Array<Animation>;
  16535. private _scene;
  16536. private _isDirty;
  16537. private _transformMatrices;
  16538. private _transformMatrixTexture;
  16539. private _meshesWithPoseMatrix;
  16540. private _animatables;
  16541. private _identity;
  16542. private _synchronizedWithMesh;
  16543. private _ranges;
  16544. private _lastAbsoluteTransformsUpdateId;
  16545. private _canUseTextureForBones;
  16546. private _uniqueId;
  16547. /** @hidden */
  16548. _numBonesWithLinkedTransformNode: number;
  16549. /** @hidden */
  16550. _hasWaitingData: Nullable<boolean>;
  16551. /** @hidden */
  16552. _waitingOverrideMeshId: Nullable<string>;
  16553. /**
  16554. * Specifies if the skeleton should be serialized
  16555. */
  16556. doNotSerialize: boolean;
  16557. private _useTextureToStoreBoneMatrices;
  16558. /**
  16559. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16560. * Please note that this option is not available if the hardware does not support it
  16561. */
  16562. get useTextureToStoreBoneMatrices(): boolean;
  16563. set useTextureToStoreBoneMatrices(value: boolean);
  16564. private _animationPropertiesOverride;
  16565. /**
  16566. * Gets or sets the animation properties override
  16567. */
  16568. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16569. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16570. /**
  16571. * List of inspectable custom properties (used by the Inspector)
  16572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16573. */
  16574. inspectableCustomProperties: IInspectable[];
  16575. /**
  16576. * An observable triggered before computing the skeleton's matrices
  16577. */
  16578. onBeforeComputeObservable: Observable<Skeleton>;
  16579. /**
  16580. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16581. */
  16582. get isUsingTextureForMatrices(): boolean;
  16583. /**
  16584. * Gets the unique ID of this skeleton
  16585. */
  16586. get uniqueId(): number;
  16587. /**
  16588. * Creates a new skeleton
  16589. * @param name defines the skeleton name
  16590. * @param id defines the skeleton Id
  16591. * @param scene defines the hosting scene
  16592. */
  16593. constructor(
  16594. /** defines the skeleton name */
  16595. name: string,
  16596. /** defines the skeleton Id */
  16597. id: string, scene: Scene);
  16598. /**
  16599. * Gets the current object class name.
  16600. * @return the class name
  16601. */
  16602. getClassName(): string;
  16603. /**
  16604. * Returns an array containing the root bones
  16605. * @returns an array containing the root bones
  16606. */
  16607. getChildren(): Array<Bone>;
  16608. /**
  16609. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16611. * @returns a Float32Array containing matrices data
  16612. */
  16613. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16614. /**
  16615. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16616. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16617. * @returns a raw texture containing the data
  16618. */
  16619. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16620. /**
  16621. * Gets the current hosting scene
  16622. * @returns a scene object
  16623. */
  16624. getScene(): Scene;
  16625. /**
  16626. * Gets a string representing the current skeleton data
  16627. * @param fullDetails defines a boolean indicating if we want a verbose version
  16628. * @returns a string representing the current skeleton data
  16629. */
  16630. toString(fullDetails?: boolean): string;
  16631. /**
  16632. * Get bone's index searching by name
  16633. * @param name defines bone's name to search for
  16634. * @return the indice of the bone. Returns -1 if not found
  16635. */
  16636. getBoneIndexByName(name: string): number;
  16637. /**
  16638. * Creater a new animation range
  16639. * @param name defines the name of the range
  16640. * @param from defines the start key
  16641. * @param to defines the end key
  16642. */
  16643. createAnimationRange(name: string, from: number, to: number): void;
  16644. /**
  16645. * Delete a specific animation range
  16646. * @param name defines the name of the range
  16647. * @param deleteFrames defines if frames must be removed as well
  16648. */
  16649. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16650. /**
  16651. * Gets a specific animation range
  16652. * @param name defines the name of the range to look for
  16653. * @returns the requested animation range or null if not found
  16654. */
  16655. getAnimationRange(name: string): Nullable<AnimationRange>;
  16656. /**
  16657. * Gets the list of all animation ranges defined on this skeleton
  16658. * @returns an array
  16659. */
  16660. getAnimationRanges(): Nullable<AnimationRange>[];
  16661. /**
  16662. * Copy animation range from a source skeleton.
  16663. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16664. * @param source defines the source skeleton
  16665. * @param name defines the name of the range to copy
  16666. * @param rescaleAsRequired defines if rescaling must be applied if required
  16667. * @returns true if operation was successful
  16668. */
  16669. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16670. /**
  16671. * Forces the skeleton to go to rest pose
  16672. */
  16673. returnToRest(): void;
  16674. private _getHighestAnimationFrame;
  16675. /**
  16676. * Begin a specific animation range
  16677. * @param name defines the name of the range to start
  16678. * @param loop defines if looping must be turned on (false by default)
  16679. * @param speedRatio defines the speed ratio to apply (1 by default)
  16680. * @param onAnimationEnd defines a callback which will be called when animation will end
  16681. * @returns a new animatable
  16682. */
  16683. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16684. /**
  16685. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16686. * @param skeleton defines the Skeleton containing the animation range to convert
  16687. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16688. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16689. * @returns the original skeleton
  16690. */
  16691. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16692. /** @hidden */
  16693. _markAsDirty(): void;
  16694. /** @hidden */
  16695. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16696. /** @hidden */
  16697. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16698. private _computeTransformMatrices;
  16699. /**
  16700. * Build all resources required to render a skeleton
  16701. */
  16702. prepare(): void;
  16703. /**
  16704. * Gets the list of animatables currently running for this skeleton
  16705. * @returns an array of animatables
  16706. */
  16707. getAnimatables(): IAnimatable[];
  16708. /**
  16709. * Clone the current skeleton
  16710. * @param name defines the name of the new skeleton
  16711. * @param id defines the id of the new skeleton
  16712. * @returns the new skeleton
  16713. */
  16714. clone(name: string, id?: string): Skeleton;
  16715. /**
  16716. * Enable animation blending for this skeleton
  16717. * @param blendingSpeed defines the blending speed to apply
  16718. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16719. */
  16720. enableBlending(blendingSpeed?: number): void;
  16721. /**
  16722. * Releases all resources associated with the current skeleton
  16723. */
  16724. dispose(): void;
  16725. /**
  16726. * Serialize the skeleton in a JSON object
  16727. * @returns a JSON object
  16728. */
  16729. serialize(): any;
  16730. /**
  16731. * Creates a new skeleton from serialized data
  16732. * @param parsedSkeleton defines the serialized data
  16733. * @param scene defines the hosting scene
  16734. * @returns a new skeleton
  16735. */
  16736. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16737. /**
  16738. * Compute all node absolute transforms
  16739. * @param forceUpdate defines if computation must be done even if cache is up to date
  16740. */
  16741. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16742. /**
  16743. * Gets the root pose matrix
  16744. * @returns a matrix
  16745. */
  16746. getPoseMatrix(): Nullable<Matrix>;
  16747. /**
  16748. * Sorts bones per internal index
  16749. */
  16750. sortBones(): void;
  16751. private _sortBones;
  16752. /**
  16753. * Set the current local matrix as the restPose for all bones in the skeleton.
  16754. */
  16755. setCurrentPoseAsRest(): void;
  16756. }
  16757. }
  16758. declare module "babylonjs/Meshes/instancedMesh" {
  16759. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16760. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16761. import { Camera } from "babylonjs/Cameras/camera";
  16762. import { Node } from "babylonjs/node";
  16763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16764. import { Mesh } from "babylonjs/Meshes/mesh";
  16765. import { Material } from "babylonjs/Materials/material";
  16766. import { Skeleton } from "babylonjs/Bones/skeleton";
  16767. import { Light } from "babylonjs/Lights/light";
  16768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16769. /**
  16770. * Creates an instance based on a source mesh.
  16771. */
  16772. export class InstancedMesh extends AbstractMesh {
  16773. private _sourceMesh;
  16774. private _currentLOD;
  16775. /** @hidden */
  16776. _indexInSourceMeshInstanceArray: number;
  16777. constructor(name: string, source: Mesh);
  16778. /**
  16779. * Returns the string "InstancedMesh".
  16780. */
  16781. getClassName(): string;
  16782. /** Gets the list of lights affecting that mesh */
  16783. get lightSources(): Light[];
  16784. _resyncLightSources(): void;
  16785. _resyncLightSource(light: Light): void;
  16786. _removeLightSource(light: Light, dispose: boolean): void;
  16787. /**
  16788. * If the source mesh receives shadows
  16789. */
  16790. get receiveShadows(): boolean;
  16791. /**
  16792. * The material of the source mesh
  16793. */
  16794. get material(): Nullable<Material>;
  16795. /**
  16796. * Visibility of the source mesh
  16797. */
  16798. get visibility(): number;
  16799. /**
  16800. * Skeleton of the source mesh
  16801. */
  16802. get skeleton(): Nullable<Skeleton>;
  16803. /**
  16804. * Rendering ground id of the source mesh
  16805. */
  16806. get renderingGroupId(): number;
  16807. set renderingGroupId(value: number);
  16808. /**
  16809. * Returns the total number of vertices (integer).
  16810. */
  16811. getTotalVertices(): number;
  16812. /**
  16813. * Returns a positive integer : the total number of indices in this mesh geometry.
  16814. * @returns the numner of indices or zero if the mesh has no geometry.
  16815. */
  16816. getTotalIndices(): number;
  16817. /**
  16818. * The source mesh of the instance
  16819. */
  16820. get sourceMesh(): Mesh;
  16821. /**
  16822. * Creates a new InstancedMesh object from the mesh model.
  16823. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16824. * @param name defines the name of the new instance
  16825. * @returns a new InstancedMesh
  16826. */
  16827. createInstance(name: string): InstancedMesh;
  16828. /**
  16829. * Is this node ready to be used/rendered
  16830. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16831. * @return {boolean} is it ready
  16832. */
  16833. isReady(completeCheck?: boolean): boolean;
  16834. /**
  16835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16836. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16837. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16838. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16839. */
  16840. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16841. /**
  16842. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16843. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16844. * The `data` are either a numeric array either a Float32Array.
  16845. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16846. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16847. * Note that a new underlying VertexBuffer object is created each call.
  16848. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16849. *
  16850. * Possible `kind` values :
  16851. * - VertexBuffer.PositionKind
  16852. * - VertexBuffer.UVKind
  16853. * - VertexBuffer.UV2Kind
  16854. * - VertexBuffer.UV3Kind
  16855. * - VertexBuffer.UV4Kind
  16856. * - VertexBuffer.UV5Kind
  16857. * - VertexBuffer.UV6Kind
  16858. * - VertexBuffer.ColorKind
  16859. * - VertexBuffer.MatricesIndicesKind
  16860. * - VertexBuffer.MatricesIndicesExtraKind
  16861. * - VertexBuffer.MatricesWeightsKind
  16862. * - VertexBuffer.MatricesWeightsExtraKind
  16863. *
  16864. * Returns the Mesh.
  16865. */
  16866. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16867. /**
  16868. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16869. * If the mesh has no geometry, it is simply returned as it is.
  16870. * The `data` are either a numeric array either a Float32Array.
  16871. * No new underlying VertexBuffer object is created.
  16872. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16873. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16874. *
  16875. * Possible `kind` values :
  16876. * - VertexBuffer.PositionKind
  16877. * - VertexBuffer.UVKind
  16878. * - VertexBuffer.UV2Kind
  16879. * - VertexBuffer.UV3Kind
  16880. * - VertexBuffer.UV4Kind
  16881. * - VertexBuffer.UV5Kind
  16882. * - VertexBuffer.UV6Kind
  16883. * - VertexBuffer.ColorKind
  16884. * - VertexBuffer.MatricesIndicesKind
  16885. * - VertexBuffer.MatricesIndicesExtraKind
  16886. * - VertexBuffer.MatricesWeightsKind
  16887. * - VertexBuffer.MatricesWeightsExtraKind
  16888. *
  16889. * Returns the Mesh.
  16890. */
  16891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16892. /**
  16893. * Sets the mesh indices.
  16894. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16895. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16896. * This method creates a new index buffer each call.
  16897. * Returns the Mesh.
  16898. */
  16899. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16900. /**
  16901. * Boolean : True if the mesh owns the requested kind of data.
  16902. */
  16903. isVerticesDataPresent(kind: string): boolean;
  16904. /**
  16905. * Returns an array of indices (IndicesArray).
  16906. */
  16907. getIndices(): Nullable<IndicesArray>;
  16908. get _positions(): Nullable<Vector3[]>;
  16909. /**
  16910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16911. * This means the mesh underlying bounding box and sphere are recomputed.
  16912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16913. * @returns the current mesh
  16914. */
  16915. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16916. /** @hidden */
  16917. _preActivate(): InstancedMesh;
  16918. /** @hidden */
  16919. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16920. /** @hidden */
  16921. _postActivate(): void;
  16922. getWorldMatrix(): Matrix;
  16923. get isAnInstance(): boolean;
  16924. /**
  16925. * Returns the current associated LOD AbstractMesh.
  16926. */
  16927. getLOD(camera: Camera): AbstractMesh;
  16928. /** @hidden */
  16929. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16930. /** @hidden */
  16931. _syncSubMeshes(): InstancedMesh;
  16932. /** @hidden */
  16933. _generatePointsArray(): boolean;
  16934. /** @hidden */
  16935. _updateBoundingInfo(): AbstractMesh;
  16936. /**
  16937. * Creates a new InstancedMesh from the current mesh.
  16938. * - name (string) : the cloned mesh name
  16939. * - newParent (optional Node) : the optional Node to parent the clone to.
  16940. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16941. *
  16942. * Returns the clone.
  16943. */
  16944. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16945. /**
  16946. * Disposes the InstancedMesh.
  16947. * Returns nothing.
  16948. */
  16949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16950. }
  16951. module "babylonjs/Meshes/mesh" {
  16952. interface Mesh {
  16953. /**
  16954. * Register a custom buffer that will be instanced
  16955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16956. * @param kind defines the buffer kind
  16957. * @param stride defines the stride in floats
  16958. */
  16959. registerInstancedBuffer(kind: string, stride: number): void;
  16960. /**
  16961. * true to use the edge renderer for all instances of this mesh
  16962. */
  16963. edgesShareWithInstances: boolean;
  16964. /** @hidden */
  16965. _userInstancedBuffersStorage: {
  16966. data: {
  16967. [key: string]: Float32Array;
  16968. };
  16969. sizes: {
  16970. [key: string]: number;
  16971. };
  16972. vertexBuffers: {
  16973. [key: string]: Nullable<VertexBuffer>;
  16974. };
  16975. strides: {
  16976. [key: string]: number;
  16977. };
  16978. };
  16979. }
  16980. }
  16981. module "babylonjs/Meshes/abstractMesh" {
  16982. interface AbstractMesh {
  16983. /**
  16984. * Object used to store instanced buffers defined by user
  16985. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16986. */
  16987. instancedBuffers: {
  16988. [key: string]: any;
  16989. };
  16990. }
  16991. }
  16992. }
  16993. declare module "babylonjs/Materials/shaderMaterial" {
  16994. import { Nullable } from "babylonjs/types";
  16995. import { Scene } from "babylonjs/scene";
  16996. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16998. import { Mesh } from "babylonjs/Meshes/mesh";
  16999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17001. import { Effect } from "babylonjs/Materials/effect";
  17002. import { Material } from "babylonjs/Materials/material";
  17003. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17004. /**
  17005. * Defines the options associated with the creation of a shader material.
  17006. */
  17007. export interface IShaderMaterialOptions {
  17008. /**
  17009. * Does the material work in alpha blend mode
  17010. */
  17011. needAlphaBlending: boolean;
  17012. /**
  17013. * Does the material work in alpha test mode
  17014. */
  17015. needAlphaTesting: boolean;
  17016. /**
  17017. * The list of attribute names used in the shader
  17018. */
  17019. attributes: string[];
  17020. /**
  17021. * The list of unifrom names used in the shader
  17022. */
  17023. uniforms: string[];
  17024. /**
  17025. * The list of UBO names used in the shader
  17026. */
  17027. uniformBuffers: string[];
  17028. /**
  17029. * The list of sampler names used in the shader
  17030. */
  17031. samplers: string[];
  17032. /**
  17033. * The list of defines used in the shader
  17034. */
  17035. defines: string[];
  17036. }
  17037. /**
  17038. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17039. *
  17040. * This returned material effects how the mesh will look based on the code in the shaders.
  17041. *
  17042. * @see https://doc.babylonjs.com/how_to/shader_material
  17043. */
  17044. export class ShaderMaterial extends Material {
  17045. private _shaderPath;
  17046. private _options;
  17047. private _textures;
  17048. private _textureArrays;
  17049. private _floats;
  17050. private _ints;
  17051. private _floatsArrays;
  17052. private _colors3;
  17053. private _colors3Arrays;
  17054. private _colors4;
  17055. private _colors4Arrays;
  17056. private _vectors2;
  17057. private _vectors3;
  17058. private _vectors4;
  17059. private _matrices;
  17060. private _matrixArrays;
  17061. private _matrices3x3;
  17062. private _matrices2x2;
  17063. private _vectors2Arrays;
  17064. private _vectors3Arrays;
  17065. private _vectors4Arrays;
  17066. private _cachedWorldViewMatrix;
  17067. private _cachedWorldViewProjectionMatrix;
  17068. private _renderId;
  17069. private _multiview;
  17070. private _cachedDefines;
  17071. /** Define the Url to load snippets */
  17072. static SnippetUrl: string;
  17073. /** Snippet ID if the material was created from the snippet server */
  17074. snippetId: string;
  17075. /**
  17076. * Instantiate a new shader material.
  17077. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17078. * This returned material effects how the mesh will look based on the code in the shaders.
  17079. * @see https://doc.babylonjs.com/how_to/shader_material
  17080. * @param name Define the name of the material in the scene
  17081. * @param scene Define the scene the material belongs to
  17082. * @param shaderPath Defines the route to the shader code in one of three ways:
  17083. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17084. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17085. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17086. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17087. * @param options Define the options used to create the shader
  17088. */
  17089. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17090. /**
  17091. * Gets the shader path used to define the shader code
  17092. * It can be modified to trigger a new compilation
  17093. */
  17094. get shaderPath(): any;
  17095. /**
  17096. * Sets the shader path used to define the shader code
  17097. * It can be modified to trigger a new compilation
  17098. */
  17099. set shaderPath(shaderPath: any);
  17100. /**
  17101. * Gets the options used to compile the shader.
  17102. * They can be modified to trigger a new compilation
  17103. */
  17104. get options(): IShaderMaterialOptions;
  17105. /**
  17106. * Gets the current class name of the material e.g. "ShaderMaterial"
  17107. * Mainly use in serialization.
  17108. * @returns the class name
  17109. */
  17110. getClassName(): string;
  17111. /**
  17112. * Specifies if the material will require alpha blending
  17113. * @returns a boolean specifying if alpha blending is needed
  17114. */
  17115. needAlphaBlending(): boolean;
  17116. /**
  17117. * Specifies if this material should be rendered in alpha test mode
  17118. * @returns a boolean specifying if an alpha test is needed.
  17119. */
  17120. needAlphaTesting(): boolean;
  17121. private _checkUniform;
  17122. /**
  17123. * Set a texture in the shader.
  17124. * @param name Define the name of the uniform samplers as defined in the shader
  17125. * @param texture Define the texture to bind to this sampler
  17126. * @return the material itself allowing "fluent" like uniform updates
  17127. */
  17128. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17129. /**
  17130. * Set a texture array in the shader.
  17131. * @param name Define the name of the uniform sampler array as defined in the shader
  17132. * @param textures Define the list of textures to bind to this sampler
  17133. * @return the material itself allowing "fluent" like uniform updates
  17134. */
  17135. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17136. /**
  17137. * Set a float in the shader.
  17138. * @param name Define the name of the uniform as defined in the shader
  17139. * @param value Define the value to give to the uniform
  17140. * @return the material itself allowing "fluent" like uniform updates
  17141. */
  17142. setFloat(name: string, value: number): ShaderMaterial;
  17143. /**
  17144. * Set a int in the shader.
  17145. * @param name Define the name of the uniform as defined in the shader
  17146. * @param value Define the value to give to the uniform
  17147. * @return the material itself allowing "fluent" like uniform updates
  17148. */
  17149. setInt(name: string, value: number): ShaderMaterial;
  17150. /**
  17151. * Set an array of floats in the shader.
  17152. * @param name Define the name of the uniform as defined in the shader
  17153. * @param value Define the value to give to the uniform
  17154. * @return the material itself allowing "fluent" like uniform updates
  17155. */
  17156. setFloats(name: string, value: number[]): ShaderMaterial;
  17157. /**
  17158. * Set a vec3 in the shader from a Color3.
  17159. * @param name Define the name of the uniform as defined in the shader
  17160. * @param value Define the value to give to the uniform
  17161. * @return the material itself allowing "fluent" like uniform updates
  17162. */
  17163. setColor3(name: string, value: Color3): ShaderMaterial;
  17164. /**
  17165. * Set a vec3 array in the shader from a Color3 array.
  17166. * @param name Define the name of the uniform as defined in the shader
  17167. * @param value Define the value to give to the uniform
  17168. * @return the material itself allowing "fluent" like uniform updates
  17169. */
  17170. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17171. /**
  17172. * Set a vec4 in the shader from a Color4.
  17173. * @param name Define the name of the uniform as defined in the shader
  17174. * @param value Define the value to give to the uniform
  17175. * @return the material itself allowing "fluent" like uniform updates
  17176. */
  17177. setColor4(name: string, value: Color4): ShaderMaterial;
  17178. /**
  17179. * Set a vec4 array in the shader from a Color4 array.
  17180. * @param name Define the name of the uniform as defined in the shader
  17181. * @param value Define the value to give to the uniform
  17182. * @return the material itself allowing "fluent" like uniform updates
  17183. */
  17184. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17185. /**
  17186. * Set a vec2 in the shader from a Vector2.
  17187. * @param name Define the name of the uniform as defined in the shader
  17188. * @param value Define the value to give to the uniform
  17189. * @return the material itself allowing "fluent" like uniform updates
  17190. */
  17191. setVector2(name: string, value: Vector2): ShaderMaterial;
  17192. /**
  17193. * Set a vec3 in the shader from a Vector3.
  17194. * @param name Define the name of the uniform as defined in the shader
  17195. * @param value Define the value to give to the uniform
  17196. * @return the material itself allowing "fluent" like uniform updates
  17197. */
  17198. setVector3(name: string, value: Vector3): ShaderMaterial;
  17199. /**
  17200. * Set a vec4 in the shader from a Vector4.
  17201. * @param name Define the name of the uniform as defined in the shader
  17202. * @param value Define the value to give to the uniform
  17203. * @return the material itself allowing "fluent" like uniform updates
  17204. */
  17205. setVector4(name: string, value: Vector4): ShaderMaterial;
  17206. /**
  17207. * Set a mat4 in the shader from a Matrix.
  17208. * @param name Define the name of the uniform as defined in the shader
  17209. * @param value Define the value to give to the uniform
  17210. * @return the material itself allowing "fluent" like uniform updates
  17211. */
  17212. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17213. /**
  17214. * Set a float32Array in the shader from a matrix array.
  17215. * @param name Define the name of the uniform as defined in the shader
  17216. * @param value Define the value to give to the uniform
  17217. * @return the material itself allowing "fluent" like uniform updates
  17218. */
  17219. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17220. /**
  17221. * Set a mat3 in the shader from a Float32Array.
  17222. * @param name Define the name of the uniform as defined in the shader
  17223. * @param value Define the value to give to the uniform
  17224. * @return the material itself allowing "fluent" like uniform updates
  17225. */
  17226. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17227. /**
  17228. * Set a mat2 in the shader from a Float32Array.
  17229. * @param name Define the name of the uniform as defined in the shader
  17230. * @param value Define the value to give to the uniform
  17231. * @return the material itself allowing "fluent" like uniform updates
  17232. */
  17233. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17234. /**
  17235. * Set a vec2 array in the shader from a number array.
  17236. * @param name Define the name of the uniform as defined in the shader
  17237. * @param value Define the value to give to the uniform
  17238. * @return the material itself allowing "fluent" like uniform updates
  17239. */
  17240. setArray2(name: string, value: number[]): ShaderMaterial;
  17241. /**
  17242. * Set a vec3 array in the shader from a number array.
  17243. * @param name Define the name of the uniform as defined in the shader
  17244. * @param value Define the value to give to the uniform
  17245. * @return the material itself allowing "fluent" like uniform updates
  17246. */
  17247. setArray3(name: string, value: number[]): ShaderMaterial;
  17248. /**
  17249. * Set a vec4 array in the shader from a number array.
  17250. * @param name Define the name of the uniform as defined in the shader
  17251. * @param value Define the value to give to the uniform
  17252. * @return the material itself allowing "fluent" like uniform updates
  17253. */
  17254. setArray4(name: string, value: number[]): ShaderMaterial;
  17255. private _checkCache;
  17256. /**
  17257. * Specifies that the submesh is ready to be used
  17258. * @param mesh defines the mesh to check
  17259. * @param subMesh defines which submesh to check
  17260. * @param useInstances specifies that instances should be used
  17261. * @returns a boolean indicating that the submesh is ready or not
  17262. */
  17263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17264. /**
  17265. * Checks if the material is ready to render the requested mesh
  17266. * @param mesh Define the mesh to render
  17267. * @param useInstances Define whether or not the material is used with instances
  17268. * @returns true if ready, otherwise false
  17269. */
  17270. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17271. /**
  17272. * Binds the world matrix to the material
  17273. * @param world defines the world transformation matrix
  17274. * @param effectOverride - If provided, use this effect instead of internal effect
  17275. */
  17276. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17277. /**
  17278. * Binds the submesh to this material by preparing the effect and shader to draw
  17279. * @param world defines the world transformation matrix
  17280. * @param mesh defines the mesh containing the submesh
  17281. * @param subMesh defines the submesh to bind the material to
  17282. */
  17283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17284. /**
  17285. * Binds the material to the mesh
  17286. * @param world defines the world transformation matrix
  17287. * @param mesh defines the mesh to bind the material to
  17288. * @param effectOverride - If provided, use this effect instead of internal effect
  17289. */
  17290. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17291. protected _afterBind(mesh?: Mesh): void;
  17292. /**
  17293. * Gets the active textures from the material
  17294. * @returns an array of textures
  17295. */
  17296. getActiveTextures(): BaseTexture[];
  17297. /**
  17298. * Specifies if the material uses a texture
  17299. * @param texture defines the texture to check against the material
  17300. * @returns a boolean specifying if the material uses the texture
  17301. */
  17302. hasTexture(texture: BaseTexture): boolean;
  17303. /**
  17304. * Makes a duplicate of the material, and gives it a new name
  17305. * @param name defines the new name for the duplicated material
  17306. * @returns the cloned material
  17307. */
  17308. clone(name: string): ShaderMaterial;
  17309. /**
  17310. * Disposes the material
  17311. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17312. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17313. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17314. */
  17315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17316. /**
  17317. * Serializes this material in a JSON representation
  17318. * @returns the serialized material object
  17319. */
  17320. serialize(): any;
  17321. /**
  17322. * Creates a shader material from parsed shader material data
  17323. * @param source defines the JSON represnetation of the material
  17324. * @param scene defines the hosting scene
  17325. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17326. * @returns a new material
  17327. */
  17328. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17329. /**
  17330. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17331. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17332. * @param url defines the url to load from
  17333. * @param scene defines the hosting scene
  17334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17335. * @returns a promise that will resolve to the new ShaderMaterial
  17336. */
  17337. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17338. /**
  17339. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17340. * @param snippetId defines the snippet to load
  17341. * @param scene defines the hosting scene
  17342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17343. * @returns a promise that will resolve to the new ShaderMaterial
  17344. */
  17345. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17346. }
  17347. }
  17348. declare module "babylonjs/Shaders/color.fragment" {
  17349. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17351. /** @hidden */
  17352. export var colorPixelShader: {
  17353. name: string;
  17354. shader: string;
  17355. };
  17356. }
  17357. declare module "babylonjs/Shaders/color.vertex" {
  17358. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17361. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17362. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17363. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17364. /** @hidden */
  17365. export var colorVertexShader: {
  17366. name: string;
  17367. shader: string;
  17368. };
  17369. }
  17370. declare module "babylonjs/Meshes/linesMesh" {
  17371. import { Nullable } from "babylonjs/types";
  17372. import { Scene } from "babylonjs/scene";
  17373. import { Color3 } from "babylonjs/Maths/math.color";
  17374. import { Node } from "babylonjs/node";
  17375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17376. import { Mesh } from "babylonjs/Meshes/mesh";
  17377. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17378. import { Effect } from "babylonjs/Materials/effect";
  17379. import { Material } from "babylonjs/Materials/material";
  17380. import "babylonjs/Shaders/color.fragment";
  17381. import "babylonjs/Shaders/color.vertex";
  17382. /**
  17383. * Line mesh
  17384. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17385. */
  17386. export class LinesMesh extends Mesh {
  17387. /**
  17388. * If vertex color should be applied to the mesh
  17389. */
  17390. readonly useVertexColor?: boolean | undefined;
  17391. /**
  17392. * If vertex alpha should be applied to the mesh
  17393. */
  17394. readonly useVertexAlpha?: boolean | undefined;
  17395. /**
  17396. * Color of the line (Default: White)
  17397. */
  17398. color: Color3;
  17399. /**
  17400. * Alpha of the line (Default: 1)
  17401. */
  17402. alpha: number;
  17403. /**
  17404. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17405. * This margin is expressed in world space coordinates, so its value may vary.
  17406. * Default value is 0.1
  17407. */
  17408. intersectionThreshold: number;
  17409. private _colorShader;
  17410. private color4;
  17411. /**
  17412. * Creates a new LinesMesh
  17413. * @param name defines the name
  17414. * @param scene defines the hosting scene
  17415. * @param parent defines the parent mesh if any
  17416. * @param source defines the optional source LinesMesh used to clone data from
  17417. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17418. * When false, achieved by calling a clone(), also passing False.
  17419. * This will make creation of children, recursive.
  17420. * @param useVertexColor defines if this LinesMesh supports vertex color
  17421. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17422. */
  17423. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17424. /**
  17425. * If vertex color should be applied to the mesh
  17426. */
  17427. useVertexColor?: boolean | undefined,
  17428. /**
  17429. * If vertex alpha should be applied to the mesh
  17430. */
  17431. useVertexAlpha?: boolean | undefined);
  17432. private _addClipPlaneDefine;
  17433. private _removeClipPlaneDefine;
  17434. isReady(): boolean;
  17435. /**
  17436. * Returns the string "LineMesh"
  17437. */
  17438. getClassName(): string;
  17439. /**
  17440. * @hidden
  17441. */
  17442. get material(): Material;
  17443. /**
  17444. * @hidden
  17445. */
  17446. set material(value: Material);
  17447. /**
  17448. * @hidden
  17449. */
  17450. get checkCollisions(): boolean;
  17451. /** @hidden */
  17452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17453. /** @hidden */
  17454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17455. /**
  17456. * Disposes of the line mesh
  17457. * @param doNotRecurse If children should be disposed
  17458. */
  17459. dispose(doNotRecurse?: boolean): void;
  17460. /**
  17461. * Returns a new LineMesh object cloned from the current one.
  17462. */
  17463. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17464. /**
  17465. * Creates a new InstancedLinesMesh object from the mesh model.
  17466. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17467. * @param name defines the name of the new instance
  17468. * @returns a new InstancedLinesMesh
  17469. */
  17470. createInstance(name: string): InstancedLinesMesh;
  17471. }
  17472. /**
  17473. * Creates an instance based on a source LinesMesh
  17474. */
  17475. export class InstancedLinesMesh extends InstancedMesh {
  17476. /**
  17477. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17478. * This margin is expressed in world space coordinates, so its value may vary.
  17479. * Initilized with the intersectionThreshold value of the source LinesMesh
  17480. */
  17481. intersectionThreshold: number;
  17482. constructor(name: string, source: LinesMesh);
  17483. /**
  17484. * Returns the string "InstancedLinesMesh".
  17485. */
  17486. getClassName(): string;
  17487. }
  17488. }
  17489. declare module "babylonjs/Shaders/line.fragment" {
  17490. /** @hidden */
  17491. export var linePixelShader: {
  17492. name: string;
  17493. shader: string;
  17494. };
  17495. }
  17496. declare module "babylonjs/Shaders/line.vertex" {
  17497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17498. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17499. /** @hidden */
  17500. export var lineVertexShader: {
  17501. name: string;
  17502. shader: string;
  17503. };
  17504. }
  17505. declare module "babylonjs/Rendering/edgesRenderer" {
  17506. import { Nullable } from "babylonjs/types";
  17507. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17509. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17510. import { IDisposable } from "babylonjs/scene";
  17511. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17512. import "babylonjs/Shaders/line.fragment";
  17513. import "babylonjs/Shaders/line.vertex";
  17514. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17515. import { SmartArray } from "babylonjs/Misc/smartArray";
  17516. module "babylonjs/scene" {
  17517. interface Scene {
  17518. /** @hidden */
  17519. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17520. }
  17521. }
  17522. module "babylonjs/Meshes/abstractMesh" {
  17523. interface AbstractMesh {
  17524. /**
  17525. * Gets the edgesRenderer associated with the mesh
  17526. */
  17527. edgesRenderer: Nullable<EdgesRenderer>;
  17528. }
  17529. }
  17530. module "babylonjs/Meshes/linesMesh" {
  17531. interface LinesMesh {
  17532. /**
  17533. * Enables the edge rendering mode on the mesh.
  17534. * This mode makes the mesh edges visible
  17535. * @param epsilon defines the maximal distance between two angles to detect a face
  17536. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17537. * @returns the currentAbstractMesh
  17538. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17539. */
  17540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17541. }
  17542. }
  17543. module "babylonjs/Meshes/linesMesh" {
  17544. interface InstancedLinesMesh {
  17545. /**
  17546. * Enables the edge rendering mode on the mesh.
  17547. * This mode makes the mesh edges visible
  17548. * @param epsilon defines the maximal distance between two angles to detect a face
  17549. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17550. * @returns the current InstancedLinesMesh
  17551. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17552. */
  17553. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17554. }
  17555. }
  17556. /**
  17557. * Defines the minimum contract an Edges renderer should follow.
  17558. */
  17559. export interface IEdgesRenderer extends IDisposable {
  17560. /**
  17561. * Gets or sets a boolean indicating if the edgesRenderer is active
  17562. */
  17563. isEnabled: boolean;
  17564. /**
  17565. * Renders the edges of the attached mesh,
  17566. */
  17567. render(): void;
  17568. /**
  17569. * Checks wether or not the edges renderer is ready to render.
  17570. * @return true if ready, otherwise false.
  17571. */
  17572. isReady(): boolean;
  17573. /**
  17574. * List of instances to render in case the source mesh has instances
  17575. */
  17576. customInstances: SmartArray<Matrix>;
  17577. }
  17578. /**
  17579. * Defines the additional options of the edges renderer
  17580. */
  17581. export interface IEdgesRendererOptions {
  17582. /**
  17583. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17584. * If not defined, the default value is true
  17585. */
  17586. useAlternateEdgeFinder?: boolean;
  17587. /**
  17588. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17589. * If not defined, the default value is true.
  17590. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17591. * This option is used only if useAlternateEdgeFinder = true
  17592. */
  17593. useFastVertexMerger?: boolean;
  17594. /**
  17595. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17596. * The default value is 1e-6
  17597. * This option is used only if useAlternateEdgeFinder = true
  17598. */
  17599. epsilonVertexMerge?: number;
  17600. /**
  17601. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17602. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17603. * This option is used only if useAlternateEdgeFinder = true
  17604. */
  17605. applyTessellation?: boolean;
  17606. /**
  17607. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17608. * The default value is 1e-6
  17609. * This option is used only if useAlternateEdgeFinder = true
  17610. */
  17611. epsilonVertexAligned?: number;
  17612. }
  17613. /**
  17614. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17615. */
  17616. export class EdgesRenderer implements IEdgesRenderer {
  17617. /**
  17618. * Define the size of the edges with an orthographic camera
  17619. */
  17620. edgesWidthScalerForOrthographic: number;
  17621. /**
  17622. * Define the size of the edges with a perspective camera
  17623. */
  17624. edgesWidthScalerForPerspective: number;
  17625. protected _source: AbstractMesh;
  17626. protected _linesPositions: number[];
  17627. protected _linesNormals: number[];
  17628. protected _linesIndices: number[];
  17629. protected _epsilon: number;
  17630. protected _indicesCount: number;
  17631. protected _lineShader: ShaderMaterial;
  17632. protected _ib: DataBuffer;
  17633. protected _buffers: {
  17634. [key: string]: Nullable<VertexBuffer>;
  17635. };
  17636. protected _buffersForInstances: {
  17637. [key: string]: Nullable<VertexBuffer>;
  17638. };
  17639. protected _checkVerticesInsteadOfIndices: boolean;
  17640. protected _options: Nullable<IEdgesRendererOptions>;
  17641. private _meshRebuildObserver;
  17642. private _meshDisposeObserver;
  17643. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17644. isEnabled: boolean;
  17645. /**
  17646. * List of instances to render in case the source mesh has instances
  17647. */
  17648. customInstances: SmartArray<Matrix>;
  17649. private static GetShader;
  17650. /**
  17651. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17652. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17653. * @param source Mesh used to create edges
  17654. * @param epsilon sum of angles in adjacency to check for edge
  17655. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17656. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17657. * @param options The options to apply when generating the edges
  17658. */
  17659. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17660. protected _prepareRessources(): void;
  17661. /** @hidden */
  17662. _rebuild(): void;
  17663. /**
  17664. * Releases the required resources for the edges renderer
  17665. */
  17666. dispose(): void;
  17667. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17668. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17669. /**
  17670. * Checks if the pair of p0 and p1 is en edge
  17671. * @param faceIndex
  17672. * @param edge
  17673. * @param faceNormals
  17674. * @param p0
  17675. * @param p1
  17676. * @private
  17677. */
  17678. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17679. /**
  17680. * push line into the position, normal and index buffer
  17681. * @protected
  17682. */
  17683. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17684. /**
  17685. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17686. */
  17687. private _tessellateTriangle;
  17688. private _generateEdgesLinesAlternate;
  17689. /**
  17690. * Generates lines edges from adjacencjes
  17691. * @private
  17692. */
  17693. _generateEdgesLines(): void;
  17694. /**
  17695. * Checks wether or not the edges renderer is ready to render.
  17696. * @return true if ready, otherwise false.
  17697. */
  17698. isReady(): boolean;
  17699. /**
  17700. * Renders the edges of the attached mesh,
  17701. */
  17702. render(): void;
  17703. }
  17704. /**
  17705. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17706. */
  17707. export class LineEdgesRenderer extends EdgesRenderer {
  17708. /**
  17709. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17710. * @param source LineMesh used to generate edges
  17711. * @param epsilon not important (specified angle for edge detection)
  17712. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17713. */
  17714. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17715. /**
  17716. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17717. */
  17718. _generateEdgesLines(): void;
  17719. }
  17720. }
  17721. declare module "babylonjs/Rendering/renderingGroup" {
  17722. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17725. import { Nullable } from "babylonjs/types";
  17726. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17727. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17728. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17729. import { Material } from "babylonjs/Materials/material";
  17730. import { Scene } from "babylonjs/scene";
  17731. /**
  17732. * This represents the object necessary to create a rendering group.
  17733. * This is exclusively used and created by the rendering manager.
  17734. * To modify the behavior, you use the available helpers in your scene or meshes.
  17735. * @hidden
  17736. */
  17737. export class RenderingGroup {
  17738. index: number;
  17739. private static _zeroVector;
  17740. private _scene;
  17741. private _opaqueSubMeshes;
  17742. private _transparentSubMeshes;
  17743. private _alphaTestSubMeshes;
  17744. private _depthOnlySubMeshes;
  17745. private _particleSystems;
  17746. private _spriteManagers;
  17747. private _opaqueSortCompareFn;
  17748. private _alphaTestSortCompareFn;
  17749. private _transparentSortCompareFn;
  17750. private _renderOpaque;
  17751. private _renderAlphaTest;
  17752. private _renderTransparent;
  17753. /** @hidden */
  17754. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17755. onBeforeTransparentRendering: () => void;
  17756. /**
  17757. * Set the opaque sort comparison function.
  17758. * If null the sub meshes will be render in the order they were created
  17759. */
  17760. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17761. /**
  17762. * Set the alpha test sort comparison function.
  17763. * If null the sub meshes will be render in the order they were created
  17764. */
  17765. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17766. /**
  17767. * Set the transparent sort comparison function.
  17768. * If null the sub meshes will be render in the order they were created
  17769. */
  17770. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17771. /**
  17772. * Creates a new rendering group.
  17773. * @param index The rendering group index
  17774. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17775. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17776. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17777. */
  17778. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17779. /**
  17780. * Render all the sub meshes contained in the group.
  17781. * @param customRenderFunction Used to override the default render behaviour of the group.
  17782. * @returns true if rendered some submeshes.
  17783. */
  17784. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17785. /**
  17786. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17787. * @param subMeshes The submeshes to render
  17788. */
  17789. private renderOpaqueSorted;
  17790. /**
  17791. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17792. * @param subMeshes The submeshes to render
  17793. */
  17794. private renderAlphaTestSorted;
  17795. /**
  17796. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17797. * @param subMeshes The submeshes to render
  17798. */
  17799. private renderTransparentSorted;
  17800. /**
  17801. * Renders the submeshes in a specified order.
  17802. * @param subMeshes The submeshes to sort before render
  17803. * @param sortCompareFn The comparison function use to sort
  17804. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17805. * @param transparent Specifies to activate blending if true
  17806. */
  17807. private static renderSorted;
  17808. /**
  17809. * Renders the submeshes in the order they were dispatched (no sort applied).
  17810. * @param subMeshes The submeshes to render
  17811. */
  17812. private static renderUnsorted;
  17813. /**
  17814. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17815. * are rendered back to front if in the same alpha index.
  17816. *
  17817. * @param a The first submesh
  17818. * @param b The second submesh
  17819. * @returns The result of the comparison
  17820. */
  17821. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17822. /**
  17823. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17824. * are rendered back to front.
  17825. *
  17826. * @param a The first submesh
  17827. * @param b The second submesh
  17828. * @returns The result of the comparison
  17829. */
  17830. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17831. /**
  17832. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17833. * are rendered front to back (prevent overdraw).
  17834. *
  17835. * @param a The first submesh
  17836. * @param b The second submesh
  17837. * @returns The result of the comparison
  17838. */
  17839. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17840. /**
  17841. * Resets the different lists of submeshes to prepare a new frame.
  17842. */
  17843. prepare(): void;
  17844. dispose(): void;
  17845. /**
  17846. * Inserts the submesh in its correct queue depending on its material.
  17847. * @param subMesh The submesh to dispatch
  17848. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17849. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17850. */
  17851. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17852. dispatchSprites(spriteManager: ISpriteManager): void;
  17853. dispatchParticles(particleSystem: IParticleSystem): void;
  17854. private _renderParticles;
  17855. private _renderSprites;
  17856. }
  17857. }
  17858. declare module "babylonjs/Rendering/renderingManager" {
  17859. import { Nullable } from "babylonjs/types";
  17860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17862. import { SmartArray } from "babylonjs/Misc/smartArray";
  17863. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17865. import { Material } from "babylonjs/Materials/material";
  17866. import { Scene } from "babylonjs/scene";
  17867. import { Camera } from "babylonjs/Cameras/camera";
  17868. /**
  17869. * Interface describing the different options available in the rendering manager
  17870. * regarding Auto Clear between groups.
  17871. */
  17872. export interface IRenderingManagerAutoClearSetup {
  17873. /**
  17874. * Defines whether or not autoclear is enable.
  17875. */
  17876. autoClear: boolean;
  17877. /**
  17878. * Defines whether or not to autoclear the depth buffer.
  17879. */
  17880. depth: boolean;
  17881. /**
  17882. * Defines whether or not to autoclear the stencil buffer.
  17883. */
  17884. stencil: boolean;
  17885. }
  17886. /**
  17887. * This class is used by the onRenderingGroupObservable
  17888. */
  17889. export class RenderingGroupInfo {
  17890. /**
  17891. * The Scene that being rendered
  17892. */
  17893. scene: Scene;
  17894. /**
  17895. * The camera currently used for the rendering pass
  17896. */
  17897. camera: Nullable<Camera>;
  17898. /**
  17899. * The ID of the renderingGroup being processed
  17900. */
  17901. renderingGroupId: number;
  17902. }
  17903. /**
  17904. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17905. * It is enable to manage the different groups as well as the different necessary sort functions.
  17906. * This should not be used directly aside of the few static configurations
  17907. */
  17908. export class RenderingManager {
  17909. /**
  17910. * The max id used for rendering groups (not included)
  17911. */
  17912. static MAX_RENDERINGGROUPS: number;
  17913. /**
  17914. * The min id used for rendering groups (included)
  17915. */
  17916. static MIN_RENDERINGGROUPS: number;
  17917. /**
  17918. * Used to globally prevent autoclearing scenes.
  17919. */
  17920. static AUTOCLEAR: boolean;
  17921. /**
  17922. * @hidden
  17923. */
  17924. _useSceneAutoClearSetup: boolean;
  17925. private _scene;
  17926. private _renderingGroups;
  17927. private _depthStencilBufferAlreadyCleaned;
  17928. private _autoClearDepthStencil;
  17929. private _customOpaqueSortCompareFn;
  17930. private _customAlphaTestSortCompareFn;
  17931. private _customTransparentSortCompareFn;
  17932. private _renderingGroupInfo;
  17933. /**
  17934. * Instantiates a new rendering group for a particular scene
  17935. * @param scene Defines the scene the groups belongs to
  17936. */
  17937. constructor(scene: Scene);
  17938. private _clearDepthStencilBuffer;
  17939. /**
  17940. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17941. * @hidden
  17942. */
  17943. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17944. /**
  17945. * Resets the different information of the group to prepare a new frame
  17946. * @hidden
  17947. */
  17948. reset(): void;
  17949. /**
  17950. * Dispose and release the group and its associated resources.
  17951. * @hidden
  17952. */
  17953. dispose(): void;
  17954. /**
  17955. * Clear the info related to rendering groups preventing retention points during dispose.
  17956. */
  17957. freeRenderingGroups(): void;
  17958. private _prepareRenderingGroup;
  17959. /**
  17960. * Add a sprite manager to the rendering manager in order to render it this frame.
  17961. * @param spriteManager Define the sprite manager to render
  17962. */
  17963. dispatchSprites(spriteManager: ISpriteManager): void;
  17964. /**
  17965. * Add a particle system to the rendering manager in order to render it this frame.
  17966. * @param particleSystem Define the particle system to render
  17967. */
  17968. dispatchParticles(particleSystem: IParticleSystem): void;
  17969. /**
  17970. * Add a submesh to the manager in order to render it this frame
  17971. * @param subMesh The submesh to dispatch
  17972. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17973. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17974. */
  17975. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17976. /**
  17977. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17978. * This allowed control for front to back rendering or reversly depending of the special needs.
  17979. *
  17980. * @param renderingGroupId The rendering group id corresponding to its index
  17981. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17982. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17983. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17984. */
  17985. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17986. /**
  17987. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17988. *
  17989. * @param renderingGroupId The rendering group id corresponding to its index
  17990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17991. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17992. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17993. */
  17994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17995. /**
  17996. * Gets the current auto clear configuration for one rendering group of the rendering
  17997. * manager.
  17998. * @param index the rendering group index to get the information for
  17999. * @returns The auto clear setup for the requested rendering group
  18000. */
  18001. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18002. }
  18003. }
  18004. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18005. import { SmartArray } from "babylonjs/Misc/smartArray";
  18006. import { Nullable } from "babylonjs/types";
  18007. import { Scene } from "babylonjs/scene";
  18008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18011. import { Mesh } from "babylonjs/Meshes/mesh";
  18012. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18013. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18014. import { Effect } from "babylonjs/Materials/effect";
  18015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18017. import "babylonjs/Shaders/shadowMap.fragment";
  18018. import "babylonjs/Shaders/shadowMap.vertex";
  18019. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18020. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18021. import { Observable } from "babylonjs/Misc/observable";
  18022. /**
  18023. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18024. */
  18025. export interface ICustomShaderOptions {
  18026. /**
  18027. * Gets or sets the custom shader name to use
  18028. */
  18029. shaderName: string;
  18030. /**
  18031. * The list of attribute names used in the shader
  18032. */
  18033. attributes?: string[];
  18034. /**
  18035. * The list of unifrom names used in the shader
  18036. */
  18037. uniforms?: string[];
  18038. /**
  18039. * The list of sampler names used in the shader
  18040. */
  18041. samplers?: string[];
  18042. /**
  18043. * The list of defines used in the shader
  18044. */
  18045. defines?: string[];
  18046. }
  18047. /**
  18048. * Interface to implement to create a shadow generator compatible with BJS.
  18049. */
  18050. export interface IShadowGenerator {
  18051. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18052. id: string;
  18053. /**
  18054. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18055. * @returns The render target texture if present otherwise, null
  18056. */
  18057. getShadowMap(): Nullable<RenderTargetTexture>;
  18058. /**
  18059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18060. * @param subMesh The submesh we want to render in the shadow map
  18061. * @param useInstances Defines wether will draw in the map using instances
  18062. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18063. * @returns true if ready otherwise, false
  18064. */
  18065. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18066. /**
  18067. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18068. * @param defines Defines of the material we want to update
  18069. * @param lightIndex Index of the light in the enabled light list of the material
  18070. */
  18071. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18072. /**
  18073. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18074. * defined in the generator but impacting the effect).
  18075. * It implies the unifroms available on the materials are the standard BJS ones.
  18076. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18077. * @param effect The effect we are binfing the information for
  18078. */
  18079. bindShadowLight(lightIndex: string, effect: Effect): void;
  18080. /**
  18081. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18082. * (eq to shadow prjection matrix * light transform matrix)
  18083. * @returns The transform matrix used to create the shadow map
  18084. */
  18085. getTransformMatrix(): Matrix;
  18086. /**
  18087. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18088. * Cube and 2D textures for instance.
  18089. */
  18090. recreateShadowMap(): void;
  18091. /**
  18092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18093. * @param onCompiled Callback triggered at the and of the effects compilation
  18094. * @param options Sets of optional options forcing the compilation with different modes
  18095. */
  18096. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18097. useInstances: boolean;
  18098. }>): void;
  18099. /**
  18100. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18101. * @param options Sets of optional options forcing the compilation with different modes
  18102. * @returns A promise that resolves when the compilation completes
  18103. */
  18104. forceCompilationAsync(options?: Partial<{
  18105. useInstances: boolean;
  18106. }>): Promise<void>;
  18107. /**
  18108. * Serializes the shadow generator setup to a json object.
  18109. * @returns The serialized JSON object
  18110. */
  18111. serialize(): any;
  18112. /**
  18113. * Disposes the Shadow map and related Textures and effects.
  18114. */
  18115. dispose(): void;
  18116. }
  18117. /**
  18118. * Default implementation IShadowGenerator.
  18119. * This is the main object responsible of generating shadows in the framework.
  18120. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18121. */
  18122. export class ShadowGenerator implements IShadowGenerator {
  18123. /**
  18124. * Name of the shadow generator class
  18125. */
  18126. static CLASSNAME: string;
  18127. /**
  18128. * Shadow generator mode None: no filtering applied.
  18129. */
  18130. static readonly FILTER_NONE: number;
  18131. /**
  18132. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18134. */
  18135. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18136. /**
  18137. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18138. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18139. */
  18140. static readonly FILTER_POISSONSAMPLING: number;
  18141. /**
  18142. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18143. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18144. */
  18145. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18146. /**
  18147. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18148. * edge artifacts on steep falloff.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18154. * edge artifacts on steep falloff.
  18155. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18156. */
  18157. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18158. /**
  18159. * Shadow generator mode PCF: Percentage Closer Filtering
  18160. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18161. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18162. */
  18163. static readonly FILTER_PCF: number;
  18164. /**
  18165. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18166. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18167. * Contact Hardening
  18168. */
  18169. static readonly FILTER_PCSS: number;
  18170. /**
  18171. * Reserved for PCF and PCSS
  18172. * Highest Quality.
  18173. *
  18174. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18175. *
  18176. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18177. */
  18178. static readonly QUALITY_HIGH: number;
  18179. /**
  18180. * Reserved for PCF and PCSS
  18181. * Good tradeoff for quality/perf cross devices
  18182. *
  18183. * Execute PCF on a 3*3 kernel.
  18184. *
  18185. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18186. */
  18187. static readonly QUALITY_MEDIUM: number;
  18188. /**
  18189. * Reserved for PCF and PCSS
  18190. * The lowest quality but the fastest.
  18191. *
  18192. * Execute PCF on a 1*1 kernel.
  18193. *
  18194. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18195. */
  18196. static readonly QUALITY_LOW: number;
  18197. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18198. id: string;
  18199. /** Gets or sets the custom shader name to use */
  18200. customShaderOptions: ICustomShaderOptions;
  18201. /**
  18202. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18203. */
  18204. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18205. /**
  18206. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18207. */
  18208. onAfterShadowMapRenderObservable: Observable<Effect>;
  18209. /**
  18210. * Observable triggered before a mesh is rendered in the shadow map.
  18211. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18212. */
  18213. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18214. /**
  18215. * Observable triggered after a mesh is rendered in the shadow map.
  18216. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18217. */
  18218. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18219. protected _bias: number;
  18220. /**
  18221. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18222. */
  18223. get bias(): number;
  18224. /**
  18225. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18226. */
  18227. set bias(bias: number);
  18228. protected _normalBias: number;
  18229. /**
  18230. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18231. */
  18232. get normalBias(): number;
  18233. /**
  18234. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18235. */
  18236. set normalBias(normalBias: number);
  18237. protected _blurBoxOffset: number;
  18238. /**
  18239. * Gets the blur box offset: offset applied during the blur pass.
  18240. * Only useful if useKernelBlur = false
  18241. */
  18242. get blurBoxOffset(): number;
  18243. /**
  18244. * Sets the blur box offset: offset applied during the blur pass.
  18245. * Only useful if useKernelBlur = false
  18246. */
  18247. set blurBoxOffset(value: number);
  18248. protected _blurScale: number;
  18249. /**
  18250. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18251. * 2 means half of the size.
  18252. */
  18253. get blurScale(): number;
  18254. /**
  18255. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18256. * 2 means half of the size.
  18257. */
  18258. set blurScale(value: number);
  18259. protected _blurKernel: number;
  18260. /**
  18261. * Gets the blur kernel: kernel size of the blur pass.
  18262. * Only useful if useKernelBlur = true
  18263. */
  18264. get blurKernel(): number;
  18265. /**
  18266. * Sets the blur kernel: kernel size of the blur pass.
  18267. * Only useful if useKernelBlur = true
  18268. */
  18269. set blurKernel(value: number);
  18270. protected _useKernelBlur: boolean;
  18271. /**
  18272. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18273. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18274. */
  18275. get useKernelBlur(): boolean;
  18276. /**
  18277. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18278. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18279. */
  18280. set useKernelBlur(value: boolean);
  18281. protected _depthScale: number;
  18282. /**
  18283. * Gets the depth scale used in ESM mode.
  18284. */
  18285. get depthScale(): number;
  18286. /**
  18287. * Sets the depth scale used in ESM mode.
  18288. * This can override the scale stored on the light.
  18289. */
  18290. set depthScale(value: number);
  18291. protected _validateFilter(filter: number): number;
  18292. protected _filter: number;
  18293. /**
  18294. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18295. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18296. */
  18297. get filter(): number;
  18298. /**
  18299. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18300. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18301. */
  18302. set filter(value: number);
  18303. /**
  18304. * Gets if the current filter is set to Poisson Sampling.
  18305. */
  18306. get usePoissonSampling(): boolean;
  18307. /**
  18308. * Sets the current filter to Poisson Sampling.
  18309. */
  18310. set usePoissonSampling(value: boolean);
  18311. /**
  18312. * Gets if the current filter is set to ESM.
  18313. */
  18314. get useExponentialShadowMap(): boolean;
  18315. /**
  18316. * Sets the current filter is to ESM.
  18317. */
  18318. set useExponentialShadowMap(value: boolean);
  18319. /**
  18320. * Gets if the current filter is set to filtered ESM.
  18321. */
  18322. get useBlurExponentialShadowMap(): boolean;
  18323. /**
  18324. * Gets if the current filter is set to filtered ESM.
  18325. */
  18326. set useBlurExponentialShadowMap(value: boolean);
  18327. /**
  18328. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18329. * exponential to prevent steep falloff artifacts).
  18330. */
  18331. get useCloseExponentialShadowMap(): boolean;
  18332. /**
  18333. * Sets the current filter to "close ESM" (using the inverse of the
  18334. * exponential to prevent steep falloff artifacts).
  18335. */
  18336. set useCloseExponentialShadowMap(value: boolean);
  18337. /**
  18338. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18339. * exponential to prevent steep falloff artifacts).
  18340. */
  18341. get useBlurCloseExponentialShadowMap(): boolean;
  18342. /**
  18343. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18344. * exponential to prevent steep falloff artifacts).
  18345. */
  18346. set useBlurCloseExponentialShadowMap(value: boolean);
  18347. /**
  18348. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18349. */
  18350. get usePercentageCloserFiltering(): boolean;
  18351. /**
  18352. * Sets the current filter to "PCF" (percentage closer filtering).
  18353. */
  18354. set usePercentageCloserFiltering(value: boolean);
  18355. protected _filteringQuality: number;
  18356. /**
  18357. * Gets the PCF or PCSS Quality.
  18358. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18359. */
  18360. get filteringQuality(): number;
  18361. /**
  18362. * Sets the PCF or PCSS Quality.
  18363. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18364. */
  18365. set filteringQuality(filteringQuality: number);
  18366. /**
  18367. * Gets if the current filter is set to "PCSS" (contact hardening).
  18368. */
  18369. get useContactHardeningShadow(): boolean;
  18370. /**
  18371. * Sets the current filter to "PCSS" (contact hardening).
  18372. */
  18373. set useContactHardeningShadow(value: boolean);
  18374. protected _contactHardeningLightSizeUVRatio: number;
  18375. /**
  18376. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18377. * Using a ratio helps keeping shape stability independently of the map size.
  18378. *
  18379. * It does not account for the light projection as it was having too much
  18380. * instability during the light setup or during light position changes.
  18381. *
  18382. * Only valid if useContactHardeningShadow is true.
  18383. */
  18384. get contactHardeningLightSizeUVRatio(): number;
  18385. /**
  18386. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18387. * Using a ratio helps keeping shape stability independently of the map size.
  18388. *
  18389. * It does not account for the light projection as it was having too much
  18390. * instability during the light setup or during light position changes.
  18391. *
  18392. * Only valid if useContactHardeningShadow is true.
  18393. */
  18394. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18395. protected _darkness: number;
  18396. /** Gets or sets the actual darkness of a shadow */
  18397. get darkness(): number;
  18398. set darkness(value: number);
  18399. /**
  18400. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18401. * 0 means strongest and 1 would means no shadow.
  18402. * @returns the darkness.
  18403. */
  18404. getDarkness(): number;
  18405. /**
  18406. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18407. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18408. * @returns the shadow generator allowing fluent coding.
  18409. */
  18410. setDarkness(darkness: number): ShadowGenerator;
  18411. protected _transparencyShadow: boolean;
  18412. /** Gets or sets the ability to have transparent shadow */
  18413. get transparencyShadow(): boolean;
  18414. set transparencyShadow(value: boolean);
  18415. /**
  18416. * Sets the ability to have transparent shadow (boolean).
  18417. * @param transparent True if transparent else False
  18418. * @returns the shadow generator allowing fluent coding
  18419. */
  18420. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18421. /**
  18422. * Enables or disables shadows with varying strength based on the transparency
  18423. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18424. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18425. * mesh.visibility * alphaTexture.a
  18426. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18427. */
  18428. enableSoftTransparentShadow: boolean;
  18429. protected _shadowMap: Nullable<RenderTargetTexture>;
  18430. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18431. /**
  18432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18433. * @returns The render target texture if present otherwise, null
  18434. */
  18435. getShadowMap(): Nullable<RenderTargetTexture>;
  18436. /**
  18437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18438. * @returns The render target texture if the shadow map is present otherwise, null
  18439. */
  18440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18441. /**
  18442. * Gets the class name of that object
  18443. * @returns "ShadowGenerator"
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18448. * @param mesh Mesh to add
  18449. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18450. * @returns the Shadow Generator itself
  18451. */
  18452. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18453. /**
  18454. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18455. * @param mesh Mesh to remove
  18456. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18457. * @returns the Shadow Generator itself
  18458. */
  18459. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18460. /**
  18461. * Controls the extent to which the shadows fade out at the edge of the frustum
  18462. */
  18463. frustumEdgeFalloff: number;
  18464. protected _light: IShadowLight;
  18465. /**
  18466. * Returns the associated light object.
  18467. * @returns the light generating the shadow
  18468. */
  18469. getLight(): IShadowLight;
  18470. /**
  18471. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18472. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18473. * It might on the other hand introduce peter panning.
  18474. */
  18475. forceBackFacesOnly: boolean;
  18476. protected _scene: Scene;
  18477. protected _lightDirection: Vector3;
  18478. protected _effect: Effect;
  18479. protected _viewMatrix: Matrix;
  18480. protected _projectionMatrix: Matrix;
  18481. protected _transformMatrix: Matrix;
  18482. protected _cachedPosition: Vector3;
  18483. protected _cachedDirection: Vector3;
  18484. protected _cachedDefines: string;
  18485. protected _currentRenderID: number;
  18486. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18487. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18488. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18489. protected _blurPostProcesses: PostProcess[];
  18490. protected _mapSize: number;
  18491. protected _currentFaceIndex: number;
  18492. protected _currentFaceIndexCache: number;
  18493. protected _textureType: number;
  18494. protected _defaultTextureMatrix: Matrix;
  18495. protected _storedUniqueId: Nullable<number>;
  18496. /** @hidden */
  18497. static _SceneComponentInitialization: (scene: Scene) => void;
  18498. /**
  18499. * Gets or sets the size of the texture what stores the shadows
  18500. */
  18501. get mapSize(): number;
  18502. set mapSize(size: number);
  18503. /**
  18504. * Creates a ShadowGenerator object.
  18505. * A ShadowGenerator is the required tool to use the shadows.
  18506. * Each light casting shadows needs to use its own ShadowGenerator.
  18507. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18508. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18509. * @param light The light object generating the shadows.
  18510. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18511. */
  18512. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18513. protected _initializeGenerator(): void;
  18514. protected _createTargetRenderTexture(): void;
  18515. protected _initializeShadowMap(): void;
  18516. protected _initializeBlurRTTAndPostProcesses(): void;
  18517. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18518. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18519. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18520. protected _applyFilterValues(): void;
  18521. /**
  18522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18523. * @param onCompiled Callback triggered at the and of the effects compilation
  18524. * @param options Sets of optional options forcing the compilation with different modes
  18525. */
  18526. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18527. useInstances: boolean;
  18528. }>): void;
  18529. /**
  18530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18531. * @param options Sets of optional options forcing the compilation with different modes
  18532. * @returns A promise that resolves when the compilation completes
  18533. */
  18534. forceCompilationAsync(options?: Partial<{
  18535. useInstances: boolean;
  18536. }>): Promise<void>;
  18537. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18538. private _prepareShadowDefines;
  18539. /**
  18540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18541. * @param subMesh The submesh we want to render in the shadow map
  18542. * @param useInstances Defines wether will draw in the map using instances
  18543. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18544. * @returns true if ready otherwise, false
  18545. */
  18546. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18547. /**
  18548. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18549. * @param defines Defines of the material we want to update
  18550. * @param lightIndex Index of the light in the enabled light list of the material
  18551. */
  18552. prepareDefines(defines: any, lightIndex: number): void;
  18553. /**
  18554. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18555. * defined in the generator but impacting the effect).
  18556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18557. * @param effect The effect we are binfing the information for
  18558. */
  18559. bindShadowLight(lightIndex: string, effect: Effect): void;
  18560. /**
  18561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18562. * (eq to shadow prjection matrix * light transform matrix)
  18563. * @returns The transform matrix used to create the shadow map
  18564. */
  18565. getTransformMatrix(): Matrix;
  18566. /**
  18567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18568. * Cube and 2D textures for instance.
  18569. */
  18570. recreateShadowMap(): void;
  18571. protected _disposeBlurPostProcesses(): void;
  18572. protected _disposeRTTandPostProcesses(): void;
  18573. /**
  18574. * Disposes the ShadowGenerator.
  18575. * Returns nothing.
  18576. */
  18577. dispose(): void;
  18578. /**
  18579. * Serializes the shadow generator setup to a json object.
  18580. * @returns The serialized JSON object
  18581. */
  18582. serialize(): any;
  18583. /**
  18584. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18585. * @param parsedShadowGenerator The JSON object to parse
  18586. * @param scene The scene to create the shadow map for
  18587. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18588. * @returns The parsed shadow generator
  18589. */
  18590. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18591. }
  18592. }
  18593. declare module "babylonjs/Lights/light" {
  18594. import { Nullable } from "babylonjs/types";
  18595. import { Scene } from "babylonjs/scene";
  18596. import { Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3 } from "babylonjs/Maths/math.color";
  18598. import { Node } from "babylonjs/node";
  18599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18600. import { Effect } from "babylonjs/Materials/effect";
  18601. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18602. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18603. /**
  18604. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18605. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18606. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18607. */
  18608. export abstract class Light extends Node {
  18609. /**
  18610. * Falloff Default: light is falling off following the material specification:
  18611. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18612. */
  18613. static readonly FALLOFF_DEFAULT: number;
  18614. /**
  18615. * Falloff Physical: light is falling off following the inverse squared distance law.
  18616. */
  18617. static readonly FALLOFF_PHYSICAL: number;
  18618. /**
  18619. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18620. * to enhance interoperability with other engines.
  18621. */
  18622. static readonly FALLOFF_GLTF: number;
  18623. /**
  18624. * Falloff Standard: light is falling off like in the standard material
  18625. * to enhance interoperability with other materials.
  18626. */
  18627. static readonly FALLOFF_STANDARD: number;
  18628. /**
  18629. * If every light affecting the material is in this lightmapMode,
  18630. * material.lightmapTexture adds or multiplies
  18631. * (depends on material.useLightmapAsShadowmap)
  18632. * after every other light calculations.
  18633. */
  18634. static readonly LIGHTMAP_DEFAULT: number;
  18635. /**
  18636. * material.lightmapTexture as only diffuse lighting from this light
  18637. * adds only specular lighting from this light
  18638. * adds dynamic shadows
  18639. */
  18640. static readonly LIGHTMAP_SPECULAR: number;
  18641. /**
  18642. * material.lightmapTexture as only lighting
  18643. * no light calculation from this light
  18644. * only adds dynamic shadows from this light
  18645. */
  18646. static readonly LIGHTMAP_SHADOWSONLY: number;
  18647. /**
  18648. * Each light type uses the default quantity according to its type:
  18649. * point/spot lights use luminous intensity
  18650. * directional lights use illuminance
  18651. */
  18652. static readonly INTENSITYMODE_AUTOMATIC: number;
  18653. /**
  18654. * lumen (lm)
  18655. */
  18656. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18657. /**
  18658. * candela (lm/sr)
  18659. */
  18660. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18661. /**
  18662. * lux (lm/m^2)
  18663. */
  18664. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18665. /**
  18666. * nit (cd/m^2)
  18667. */
  18668. static readonly INTENSITYMODE_LUMINANCE: number;
  18669. /**
  18670. * Light type const id of the point light.
  18671. */
  18672. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18673. /**
  18674. * Light type const id of the directional light.
  18675. */
  18676. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18677. /**
  18678. * Light type const id of the spot light.
  18679. */
  18680. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18681. /**
  18682. * Light type const id of the hemispheric light.
  18683. */
  18684. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18685. /**
  18686. * Diffuse gives the basic color to an object.
  18687. */
  18688. diffuse: Color3;
  18689. /**
  18690. * Specular produces a highlight color on an object.
  18691. * Note: This is note affecting PBR materials.
  18692. */
  18693. specular: Color3;
  18694. /**
  18695. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18696. * falling off base on range or angle.
  18697. * This can be set to any values in Light.FALLOFF_x.
  18698. *
  18699. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18700. * other types of materials.
  18701. */
  18702. falloffType: number;
  18703. /**
  18704. * Strength of the light.
  18705. * Note: By default it is define in the framework own unit.
  18706. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18707. */
  18708. intensity: number;
  18709. private _range;
  18710. protected _inverseSquaredRange: number;
  18711. /**
  18712. * Defines how far from the source the light is impacting in scene units.
  18713. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18714. */
  18715. get range(): number;
  18716. /**
  18717. * Defines how far from the source the light is impacting in scene units.
  18718. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18719. */
  18720. set range(value: number);
  18721. /**
  18722. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18723. * of light.
  18724. */
  18725. private _photometricScale;
  18726. private _intensityMode;
  18727. /**
  18728. * Gets the photometric scale used to interpret the intensity.
  18729. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18730. */
  18731. get intensityMode(): number;
  18732. /**
  18733. * Sets the photometric scale used to interpret the intensity.
  18734. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18735. */
  18736. set intensityMode(value: number);
  18737. private _radius;
  18738. /**
  18739. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18740. */
  18741. get radius(): number;
  18742. /**
  18743. * sets the light radius used by PBR Materials to simulate soft area lights.
  18744. */
  18745. set radius(value: number);
  18746. private _renderPriority;
  18747. /**
  18748. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18749. * exceeding the number allowed of the materials.
  18750. */
  18751. renderPriority: number;
  18752. private _shadowEnabled;
  18753. /**
  18754. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18755. * the current shadow generator.
  18756. */
  18757. get shadowEnabled(): boolean;
  18758. /**
  18759. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18760. * the current shadow generator.
  18761. */
  18762. set shadowEnabled(value: boolean);
  18763. private _includedOnlyMeshes;
  18764. /**
  18765. * Gets the only meshes impacted by this light.
  18766. */
  18767. get includedOnlyMeshes(): AbstractMesh[];
  18768. /**
  18769. * Sets the only meshes impacted by this light.
  18770. */
  18771. set includedOnlyMeshes(value: AbstractMesh[]);
  18772. private _excludedMeshes;
  18773. /**
  18774. * Gets the meshes not impacted by this light.
  18775. */
  18776. get excludedMeshes(): AbstractMesh[];
  18777. /**
  18778. * Sets the meshes not impacted by this light.
  18779. */
  18780. set excludedMeshes(value: AbstractMesh[]);
  18781. private _excludeWithLayerMask;
  18782. /**
  18783. * Gets the layer id use to find what meshes are not impacted by the light.
  18784. * Inactive if 0
  18785. */
  18786. get excludeWithLayerMask(): number;
  18787. /**
  18788. * Sets the layer id use to find what meshes are not impacted by the light.
  18789. * Inactive if 0
  18790. */
  18791. set excludeWithLayerMask(value: number);
  18792. private _includeOnlyWithLayerMask;
  18793. /**
  18794. * Gets the layer id use to find what meshes are impacted by the light.
  18795. * Inactive if 0
  18796. */
  18797. get includeOnlyWithLayerMask(): number;
  18798. /**
  18799. * Sets the layer id use to find what meshes are impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. set includeOnlyWithLayerMask(value: number);
  18803. private _lightmapMode;
  18804. /**
  18805. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18806. */
  18807. get lightmapMode(): number;
  18808. /**
  18809. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18810. */
  18811. set lightmapMode(value: number);
  18812. /**
  18813. * Shadow generator associted to the light.
  18814. * @hidden Internal use only.
  18815. */
  18816. _shadowGenerator: Nullable<IShadowGenerator>;
  18817. /**
  18818. * @hidden Internal use only.
  18819. */
  18820. _excludedMeshesIds: string[];
  18821. /**
  18822. * @hidden Internal use only.
  18823. */
  18824. _includedOnlyMeshesIds: string[];
  18825. /**
  18826. * The current light unifom buffer.
  18827. * @hidden Internal use only.
  18828. */
  18829. _uniformBuffer: UniformBuffer;
  18830. /** @hidden */
  18831. _renderId: number;
  18832. /**
  18833. * Creates a Light object in the scene.
  18834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18835. * @param name The firendly name of the light
  18836. * @param scene The scene the light belongs too
  18837. */
  18838. constructor(name: string, scene: Scene);
  18839. protected abstract _buildUniformLayout(): void;
  18840. /**
  18841. * Sets the passed Effect "effect" with the Light information.
  18842. * @param effect The effect to update
  18843. * @param lightIndex The index of the light in the effect to update
  18844. * @returns The light
  18845. */
  18846. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18847. /**
  18848. * Sets the passed Effect "effect" with the Light textures.
  18849. * @param effect The effect to update
  18850. * @param lightIndex The index of the light in the effect to update
  18851. * @returns The light
  18852. */
  18853. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18854. /**
  18855. * Binds the lights information from the scene to the effect for the given mesh.
  18856. * @param lightIndex Light index
  18857. * @param scene The scene where the light belongs to
  18858. * @param effect The effect we are binding the data to
  18859. * @param useSpecular Defines if specular is supported
  18860. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18861. */
  18862. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18863. /**
  18864. * Sets the passed Effect "effect" with the Light information.
  18865. * @param effect The effect to update
  18866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18867. * @returns The light
  18868. */
  18869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18870. /**
  18871. * Returns the string "Light".
  18872. * @returns the class name
  18873. */
  18874. getClassName(): string;
  18875. /** @hidden */
  18876. readonly _isLight: boolean;
  18877. /**
  18878. * Converts the light information to a readable string for debug purpose.
  18879. * @param fullDetails Supports for multiple levels of logging within scene loading
  18880. * @returns the human readable light info
  18881. */
  18882. toString(fullDetails?: boolean): string;
  18883. /** @hidden */
  18884. protected _syncParentEnabledState(): void;
  18885. /**
  18886. * Set the enabled state of this node.
  18887. * @param value - the new enabled state
  18888. */
  18889. setEnabled(value: boolean): void;
  18890. /**
  18891. * Returns the Light associated shadow generator if any.
  18892. * @return the associated shadow generator.
  18893. */
  18894. getShadowGenerator(): Nullable<IShadowGenerator>;
  18895. /**
  18896. * Returns a Vector3, the absolute light position in the World.
  18897. * @returns the world space position of the light
  18898. */
  18899. getAbsolutePosition(): Vector3;
  18900. /**
  18901. * Specifies if the light will affect the passed mesh.
  18902. * @param mesh The mesh to test against the light
  18903. * @return true the mesh is affected otherwise, false.
  18904. */
  18905. canAffectMesh(mesh: AbstractMesh): boolean;
  18906. /**
  18907. * Sort function to order lights for rendering.
  18908. * @param a First Light object to compare to second.
  18909. * @param b Second Light object to compare first.
  18910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18911. */
  18912. static CompareLightsPriority(a: Light, b: Light): number;
  18913. /**
  18914. * Releases resources associated with this node.
  18915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18917. */
  18918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18919. /**
  18920. * Returns the light type ID (integer).
  18921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18922. */
  18923. getTypeID(): number;
  18924. /**
  18925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18926. * @returns the scaled intensity in intensity mode unit
  18927. */
  18928. getScaledIntensity(): number;
  18929. /**
  18930. * Returns a new Light object, named "name", from the current one.
  18931. * @param name The name of the cloned light
  18932. * @param newParent The parent of this light, if it has one
  18933. * @returns the new created light
  18934. */
  18935. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18936. /**
  18937. * Serializes the current light into a Serialization object.
  18938. * @returns the serialized object.
  18939. */
  18940. serialize(): any;
  18941. /**
  18942. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18943. * This new light is named "name" and added to the passed scene.
  18944. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18945. * @param name The friendly name of the light
  18946. * @param scene The scene the new light will belong to
  18947. * @returns the constructor function
  18948. */
  18949. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18950. /**
  18951. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18952. * @param parsedLight The JSON representation of the light
  18953. * @param scene The scene to create the parsed light in
  18954. * @returns the created light after parsing
  18955. */
  18956. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18957. private _hookArrayForExcluded;
  18958. private _hookArrayForIncludedOnly;
  18959. private _resyncMeshes;
  18960. /**
  18961. * Forces the meshes to update their light related information in their rendering used effects
  18962. * @hidden Internal Use Only
  18963. */
  18964. _markMeshesAsLightDirty(): void;
  18965. /**
  18966. * Recomputes the cached photometric scale if needed.
  18967. */
  18968. private _computePhotometricScale;
  18969. /**
  18970. * Returns the Photometric Scale according to the light type and intensity mode.
  18971. */
  18972. private _getPhotometricScale;
  18973. /**
  18974. * Reorder the light in the scene according to their defined priority.
  18975. * @hidden Internal Use Only
  18976. */
  18977. _reorderLightsInScene(): void;
  18978. /**
  18979. * Prepares the list of defines specific to the light type.
  18980. * @param defines the list of defines
  18981. * @param lightIndex defines the index of the light for the effect
  18982. */
  18983. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18984. }
  18985. }
  18986. declare module "babylonjs/Materials/prePassConfiguration" {
  18987. import { Matrix } from "babylonjs/Maths/math.vector";
  18988. import { Mesh } from "babylonjs/Meshes/mesh";
  18989. import { Scene } from "babylonjs/scene";
  18990. import { Effect } from "babylonjs/Materials/effect";
  18991. /**
  18992. * Configuration needed for prepass-capable materials
  18993. */
  18994. export class PrePassConfiguration {
  18995. /**
  18996. * Previous world matrices of meshes carrying this material
  18997. * Used for computing velocity
  18998. */
  18999. previousWorldMatrices: {
  19000. [index: number]: Matrix;
  19001. };
  19002. /**
  19003. * Previous view project matrix
  19004. * Used for computing velocity
  19005. */
  19006. previousViewProjection: Matrix;
  19007. /**
  19008. * Previous bones of meshes carrying this material
  19009. * Used for computing velocity
  19010. */
  19011. previousBones: {
  19012. [index: number]: Float32Array;
  19013. };
  19014. /**
  19015. * Add the required uniforms to the current list.
  19016. * @param uniforms defines the current uniform list.
  19017. */
  19018. static AddUniforms(uniforms: string[]): void;
  19019. /**
  19020. * Add the required samplers to the current list.
  19021. * @param samplers defines the current sampler list.
  19022. */
  19023. static AddSamplers(samplers: string[]): void;
  19024. /**
  19025. * Binds the material data.
  19026. * @param effect defines the effect to update
  19027. * @param scene defines the scene the material belongs to.
  19028. * @param mesh The mesh
  19029. * @param world World matrix of this mesh
  19030. * @param isFrozen Is the material frozen
  19031. */
  19032. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19033. }
  19034. }
  19035. declare module "babylonjs/Cameras/targetCamera" {
  19036. import { Nullable } from "babylonjs/types";
  19037. import { Camera } from "babylonjs/Cameras/camera";
  19038. import { Scene } from "babylonjs/scene";
  19039. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19040. /**
  19041. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19042. * This is the base of the follow, arc rotate cameras and Free camera
  19043. * @see https://doc.babylonjs.com/features/cameras
  19044. */
  19045. export class TargetCamera extends Camera {
  19046. private static _RigCamTransformMatrix;
  19047. private static _TargetTransformMatrix;
  19048. private static _TargetFocalPoint;
  19049. private _tmpUpVector;
  19050. private _tmpTargetVector;
  19051. /**
  19052. * Define the current direction the camera is moving to
  19053. */
  19054. cameraDirection: Vector3;
  19055. /**
  19056. * Define the current rotation the camera is rotating to
  19057. */
  19058. cameraRotation: Vector2;
  19059. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19060. ignoreParentScaling: boolean;
  19061. /**
  19062. * When set, the up vector of the camera will be updated by the rotation of the camera
  19063. */
  19064. updateUpVectorFromRotation: boolean;
  19065. private _tmpQuaternion;
  19066. /**
  19067. * Define the current rotation of the camera
  19068. */
  19069. rotation: Vector3;
  19070. /**
  19071. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19072. */
  19073. rotationQuaternion: Quaternion;
  19074. /**
  19075. * Define the current speed of the camera
  19076. */
  19077. speed: number;
  19078. /**
  19079. * Add constraint to the camera to prevent it to move freely in all directions and
  19080. * around all axis.
  19081. */
  19082. noRotationConstraint: boolean;
  19083. /**
  19084. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19085. * panning
  19086. */
  19087. invertRotation: boolean;
  19088. /**
  19089. * Speed multiplier for inverse camera panning
  19090. */
  19091. inverseRotationSpeed: number;
  19092. /**
  19093. * Define the current target of the camera as an object or a position.
  19094. */
  19095. lockedTarget: any;
  19096. /** @hidden */
  19097. _currentTarget: Vector3;
  19098. /** @hidden */
  19099. _initialFocalDistance: number;
  19100. /** @hidden */
  19101. _viewMatrix: Matrix;
  19102. /** @hidden */
  19103. _camMatrix: Matrix;
  19104. /** @hidden */
  19105. _cameraTransformMatrix: Matrix;
  19106. /** @hidden */
  19107. _cameraRotationMatrix: Matrix;
  19108. /** @hidden */
  19109. _referencePoint: Vector3;
  19110. /** @hidden */
  19111. _transformedReferencePoint: Vector3;
  19112. /** @hidden */
  19113. _reset: () => void;
  19114. private _defaultUp;
  19115. /**
  19116. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19117. * This is the base of the follow, arc rotate cameras and Free camera
  19118. * @see https://doc.babylonjs.com/features/cameras
  19119. * @param name Defines the name of the camera in the scene
  19120. * @param position Defines the start position of the camera in the scene
  19121. * @param scene Defines the scene the camera belongs to
  19122. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19123. */
  19124. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19125. /**
  19126. * Gets the position in front of the camera at a given distance.
  19127. * @param distance The distance from the camera we want the position to be
  19128. * @returns the position
  19129. */
  19130. getFrontPosition(distance: number): Vector3;
  19131. /** @hidden */
  19132. _getLockedTargetPosition(): Nullable<Vector3>;
  19133. private _storedPosition;
  19134. private _storedRotation;
  19135. private _storedRotationQuaternion;
  19136. /**
  19137. * Store current camera state of the camera (fov, position, rotation, etc..)
  19138. * @returns the camera
  19139. */
  19140. storeState(): Camera;
  19141. /**
  19142. * Restored camera state. You must call storeState() first
  19143. * @returns whether it was successful or not
  19144. * @hidden
  19145. */
  19146. _restoreStateValues(): boolean;
  19147. /** @hidden */
  19148. _initCache(): void;
  19149. /** @hidden */
  19150. _updateCache(ignoreParentClass?: boolean): void;
  19151. /** @hidden */
  19152. _isSynchronizedViewMatrix(): boolean;
  19153. /** @hidden */
  19154. _computeLocalCameraSpeed(): number;
  19155. /**
  19156. * Defines the target the camera should look at.
  19157. * @param target Defines the new target as a Vector or a mesh
  19158. */
  19159. setTarget(target: Vector3): void;
  19160. /**
  19161. * Defines the target point of the camera.
  19162. * The camera looks towards it form the radius distance.
  19163. */
  19164. get target(): Vector3;
  19165. set target(value: Vector3);
  19166. /**
  19167. * Return the current target position of the camera. This value is expressed in local space.
  19168. * @returns the target position
  19169. */
  19170. getTarget(): Vector3;
  19171. /** @hidden */
  19172. _decideIfNeedsToMove(): boolean;
  19173. /** @hidden */
  19174. _updatePosition(): void;
  19175. /** @hidden */
  19176. _checkInputs(): void;
  19177. protected _updateCameraRotationMatrix(): void;
  19178. /**
  19179. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  19180. * @returns the current camera
  19181. */
  19182. private _rotateUpVectorWithCameraRotationMatrix;
  19183. private _cachedRotationZ;
  19184. private _cachedQuaternionRotationZ;
  19185. /** @hidden */
  19186. _getViewMatrix(): Matrix;
  19187. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19188. /**
  19189. * @hidden
  19190. */
  19191. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19192. /**
  19193. * @hidden
  19194. */
  19195. _updateRigCameras(): void;
  19196. private _getRigCamPositionAndTarget;
  19197. /**
  19198. * Gets the current object class name.
  19199. * @return the class name
  19200. */
  19201. getClassName(): string;
  19202. }
  19203. }
  19204. declare module "babylonjs/Events/keyboardEvents" {
  19205. /**
  19206. * Gather the list of keyboard event types as constants.
  19207. */
  19208. export class KeyboardEventTypes {
  19209. /**
  19210. * The keydown event is fired when a key becomes active (pressed).
  19211. */
  19212. static readonly KEYDOWN: number;
  19213. /**
  19214. * The keyup event is fired when a key has been released.
  19215. */
  19216. static readonly KEYUP: number;
  19217. }
  19218. /**
  19219. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19220. */
  19221. export class KeyboardInfo {
  19222. /**
  19223. * Defines the type of event (KeyboardEventTypes)
  19224. */
  19225. type: number;
  19226. /**
  19227. * Defines the related dom event
  19228. */
  19229. event: KeyboardEvent;
  19230. /**
  19231. * Instantiates a new keyboard info.
  19232. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19233. * @param type Defines the type of event (KeyboardEventTypes)
  19234. * @param event Defines the related dom event
  19235. */
  19236. constructor(
  19237. /**
  19238. * Defines the type of event (KeyboardEventTypes)
  19239. */
  19240. type: number,
  19241. /**
  19242. * Defines the related dom event
  19243. */
  19244. event: KeyboardEvent);
  19245. }
  19246. /**
  19247. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19248. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19249. */
  19250. export class KeyboardInfoPre extends KeyboardInfo {
  19251. /**
  19252. * Defines the type of event (KeyboardEventTypes)
  19253. */
  19254. type: number;
  19255. /**
  19256. * Defines the related dom event
  19257. */
  19258. event: KeyboardEvent;
  19259. /**
  19260. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19261. */
  19262. skipOnPointerObservable: boolean;
  19263. /**
  19264. * Instantiates a new keyboard pre info.
  19265. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19266. * @param type Defines the type of event (KeyboardEventTypes)
  19267. * @param event Defines the related dom event
  19268. */
  19269. constructor(
  19270. /**
  19271. * Defines the type of event (KeyboardEventTypes)
  19272. */
  19273. type: number,
  19274. /**
  19275. * Defines the related dom event
  19276. */
  19277. event: KeyboardEvent);
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19281. import { Nullable } from "babylonjs/types";
  19282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19284. /**
  19285. * Manage the keyboard inputs to control the movement of a free camera.
  19286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19287. */
  19288. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19289. /**
  19290. * Defines the camera the input is attached to.
  19291. */
  19292. camera: FreeCamera;
  19293. /**
  19294. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19295. */
  19296. keysUp: number[];
  19297. /**
  19298. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19299. */
  19300. keysUpward: number[];
  19301. /**
  19302. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19303. */
  19304. keysDown: number[];
  19305. /**
  19306. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19307. */
  19308. keysDownward: number[];
  19309. /**
  19310. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19311. */
  19312. keysLeft: number[];
  19313. /**
  19314. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19315. */
  19316. keysRight: number[];
  19317. private _keys;
  19318. private _onCanvasBlurObserver;
  19319. private _onKeyboardObserver;
  19320. private _engine;
  19321. private _scene;
  19322. /**
  19323. * Attach the input controls to a specific dom element to get the input from.
  19324. * @param element Defines the element the controls should be listened from
  19325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19326. */
  19327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19328. /**
  19329. * Detach the current controls from the specified dom element.
  19330. * @param element Defines the element to stop listening the inputs from
  19331. */
  19332. detachControl(element: Nullable<HTMLElement>): void;
  19333. /**
  19334. * Update the current camera state depending on the inputs that have been used this frame.
  19335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19336. */
  19337. checkInputs(): void;
  19338. /**
  19339. * Gets the class name of the current intput.
  19340. * @returns the class name
  19341. */
  19342. getClassName(): string;
  19343. /** @hidden */
  19344. _onLostFocus(): void;
  19345. /**
  19346. * Get the friendly name associated with the input class.
  19347. * @returns the input friendly name
  19348. */
  19349. getSimpleName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Events/pointerEvents" {
  19353. import { Nullable } from "babylonjs/types";
  19354. import { Vector2 } from "babylonjs/Maths/math.vector";
  19355. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19356. import { Ray } from "babylonjs/Culling/ray";
  19357. /**
  19358. * Gather the list of pointer event types as constants.
  19359. */
  19360. export class PointerEventTypes {
  19361. /**
  19362. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  19363. */
  19364. static readonly POINTERDOWN: number;
  19365. /**
  19366. * The pointerup event is fired when a pointer is no longer active.
  19367. */
  19368. static readonly POINTERUP: number;
  19369. /**
  19370. * The pointermove event is fired when a pointer changes coordinates.
  19371. */
  19372. static readonly POINTERMOVE: number;
  19373. /**
  19374. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19375. */
  19376. static readonly POINTERWHEEL: number;
  19377. /**
  19378. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19379. */
  19380. static readonly POINTERPICK: number;
  19381. /**
  19382. * The pointertap event is fired when a the object has been touched and released without drag.
  19383. */
  19384. static readonly POINTERTAP: number;
  19385. /**
  19386. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19387. */
  19388. static readonly POINTERDOUBLETAP: number;
  19389. }
  19390. /**
  19391. * Base class of pointer info types.
  19392. */
  19393. export class PointerInfoBase {
  19394. /**
  19395. * Defines the type of event (PointerEventTypes)
  19396. */
  19397. type: number;
  19398. /**
  19399. * Defines the related dom event
  19400. */
  19401. event: PointerEvent | MouseWheelEvent;
  19402. /**
  19403. * Instantiates the base class of pointers info.
  19404. * @param type Defines the type of event (PointerEventTypes)
  19405. * @param event Defines the related dom event
  19406. */
  19407. constructor(
  19408. /**
  19409. * Defines the type of event (PointerEventTypes)
  19410. */
  19411. type: number,
  19412. /**
  19413. * Defines the related dom event
  19414. */
  19415. event: PointerEvent | MouseWheelEvent);
  19416. }
  19417. /**
  19418. * This class is used to store pointer related info for the onPrePointerObservable event.
  19419. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19420. */
  19421. export class PointerInfoPre extends PointerInfoBase {
  19422. /**
  19423. * Ray from a pointer if availible (eg. 6dof controller)
  19424. */
  19425. ray: Nullable<Ray>;
  19426. /**
  19427. * Defines the local position of the pointer on the canvas.
  19428. */
  19429. localPosition: Vector2;
  19430. /**
  19431. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19432. */
  19433. skipOnPointerObservable: boolean;
  19434. /**
  19435. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19436. * @param type Defines the type of event (PointerEventTypes)
  19437. * @param event Defines the related dom event
  19438. * @param localX Defines the local x coordinates of the pointer when the event occured
  19439. * @param localY Defines the local y coordinates of the pointer when the event occured
  19440. */
  19441. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19442. }
  19443. /**
  19444. * This type contains all the data related to a pointer event in Babylon.js.
  19445. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  19446. */
  19447. export class PointerInfo extends PointerInfoBase {
  19448. /**
  19449. * Defines the picking info associated to the info (if any)\
  19450. */
  19451. pickInfo: Nullable<PickingInfo>;
  19452. /**
  19453. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19454. * @param type Defines the type of event (PointerEventTypes)
  19455. * @param event Defines the related dom event
  19456. * @param pickInfo Defines the picking info associated to the info (if any)\
  19457. */
  19458. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19459. /**
  19460. * Defines the picking info associated to the info (if any)\
  19461. */
  19462. pickInfo: Nullable<PickingInfo>);
  19463. }
  19464. /**
  19465. * Data relating to a touch event on the screen.
  19466. */
  19467. export interface PointerTouch {
  19468. /**
  19469. * X coordinate of touch.
  19470. */
  19471. x: number;
  19472. /**
  19473. * Y coordinate of touch.
  19474. */
  19475. y: number;
  19476. /**
  19477. * Id of touch. Unique for each finger.
  19478. */
  19479. pointerId: number;
  19480. /**
  19481. * Event type passed from DOM.
  19482. */
  19483. type: any;
  19484. }
  19485. }
  19486. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19487. import { Observable } from "babylonjs/Misc/observable";
  19488. import { Nullable } from "babylonjs/types";
  19489. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19491. /**
  19492. * Manage the mouse inputs to control the movement of a free camera.
  19493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19494. */
  19495. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19496. /**
  19497. * Define if touch is enabled in the mouse input
  19498. */
  19499. touchEnabled: boolean;
  19500. /**
  19501. * Defines the camera the input is attached to.
  19502. */
  19503. camera: FreeCamera;
  19504. /**
  19505. * Defines the buttons associated with the input to handle camera move.
  19506. */
  19507. buttons: number[];
  19508. /**
  19509. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19510. */
  19511. angularSensibility: number;
  19512. private _pointerInput;
  19513. private _onMouseMove;
  19514. private _observer;
  19515. private previousPosition;
  19516. /**
  19517. * Observable for when a pointer move event occurs containing the move offset
  19518. */
  19519. onPointerMovedObservable: Observable<{
  19520. offsetX: number;
  19521. offsetY: number;
  19522. }>;
  19523. /**
  19524. * @hidden
  19525. * If the camera should be rotated automatically based on pointer movement
  19526. */
  19527. _allowCameraRotation: boolean;
  19528. /**
  19529. * Manage the mouse inputs to control the movement of a free camera.
  19530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19531. * @param touchEnabled Defines if touch is enabled or not
  19532. */
  19533. constructor(
  19534. /**
  19535. * Define if touch is enabled in the mouse input
  19536. */
  19537. touchEnabled?: boolean);
  19538. /**
  19539. * Attach the input controls to a specific dom element to get the input from.
  19540. * @param element Defines the element the controls should be listened from
  19541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19542. */
  19543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19544. /**
  19545. * Called on JS contextmenu event.
  19546. * Override this method to provide functionality.
  19547. */
  19548. protected onContextMenu(evt: PointerEvent): void;
  19549. /**
  19550. * Detach the current controls from the specified dom element.
  19551. * @param element Defines the element to stop listening the inputs from
  19552. */
  19553. detachControl(element: Nullable<HTMLElement>): void;
  19554. /**
  19555. * Gets the class name of the current intput.
  19556. * @returns the class name
  19557. */
  19558. getClassName(): string;
  19559. /**
  19560. * Get the friendly name associated with the input class.
  19561. * @returns the input friendly name
  19562. */
  19563. getSimpleName(): string;
  19564. }
  19565. }
  19566. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19567. import { Nullable } from "babylonjs/types";
  19568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19569. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19570. /**
  19571. * Manage the touch inputs to control the movement of a free camera.
  19572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19573. */
  19574. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19575. /**
  19576. * Define if mouse events can be treated as touch events
  19577. */
  19578. allowMouse: boolean;
  19579. /**
  19580. * Defines the camera the input is attached to.
  19581. */
  19582. camera: FreeCamera;
  19583. /**
  19584. * Defines the touch sensibility for rotation.
  19585. * The higher the faster.
  19586. */
  19587. touchAngularSensibility: number;
  19588. /**
  19589. * Defines the touch sensibility for move.
  19590. * The higher the faster.
  19591. */
  19592. touchMoveSensibility: number;
  19593. private _offsetX;
  19594. private _offsetY;
  19595. private _pointerPressed;
  19596. private _pointerInput;
  19597. private _observer;
  19598. private _onLostFocus;
  19599. /**
  19600. * Manage the touch inputs to control the movement of a free camera.
  19601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19602. * @param allowMouse Defines if mouse events can be treated as touch events
  19603. */
  19604. constructor(
  19605. /**
  19606. * Define if mouse events can be treated as touch events
  19607. */
  19608. allowMouse?: boolean);
  19609. /**
  19610. * Attach the input controls to a specific dom element to get the input from.
  19611. * @param element Defines the element the controls should be listened from
  19612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19613. */
  19614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19615. /**
  19616. * Detach the current controls from the specified dom element.
  19617. * @param element Defines the element to stop listening the inputs from
  19618. */
  19619. detachControl(element: Nullable<HTMLElement>): void;
  19620. /**
  19621. * Update the current camera state depending on the inputs that have been used this frame.
  19622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19623. */
  19624. checkInputs(): void;
  19625. /**
  19626. * Gets the class name of the current intput.
  19627. * @returns the class name
  19628. */
  19629. getClassName(): string;
  19630. /**
  19631. * Get the friendly name associated with the input class.
  19632. * @returns the input friendly name
  19633. */
  19634. getSimpleName(): string;
  19635. }
  19636. }
  19637. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19638. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19639. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19640. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19641. import { Nullable } from "babylonjs/types";
  19642. /**
  19643. * Default Inputs manager for the FreeCamera.
  19644. * It groups all the default supported inputs for ease of use.
  19645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19646. */
  19647. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19648. /**
  19649. * @hidden
  19650. */
  19651. _mouseInput: Nullable<FreeCameraMouseInput>;
  19652. /**
  19653. * Instantiates a new FreeCameraInputsManager.
  19654. * @param camera Defines the camera the inputs belong to
  19655. */
  19656. constructor(camera: FreeCamera);
  19657. /**
  19658. * Add keyboard input support to the input manager.
  19659. * @returns the current input manager
  19660. */
  19661. addKeyboard(): FreeCameraInputsManager;
  19662. /**
  19663. * Add mouse input support to the input manager.
  19664. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19665. * @returns the current input manager
  19666. */
  19667. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19668. /**
  19669. * Removes the mouse input support from the manager
  19670. * @returns the current input manager
  19671. */
  19672. removeMouse(): FreeCameraInputsManager;
  19673. /**
  19674. * Add touch input support to the input manager.
  19675. * @returns the current input manager
  19676. */
  19677. addTouch(): FreeCameraInputsManager;
  19678. /**
  19679. * Remove all attached input methods from a camera
  19680. */
  19681. clear(): void;
  19682. }
  19683. }
  19684. declare module "babylonjs/Cameras/freeCamera" {
  19685. import { Vector3 } from "babylonjs/Maths/math.vector";
  19686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19687. import { Scene } from "babylonjs/scene";
  19688. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19689. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19690. /**
  19691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19692. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19693. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19694. */
  19695. export class FreeCamera extends TargetCamera {
  19696. /**
  19697. * Define the collision ellipsoid of the camera.
  19698. * This is helpful to simulate a camera body like the player body around the camera
  19699. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19700. */
  19701. ellipsoid: Vector3;
  19702. /**
  19703. * Define an offset for the position of the ellipsoid around the camera.
  19704. * This can be helpful to determine the center of the body near the gravity center of the body
  19705. * instead of its head.
  19706. */
  19707. ellipsoidOffset: Vector3;
  19708. /**
  19709. * Enable or disable collisions of the camera with the rest of the scene objects.
  19710. */
  19711. checkCollisions: boolean;
  19712. /**
  19713. * Enable or disable gravity on the camera.
  19714. */
  19715. applyGravity: boolean;
  19716. /**
  19717. * Define the input manager associated to the camera.
  19718. */
  19719. inputs: FreeCameraInputsManager;
  19720. /**
  19721. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19722. * Higher values reduce sensitivity.
  19723. */
  19724. get angularSensibility(): number;
  19725. /**
  19726. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19727. * Higher values reduce sensitivity.
  19728. */
  19729. set angularSensibility(value: number);
  19730. /**
  19731. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19732. */
  19733. get keysUp(): number[];
  19734. set keysUp(value: number[]);
  19735. /**
  19736. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19737. */
  19738. get keysUpward(): number[];
  19739. set keysUpward(value: number[]);
  19740. /**
  19741. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19742. */
  19743. get keysDown(): number[];
  19744. set keysDown(value: number[]);
  19745. /**
  19746. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19747. */
  19748. get keysDownward(): number[];
  19749. set keysDownward(value: number[]);
  19750. /**
  19751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19752. */
  19753. get keysLeft(): number[];
  19754. set keysLeft(value: number[]);
  19755. /**
  19756. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19757. */
  19758. get keysRight(): number[];
  19759. set keysRight(value: number[]);
  19760. /**
  19761. * Event raised when the camera collide with a mesh in the scene.
  19762. */
  19763. onCollide: (collidedMesh: AbstractMesh) => void;
  19764. private _collider;
  19765. private _needMoveForGravity;
  19766. private _oldPosition;
  19767. private _diffPosition;
  19768. private _newPosition;
  19769. /** @hidden */
  19770. _localDirection: Vector3;
  19771. /** @hidden */
  19772. _transformedDirection: Vector3;
  19773. /**
  19774. * Instantiates a Free Camera.
  19775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19776. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19777. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19778. * @param name Define the name of the camera in the scene
  19779. * @param position Define the start position of the camera in the scene
  19780. * @param scene Define the scene the camera belongs to
  19781. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19782. */
  19783. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19784. /**
  19785. * Attached controls to the current camera.
  19786. * @param element Defines the element the controls should be listened from
  19787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19788. */
  19789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19790. /**
  19791. * Detach the current controls from the camera.
  19792. * The camera will stop reacting to inputs.
  19793. * @param element Defines the element to stop listening the inputs from
  19794. */
  19795. detachControl(element: HTMLElement): void;
  19796. private _collisionMask;
  19797. /**
  19798. * Define a collision mask to limit the list of object the camera can collide with
  19799. */
  19800. get collisionMask(): number;
  19801. set collisionMask(mask: number);
  19802. /** @hidden */
  19803. _collideWithWorld(displacement: Vector3): void;
  19804. private _onCollisionPositionChange;
  19805. /** @hidden */
  19806. _checkInputs(): void;
  19807. /** @hidden */
  19808. _decideIfNeedsToMove(): boolean;
  19809. /** @hidden */
  19810. _updatePosition(): void;
  19811. /**
  19812. * Destroy the camera and release the current resources hold by it.
  19813. */
  19814. dispose(): void;
  19815. /**
  19816. * Gets the current object class name.
  19817. * @return the class name
  19818. */
  19819. getClassName(): string;
  19820. }
  19821. }
  19822. declare module "babylonjs/Gamepads/gamepad" {
  19823. import { Observable } from "babylonjs/Misc/observable";
  19824. /**
  19825. * Represents a gamepad control stick position
  19826. */
  19827. export class StickValues {
  19828. /**
  19829. * The x component of the control stick
  19830. */
  19831. x: number;
  19832. /**
  19833. * The y component of the control stick
  19834. */
  19835. y: number;
  19836. /**
  19837. * Initializes the gamepad x and y control stick values
  19838. * @param x The x component of the gamepad control stick value
  19839. * @param y The y component of the gamepad control stick value
  19840. */
  19841. constructor(
  19842. /**
  19843. * The x component of the control stick
  19844. */
  19845. x: number,
  19846. /**
  19847. * The y component of the control stick
  19848. */
  19849. y: number);
  19850. }
  19851. /**
  19852. * An interface which manages callbacks for gamepad button changes
  19853. */
  19854. export interface GamepadButtonChanges {
  19855. /**
  19856. * Called when a gamepad has been changed
  19857. */
  19858. changed: boolean;
  19859. /**
  19860. * Called when a gamepad press event has been triggered
  19861. */
  19862. pressChanged: boolean;
  19863. /**
  19864. * Called when a touch event has been triggered
  19865. */
  19866. touchChanged: boolean;
  19867. /**
  19868. * Called when a value has changed
  19869. */
  19870. valueChanged: boolean;
  19871. }
  19872. /**
  19873. * Represents a gamepad
  19874. */
  19875. export class Gamepad {
  19876. /**
  19877. * The id of the gamepad
  19878. */
  19879. id: string;
  19880. /**
  19881. * The index of the gamepad
  19882. */
  19883. index: number;
  19884. /**
  19885. * The browser gamepad
  19886. */
  19887. browserGamepad: any;
  19888. /**
  19889. * Specifies what type of gamepad this represents
  19890. */
  19891. type: number;
  19892. private _leftStick;
  19893. private _rightStick;
  19894. /** @hidden */
  19895. _isConnected: boolean;
  19896. private _leftStickAxisX;
  19897. private _leftStickAxisY;
  19898. private _rightStickAxisX;
  19899. private _rightStickAxisY;
  19900. /**
  19901. * Triggered when the left control stick has been changed
  19902. */
  19903. private _onleftstickchanged;
  19904. /**
  19905. * Triggered when the right control stick has been changed
  19906. */
  19907. private _onrightstickchanged;
  19908. /**
  19909. * Represents a gamepad controller
  19910. */
  19911. static GAMEPAD: number;
  19912. /**
  19913. * Represents a generic controller
  19914. */
  19915. static GENERIC: number;
  19916. /**
  19917. * Represents an XBox controller
  19918. */
  19919. static XBOX: number;
  19920. /**
  19921. * Represents a pose-enabled controller
  19922. */
  19923. static POSE_ENABLED: number;
  19924. /**
  19925. * Represents an Dual Shock controller
  19926. */
  19927. static DUALSHOCK: number;
  19928. /**
  19929. * Specifies whether the left control stick should be Y-inverted
  19930. */
  19931. protected _invertLeftStickY: boolean;
  19932. /**
  19933. * Specifies if the gamepad has been connected
  19934. */
  19935. get isConnected(): boolean;
  19936. /**
  19937. * Initializes the gamepad
  19938. * @param id The id of the gamepad
  19939. * @param index The index of the gamepad
  19940. * @param browserGamepad The browser gamepad
  19941. * @param leftStickX The x component of the left joystick
  19942. * @param leftStickY The y component of the left joystick
  19943. * @param rightStickX The x component of the right joystick
  19944. * @param rightStickY The y component of the right joystick
  19945. */
  19946. constructor(
  19947. /**
  19948. * The id of the gamepad
  19949. */
  19950. id: string,
  19951. /**
  19952. * The index of the gamepad
  19953. */
  19954. index: number,
  19955. /**
  19956. * The browser gamepad
  19957. */
  19958. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19959. /**
  19960. * Callback triggered when the left joystick has changed
  19961. * @param callback
  19962. */
  19963. onleftstickchanged(callback: (values: StickValues) => void): void;
  19964. /**
  19965. * Callback triggered when the right joystick has changed
  19966. * @param callback
  19967. */
  19968. onrightstickchanged(callback: (values: StickValues) => void): void;
  19969. /**
  19970. * Gets the left joystick
  19971. */
  19972. get leftStick(): StickValues;
  19973. /**
  19974. * Sets the left joystick values
  19975. */
  19976. set leftStick(newValues: StickValues);
  19977. /**
  19978. * Gets the right joystick
  19979. */
  19980. get rightStick(): StickValues;
  19981. /**
  19982. * Sets the right joystick value
  19983. */
  19984. set rightStick(newValues: StickValues);
  19985. /**
  19986. * Updates the gamepad joystick positions
  19987. */
  19988. update(): void;
  19989. /**
  19990. * Disposes the gamepad
  19991. */
  19992. dispose(): void;
  19993. }
  19994. /**
  19995. * Represents a generic gamepad
  19996. */
  19997. export class GenericPad extends Gamepad {
  19998. private _buttons;
  19999. private _onbuttondown;
  20000. private _onbuttonup;
  20001. /**
  20002. * Observable triggered when a button has been pressed
  20003. */
  20004. onButtonDownObservable: Observable<number>;
  20005. /**
  20006. * Observable triggered when a button has been released
  20007. */
  20008. onButtonUpObservable: Observable<number>;
  20009. /**
  20010. * Callback triggered when a button has been pressed
  20011. * @param callback Called when a button has been pressed
  20012. */
  20013. onbuttondown(callback: (buttonPressed: number) => void): void;
  20014. /**
  20015. * Callback triggered when a button has been released
  20016. * @param callback Called when a button has been released
  20017. */
  20018. onbuttonup(callback: (buttonReleased: number) => void): void;
  20019. /**
  20020. * Initializes the generic gamepad
  20021. * @param id The id of the generic gamepad
  20022. * @param index The index of the generic gamepad
  20023. * @param browserGamepad The browser gamepad
  20024. */
  20025. constructor(id: string, index: number, browserGamepad: any);
  20026. private _setButtonValue;
  20027. /**
  20028. * Updates the generic gamepad
  20029. */
  20030. update(): void;
  20031. /**
  20032. * Disposes the generic gamepad
  20033. */
  20034. dispose(): void;
  20035. }
  20036. }
  20037. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20038. import { Observable } from "babylonjs/Misc/observable";
  20039. import { Nullable } from "babylonjs/types";
  20040. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20043. import { Ray } from "babylonjs/Culling/ray";
  20044. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20045. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20046. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20047. /**
  20048. * Defines the types of pose enabled controllers that are supported
  20049. */
  20050. export enum PoseEnabledControllerType {
  20051. /**
  20052. * HTC Vive
  20053. */
  20054. VIVE = 0,
  20055. /**
  20056. * Oculus Rift
  20057. */
  20058. OCULUS = 1,
  20059. /**
  20060. * Windows mixed reality
  20061. */
  20062. WINDOWS = 2,
  20063. /**
  20064. * Samsung gear VR
  20065. */
  20066. GEAR_VR = 3,
  20067. /**
  20068. * Google Daydream
  20069. */
  20070. DAYDREAM = 4,
  20071. /**
  20072. * Generic
  20073. */
  20074. GENERIC = 5
  20075. }
  20076. /**
  20077. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20078. */
  20079. export interface MutableGamepadButton {
  20080. /**
  20081. * Value of the button/trigger
  20082. */
  20083. value: number;
  20084. /**
  20085. * If the button/trigger is currently touched
  20086. */
  20087. touched: boolean;
  20088. /**
  20089. * If the button/trigger is currently pressed
  20090. */
  20091. pressed: boolean;
  20092. }
  20093. /**
  20094. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20095. * @hidden
  20096. */
  20097. export interface ExtendedGamepadButton extends GamepadButton {
  20098. /**
  20099. * If the button/trigger is currently pressed
  20100. */
  20101. readonly pressed: boolean;
  20102. /**
  20103. * If the button/trigger is currently touched
  20104. */
  20105. readonly touched: boolean;
  20106. /**
  20107. * Value of the button/trigger
  20108. */
  20109. readonly value: number;
  20110. }
  20111. /** @hidden */
  20112. export interface _GamePadFactory {
  20113. /**
  20114. * Returns whether or not the current gamepad can be created for this type of controller.
  20115. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20116. * @returns true if it can be created, otherwise false
  20117. */
  20118. canCreate(gamepadInfo: any): boolean;
  20119. /**
  20120. * Creates a new instance of the Gamepad.
  20121. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20122. * @returns the new gamepad instance
  20123. */
  20124. create(gamepadInfo: any): Gamepad;
  20125. }
  20126. /**
  20127. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20128. */
  20129. export class PoseEnabledControllerHelper {
  20130. /** @hidden */
  20131. static _ControllerFactories: _GamePadFactory[];
  20132. /** @hidden */
  20133. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20134. /**
  20135. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20136. * @param vrGamepad the gamepad to initialized
  20137. * @returns a vr controller of the type the gamepad identified as
  20138. */
  20139. static InitiateController(vrGamepad: any): Gamepad;
  20140. }
  20141. /**
  20142. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20143. */
  20144. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20145. /**
  20146. * If the controller is used in a webXR session
  20147. */
  20148. isXR: boolean;
  20149. private _deviceRoomPosition;
  20150. private _deviceRoomRotationQuaternion;
  20151. /**
  20152. * The device position in babylon space
  20153. */
  20154. devicePosition: Vector3;
  20155. /**
  20156. * The device rotation in babylon space
  20157. */
  20158. deviceRotationQuaternion: Quaternion;
  20159. /**
  20160. * The scale factor of the device in babylon space
  20161. */
  20162. deviceScaleFactor: number;
  20163. /**
  20164. * (Likely devicePosition should be used instead) The device position in its room space
  20165. */
  20166. position: Vector3;
  20167. /**
  20168. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20169. */
  20170. rotationQuaternion: Quaternion;
  20171. /**
  20172. * The type of controller (Eg. Windows mixed reality)
  20173. */
  20174. controllerType: PoseEnabledControllerType;
  20175. protected _calculatedPosition: Vector3;
  20176. private _calculatedRotation;
  20177. /**
  20178. * The raw pose from the device
  20179. */
  20180. rawPose: DevicePose;
  20181. private _trackPosition;
  20182. private _maxRotationDistFromHeadset;
  20183. private _draggedRoomRotation;
  20184. /**
  20185. * @hidden
  20186. */
  20187. _disableTrackPosition(fixedPosition: Vector3): void;
  20188. /**
  20189. * Internal, the mesh attached to the controller
  20190. * @hidden
  20191. */
  20192. _mesh: Nullable<AbstractMesh>;
  20193. private _poseControlledCamera;
  20194. private _leftHandSystemQuaternion;
  20195. /**
  20196. * Internal, matrix used to convert room space to babylon space
  20197. * @hidden
  20198. */
  20199. _deviceToWorld: Matrix;
  20200. /**
  20201. * Node to be used when casting a ray from the controller
  20202. * @hidden
  20203. */
  20204. _pointingPoseNode: Nullable<TransformNode>;
  20205. /**
  20206. * Name of the child mesh that can be used to cast a ray from the controller
  20207. */
  20208. static readonly POINTING_POSE: string;
  20209. /**
  20210. * Creates a new PoseEnabledController from a gamepad
  20211. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20212. */
  20213. constructor(browserGamepad: any);
  20214. private _workingMatrix;
  20215. /**
  20216. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20217. */
  20218. update(): void;
  20219. /**
  20220. * Updates only the pose device and mesh without doing any button event checking
  20221. */
  20222. protected _updatePoseAndMesh(): void;
  20223. /**
  20224. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20225. * @param poseData raw pose fromthe device
  20226. */
  20227. updateFromDevice(poseData: DevicePose): void;
  20228. /**
  20229. * @hidden
  20230. */
  20231. _meshAttachedObservable: Observable<AbstractMesh>;
  20232. /**
  20233. * Attaches a mesh to the controller
  20234. * @param mesh the mesh to be attached
  20235. */
  20236. attachToMesh(mesh: AbstractMesh): void;
  20237. /**
  20238. * Attaches the controllers mesh to a camera
  20239. * @param camera the camera the mesh should be attached to
  20240. */
  20241. attachToPoseControlledCamera(camera: TargetCamera): void;
  20242. /**
  20243. * Disposes of the controller
  20244. */
  20245. dispose(): void;
  20246. /**
  20247. * The mesh that is attached to the controller
  20248. */
  20249. get mesh(): Nullable<AbstractMesh>;
  20250. /**
  20251. * Gets the ray of the controller in the direction the controller is pointing
  20252. * @param length the length the resulting ray should be
  20253. * @returns a ray in the direction the controller is pointing
  20254. */
  20255. getForwardRay(length?: number): Ray;
  20256. }
  20257. }
  20258. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20259. import { Observable } from "babylonjs/Misc/observable";
  20260. import { Scene } from "babylonjs/scene";
  20261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20262. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20263. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20264. import { Nullable } from "babylonjs/types";
  20265. /**
  20266. * Defines the WebVRController object that represents controllers tracked in 3D space
  20267. */
  20268. export abstract class WebVRController extends PoseEnabledController {
  20269. /**
  20270. * Internal, the default controller model for the controller
  20271. */
  20272. protected _defaultModel: Nullable<AbstractMesh>;
  20273. /**
  20274. * Fired when the trigger state has changed
  20275. */
  20276. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20277. /**
  20278. * Fired when the main button state has changed
  20279. */
  20280. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20281. /**
  20282. * Fired when the secondary button state has changed
  20283. */
  20284. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20285. /**
  20286. * Fired when the pad state has changed
  20287. */
  20288. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20289. /**
  20290. * Fired when controllers stick values have changed
  20291. */
  20292. onPadValuesChangedObservable: Observable<StickValues>;
  20293. /**
  20294. * Array of button availible on the controller
  20295. */
  20296. protected _buttons: Array<MutableGamepadButton>;
  20297. private _onButtonStateChange;
  20298. /**
  20299. * Fired when a controller button's state has changed
  20300. * @param callback the callback containing the button that was modified
  20301. */
  20302. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20303. /**
  20304. * X and Y axis corresponding to the controllers joystick
  20305. */
  20306. pad: StickValues;
  20307. /**
  20308. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20309. */
  20310. hand: string;
  20311. /**
  20312. * The default controller model for the controller
  20313. */
  20314. get defaultModel(): Nullable<AbstractMesh>;
  20315. /**
  20316. * Creates a new WebVRController from a gamepad
  20317. * @param vrGamepad the gamepad that the WebVRController should be created from
  20318. */
  20319. constructor(vrGamepad: any);
  20320. /**
  20321. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20322. */
  20323. update(): void;
  20324. /**
  20325. * Function to be called when a button is modified
  20326. */
  20327. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20328. /**
  20329. * Loads a mesh and attaches it to the controller
  20330. * @param scene the scene the mesh should be added to
  20331. * @param meshLoaded callback for when the mesh has been loaded
  20332. */
  20333. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20334. private _setButtonValue;
  20335. private _changes;
  20336. private _checkChanges;
  20337. /**
  20338. * Disposes of th webVRCOntroller
  20339. */
  20340. dispose(): void;
  20341. }
  20342. }
  20343. declare module "babylonjs/Lights/hemisphericLight" {
  20344. import { Nullable } from "babylonjs/types";
  20345. import { Scene } from "babylonjs/scene";
  20346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20347. import { Color3 } from "babylonjs/Maths/math.color";
  20348. import { Effect } from "babylonjs/Materials/effect";
  20349. import { Light } from "babylonjs/Lights/light";
  20350. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20351. /**
  20352. * The HemisphericLight simulates the ambient environment light,
  20353. * so the passed direction is the light reflection direction, not the incoming direction.
  20354. */
  20355. export class HemisphericLight extends Light {
  20356. /**
  20357. * The groundColor is the light in the opposite direction to the one specified during creation.
  20358. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  20359. */
  20360. groundColor: Color3;
  20361. /**
  20362. * The light reflection direction, not the incoming direction.
  20363. */
  20364. direction: Vector3;
  20365. /**
  20366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20368. * The HemisphericLight can't cast shadows.
  20369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20370. * @param name The friendly name of the light
  20371. * @param direction The direction of the light reflection
  20372. * @param scene The scene the light belongs to
  20373. */
  20374. constructor(name: string, direction: Vector3, scene: Scene);
  20375. protected _buildUniformLayout(): void;
  20376. /**
  20377. * Returns the string "HemisphericLight".
  20378. * @return The class name
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20383. * Returns the updated direction.
  20384. * @param target The target the direction should point to
  20385. * @return The computed direction
  20386. */
  20387. setDirectionToTarget(target: Vector3): Vector3;
  20388. /**
  20389. * Returns the shadow generator associated to the light.
  20390. * @returns Always null for hemispheric lights because it does not support shadows.
  20391. */
  20392. getShadowGenerator(): Nullable<IShadowGenerator>;
  20393. /**
  20394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20395. * @param effect The effect to update
  20396. * @param lightIndex The index of the light in the effect to update
  20397. * @returns The hemispheric light
  20398. */
  20399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20400. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20401. /**
  20402. * Computes the world matrix of the node
  20403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20404. * @param useWasUpdatedFlag defines a reserved property
  20405. * @returns the world matrix
  20406. */
  20407. computeWorldMatrix(): Matrix;
  20408. /**
  20409. * Returns the integer 3.
  20410. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20411. */
  20412. getTypeID(): number;
  20413. /**
  20414. * Prepares the list of defines specific to the light type.
  20415. * @param defines the list of defines
  20416. * @param lightIndex defines the index of the light for the effect
  20417. */
  20418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20419. }
  20420. }
  20421. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20422. /** @hidden */
  20423. export var vrMultiviewToSingleviewPixelShader: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20430. import { Scene } from "babylonjs/scene";
  20431. /**
  20432. * Renders to multiple views with a single draw call
  20433. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20434. */
  20435. export class MultiviewRenderTarget extends RenderTargetTexture {
  20436. /**
  20437. * Creates a multiview render target
  20438. * @param scene scene used with the render target
  20439. * @param size the size of the render target (used for each view)
  20440. */
  20441. constructor(scene: Scene, size?: number | {
  20442. width: number;
  20443. height: number;
  20444. } | {
  20445. ratio: number;
  20446. });
  20447. /**
  20448. * @hidden
  20449. * @param faceIndex the face index, if its a cube texture
  20450. */
  20451. _bindFrameBuffer(faceIndex?: number): void;
  20452. /**
  20453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20454. * @returns the view count
  20455. */
  20456. getViewCount(): number;
  20457. }
  20458. }
  20459. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20460. import { Camera } from "babylonjs/Cameras/camera";
  20461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20462. import { Nullable } from "babylonjs/types";
  20463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20464. import { Matrix } from "babylonjs/Maths/math.vector";
  20465. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20466. module "babylonjs/Engines/engine" {
  20467. interface Engine {
  20468. /**
  20469. * Creates a new multiview render target
  20470. * @param width defines the width of the texture
  20471. * @param height defines the height of the texture
  20472. * @returns the created multiview texture
  20473. */
  20474. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20475. /**
  20476. * Binds a multiview framebuffer to be drawn to
  20477. * @param multiviewTexture texture to bind
  20478. */
  20479. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20480. }
  20481. }
  20482. module "babylonjs/Cameras/camera" {
  20483. interface Camera {
  20484. /**
  20485. * @hidden
  20486. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20487. */
  20488. _useMultiviewToSingleView: boolean;
  20489. /**
  20490. * @hidden
  20491. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20492. */
  20493. _multiviewTexture: Nullable<RenderTargetTexture>;
  20494. /**
  20495. * @hidden
  20496. * ensures the multiview texture of the camera exists and has the specified width/height
  20497. * @param width height to set on the multiview texture
  20498. * @param height width to set on the multiview texture
  20499. */
  20500. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20501. }
  20502. }
  20503. module "babylonjs/scene" {
  20504. interface Scene {
  20505. /** @hidden */
  20506. _transformMatrixR: Matrix;
  20507. /** @hidden */
  20508. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20509. /** @hidden */
  20510. _createMultiviewUbo(): void;
  20511. /** @hidden */
  20512. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20513. /** @hidden */
  20514. _renderMultiviewToSingleView(camera: Camera): void;
  20515. }
  20516. }
  20517. }
  20518. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20519. import { Camera } from "babylonjs/Cameras/camera";
  20520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20521. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20522. import "babylonjs/Engines/Extensions/engine.multiview";
  20523. /**
  20524. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20525. * This will not be used for webXR as it supports displaying texture arrays directly
  20526. */
  20527. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20528. /**
  20529. * Gets a string identifying the name of the class
  20530. * @returns "VRMultiviewToSingleviewPostProcess" string
  20531. */
  20532. getClassName(): string;
  20533. /**
  20534. * Initializes a VRMultiviewToSingleview
  20535. * @param name name of the post process
  20536. * @param camera camera to be applied to
  20537. * @param scaleFactor scaling factor to the size of the output texture
  20538. */
  20539. constructor(name: string, camera: Camera, scaleFactor: number);
  20540. }
  20541. }
  20542. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20543. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20544. import { Nullable } from "babylonjs/types";
  20545. import { Size } from "babylonjs/Maths/math.size";
  20546. import { Observable } from "babylonjs/Misc/observable";
  20547. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20548. /**
  20549. * Interface used to define additional presentation attributes
  20550. */
  20551. export interface IVRPresentationAttributes {
  20552. /**
  20553. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20554. */
  20555. highRefreshRate: boolean;
  20556. /**
  20557. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20558. */
  20559. foveationLevel: number;
  20560. }
  20561. module "babylonjs/Engines/engine" {
  20562. interface Engine {
  20563. /** @hidden */
  20564. _vrDisplay: any;
  20565. /** @hidden */
  20566. _vrSupported: boolean;
  20567. /** @hidden */
  20568. _oldSize: Size;
  20569. /** @hidden */
  20570. _oldHardwareScaleFactor: number;
  20571. /** @hidden */
  20572. _vrExclusivePointerMode: boolean;
  20573. /** @hidden */
  20574. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20575. /** @hidden */
  20576. _onVRDisplayPointerRestricted: () => void;
  20577. /** @hidden */
  20578. _onVRDisplayPointerUnrestricted: () => void;
  20579. /** @hidden */
  20580. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20581. /** @hidden */
  20582. _onVrDisplayDisconnect: Nullable<() => void>;
  20583. /** @hidden */
  20584. _onVrDisplayPresentChange: Nullable<() => void>;
  20585. /**
  20586. * Observable signaled when VR display mode changes
  20587. */
  20588. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20589. /**
  20590. * Observable signaled when VR request present is complete
  20591. */
  20592. onVRRequestPresentComplete: Observable<boolean>;
  20593. /**
  20594. * Observable signaled when VR request present starts
  20595. */
  20596. onVRRequestPresentStart: Observable<Engine>;
  20597. /**
  20598. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20599. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20600. */
  20601. isInVRExclusivePointerMode: boolean;
  20602. /**
  20603. * Gets a boolean indicating if a webVR device was detected
  20604. * @returns true if a webVR device was detected
  20605. */
  20606. isVRDevicePresent(): boolean;
  20607. /**
  20608. * Gets the current webVR device
  20609. * @returns the current webVR device (or null)
  20610. */
  20611. getVRDevice(): any;
  20612. /**
  20613. * Initializes a webVR display and starts listening to display change events
  20614. * The onVRDisplayChangedObservable will be notified upon these changes
  20615. * @returns A promise containing a VRDisplay and if vr is supported
  20616. */
  20617. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20618. /** @hidden */
  20619. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20620. /**
  20621. * Gets or sets the presentation attributes used to configure VR rendering
  20622. */
  20623. vrPresentationAttributes?: IVRPresentationAttributes;
  20624. /**
  20625. * Call this function to switch to webVR mode
  20626. * Will do nothing if webVR is not supported or if there is no webVR device
  20627. * @param options the webvr options provided to the camera. mainly used for multiview
  20628. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20629. */
  20630. enableVR(options: WebVROptions): void;
  20631. /** @hidden */
  20632. _onVRFullScreenTriggered(): void;
  20633. }
  20634. }
  20635. }
  20636. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20637. import { Nullable } from "babylonjs/types";
  20638. import { Observable } from "babylonjs/Misc/observable";
  20639. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20640. import { Scene } from "babylonjs/scene";
  20641. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20642. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20643. import { Node } from "babylonjs/node";
  20644. import { Ray } from "babylonjs/Culling/ray";
  20645. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20646. import "babylonjs/Engines/Extensions/engine.webVR";
  20647. /**
  20648. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20649. * IMPORTANT!! The data is right-hand data.
  20650. * @export
  20651. * @interface DevicePose
  20652. */
  20653. export interface DevicePose {
  20654. /**
  20655. * The position of the device, values in array are [x,y,z].
  20656. */
  20657. readonly position: Nullable<Float32Array>;
  20658. /**
  20659. * The linearVelocity of the device, values in array are [x,y,z].
  20660. */
  20661. readonly linearVelocity: Nullable<Float32Array>;
  20662. /**
  20663. * The linearAcceleration of the device, values in array are [x,y,z].
  20664. */
  20665. readonly linearAcceleration: Nullable<Float32Array>;
  20666. /**
  20667. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20668. */
  20669. readonly orientation: Nullable<Float32Array>;
  20670. /**
  20671. * The angularVelocity of the device, values in array are [x,y,z].
  20672. */
  20673. readonly angularVelocity: Nullable<Float32Array>;
  20674. /**
  20675. * The angularAcceleration of the device, values in array are [x,y,z].
  20676. */
  20677. readonly angularAcceleration: Nullable<Float32Array>;
  20678. }
  20679. /**
  20680. * Interface representing a pose controlled object in Babylon.
  20681. * A pose controlled object has both regular pose values as well as pose values
  20682. * from an external device such as a VR head mounted display
  20683. */
  20684. export interface PoseControlled {
  20685. /**
  20686. * The position of the object in babylon space.
  20687. */
  20688. position: Vector3;
  20689. /**
  20690. * The rotation quaternion of the object in babylon space.
  20691. */
  20692. rotationQuaternion: Quaternion;
  20693. /**
  20694. * The position of the device in babylon space.
  20695. */
  20696. devicePosition?: Vector3;
  20697. /**
  20698. * The rotation quaternion of the device in babylon space.
  20699. */
  20700. deviceRotationQuaternion: Quaternion;
  20701. /**
  20702. * The raw pose coming from the device.
  20703. */
  20704. rawPose: Nullable<DevicePose>;
  20705. /**
  20706. * The scale of the device to be used when translating from device space to babylon space.
  20707. */
  20708. deviceScaleFactor: number;
  20709. /**
  20710. * Updates the poseControlled values based on the input device pose.
  20711. * @param poseData the pose data to update the object with
  20712. */
  20713. updateFromDevice(poseData: DevicePose): void;
  20714. }
  20715. /**
  20716. * Set of options to customize the webVRCamera
  20717. */
  20718. export interface WebVROptions {
  20719. /**
  20720. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20721. */
  20722. trackPosition?: boolean;
  20723. /**
  20724. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20725. */
  20726. positionScale?: number;
  20727. /**
  20728. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20729. */
  20730. displayName?: string;
  20731. /**
  20732. * Should the native controller meshes be initialized. (default: true)
  20733. */
  20734. controllerMeshes?: boolean;
  20735. /**
  20736. * Creating a default HemiLight only on controllers. (default: true)
  20737. */
  20738. defaultLightingOnControllers?: boolean;
  20739. /**
  20740. * If you don't want to use the default VR button of the helper. (default: false)
  20741. */
  20742. useCustomVRButton?: boolean;
  20743. /**
  20744. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20745. */
  20746. customVRButton?: HTMLButtonElement;
  20747. /**
  20748. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20749. */
  20750. rayLength?: number;
  20751. /**
  20752. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20753. */
  20754. defaultHeight?: number;
  20755. /**
  20756. * If multiview should be used if availible (default: false)
  20757. */
  20758. useMultiview?: boolean;
  20759. }
  20760. /**
  20761. * This represents a WebVR camera.
  20762. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20763. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20764. */
  20765. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20766. private webVROptions;
  20767. /**
  20768. * @hidden
  20769. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20770. */
  20771. _vrDevice: any;
  20772. /**
  20773. * The rawPose of the vrDevice.
  20774. */
  20775. rawPose: Nullable<DevicePose>;
  20776. private _onVREnabled;
  20777. private _specsVersion;
  20778. private _attached;
  20779. private _frameData;
  20780. protected _descendants: Array<Node>;
  20781. private _deviceRoomPosition;
  20782. /** @hidden */
  20783. _deviceRoomRotationQuaternion: Quaternion;
  20784. private _standingMatrix;
  20785. /**
  20786. * Represents device position in babylon space.
  20787. */
  20788. devicePosition: Vector3;
  20789. /**
  20790. * Represents device rotation in babylon space.
  20791. */
  20792. deviceRotationQuaternion: Quaternion;
  20793. /**
  20794. * The scale of the device to be used when translating from device space to babylon space.
  20795. */
  20796. deviceScaleFactor: number;
  20797. private _deviceToWorld;
  20798. private _worldToDevice;
  20799. /**
  20800. * References to the webVR controllers for the vrDevice.
  20801. */
  20802. controllers: Array<WebVRController>;
  20803. /**
  20804. * Emits an event when a controller is attached.
  20805. */
  20806. onControllersAttachedObservable: Observable<WebVRController[]>;
  20807. /**
  20808. * Emits an event when a controller's mesh has been loaded;
  20809. */
  20810. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20811. /**
  20812. * Emits an event when the HMD's pose has been updated.
  20813. */
  20814. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20815. private _poseSet;
  20816. /**
  20817. * If the rig cameras be used as parent instead of this camera.
  20818. */
  20819. rigParenting: boolean;
  20820. private _lightOnControllers;
  20821. private _defaultHeight?;
  20822. /**
  20823. * Instantiates a WebVRFreeCamera.
  20824. * @param name The name of the WebVRFreeCamera
  20825. * @param position The starting anchor position for the camera
  20826. * @param scene The scene the camera belongs to
  20827. * @param webVROptions a set of customizable options for the webVRCamera
  20828. */
  20829. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20830. /**
  20831. * Gets the device distance from the ground in meters.
  20832. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20833. */
  20834. deviceDistanceToRoomGround(): number;
  20835. /**
  20836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20837. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20838. */
  20839. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20840. /**
  20841. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20842. * @returns A promise with a boolean set to if the standing matrix is supported.
  20843. */
  20844. useStandingMatrixAsync(): Promise<boolean>;
  20845. /**
  20846. * Disposes the camera
  20847. */
  20848. dispose(): void;
  20849. /**
  20850. * Gets a vrController by name.
  20851. * @param name The name of the controller to retreive
  20852. * @returns the controller matching the name specified or null if not found
  20853. */
  20854. getControllerByName(name: string): Nullable<WebVRController>;
  20855. private _leftController;
  20856. /**
  20857. * The controller corresponding to the users left hand.
  20858. */
  20859. get leftController(): Nullable<WebVRController>;
  20860. private _rightController;
  20861. /**
  20862. * The controller corresponding to the users right hand.
  20863. */
  20864. get rightController(): Nullable<WebVRController>;
  20865. /**
  20866. * Casts a ray forward from the vrCamera's gaze.
  20867. * @param length Length of the ray (default: 100)
  20868. * @returns the ray corresponding to the gaze
  20869. */
  20870. getForwardRay(length?: number): Ray;
  20871. /**
  20872. * @hidden
  20873. * Updates the camera based on device's frame data
  20874. */
  20875. _checkInputs(): void;
  20876. /**
  20877. * Updates the poseControlled values based on the input device pose.
  20878. * @param poseData Pose coming from the device
  20879. */
  20880. updateFromDevice(poseData: DevicePose): void;
  20881. private _htmlElementAttached;
  20882. private _detachIfAttached;
  20883. /**
  20884. * WebVR's attach control will start broadcasting frames to the device.
  20885. * Note that in certain browsers (chrome for example) this function must be called
  20886. * within a user-interaction callback. Example:
  20887. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20888. *
  20889. * @param element html element to attach the vrDevice to
  20890. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20891. */
  20892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20893. /**
  20894. * Detaches the camera from the html element and disables VR
  20895. *
  20896. * @param element html element to detach from
  20897. */
  20898. detachControl(element: HTMLElement): void;
  20899. /**
  20900. * @returns the name of this class
  20901. */
  20902. getClassName(): string;
  20903. /**
  20904. * Calls resetPose on the vrDisplay
  20905. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20906. */
  20907. resetToCurrentRotation(): void;
  20908. /**
  20909. * @hidden
  20910. * Updates the rig cameras (left and right eye)
  20911. */
  20912. _updateRigCameras(): void;
  20913. private _workingVector;
  20914. private _oneVector;
  20915. private _workingMatrix;
  20916. private updateCacheCalled;
  20917. private _correctPositionIfNotTrackPosition;
  20918. /**
  20919. * @hidden
  20920. * Updates the cached values of the camera
  20921. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20922. */
  20923. _updateCache(ignoreParentClass?: boolean): void;
  20924. /**
  20925. * @hidden
  20926. * Get current device position in babylon world
  20927. */
  20928. _computeDevicePosition(): void;
  20929. /**
  20930. * Updates the current device position and rotation in the babylon world
  20931. */
  20932. update(): void;
  20933. /**
  20934. * @hidden
  20935. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20936. * @returns an identity matrix
  20937. */
  20938. _getViewMatrix(): Matrix;
  20939. private _tmpMatrix;
  20940. /**
  20941. * This function is called by the two RIG cameras.
  20942. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20943. * @hidden
  20944. */
  20945. _getWebVRViewMatrix(): Matrix;
  20946. /** @hidden */
  20947. _getWebVRProjectionMatrix(): Matrix;
  20948. private _onGamepadConnectedObserver;
  20949. private _onGamepadDisconnectedObserver;
  20950. private _updateCacheWhenTrackingDisabledObserver;
  20951. /**
  20952. * Initializes the controllers and their meshes
  20953. */
  20954. initControllers(): void;
  20955. }
  20956. }
  20957. declare module "babylonjs/Materials/materialHelper" {
  20958. import { Nullable } from "babylonjs/types";
  20959. import { Scene } from "babylonjs/scene";
  20960. import { Engine } from "babylonjs/Engines/engine";
  20961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20962. import { Light } from "babylonjs/Lights/light";
  20963. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20965. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20967. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20969. /**
  20970. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20971. *
  20972. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20973. *
  20974. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20975. */
  20976. export class MaterialHelper {
  20977. /**
  20978. * Bind the current view position to an effect.
  20979. * @param effect The effect to be bound
  20980. * @param scene The scene the eyes position is used from
  20981. * @param variableName name of the shader variable that will hold the eye position
  20982. */
  20983. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20984. /**
  20985. * Helps preparing the defines values about the UVs in used in the effect.
  20986. * UVs are shared as much as we can accross channels in the shaders.
  20987. * @param texture The texture we are preparing the UVs for
  20988. * @param defines The defines to update
  20989. * @param key The channel key "diffuse", "specular"... used in the shader
  20990. */
  20991. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20992. /**
  20993. * Binds a texture matrix value to its corrsponding uniform
  20994. * @param texture The texture to bind the matrix for
  20995. * @param uniformBuffer The uniform buffer receivin the data
  20996. * @param key The channel key "diffuse", "specular"... used in the shader
  20997. */
  20998. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20999. /**
  21000. * Gets the current status of the fog (should it be enabled?)
  21001. * @param mesh defines the mesh to evaluate for fog support
  21002. * @param scene defines the hosting scene
  21003. * @returns true if fog must be enabled
  21004. */
  21005. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21006. /**
  21007. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21008. * @param mesh defines the current mesh
  21009. * @param scene defines the current scene
  21010. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21011. * @param pointsCloud defines if point cloud rendering has to be turned on
  21012. * @param fogEnabled defines if fog has to be turned on
  21013. * @param alphaTest defines if alpha testing has to be turned on
  21014. * @param defines defines the current list of defines
  21015. */
  21016. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21017. /**
  21018. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21019. * @param scene defines the current scene
  21020. * @param engine defines the current engine
  21021. * @param defines specifies the list of active defines
  21022. * @param useInstances defines if instances have to be turned on
  21023. * @param useClipPlane defines if clip plane have to be turned on
  21024. * @param useInstances defines if instances have to be turned on
  21025. * @param useThinInstances defines if thin instances have to be turned on
  21026. */
  21027. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21028. /**
  21029. * Prepares the defines for bones
  21030. * @param mesh The mesh containing the geometry data we will draw
  21031. * @param defines The defines to update
  21032. */
  21033. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21034. /**
  21035. * Prepares the defines for morph targets
  21036. * @param mesh The mesh containing the geometry data we will draw
  21037. * @param defines The defines to update
  21038. */
  21039. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21040. /**
  21041. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21042. * @param mesh The mesh containing the geometry data we will draw
  21043. * @param defines The defines to update
  21044. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21045. * @param useBones Precise whether bones should be used or not (override mesh info)
  21046. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21047. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21048. * @returns false if defines are considered not dirty and have not been checked
  21049. */
  21050. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21051. /**
  21052. * Prepares the defines related to multiview
  21053. * @param scene The scene we are intending to draw
  21054. * @param defines The defines to update
  21055. */
  21056. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21057. /**
  21058. * Prepares the defines related to the prepass
  21059. * @param scene The scene we are intending to draw
  21060. * @param defines The defines to update
  21061. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21062. */
  21063. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21064. /**
  21065. * Prepares the defines related to the light information passed in parameter
  21066. * @param scene The scene we are intending to draw
  21067. * @param mesh The mesh the effect is compiling for
  21068. * @param light The light the effect is compiling for
  21069. * @param lightIndex The index of the light
  21070. * @param defines The defines to update
  21071. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21072. * @param state Defines the current state regarding what is needed (normals, etc...)
  21073. */
  21074. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21075. needNormals: boolean;
  21076. needRebuild: boolean;
  21077. shadowEnabled: boolean;
  21078. specularEnabled: boolean;
  21079. lightmapMode: boolean;
  21080. }): void;
  21081. /**
  21082. * Prepares the defines related to the light information passed in parameter
  21083. * @param scene The scene we are intending to draw
  21084. * @param mesh The mesh the effect is compiling for
  21085. * @param defines The defines to update
  21086. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21087. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21088. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21089. * @returns true if normals will be required for the rest of the effect
  21090. */
  21091. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21092. /**
  21093. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21094. * @param lightIndex defines the light index
  21095. * @param uniformsList The uniform list
  21096. * @param samplersList The sampler list
  21097. * @param projectedLightTexture defines if projected texture must be used
  21098. * @param uniformBuffersList defines an optional list of uniform buffers
  21099. */
  21100. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21101. /**
  21102. * Prepares the uniforms and samplers list to be used in the effect
  21103. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21104. * @param samplersList The sampler list
  21105. * @param defines The defines helping in the list generation
  21106. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21107. */
  21108. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21109. /**
  21110. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21111. * @param defines The defines to update while falling back
  21112. * @param fallbacks The authorized effect fallbacks
  21113. * @param maxSimultaneousLights The maximum number of lights allowed
  21114. * @param rank the current rank of the Effect
  21115. * @returns The newly affected rank
  21116. */
  21117. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21118. private static _TmpMorphInfluencers;
  21119. /**
  21120. * Prepares the list of attributes required for morph targets according to the effect defines.
  21121. * @param attribs The current list of supported attribs
  21122. * @param mesh The mesh to prepare the morph targets attributes for
  21123. * @param influencers The number of influencers
  21124. */
  21125. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21126. /**
  21127. * Prepares the list of attributes required for morph targets according to the effect defines.
  21128. * @param attribs The current list of supported attribs
  21129. * @param mesh The mesh to prepare the morph targets attributes for
  21130. * @param defines The current Defines of the effect
  21131. */
  21132. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21133. /**
  21134. * Prepares the list of attributes required for bones according to the effect defines.
  21135. * @param attribs The current list of supported attribs
  21136. * @param mesh The mesh to prepare the bones attributes for
  21137. * @param defines The current Defines of the effect
  21138. * @param fallbacks The current efffect fallback strategy
  21139. */
  21140. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21141. /**
  21142. * Check and prepare the list of attributes required for instances according to the effect defines.
  21143. * @param attribs The current list of supported attribs
  21144. * @param defines The current MaterialDefines of the effect
  21145. */
  21146. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21147. /**
  21148. * Add the list of attributes required for instances to the attribs array.
  21149. * @param attribs The current list of supported attribs
  21150. */
  21151. static PushAttributesForInstances(attribs: string[]): void;
  21152. /**
  21153. * Binds the light information to the effect.
  21154. * @param light The light containing the generator
  21155. * @param effect The effect we are binding the data to
  21156. * @param lightIndex The light index in the effect used to render
  21157. */
  21158. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21159. /**
  21160. * Binds the lights information from the scene to the effect for the given mesh.
  21161. * @param light Light to bind
  21162. * @param lightIndex Light index
  21163. * @param scene The scene where the light belongs to
  21164. * @param effect The effect we are binding the data to
  21165. * @param useSpecular Defines if specular is supported
  21166. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21167. */
  21168. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21169. /**
  21170. * Binds the lights information from the scene to the effect for the given mesh.
  21171. * @param scene The scene the lights belongs to
  21172. * @param mesh The mesh we are binding the information to render
  21173. * @param effect The effect we are binding the data to
  21174. * @param defines The generated defines for the effect
  21175. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21176. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21177. */
  21178. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21179. private static _tempFogColor;
  21180. /**
  21181. * Binds the fog information from the scene to the effect for the given mesh.
  21182. * @param scene The scene the lights belongs to
  21183. * @param mesh The mesh we are binding the information to render
  21184. * @param effect The effect we are binding the data to
  21185. * @param linearSpace Defines if the fog effect is applied in linear space
  21186. */
  21187. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21188. /**
  21189. * Binds the bones information from the mesh to the effect.
  21190. * @param mesh The mesh we are binding the information to render
  21191. * @param effect The effect we are binding the data to
  21192. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21193. */
  21194. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21195. private static _CopyBonesTransformationMatrices;
  21196. /**
  21197. * Binds the morph targets information from the mesh to the effect.
  21198. * @param abstractMesh The mesh we are binding the information to render
  21199. * @param effect The effect we are binding the data to
  21200. */
  21201. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21202. /**
  21203. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21204. * @param defines The generated defines used in the effect
  21205. * @param effect The effect we are binding the data to
  21206. * @param scene The scene we are willing to render with logarithmic scale for
  21207. */
  21208. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21209. /**
  21210. * Binds the clip plane information from the scene to the effect.
  21211. * @param scene The scene the clip plane information are extracted from
  21212. * @param effect The effect we are binding the data to
  21213. */
  21214. static BindClipPlane(effect: Effect, scene: Scene): void;
  21215. }
  21216. }
  21217. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21219. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21220. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21221. import { Nullable } from "babylonjs/types";
  21222. import { Effect } from "babylonjs/Materials/effect";
  21223. import { Matrix } from "babylonjs/Maths/math.vector";
  21224. import { Scene } from "babylonjs/scene";
  21225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21227. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21228. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21229. import { Observable } from "babylonjs/Misc/observable";
  21230. /**
  21231. * Block used to expose an input value
  21232. */
  21233. export class InputBlock extends NodeMaterialBlock {
  21234. private _mode;
  21235. private _associatedVariableName;
  21236. private _storedValue;
  21237. private _valueCallback;
  21238. private _type;
  21239. private _animationType;
  21240. /** Gets or set a value used to limit the range of float values */
  21241. min: number;
  21242. /** Gets or set a value used to limit the range of float values */
  21243. max: number;
  21244. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21245. isBoolean: boolean;
  21246. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21247. matrixMode: number;
  21248. /** @hidden */
  21249. _systemValue: Nullable<NodeMaterialSystemValues>;
  21250. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21251. isConstant: boolean;
  21252. /** Gets or sets the group to use to display this block in the Inspector */
  21253. groupInInspector: string;
  21254. /** Gets an observable raised when the value is changed */
  21255. onValueChangedObservable: Observable<InputBlock>;
  21256. /**
  21257. * Gets or sets the connection point type (default is float)
  21258. */
  21259. get type(): NodeMaterialBlockConnectionPointTypes;
  21260. /**
  21261. * Creates a new InputBlock
  21262. * @param name defines the block name
  21263. * @param target defines the target of that block (Vertex by default)
  21264. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21265. */
  21266. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21267. /**
  21268. * Validates if a name is a reserve word.
  21269. * @param newName the new name to be given to the node.
  21270. * @returns false if the name is a reserve word, else true.
  21271. */
  21272. validateBlockName(newName: string): boolean;
  21273. /**
  21274. * Gets the output component
  21275. */
  21276. get output(): NodeMaterialConnectionPoint;
  21277. /**
  21278. * Set the source of this connection point to a vertex attribute
  21279. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21280. * @returns the current connection point
  21281. */
  21282. setAsAttribute(attributeName?: string): InputBlock;
  21283. /**
  21284. * Set the source of this connection point to a system value
  21285. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21286. * @returns the current connection point
  21287. */
  21288. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21289. /**
  21290. * Gets or sets the value of that point.
  21291. * Please note that this value will be ignored if valueCallback is defined
  21292. */
  21293. get value(): any;
  21294. set value(value: any);
  21295. /**
  21296. * Gets or sets a callback used to get the value of that point.
  21297. * Please note that setting this value will force the connection point to ignore the value property
  21298. */
  21299. get valueCallback(): () => any;
  21300. set valueCallback(value: () => any);
  21301. /**
  21302. * Gets or sets the associated variable name in the shader
  21303. */
  21304. get associatedVariableName(): string;
  21305. set associatedVariableName(value: string);
  21306. /** Gets or sets the type of animation applied to the input */
  21307. get animationType(): AnimatedInputBlockTypes;
  21308. set animationType(value: AnimatedInputBlockTypes);
  21309. /**
  21310. * Gets a boolean indicating that this connection point not defined yet
  21311. */
  21312. get isUndefined(): boolean;
  21313. /**
  21314. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21315. * In this case the connection point name must be the name of the uniform to use.
  21316. * Can only be set on inputs
  21317. */
  21318. get isUniform(): boolean;
  21319. set isUniform(value: boolean);
  21320. /**
  21321. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21322. * In this case the connection point name must be the name of the attribute to use
  21323. * Can only be set on inputs
  21324. */
  21325. get isAttribute(): boolean;
  21326. set isAttribute(value: boolean);
  21327. /**
  21328. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21329. * Can only be set on exit points
  21330. */
  21331. get isVarying(): boolean;
  21332. set isVarying(value: boolean);
  21333. /**
  21334. * Gets a boolean indicating that the current connection point is a system value
  21335. */
  21336. get isSystemValue(): boolean;
  21337. /**
  21338. * Gets or sets the current well known value or null if not defined as a system value
  21339. */
  21340. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21341. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21342. /**
  21343. * Gets the current class name
  21344. * @returns the class name
  21345. */
  21346. getClassName(): string;
  21347. /**
  21348. * Animate the input if animationType !== None
  21349. * @param scene defines the rendering scene
  21350. */
  21351. animate(scene: Scene): void;
  21352. private _emitDefine;
  21353. initialize(state: NodeMaterialBuildState): void;
  21354. /**
  21355. * Set the input block to its default value (based on its type)
  21356. */
  21357. setDefaultValue(): void;
  21358. private _emitConstant;
  21359. /** @hidden */
  21360. get _noContextSwitch(): boolean;
  21361. private _emit;
  21362. /** @hidden */
  21363. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21364. /** @hidden */
  21365. _transmit(effect: Effect, scene: Scene): void;
  21366. protected _buildBlock(state: NodeMaterialBuildState): void;
  21367. protected _dumpPropertiesCode(): string;
  21368. dispose(): void;
  21369. serialize(): any;
  21370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21371. }
  21372. }
  21373. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21374. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21375. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21376. import { Nullable } from "babylonjs/types";
  21377. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21378. import { Observable } from "babylonjs/Misc/observable";
  21379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21380. /**
  21381. * Enum used to define the compatibility state between two connection points
  21382. */
  21383. export enum NodeMaterialConnectionPointCompatibilityStates {
  21384. /** Points are compatibles */
  21385. Compatible = 0,
  21386. /** Points are incompatible because of their types */
  21387. TypeIncompatible = 1,
  21388. /** Points are incompatible because of their targets (vertex vs fragment) */
  21389. TargetIncompatible = 2
  21390. }
  21391. /**
  21392. * Defines the direction of a connection point
  21393. */
  21394. export enum NodeMaterialConnectionPointDirection {
  21395. /** Input */
  21396. Input = 0,
  21397. /** Output */
  21398. Output = 1
  21399. }
  21400. /**
  21401. * Defines a connection point for a block
  21402. */
  21403. export class NodeMaterialConnectionPoint {
  21404. /** @hidden */
  21405. _ownerBlock: NodeMaterialBlock;
  21406. /** @hidden */
  21407. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21408. private _endpoints;
  21409. private _associatedVariableName;
  21410. private _direction;
  21411. /** @hidden */
  21412. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21413. /** @hidden */
  21414. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21415. private _type;
  21416. /** @hidden */
  21417. _enforceAssociatedVariableName: boolean;
  21418. /** Gets the direction of the point */
  21419. get direction(): NodeMaterialConnectionPointDirection;
  21420. /** Indicates that this connection point needs dual validation before being connected to another point */
  21421. needDualDirectionValidation: boolean;
  21422. /**
  21423. * Gets or sets the additional types supported by this connection point
  21424. */
  21425. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21426. /**
  21427. * Gets or sets the additional types excluded by this connection point
  21428. */
  21429. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21430. /**
  21431. * Observable triggered when this point is connected
  21432. */
  21433. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21434. /**
  21435. * Gets or sets the associated variable name in the shader
  21436. */
  21437. get associatedVariableName(): string;
  21438. set associatedVariableName(value: string);
  21439. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21440. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21441. /**
  21442. * Gets or sets the connection point type (default is float)
  21443. */
  21444. get type(): NodeMaterialBlockConnectionPointTypes;
  21445. set type(value: NodeMaterialBlockConnectionPointTypes);
  21446. /**
  21447. * Gets or sets the connection point name
  21448. */
  21449. name: string;
  21450. /**
  21451. * Gets or sets the connection point name
  21452. */
  21453. displayName: string;
  21454. /**
  21455. * Gets or sets a boolean indicating that this connection point can be omitted
  21456. */
  21457. isOptional: boolean;
  21458. /**
  21459. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21460. */
  21461. isExposedOnFrame: boolean;
  21462. /**
  21463. * Gets or sets number indicating the position that the port is exposed to on a frame
  21464. */
  21465. exposedPortPosition: number;
  21466. /**
  21467. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21468. */
  21469. define: string;
  21470. /** @hidden */
  21471. _prioritizeVertex: boolean;
  21472. private _target;
  21473. /** Gets or sets the target of that connection point */
  21474. get target(): NodeMaterialBlockTargets;
  21475. set target(value: NodeMaterialBlockTargets);
  21476. /**
  21477. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21478. */
  21479. get isConnected(): boolean;
  21480. /**
  21481. * Gets a boolean indicating that the current point is connected to an input block
  21482. */
  21483. get isConnectedToInputBlock(): boolean;
  21484. /**
  21485. * Gets a the connected input block (if any)
  21486. */
  21487. get connectInputBlock(): Nullable<InputBlock>;
  21488. /** Get the other side of the connection (if any) */
  21489. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21490. /** Get the block that owns this connection point */
  21491. get ownerBlock(): NodeMaterialBlock;
  21492. /** Get the block connected on the other side of this connection (if any) */
  21493. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21494. /** Get the block connected on the endpoints of this connection (if any) */
  21495. get connectedBlocks(): Array<NodeMaterialBlock>;
  21496. /** Gets the list of connected endpoints */
  21497. get endpoints(): NodeMaterialConnectionPoint[];
  21498. /** Gets a boolean indicating if that output point is connected to at least one input */
  21499. get hasEndpoints(): boolean;
  21500. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21501. get isConnectedInVertexShader(): boolean;
  21502. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21503. get isConnectedInFragmentShader(): boolean;
  21504. /**
  21505. * Creates a block suitable to be used as an input for this input point.
  21506. * If null is returned, a block based on the point type will be created.
  21507. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21508. */
  21509. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21510. /**
  21511. * Creates a new connection point
  21512. * @param name defines the connection point name
  21513. * @param ownerBlock defines the block hosting this connection point
  21514. * @param direction defines the direction of the connection point
  21515. */
  21516. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21517. /**
  21518. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21519. * @returns the class name
  21520. */
  21521. getClassName(): string;
  21522. /**
  21523. * Gets a boolean indicating if the current point can be connected to another point
  21524. * @param connectionPoint defines the other connection point
  21525. * @returns a boolean
  21526. */
  21527. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21528. /**
  21529. * Gets a number indicating if the current point can be connected to another point
  21530. * @param connectionPoint defines the other connection point
  21531. * @returns a number defining the compatibility state
  21532. */
  21533. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21534. /**
  21535. * Connect this point to another connection point
  21536. * @param connectionPoint defines the other connection point
  21537. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21538. * @returns the current connection point
  21539. */
  21540. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Disconnect this point from one of his endpoint
  21543. * @param endpoint defines the other connection point
  21544. * @returns the current connection point
  21545. */
  21546. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Serializes this point in a JSON representation
  21549. * @param isInput defines if the connection point is an input (default is true)
  21550. * @returns the serialized point object
  21551. */
  21552. serialize(isInput?: boolean): any;
  21553. /**
  21554. * Release resources
  21555. */
  21556. dispose(): void;
  21557. }
  21558. }
  21559. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21560. /**
  21561. * Enum used to define the material modes
  21562. */
  21563. export enum NodeMaterialModes {
  21564. /** Regular material */
  21565. Material = 0,
  21566. /** For post process */
  21567. PostProcess = 1,
  21568. /** For particle system */
  21569. Particle = 2,
  21570. /** For procedural texture */
  21571. ProceduralTexture = 3
  21572. }
  21573. }
  21574. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21577. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21581. import { Effect } from "babylonjs/Materials/effect";
  21582. import { Mesh } from "babylonjs/Meshes/mesh";
  21583. import { Nullable } from "babylonjs/types";
  21584. import { Texture } from "babylonjs/Materials/Textures/texture";
  21585. import { Scene } from "babylonjs/scene";
  21586. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21587. /**
  21588. * Block used to read a texture from a sampler
  21589. */
  21590. export class TextureBlock extends NodeMaterialBlock {
  21591. private _defineName;
  21592. private _linearDefineName;
  21593. private _gammaDefineName;
  21594. private _tempTextureRead;
  21595. private _samplerName;
  21596. private _transformedUVName;
  21597. private _textureTransformName;
  21598. private _textureInfoName;
  21599. private _mainUVName;
  21600. private _mainUVDefineName;
  21601. private _fragmentOnly;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<Texture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new TextureBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string, fragmentOnly?: boolean);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. get target(): NodeMaterialBlockTargets;
  21653. autoConfigure(material: NodeMaterial): void;
  21654. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21656. isReady(): boolean;
  21657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21658. private get _isMixed();
  21659. private _injectVertexCode;
  21660. private _writeTextureRead;
  21661. private _writeOutput;
  21662. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21663. protected _dumpPropertiesCode(): string;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21669. /** @hidden */
  21670. export var reflectionFunction: {
  21671. name: string;
  21672. shader: string;
  21673. };
  21674. }
  21675. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21682. import { Effect } from "babylonjs/Materials/effect";
  21683. import { Mesh } from "babylonjs/Meshes/mesh";
  21684. import { Nullable } from "babylonjs/types";
  21685. import { Scene } from "babylonjs/scene";
  21686. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21687. /**
  21688. * Base block used to read a reflection texture from a sampler
  21689. */
  21690. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21691. /** @hidden */
  21692. _define3DName: string;
  21693. /** @hidden */
  21694. _defineCubicName: string;
  21695. /** @hidden */
  21696. _defineExplicitName: string;
  21697. /** @hidden */
  21698. _defineProjectionName: string;
  21699. /** @hidden */
  21700. _defineLocalCubicName: string;
  21701. /** @hidden */
  21702. _defineSphericalName: string;
  21703. /** @hidden */
  21704. _definePlanarName: string;
  21705. /** @hidden */
  21706. _defineEquirectangularName: string;
  21707. /** @hidden */
  21708. _defineMirroredEquirectangularFixedName: string;
  21709. /** @hidden */
  21710. _defineEquirectangularFixedName: string;
  21711. /** @hidden */
  21712. _defineSkyboxName: string;
  21713. /** @hidden */
  21714. _defineOppositeZ: string;
  21715. /** @hidden */
  21716. _cubeSamplerName: string;
  21717. /** @hidden */
  21718. _2DSamplerName: string;
  21719. protected _positionUVWName: string;
  21720. protected _directionWName: string;
  21721. protected _reflectionVectorName: string;
  21722. /** @hidden */
  21723. _reflectionCoordsName: string;
  21724. /** @hidden */
  21725. _reflectionMatrixName: string;
  21726. protected _reflectionColorName: string;
  21727. /**
  21728. * Gets or sets the texture associated with the node
  21729. */
  21730. texture: Nullable<BaseTexture>;
  21731. /**
  21732. * Create a new ReflectionTextureBaseBlock
  21733. * @param name defines the block name
  21734. */
  21735. constructor(name: string);
  21736. /**
  21737. * Gets the current class name
  21738. * @returns the class name
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Gets the world position input component
  21743. */
  21744. abstract get position(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the world position input component
  21747. */
  21748. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the world normal input component
  21751. */
  21752. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the world input component
  21755. */
  21756. abstract get world(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the camera (or eye) position component
  21759. */
  21760. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the view input component
  21763. */
  21764. abstract get view(): NodeMaterialConnectionPoint;
  21765. protected _getTexture(): Nullable<BaseTexture>;
  21766. autoConfigure(material: NodeMaterial): void;
  21767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21768. isReady(): boolean;
  21769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21770. /**
  21771. * Gets the code to inject in the vertex shader
  21772. * @param state current state of the node material building
  21773. * @returns the shader code
  21774. */
  21775. handleVertexSide(state: NodeMaterialBuildState): string;
  21776. /**
  21777. * Handles the inits for the fragment code path
  21778. * @param state node material build state
  21779. */
  21780. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21781. /**
  21782. * Generates the reflection coords code for the fragment code path
  21783. * @param worldNormalVarName name of the world normal variable
  21784. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21785. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21786. * @returns the shader code
  21787. */
  21788. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21789. /**
  21790. * Generates the reflection color code for the fragment code path
  21791. * @param lodVarName name of the lod variable
  21792. * @param swizzleLookupTexture swizzle to use for the final color variable
  21793. * @returns the shader code
  21794. */
  21795. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21796. /**
  21797. * Generates the code corresponding to the connected output points
  21798. * @param state node material build state
  21799. * @param varName name of the variable to output
  21800. * @returns the shader code
  21801. */
  21802. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21803. protected _buildBlock(state: NodeMaterialBuildState): this;
  21804. protected _dumpPropertiesCode(): string;
  21805. serialize(): any;
  21806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21807. }
  21808. }
  21809. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21811. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21812. import { Nullable } from "babylonjs/types";
  21813. /**
  21814. * Defines a connection point to be used for points with a custom object type
  21815. */
  21816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21817. private _blockType;
  21818. private _blockName;
  21819. private _nameForCheking?;
  21820. /**
  21821. * Creates a new connection point
  21822. * @param name defines the connection point name
  21823. * @param ownerBlock defines the block hosting this connection point
  21824. * @param direction defines the direction of the connection point
  21825. */
  21826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21827. /**
  21828. * Gets a number indicating if the current point can be connected to another point
  21829. * @param connectionPoint defines the other connection point
  21830. * @returns a number defining the compatibility state
  21831. */
  21832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21833. /**
  21834. * Creates a block suitable to be used as an input for this input point.
  21835. * If null is returned, a block based on the point type will be created.
  21836. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21837. */
  21838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21839. }
  21840. }
  21841. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21842. /**
  21843. * Enum defining the type of properties that can be edited in the property pages in the NME
  21844. */
  21845. export enum PropertyTypeForEdition {
  21846. /** property is a boolean */
  21847. Boolean = 0,
  21848. /** property is a float */
  21849. Float = 1,
  21850. /** property is a Vector2 */
  21851. Vector2 = 2,
  21852. /** property is a list of values */
  21853. List = 3
  21854. }
  21855. /**
  21856. * Interface that defines an option in a variable of type list
  21857. */
  21858. export interface IEditablePropertyListOption {
  21859. /** label of the option */
  21860. "label": string;
  21861. /** value of the option */
  21862. "value": number;
  21863. }
  21864. /**
  21865. * Interface that defines the options available for an editable property
  21866. */
  21867. export interface IEditablePropertyOption {
  21868. /** min value */
  21869. "min"?: number;
  21870. /** max value */
  21871. "max"?: number;
  21872. /** notifiers: indicates which actions to take when the property is changed */
  21873. "notifiers"?: {
  21874. /** the material should be rebuilt */
  21875. "rebuild"?: boolean;
  21876. /** the preview should be updated */
  21877. "update"?: boolean;
  21878. };
  21879. /** list of the options for a variable of type list */
  21880. "options"?: IEditablePropertyListOption[];
  21881. }
  21882. /**
  21883. * Interface that describes an editable property
  21884. */
  21885. export interface IPropertyDescriptionForEdition {
  21886. /** name of the property */
  21887. "propertyName": string;
  21888. /** display name of the property */
  21889. "displayName": string;
  21890. /** type of the property */
  21891. "type": PropertyTypeForEdition;
  21892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21893. "groupName": string;
  21894. /** options for the property */
  21895. "options": IEditablePropertyOption;
  21896. }
  21897. /**
  21898. * Decorator that flags a property in a node material block as being editable
  21899. */
  21900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21901. }
  21902. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21905. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21907. import { Nullable } from "babylonjs/types";
  21908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21909. import { Mesh } from "babylonjs/Meshes/mesh";
  21910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21911. import { Effect } from "babylonjs/Materials/effect";
  21912. import { Scene } from "babylonjs/scene";
  21913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21914. /**
  21915. * Block used to implement the refraction part of the sub surface module of the PBR material
  21916. */
  21917. export class RefractionBlock extends NodeMaterialBlock {
  21918. /** @hidden */
  21919. _define3DName: string;
  21920. /** @hidden */
  21921. _refractionMatrixName: string;
  21922. /** @hidden */
  21923. _defineLODRefractionAlpha: string;
  21924. /** @hidden */
  21925. _defineLinearSpecularRefraction: string;
  21926. /** @hidden */
  21927. _defineOppositeZ: string;
  21928. /** @hidden */
  21929. _cubeSamplerName: string;
  21930. /** @hidden */
  21931. _2DSamplerName: string;
  21932. /** @hidden */
  21933. _vRefractionMicrosurfaceInfosName: string;
  21934. /** @hidden */
  21935. _vRefractionInfosName: string;
  21936. private _scene;
  21937. /**
  21938. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21939. * Materials half opaque for instance using refraction could benefit from this control.
  21940. */
  21941. linkRefractionWithTransparency: boolean;
  21942. /**
  21943. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21944. */
  21945. invertRefractionY: boolean;
  21946. /**
  21947. * Gets or sets the texture associated with the node
  21948. */
  21949. texture: Nullable<BaseTexture>;
  21950. /**
  21951. * Create a new RefractionBlock
  21952. * @param name defines the block name
  21953. */
  21954. constructor(name: string);
  21955. /**
  21956. * Gets the current class name
  21957. * @returns the class name
  21958. */
  21959. getClassName(): string;
  21960. /**
  21961. * Gets the intensity input component
  21962. */
  21963. get intensity(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the index of refraction input component
  21966. */
  21967. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the tint at distance input component
  21970. */
  21971. get tintAtDistance(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the view input component
  21974. */
  21975. get view(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the refraction object output component
  21978. */
  21979. get refraction(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Returns true if the block has a texture
  21982. */
  21983. get hasTexture(): boolean;
  21984. protected _getTexture(): Nullable<BaseTexture>;
  21985. autoConfigure(material: NodeMaterial): void;
  21986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21987. isReady(): boolean;
  21988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21989. /**
  21990. * Gets the main code of the block (fragment side)
  21991. * @param state current state of the node material building
  21992. * @returns the shader code
  21993. */
  21994. getCode(state: NodeMaterialBuildState): string;
  21995. protected _buildBlock(state: NodeMaterialBuildState): this;
  21996. protected _dumpPropertiesCode(): string;
  21997. serialize(): any;
  21998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22004. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22007. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22009. import { Nullable } from "babylonjs/types";
  22010. import { Scene } from "babylonjs/scene";
  22011. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22012. /**
  22013. * Base block used as input for post process
  22014. */
  22015. export class CurrentScreenBlock extends NodeMaterialBlock {
  22016. private _samplerName;
  22017. private _linearDefineName;
  22018. private _gammaDefineName;
  22019. private _mainUVName;
  22020. private _tempTextureRead;
  22021. /**
  22022. * Gets or sets the texture associated with the node
  22023. */
  22024. texture: Nullable<BaseTexture>;
  22025. /**
  22026. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22027. */
  22028. convertToGammaSpace: boolean;
  22029. /**
  22030. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22031. */
  22032. convertToLinearSpace: boolean;
  22033. /**
  22034. * Create a new CurrentScreenBlock
  22035. * @param name defines the block name
  22036. */
  22037. constructor(name: string);
  22038. /**
  22039. * Gets the current class name
  22040. * @returns the class name
  22041. */
  22042. getClassName(): string;
  22043. /**
  22044. * Gets the uv input component
  22045. */
  22046. get uv(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the rgba output component
  22049. */
  22050. get rgba(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the rgb output component
  22053. */
  22054. get rgb(): NodeMaterialConnectionPoint;
  22055. /**
  22056. * Gets the r output component
  22057. */
  22058. get r(): NodeMaterialConnectionPoint;
  22059. /**
  22060. * Gets the g output component
  22061. */
  22062. get g(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the b output component
  22065. */
  22066. get b(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the a output component
  22069. */
  22070. get a(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Initialize the block and prepare the context for build
  22073. * @param state defines the state that will be used for the build
  22074. */
  22075. initialize(state: NodeMaterialBuildState): void;
  22076. get target(): NodeMaterialBlockTargets;
  22077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22078. isReady(): boolean;
  22079. private _injectVertexCode;
  22080. private _writeTextureRead;
  22081. private _writeOutput;
  22082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22083. serialize(): any;
  22084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22085. }
  22086. }
  22087. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22092. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { Scene } from "babylonjs/scene";
  22096. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22097. /**
  22098. * Base block used for the particle texture
  22099. */
  22100. export class ParticleTextureBlock extends NodeMaterialBlock {
  22101. private _samplerName;
  22102. private _linearDefineName;
  22103. private _gammaDefineName;
  22104. private _tempTextureRead;
  22105. /**
  22106. * Gets or sets the texture associated with the node
  22107. */
  22108. texture: Nullable<BaseTexture>;
  22109. /**
  22110. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22111. */
  22112. convertToGammaSpace: boolean;
  22113. /**
  22114. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22115. */
  22116. convertToLinearSpace: boolean;
  22117. /**
  22118. * Create a new ParticleTextureBlock
  22119. * @param name defines the block name
  22120. */
  22121. constructor(name: string);
  22122. /**
  22123. * Gets the current class name
  22124. * @returns the class name
  22125. */
  22126. getClassName(): string;
  22127. /**
  22128. * Gets the uv input component
  22129. */
  22130. get uv(): NodeMaterialConnectionPoint;
  22131. /**
  22132. * Gets the rgba output component
  22133. */
  22134. get rgba(): NodeMaterialConnectionPoint;
  22135. /**
  22136. * Gets the rgb output component
  22137. */
  22138. get rgb(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the r output component
  22141. */
  22142. get r(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the g output component
  22145. */
  22146. get g(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the b output component
  22149. */
  22150. get b(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the a output component
  22153. */
  22154. get a(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Initialize the block and prepare the context for build
  22157. * @param state defines the state that will be used for the build
  22158. */
  22159. initialize(state: NodeMaterialBuildState): void;
  22160. autoConfigure(material: NodeMaterial): void;
  22161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22162. isReady(): boolean;
  22163. private _writeOutput;
  22164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22165. serialize(): any;
  22166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22167. }
  22168. }
  22169. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22172. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22173. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22174. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22175. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22176. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22177. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22178. import { Scene } from "babylonjs/scene";
  22179. /**
  22180. * Class used to store shared data between 2 NodeMaterialBuildState
  22181. */
  22182. export class NodeMaterialBuildStateSharedData {
  22183. /**
  22184. * Gets the list of emitted varyings
  22185. */
  22186. temps: string[];
  22187. /**
  22188. * Gets the list of emitted varyings
  22189. */
  22190. varyings: string[];
  22191. /**
  22192. * Gets the varying declaration string
  22193. */
  22194. varyingDeclaration: string;
  22195. /**
  22196. * Input blocks
  22197. */
  22198. inputBlocks: InputBlock[];
  22199. /**
  22200. * Input blocks
  22201. */
  22202. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22203. /**
  22204. * Bindable blocks (Blocks that need to set data to the effect)
  22205. */
  22206. bindableBlocks: NodeMaterialBlock[];
  22207. /**
  22208. * List of blocks that can provide a compilation fallback
  22209. */
  22210. blocksWithFallbacks: NodeMaterialBlock[];
  22211. /**
  22212. * List of blocks that can provide a define update
  22213. */
  22214. blocksWithDefines: NodeMaterialBlock[];
  22215. /**
  22216. * List of blocks that can provide a repeatable content
  22217. */
  22218. repeatableContentBlocks: NodeMaterialBlock[];
  22219. /**
  22220. * List of blocks that can provide a dynamic list of uniforms
  22221. */
  22222. dynamicUniformBlocks: NodeMaterialBlock[];
  22223. /**
  22224. * List of blocks that can block the isReady function for the material
  22225. */
  22226. blockingBlocks: NodeMaterialBlock[];
  22227. /**
  22228. * Gets the list of animated inputs
  22229. */
  22230. animatedInputs: InputBlock[];
  22231. /**
  22232. * Build Id used to avoid multiple recompilations
  22233. */
  22234. buildId: number;
  22235. /** List of emitted variables */
  22236. variableNames: {
  22237. [key: string]: number;
  22238. };
  22239. /** List of emitted defines */
  22240. defineNames: {
  22241. [key: string]: number;
  22242. };
  22243. /** Should emit comments? */
  22244. emitComments: boolean;
  22245. /** Emit build activity */
  22246. verbose: boolean;
  22247. /** Gets or sets the hosting scene */
  22248. scene: Scene;
  22249. /**
  22250. * Gets the compilation hints emitted at compilation time
  22251. */
  22252. hints: {
  22253. needWorldViewMatrix: boolean;
  22254. needWorldViewProjectionMatrix: boolean;
  22255. needAlphaBlending: boolean;
  22256. needAlphaTesting: boolean;
  22257. };
  22258. /**
  22259. * List of compilation checks
  22260. */
  22261. checks: {
  22262. emitVertex: boolean;
  22263. emitFragment: boolean;
  22264. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22265. };
  22266. /**
  22267. * Is vertex program allowed to be empty?
  22268. */
  22269. allowEmptyVertexProgram: boolean;
  22270. /** Creates a new shared data */
  22271. constructor();
  22272. /**
  22273. * Emits console errors and exceptions if there is a failing check
  22274. */
  22275. emitErrors(): void;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22279. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22280. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22281. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22282. /**
  22283. * Class used to store node based material build state
  22284. */
  22285. export class NodeMaterialBuildState {
  22286. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22287. supportUniformBuffers: boolean;
  22288. /**
  22289. * Gets the list of emitted attributes
  22290. */
  22291. attributes: string[];
  22292. /**
  22293. * Gets the list of emitted uniforms
  22294. */
  22295. uniforms: string[];
  22296. /**
  22297. * Gets the list of emitted constants
  22298. */
  22299. constants: string[];
  22300. /**
  22301. * Gets the list of emitted samplers
  22302. */
  22303. samplers: string[];
  22304. /**
  22305. * Gets the list of emitted functions
  22306. */
  22307. functions: {
  22308. [key: string]: string;
  22309. };
  22310. /**
  22311. * Gets the list of emitted extensions
  22312. */
  22313. extensions: {
  22314. [key: string]: string;
  22315. };
  22316. /**
  22317. * Gets the target of the compilation state
  22318. */
  22319. target: NodeMaterialBlockTargets;
  22320. /**
  22321. * Gets the list of emitted counters
  22322. */
  22323. counters: {
  22324. [key: string]: number;
  22325. };
  22326. /**
  22327. * Shared data between multiple NodeMaterialBuildState instances
  22328. */
  22329. sharedData: NodeMaterialBuildStateSharedData;
  22330. /** @hidden */
  22331. _vertexState: NodeMaterialBuildState;
  22332. /** @hidden */
  22333. _attributeDeclaration: string;
  22334. /** @hidden */
  22335. _uniformDeclaration: string;
  22336. /** @hidden */
  22337. _constantDeclaration: string;
  22338. /** @hidden */
  22339. _samplerDeclaration: string;
  22340. /** @hidden */
  22341. _varyingTransfer: string;
  22342. /** @hidden */
  22343. _injectAtEnd: string;
  22344. private _repeatableContentAnchorIndex;
  22345. /** @hidden */
  22346. _builtCompilationString: string;
  22347. /**
  22348. * Gets the emitted compilation strings
  22349. */
  22350. compilationString: string;
  22351. /**
  22352. * Finalize the compilation strings
  22353. * @param state defines the current compilation state
  22354. */
  22355. finalize(state: NodeMaterialBuildState): void;
  22356. /** @hidden */
  22357. get _repeatableContentAnchor(): string;
  22358. /** @hidden */
  22359. _getFreeVariableName(prefix: string): string;
  22360. /** @hidden */
  22361. _getFreeDefineName(prefix: string): string;
  22362. /** @hidden */
  22363. _excludeVariableName(name: string): void;
  22364. /** @hidden */
  22365. _emit2DSampler(name: string): void;
  22366. /** @hidden */
  22367. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22368. /** @hidden */
  22369. _emitExtension(name: string, extension: string, define?: string): void;
  22370. /** @hidden */
  22371. _emitFunction(name: string, code: string, comments: string): void;
  22372. /** @hidden */
  22373. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22374. replaceStrings?: {
  22375. search: RegExp;
  22376. replace: string;
  22377. }[];
  22378. repeatKey?: string;
  22379. }): string;
  22380. /** @hidden */
  22381. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22382. repeatKey?: string;
  22383. removeAttributes?: boolean;
  22384. removeUniforms?: boolean;
  22385. removeVaryings?: boolean;
  22386. removeIfDef?: boolean;
  22387. replaceStrings?: {
  22388. search: RegExp;
  22389. replace: string;
  22390. }[];
  22391. }, storeKey?: string): void;
  22392. /** @hidden */
  22393. _registerTempVariable(name: string): boolean;
  22394. /** @hidden */
  22395. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22396. /** @hidden */
  22397. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22398. /** @hidden */
  22399. _emitFloat(value: number): string;
  22400. }
  22401. }
  22402. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22403. /**
  22404. * Helper class used to generate session unique ID
  22405. */
  22406. export class UniqueIdGenerator {
  22407. private static _UniqueIdCounter;
  22408. /**
  22409. * Gets an unique (relatively to the current scene) Id
  22410. */
  22411. static get UniqueId(): number;
  22412. }
  22413. }
  22414. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22415. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22417. import { Nullable } from "babylonjs/types";
  22418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22419. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22420. import { Effect } from "babylonjs/Materials/effect";
  22421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22422. import { Mesh } from "babylonjs/Meshes/mesh";
  22423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22424. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22425. import { Scene } from "babylonjs/scene";
  22426. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22427. /**
  22428. * Defines a block that can be used inside a node based material
  22429. */
  22430. export class NodeMaterialBlock {
  22431. private _buildId;
  22432. private _buildTarget;
  22433. private _target;
  22434. private _isFinalMerger;
  22435. private _isInput;
  22436. private _name;
  22437. protected _isUnique: boolean;
  22438. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22439. inputsAreExclusive: boolean;
  22440. /** @hidden */
  22441. _codeVariableName: string;
  22442. /** @hidden */
  22443. _inputs: NodeMaterialConnectionPoint[];
  22444. /** @hidden */
  22445. _outputs: NodeMaterialConnectionPoint[];
  22446. /** @hidden */
  22447. _preparationId: number;
  22448. /**
  22449. * Gets the name of the block
  22450. */
  22451. get name(): string;
  22452. /**
  22453. * Sets the name of the block. Will check if the name is valid.
  22454. */
  22455. set name(newName: string);
  22456. /**
  22457. * Gets or sets the unique id of the node
  22458. */
  22459. uniqueId: number;
  22460. /**
  22461. * Gets or sets the comments associated with this block
  22462. */
  22463. comments: string;
  22464. /**
  22465. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22466. */
  22467. get isUnique(): boolean;
  22468. /**
  22469. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22470. */
  22471. get isFinalMerger(): boolean;
  22472. /**
  22473. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22474. */
  22475. get isInput(): boolean;
  22476. /**
  22477. * Gets or sets the build Id
  22478. */
  22479. get buildId(): number;
  22480. set buildId(value: number);
  22481. /**
  22482. * Gets or sets the target of the block
  22483. */
  22484. get target(): NodeMaterialBlockTargets;
  22485. set target(value: NodeMaterialBlockTargets);
  22486. /**
  22487. * Gets the list of input points
  22488. */
  22489. get inputs(): NodeMaterialConnectionPoint[];
  22490. /** Gets the list of output points */
  22491. get outputs(): NodeMaterialConnectionPoint[];
  22492. /**
  22493. * Find an input by its name
  22494. * @param name defines the name of the input to look for
  22495. * @returns the input or null if not found
  22496. */
  22497. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22498. /**
  22499. * Find an output by its name
  22500. * @param name defines the name of the outputto look for
  22501. * @returns the output or null if not found
  22502. */
  22503. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22504. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22505. visibleInInspector: boolean;
  22506. /**
  22507. * Creates a new NodeMaterialBlock
  22508. * @param name defines the block name
  22509. * @param target defines the target of that block (Vertex by default)
  22510. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22511. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22512. */
  22513. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22514. /**
  22515. * Initialize the block and prepare the context for build
  22516. * @param state defines the state that will be used for the build
  22517. */
  22518. initialize(state: NodeMaterialBuildState): void;
  22519. /**
  22520. * Bind data to effect. Will only be called for blocks with isBindable === true
  22521. * @param effect defines the effect to bind data to
  22522. * @param nodeMaterial defines the hosting NodeMaterial
  22523. * @param mesh defines the mesh that will be rendered
  22524. * @param subMesh defines the submesh that will be rendered
  22525. */
  22526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22527. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22528. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22529. protected _writeFloat(value: number): string;
  22530. /**
  22531. * Gets the current class name e.g. "NodeMaterialBlock"
  22532. * @returns the class name
  22533. */
  22534. getClassName(): string;
  22535. /**
  22536. * Register a new input. Must be called inside a block constructor
  22537. * @param name defines the connection point name
  22538. * @param type defines the connection point type
  22539. * @param isOptional defines a boolean indicating that this input can be omitted
  22540. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22541. * @param point an already created connection point. If not provided, create a new one
  22542. * @returns the current block
  22543. */
  22544. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22545. /**
  22546. * Register a new output. Must be called inside a block constructor
  22547. * @param name defines the connection point name
  22548. * @param type defines the connection point type
  22549. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22550. * @param point an already created connection point. If not provided, create a new one
  22551. * @returns the current block
  22552. */
  22553. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22554. /**
  22555. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22556. * @param forOutput defines an optional connection point to check compatibility with
  22557. * @returns the first available input or null
  22558. */
  22559. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22560. /**
  22561. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22562. * @param forBlock defines an optional block to check compatibility with
  22563. * @returns the first available input or null
  22564. */
  22565. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22566. /**
  22567. * Gets the sibling of the given output
  22568. * @param current defines the current output
  22569. * @returns the next output in the list or null
  22570. */
  22571. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22572. /**
  22573. * Connect current block with another block
  22574. * @param other defines the block to connect with
  22575. * @param options define the various options to help pick the right connections
  22576. * @returns the current block
  22577. */
  22578. connectTo(other: NodeMaterialBlock, options?: {
  22579. input?: string;
  22580. output?: string;
  22581. outputSwizzle?: string;
  22582. }): this | undefined;
  22583. protected _buildBlock(state: NodeMaterialBuildState): void;
  22584. /**
  22585. * Add uniforms, samplers and uniform buffers at compilation time
  22586. * @param state defines the state to update
  22587. * @param nodeMaterial defines the node material requesting the update
  22588. * @param defines defines the material defines to update
  22589. * @param uniformBuffers defines the list of uniform buffer names
  22590. */
  22591. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22592. /**
  22593. * Add potential fallbacks if shader compilation fails
  22594. * @param mesh defines the mesh to be rendered
  22595. * @param fallbacks defines the current prioritized list of fallbacks
  22596. */
  22597. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22598. /**
  22599. * Initialize defines for shader compilation
  22600. * @param mesh defines the mesh to be rendered
  22601. * @param nodeMaterial defines the node material requesting the update
  22602. * @param defines defines the material defines to update
  22603. * @param useInstances specifies that instances should be used
  22604. */
  22605. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22606. /**
  22607. * Update defines for shader compilation
  22608. * @param mesh defines the mesh to be rendered
  22609. * @param nodeMaterial defines the node material requesting the update
  22610. * @param defines defines the material defines to update
  22611. * @param useInstances specifies that instances should be used
  22612. * @param subMesh defines which submesh to render
  22613. */
  22614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22615. /**
  22616. * Lets the block try to connect some inputs automatically
  22617. * @param material defines the hosting NodeMaterial
  22618. */
  22619. autoConfigure(material: NodeMaterial): void;
  22620. /**
  22621. * Function called when a block is declared as repeatable content generator
  22622. * @param vertexShaderState defines the current compilation state for the vertex shader
  22623. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param defines defines the material defines to update
  22626. */
  22627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22628. /**
  22629. * Checks if the block is ready
  22630. * @param mesh defines the mesh to be rendered
  22631. * @param nodeMaterial defines the node material requesting the update
  22632. * @param defines defines the material defines to update
  22633. * @param useInstances specifies that instances should be used
  22634. * @returns true if the block is ready
  22635. */
  22636. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22637. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22638. private _processBuild;
  22639. /**
  22640. * Validates the new name for the block node.
  22641. * @param newName the new name to be given to the node.
  22642. * @returns false if the name is a reserve word, else true.
  22643. */
  22644. validateBlockName(newName: string): boolean;
  22645. /**
  22646. * Compile the current node and generate the shader code
  22647. * @param state defines the current compilation state (uniforms, samplers, current string)
  22648. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22649. * @returns true if already built
  22650. */
  22651. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22652. protected _inputRename(name: string): string;
  22653. protected _outputRename(name: string): string;
  22654. protected _dumpPropertiesCode(): string;
  22655. /** @hidden */
  22656. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22657. /** @hidden */
  22658. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22659. /**
  22660. * Clone the current block to a new identical block
  22661. * @param scene defines the hosting scene
  22662. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22663. * @returns a copy of the current block
  22664. */
  22665. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22666. /**
  22667. * Serializes this block in a JSON representation
  22668. * @returns the serialized block object
  22669. */
  22670. serialize(): any;
  22671. /** @hidden */
  22672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22673. private _deserializePortDisplayNamesAndExposedOnFrame;
  22674. /**
  22675. * Release resources
  22676. */
  22677. dispose(): void;
  22678. }
  22679. }
  22680. declare module "babylonjs/Materials/pushMaterial" {
  22681. import { Nullable } from "babylonjs/types";
  22682. import { Scene } from "babylonjs/scene";
  22683. import { Matrix } from "babylonjs/Maths/math.vector";
  22684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22685. import { Mesh } from "babylonjs/Meshes/mesh";
  22686. import { Material } from "babylonjs/Materials/material";
  22687. import { Effect } from "babylonjs/Materials/effect";
  22688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22689. /**
  22690. * Base class of materials working in push mode in babylon JS
  22691. * @hidden
  22692. */
  22693. export class PushMaterial extends Material {
  22694. protected _activeEffect: Effect;
  22695. protected _normalMatrix: Matrix;
  22696. constructor(name: string, scene: Scene);
  22697. getEffect(): Effect;
  22698. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22699. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22700. /**
  22701. * Binds the given world matrix to the active effect
  22702. *
  22703. * @param world the matrix to bind
  22704. */
  22705. bindOnlyWorldMatrix(world: Matrix): void;
  22706. /**
  22707. * Binds the given normal matrix to the active effect
  22708. *
  22709. * @param normalMatrix the matrix to bind
  22710. */
  22711. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22712. bind(world: Matrix, mesh?: Mesh): void;
  22713. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22714. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22715. }
  22716. }
  22717. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22719. /**
  22720. * Root class for all node material optimizers
  22721. */
  22722. export class NodeMaterialOptimizer {
  22723. /**
  22724. * Function used to optimize a NodeMaterial graph
  22725. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22726. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22727. */
  22728. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22729. }
  22730. }
  22731. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22735. import { Scene } from "babylonjs/scene";
  22736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22739. /**
  22740. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22741. */
  22742. export class TransformBlock extends NodeMaterialBlock {
  22743. /**
  22744. * Defines the value to use to complement W value to transform it to a Vector4
  22745. */
  22746. complementW: number;
  22747. /**
  22748. * Defines the value to use to complement z value to transform it to a Vector4
  22749. */
  22750. complementZ: number;
  22751. /**
  22752. * Creates a new TransformBlock
  22753. * @param name defines the block name
  22754. */
  22755. constructor(name: string);
  22756. /**
  22757. * Gets the current class name
  22758. * @returns the class name
  22759. */
  22760. getClassName(): string;
  22761. /**
  22762. * Gets the vector input
  22763. */
  22764. get vector(): NodeMaterialConnectionPoint;
  22765. /**
  22766. * Gets the output component
  22767. */
  22768. get output(): NodeMaterialConnectionPoint;
  22769. /**
  22770. * Gets the xyz output component
  22771. */
  22772. get xyz(): NodeMaterialConnectionPoint;
  22773. /**
  22774. * Gets the matrix transform input
  22775. */
  22776. get transform(): NodeMaterialConnectionPoint;
  22777. protected _buildBlock(state: NodeMaterialBuildState): this;
  22778. /**
  22779. * Update defines for shader compilation
  22780. * @param mesh defines the mesh to be rendered
  22781. * @param nodeMaterial defines the node material requesting the update
  22782. * @param defines defines the material defines to update
  22783. * @param useInstances specifies that instances should be used
  22784. * @param subMesh defines which submesh to render
  22785. */
  22786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22787. serialize(): any;
  22788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22789. protected _dumpPropertiesCode(): string;
  22790. }
  22791. }
  22792. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22796. /**
  22797. * Block used to output the vertex position
  22798. */
  22799. export class VertexOutputBlock extends NodeMaterialBlock {
  22800. /**
  22801. * Creates a new VertexOutputBlock
  22802. * @param name defines the block name
  22803. */
  22804. constructor(name: string);
  22805. /**
  22806. * Gets the current class name
  22807. * @returns the class name
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Gets the vector input component
  22812. */
  22813. get vector(): NodeMaterialConnectionPoint;
  22814. protected _buildBlock(state: NodeMaterialBuildState): this;
  22815. }
  22816. }
  22817. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22821. /**
  22822. * Block used to output the final color
  22823. */
  22824. export class FragmentOutputBlock extends NodeMaterialBlock {
  22825. /**
  22826. * Create a new FragmentOutputBlock
  22827. * @param name defines the block name
  22828. */
  22829. constructor(name: string);
  22830. /**
  22831. * Gets the current class name
  22832. * @returns the class name
  22833. */
  22834. getClassName(): string;
  22835. /**
  22836. * Gets the rgba input component
  22837. */
  22838. get rgba(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the rgb input component
  22841. */
  22842. get rgb(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the a input component
  22845. */
  22846. get a(): NodeMaterialConnectionPoint;
  22847. protected _buildBlock(state: NodeMaterialBuildState): this;
  22848. }
  22849. }
  22850. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22854. /**
  22855. * Block used for the particle ramp gradient section
  22856. */
  22857. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22858. /**
  22859. * Create a new ParticleRampGradientBlock
  22860. * @param name defines the block name
  22861. */
  22862. constructor(name: string);
  22863. /**
  22864. * Gets the current class name
  22865. * @returns the class name
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Gets the color input component
  22870. */
  22871. get color(): NodeMaterialConnectionPoint;
  22872. /**
  22873. * Gets the rampColor output component
  22874. */
  22875. get rampColor(): NodeMaterialConnectionPoint;
  22876. /**
  22877. * Initialize the block and prepare the context for build
  22878. * @param state defines the state that will be used for the build
  22879. */
  22880. initialize(state: NodeMaterialBuildState): void;
  22881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22882. }
  22883. }
  22884. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22888. /**
  22889. * Block used for the particle blend multiply section
  22890. */
  22891. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22892. /**
  22893. * Create a new ParticleBlendMultiplyBlock
  22894. * @param name defines the block name
  22895. */
  22896. constructor(name: string);
  22897. /**
  22898. * Gets the current class name
  22899. * @returns the class name
  22900. */
  22901. getClassName(): string;
  22902. /**
  22903. * Gets the color input component
  22904. */
  22905. get color(): NodeMaterialConnectionPoint;
  22906. /**
  22907. * Gets the alphaTexture input component
  22908. */
  22909. get alphaTexture(): NodeMaterialConnectionPoint;
  22910. /**
  22911. * Gets the alphaColor input component
  22912. */
  22913. get alphaColor(): NodeMaterialConnectionPoint;
  22914. /**
  22915. * Gets the blendColor output component
  22916. */
  22917. get blendColor(): NodeMaterialConnectionPoint;
  22918. /**
  22919. * Initialize the block and prepare the context for build
  22920. * @param state defines the state that will be used for the build
  22921. */
  22922. initialize(state: NodeMaterialBuildState): void;
  22923. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22924. }
  22925. }
  22926. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22930. /**
  22931. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22932. */
  22933. export class VectorMergerBlock extends NodeMaterialBlock {
  22934. /**
  22935. * Create a new VectorMergerBlock
  22936. * @param name defines the block name
  22937. */
  22938. constructor(name: string);
  22939. /**
  22940. * Gets the current class name
  22941. * @returns the class name
  22942. */
  22943. getClassName(): string;
  22944. /**
  22945. * Gets the xyz component (input)
  22946. */
  22947. get xyzIn(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the xy component (input)
  22950. */
  22951. get xyIn(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the x component (input)
  22954. */
  22955. get x(): NodeMaterialConnectionPoint;
  22956. /**
  22957. * Gets the y component (input)
  22958. */
  22959. get y(): NodeMaterialConnectionPoint;
  22960. /**
  22961. * Gets the z component (input)
  22962. */
  22963. get z(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the w component (input)
  22966. */
  22967. get w(): NodeMaterialConnectionPoint;
  22968. /**
  22969. * Gets the xyzw component (output)
  22970. */
  22971. get xyzw(): NodeMaterialConnectionPoint;
  22972. /**
  22973. * Gets the xyz component (output)
  22974. */
  22975. get xyzOut(): NodeMaterialConnectionPoint;
  22976. /**
  22977. * Gets the xy component (output)
  22978. */
  22979. get xyOut(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the xy component (output)
  22982. * @deprecated Please use xyOut instead.
  22983. */
  22984. get xy(): NodeMaterialConnectionPoint;
  22985. /**
  22986. * Gets the xyz component (output)
  22987. * @deprecated Please use xyzOut instead.
  22988. */
  22989. get xyz(): NodeMaterialConnectionPoint;
  22990. protected _buildBlock(state: NodeMaterialBuildState): this;
  22991. }
  22992. }
  22993. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22997. import { Vector2 } from "babylonjs/Maths/math.vector";
  22998. import { Scene } from "babylonjs/scene";
  22999. /**
  23000. * Block used to remap a float from a range to a new one
  23001. */
  23002. export class RemapBlock extends NodeMaterialBlock {
  23003. /**
  23004. * Gets or sets the source range
  23005. */
  23006. sourceRange: Vector2;
  23007. /**
  23008. * Gets or sets the target range
  23009. */
  23010. targetRange: Vector2;
  23011. /**
  23012. * Creates a new RemapBlock
  23013. * @param name defines the block name
  23014. */
  23015. constructor(name: string);
  23016. /**
  23017. * Gets the current class name
  23018. * @returns the class name
  23019. */
  23020. getClassName(): string;
  23021. /**
  23022. * Gets the input component
  23023. */
  23024. get input(): NodeMaterialConnectionPoint;
  23025. /**
  23026. * Gets the source min input component
  23027. */
  23028. get sourceMin(): NodeMaterialConnectionPoint;
  23029. /**
  23030. * Gets the source max input component
  23031. */
  23032. get sourceMax(): NodeMaterialConnectionPoint;
  23033. /**
  23034. * Gets the target min input component
  23035. */
  23036. get targetMin(): NodeMaterialConnectionPoint;
  23037. /**
  23038. * Gets the target max input component
  23039. */
  23040. get targetMax(): NodeMaterialConnectionPoint;
  23041. /**
  23042. * Gets the output component
  23043. */
  23044. get output(): NodeMaterialConnectionPoint;
  23045. protected _buildBlock(state: NodeMaterialBuildState): this;
  23046. protected _dumpPropertiesCode(): string;
  23047. serialize(): any;
  23048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23049. }
  23050. }
  23051. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23055. /**
  23056. * Block used to multiply 2 values
  23057. */
  23058. export class MultiplyBlock extends NodeMaterialBlock {
  23059. /**
  23060. * Creates a new MultiplyBlock
  23061. * @param name defines the block name
  23062. */
  23063. constructor(name: string);
  23064. /**
  23065. * Gets the current class name
  23066. * @returns the class name
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Gets the left operand input component
  23071. */
  23072. get left(): NodeMaterialConnectionPoint;
  23073. /**
  23074. * Gets the right operand input component
  23075. */
  23076. get right(): NodeMaterialConnectionPoint;
  23077. /**
  23078. * Gets the output component
  23079. */
  23080. get output(): NodeMaterialConnectionPoint;
  23081. protected _buildBlock(state: NodeMaterialBuildState): this;
  23082. }
  23083. }
  23084. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23088. /**
  23089. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23090. */
  23091. export class ColorSplitterBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Create a new ColorSplitterBlock
  23094. * @param name defines the block name
  23095. */
  23096. constructor(name: string);
  23097. /**
  23098. * Gets the current class name
  23099. * @returns the class name
  23100. */
  23101. getClassName(): string;
  23102. /**
  23103. * Gets the rgba component (input)
  23104. */
  23105. get rgba(): NodeMaterialConnectionPoint;
  23106. /**
  23107. * Gets the rgb component (input)
  23108. */
  23109. get rgbIn(): NodeMaterialConnectionPoint;
  23110. /**
  23111. * Gets the rgb component (output)
  23112. */
  23113. get rgbOut(): NodeMaterialConnectionPoint;
  23114. /**
  23115. * Gets the r component (output)
  23116. */
  23117. get r(): NodeMaterialConnectionPoint;
  23118. /**
  23119. * Gets the g component (output)
  23120. */
  23121. get g(): NodeMaterialConnectionPoint;
  23122. /**
  23123. * Gets the b component (output)
  23124. */
  23125. get b(): NodeMaterialConnectionPoint;
  23126. /**
  23127. * Gets the a component (output)
  23128. */
  23129. get a(): NodeMaterialConnectionPoint;
  23130. protected _inputRename(name: string): string;
  23131. protected _outputRename(name: string): string;
  23132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23133. }
  23134. }
  23135. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23139. import { Scene } from "babylonjs/scene";
  23140. /**
  23141. * Operations supported by the Trigonometry block
  23142. */
  23143. export enum TrigonometryBlockOperations {
  23144. /** Cos */
  23145. Cos = 0,
  23146. /** Sin */
  23147. Sin = 1,
  23148. /** Abs */
  23149. Abs = 2,
  23150. /** Exp */
  23151. Exp = 3,
  23152. /** Exp2 */
  23153. Exp2 = 4,
  23154. /** Round */
  23155. Round = 5,
  23156. /** Floor */
  23157. Floor = 6,
  23158. /** Ceiling */
  23159. Ceiling = 7,
  23160. /** Square root */
  23161. Sqrt = 8,
  23162. /** Log */
  23163. Log = 9,
  23164. /** Tangent */
  23165. Tan = 10,
  23166. /** Arc tangent */
  23167. ArcTan = 11,
  23168. /** Arc cosinus */
  23169. ArcCos = 12,
  23170. /** Arc sinus */
  23171. ArcSin = 13,
  23172. /** Fraction */
  23173. Fract = 14,
  23174. /** Sign */
  23175. Sign = 15,
  23176. /** To radians (from degrees) */
  23177. Radians = 16,
  23178. /** To degrees (from radians) */
  23179. Degrees = 17
  23180. }
  23181. /**
  23182. * Block used to apply trigonometry operation to floats
  23183. */
  23184. export class TrigonometryBlock extends NodeMaterialBlock {
  23185. /**
  23186. * Gets or sets the operation applied by the block
  23187. */
  23188. operation: TrigonometryBlockOperations;
  23189. /**
  23190. * Creates a new TrigonometryBlock
  23191. * @param name defines the block name
  23192. */
  23193. constructor(name: string);
  23194. /**
  23195. * Gets the current class name
  23196. * @returns the class name
  23197. */
  23198. getClassName(): string;
  23199. /**
  23200. * Gets the input component
  23201. */
  23202. get input(): NodeMaterialConnectionPoint;
  23203. /**
  23204. * Gets the output component
  23205. */
  23206. get output(): NodeMaterialConnectionPoint;
  23207. protected _buildBlock(state: NodeMaterialBuildState): this;
  23208. serialize(): any;
  23209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23210. protected _dumpPropertiesCode(): string;
  23211. }
  23212. }
  23213. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23215. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23216. import { Scene } from "babylonjs/scene";
  23217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23218. import { Matrix } from "babylonjs/Maths/math.vector";
  23219. import { Mesh } from "babylonjs/Meshes/mesh";
  23220. import { Engine } from "babylonjs/Engines/engine";
  23221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23222. import { Observable } from "babylonjs/Misc/observable";
  23223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23224. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23225. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23226. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23227. import { Nullable } from "babylonjs/types";
  23228. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23229. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23230. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23231. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23232. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23233. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23234. import { Effect } from "babylonjs/Materials/effect";
  23235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23236. import { Camera } from "babylonjs/Cameras/camera";
  23237. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23238. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23239. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23240. /**
  23241. * Interface used to configure the node material editor
  23242. */
  23243. export interface INodeMaterialEditorOptions {
  23244. /** Define the URl to load node editor script */
  23245. editorURL?: string;
  23246. }
  23247. /** @hidden */
  23248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23249. NORMAL: boolean;
  23250. TANGENT: boolean;
  23251. UV1: boolean;
  23252. /** BONES */
  23253. NUM_BONE_INFLUENCERS: number;
  23254. BonesPerMesh: number;
  23255. BONETEXTURE: boolean;
  23256. /** MORPH TARGETS */
  23257. MORPHTARGETS: boolean;
  23258. MORPHTARGETS_NORMAL: boolean;
  23259. MORPHTARGETS_TANGENT: boolean;
  23260. MORPHTARGETS_UV: boolean;
  23261. NUM_MORPH_INFLUENCERS: number;
  23262. /** IMAGE PROCESSING */
  23263. IMAGEPROCESSING: boolean;
  23264. VIGNETTE: boolean;
  23265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23266. VIGNETTEBLENDMODEOPAQUE: boolean;
  23267. TONEMAPPING: boolean;
  23268. TONEMAPPING_ACES: boolean;
  23269. CONTRAST: boolean;
  23270. EXPOSURE: boolean;
  23271. COLORCURVES: boolean;
  23272. COLORGRADING: boolean;
  23273. COLORGRADING3D: boolean;
  23274. SAMPLER3DGREENDEPTH: boolean;
  23275. SAMPLER3DBGRMAP: boolean;
  23276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23277. /** MISC. */
  23278. BUMPDIRECTUV: number;
  23279. constructor();
  23280. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23281. }
  23282. /**
  23283. * Class used to configure NodeMaterial
  23284. */
  23285. export interface INodeMaterialOptions {
  23286. /**
  23287. * Defines if blocks should emit comments
  23288. */
  23289. emitComments: boolean;
  23290. }
  23291. /**
  23292. * Class used to create a node based material built by assembling shader blocks
  23293. */
  23294. export class NodeMaterial extends PushMaterial {
  23295. private static _BuildIdGenerator;
  23296. private _options;
  23297. private _vertexCompilationState;
  23298. private _fragmentCompilationState;
  23299. private _sharedData;
  23300. private _buildId;
  23301. private _buildWasSuccessful;
  23302. private _cachedWorldViewMatrix;
  23303. private _cachedWorldViewProjectionMatrix;
  23304. private _optimizers;
  23305. private _animationFrame;
  23306. /** Define the Url to load node editor script */
  23307. static EditorURL: string;
  23308. /** Define the Url to load snippets */
  23309. static SnippetUrl: string;
  23310. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23311. static IgnoreTexturesAtLoadTime: boolean;
  23312. private BJSNODEMATERIALEDITOR;
  23313. /** Get the inspector from bundle or global */
  23314. private _getGlobalNodeMaterialEditor;
  23315. /**
  23316. * Snippet ID if the material was created from the snippet server
  23317. */
  23318. snippetId: string;
  23319. /**
  23320. * Gets or sets data used by visual editor
  23321. * @see https://nme.babylonjs.com
  23322. */
  23323. editorData: any;
  23324. /**
  23325. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  23326. */
  23327. ignoreAlpha: boolean;
  23328. /**
  23329. * Defines the maximum number of lights that can be used in the material
  23330. */
  23331. maxSimultaneousLights: number;
  23332. /**
  23333. * Observable raised when the material is built
  23334. */
  23335. onBuildObservable: Observable<NodeMaterial>;
  23336. /**
  23337. * Gets or sets the root nodes of the material vertex shader
  23338. */
  23339. _vertexOutputNodes: NodeMaterialBlock[];
  23340. /**
  23341. * Gets or sets the root nodes of the material fragment (pixel) shader
  23342. */
  23343. _fragmentOutputNodes: NodeMaterialBlock[];
  23344. /** Gets or sets options to control the node material overall behavior */
  23345. get options(): INodeMaterialOptions;
  23346. set options(options: INodeMaterialOptions);
  23347. /**
  23348. * Default configuration related to image processing available in the standard Material.
  23349. */
  23350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23351. /**
  23352. * Gets the image processing configuration used either in this material.
  23353. */
  23354. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23355. /**
  23356. * Sets the Default image processing configuration used either in the this material.
  23357. *
  23358. * If sets to null, the scene one is in use.
  23359. */
  23360. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23361. /**
  23362. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23363. */
  23364. attachedBlocks: NodeMaterialBlock[];
  23365. /**
  23366. * Specifies the mode of the node material
  23367. * @hidden
  23368. */
  23369. _mode: NodeMaterialModes;
  23370. /**
  23371. * Gets the mode property
  23372. */
  23373. get mode(): NodeMaterialModes;
  23374. /**
  23375. * Create a new node based material
  23376. * @param name defines the material name
  23377. * @param scene defines the hosting scene
  23378. * @param options defines creation option
  23379. */
  23380. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23381. /**
  23382. * Gets the current class name of the material e.g. "NodeMaterial"
  23383. * @returns the class name
  23384. */
  23385. getClassName(): string;
  23386. /**
  23387. * Keep track of the image processing observer to allow dispose and replace.
  23388. */
  23389. private _imageProcessingObserver;
  23390. /**
  23391. * Attaches a new image processing configuration to the Standard Material.
  23392. * @param configuration
  23393. */
  23394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23395. /**
  23396. * Get a block by its name
  23397. * @param name defines the name of the block to retrieve
  23398. * @returns the required block or null if not found
  23399. */
  23400. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23401. /**
  23402. * Get a block by its name
  23403. * @param predicate defines the predicate used to find the good candidate
  23404. * @returns the required block or null if not found
  23405. */
  23406. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23407. /**
  23408. * Get an input block by its name
  23409. * @param predicate defines the predicate used to find the good candidate
  23410. * @returns the required input block or null if not found
  23411. */
  23412. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23413. /**
  23414. * Gets the list of input blocks attached to this material
  23415. * @returns an array of InputBlocks
  23416. */
  23417. getInputBlocks(): InputBlock[];
  23418. /**
  23419. * Adds a new optimizer to the list of optimizers
  23420. * @param optimizer defines the optimizers to add
  23421. * @returns the current material
  23422. */
  23423. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23424. /**
  23425. * Remove an optimizer from the list of optimizers
  23426. * @param optimizer defines the optimizers to remove
  23427. * @returns the current material
  23428. */
  23429. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23430. /**
  23431. * Add a new block to the list of output nodes
  23432. * @param node defines the node to add
  23433. * @returns the current material
  23434. */
  23435. addOutputNode(node: NodeMaterialBlock): this;
  23436. /**
  23437. * Remove a block from the list of root nodes
  23438. * @param node defines the node to remove
  23439. * @returns the current material
  23440. */
  23441. removeOutputNode(node: NodeMaterialBlock): this;
  23442. private _addVertexOutputNode;
  23443. private _removeVertexOutputNode;
  23444. private _addFragmentOutputNode;
  23445. private _removeFragmentOutputNode;
  23446. /**
  23447. * Specifies if the material will require alpha blending
  23448. * @returns a boolean specifying if alpha blending is needed
  23449. */
  23450. needAlphaBlending(): boolean;
  23451. /**
  23452. * Specifies if this material should be rendered in alpha test mode
  23453. * @returns a boolean specifying if an alpha test is needed.
  23454. */
  23455. needAlphaTesting(): boolean;
  23456. private _initializeBlock;
  23457. private _resetDualBlocks;
  23458. /**
  23459. * Remove a block from the current node material
  23460. * @param block defines the block to remove
  23461. */
  23462. removeBlock(block: NodeMaterialBlock): void;
  23463. /**
  23464. * Build the material and generates the inner effect
  23465. * @param verbose defines if the build should log activity
  23466. */
  23467. build(verbose?: boolean): void;
  23468. /**
  23469. * Runs an otpimization phase to try to improve the shader code
  23470. */
  23471. optimize(): void;
  23472. private _prepareDefinesForAttributes;
  23473. /**
  23474. * Create a post process from the material
  23475. * @param camera The camera to apply the render pass to.
  23476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23478. * @param engine The engine which the post process will be applied. (default: current engine)
  23479. * @param reusable If the post process can be reused on the same frame. (default: false)
  23480. * @param textureType Type of textures used when performing the post process. (default: 0)
  23481. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23482. * @returns the post process created
  23483. */
  23484. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23485. /**
  23486. * Create the post process effect from the material
  23487. * @param postProcess The post process to create the effect for
  23488. */
  23489. createEffectForPostProcess(postProcess: PostProcess): void;
  23490. private _createEffectForPostProcess;
  23491. /**
  23492. * Create a new procedural texture based on this node material
  23493. * @param size defines the size of the texture
  23494. * @param scene defines the hosting scene
  23495. * @returns the new procedural texture attached to this node material
  23496. */
  23497. createProceduralTexture(size: number | {
  23498. width: number;
  23499. height: number;
  23500. layers?: number;
  23501. }, scene: Scene): Nullable<ProceduralTexture>;
  23502. private _createEffectForParticles;
  23503. private _checkInternals;
  23504. /**
  23505. * Create the effect to be used as the custom effect for a particle system
  23506. * @param particleSystem Particle system to create the effect for
  23507. * @param onCompiled defines a function to call when the effect creation is successful
  23508. * @param onError defines a function to call when the effect creation has failed
  23509. */
  23510. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23511. private _processDefines;
  23512. /**
  23513. * Get if the submesh is ready to be used and all its information available.
  23514. * Child classes can use it to update shaders
  23515. * @param mesh defines the mesh to check
  23516. * @param subMesh defines which submesh to check
  23517. * @param useInstances specifies that instances should be used
  23518. * @returns a boolean indicating that the submesh is ready or not
  23519. */
  23520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23521. /**
  23522. * Get a string representing the shaders built by the current node graph
  23523. */
  23524. get compiledShaders(): string;
  23525. /**
  23526. * Binds the world matrix to the material
  23527. * @param world defines the world transformation matrix
  23528. */
  23529. bindOnlyWorldMatrix(world: Matrix): void;
  23530. /**
  23531. * Binds the submesh to this material by preparing the effect and shader to draw
  23532. * @param world defines the world transformation matrix
  23533. * @param mesh defines the mesh containing the submesh
  23534. * @param subMesh defines the submesh to bind the material to
  23535. */
  23536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23537. /**
  23538. * Gets the active textures from the material
  23539. * @returns an array of textures
  23540. */
  23541. getActiveTextures(): BaseTexture[];
  23542. /**
  23543. * Gets the list of texture blocks
  23544. * @returns an array of texture blocks
  23545. */
  23546. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23547. /**
  23548. * Specifies if the material uses a texture
  23549. * @param texture defines the texture to check against the material
  23550. * @returns a boolean specifying if the material uses the texture
  23551. */
  23552. hasTexture(texture: BaseTexture): boolean;
  23553. /**
  23554. * Disposes the material
  23555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23556. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23557. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23558. */
  23559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23560. /** Creates the node editor window. */
  23561. private _createNodeEditor;
  23562. /**
  23563. * Launch the node material editor
  23564. * @param config Define the configuration of the editor
  23565. * @return a promise fulfilled when the node editor is visible
  23566. */
  23567. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23568. /**
  23569. * Clear the current material
  23570. */
  23571. clear(): void;
  23572. /**
  23573. * Clear the current material and set it to a default state
  23574. */
  23575. setToDefault(): void;
  23576. /**
  23577. * Clear the current material and set it to a default state for post process
  23578. */
  23579. setToDefaultPostProcess(): void;
  23580. /**
  23581. * Clear the current material and set it to a default state for procedural texture
  23582. */
  23583. setToDefaultProceduralTexture(): void;
  23584. /**
  23585. * Clear the current material and set it to a default state for particle
  23586. */
  23587. setToDefaultParticle(): void;
  23588. /**
  23589. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23590. * @param url defines the url to load from
  23591. * @returns a promise that will fullfil when the material is fully loaded
  23592. */
  23593. loadAsync(url: string): Promise<void>;
  23594. private _gatherBlocks;
  23595. /**
  23596. * Generate a string containing the code declaration required to create an equivalent of this material
  23597. * @returns a string
  23598. */
  23599. generateCode(): string;
  23600. /**
  23601. * Serializes this material in a JSON representation
  23602. * @returns the serialized material object
  23603. */
  23604. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23605. private _restoreConnections;
  23606. /**
  23607. * Clear the current graph and load a new one from a serialization object
  23608. * @param source defines the JSON representation of the material
  23609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23610. * @param merge defines whether or not the source must be merged or replace the current content
  23611. */
  23612. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23613. /**
  23614. * Makes a duplicate of the current material.
  23615. * @param name - name to use for the new material.
  23616. */
  23617. clone(name: string): NodeMaterial;
  23618. /**
  23619. * Creates a node material from parsed material data
  23620. * @param source defines the JSON representation of the material
  23621. * @param scene defines the hosting scene
  23622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23623. * @returns a new node material
  23624. */
  23625. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23626. /**
  23627. * Creates a node material from a snippet saved in a remote file
  23628. * @param name defines the name of the material to create
  23629. * @param url defines the url to load from
  23630. * @param scene defines the hosting scene
  23631. * @returns a promise that will resolve to the new node material
  23632. */
  23633. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23634. /**
  23635. * Creates a node material from a snippet saved by the node material editor
  23636. * @param snippetId defines the snippet to load
  23637. * @param scene defines the hosting scene
  23638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23639. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23640. * @returns a promise that will resolve to the new node material
  23641. */
  23642. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23643. /**
  23644. * Creates a new node material set to default basic configuration
  23645. * @param name defines the name of the material
  23646. * @param scene defines the hosting scene
  23647. * @returns a new NodeMaterial
  23648. */
  23649. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23650. }
  23651. }
  23652. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23654. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23655. import { Nullable } from "babylonjs/types";
  23656. module "babylonjs/Engines/thinEngine" {
  23657. interface ThinEngine {
  23658. /**
  23659. * Unbind a list of render target textures from the webGL context
  23660. * This is used only when drawBuffer extension or webGL2 are active
  23661. * @param textures defines the render target textures to unbind
  23662. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23663. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23664. */
  23665. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23666. /**
  23667. * Create a multi render target texture
  23668. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23669. * @param size defines the size of the texture
  23670. * @param options defines the creation options
  23671. * @returns the cube texture as an InternalTexture
  23672. */
  23673. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23674. /**
  23675. * Update the sample count for a given multiple render target texture
  23676. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23677. * @param textures defines the textures to update
  23678. * @param samples defines the sample count to set
  23679. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23680. */
  23681. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23682. /**
  23683. * Select a subsets of attachments to draw to.
  23684. * @param attachments gl attachments
  23685. */
  23686. bindAttachments(attachments: number[]): void;
  23687. /**
  23688. * Creates a layout object to draw/clear on specific textures in a MRT
  23689. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23690. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23691. */
  23692. buildTextureLayout(textureStatus: boolean[]): number[];
  23693. /**
  23694. * Restores the webgl state to only draw on the main color attachment
  23695. */
  23696. restoreSingleAttachment(): void;
  23697. }
  23698. }
  23699. }
  23700. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23701. import { Scene } from "babylonjs/scene";
  23702. import { Engine } from "babylonjs/Engines/engine";
  23703. import { Texture } from "babylonjs/Materials/Textures/texture";
  23704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23705. import "babylonjs/Engines/Extensions/engine.multiRender";
  23706. /**
  23707. * Creation options of the multi render target texture.
  23708. */
  23709. export interface IMultiRenderTargetOptions {
  23710. /**
  23711. * Define if the texture needs to create mip maps after render.
  23712. */
  23713. generateMipMaps?: boolean;
  23714. /**
  23715. * Define the types of all the draw buffers we want to create
  23716. */
  23717. types?: number[];
  23718. /**
  23719. * Define the sampling modes of all the draw buffers we want to create
  23720. */
  23721. samplingModes?: number[];
  23722. /**
  23723. * Define if a depth buffer is required
  23724. */
  23725. generateDepthBuffer?: boolean;
  23726. /**
  23727. * Define if a stencil buffer is required
  23728. */
  23729. generateStencilBuffer?: boolean;
  23730. /**
  23731. * Define if a depth texture is required instead of a depth buffer
  23732. */
  23733. generateDepthTexture?: boolean;
  23734. /**
  23735. * Define the number of desired draw buffers
  23736. */
  23737. textureCount?: number;
  23738. /**
  23739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23740. */
  23741. doNotChangeAspectRatio?: boolean;
  23742. /**
  23743. * Define the default type of the buffers we are creating
  23744. */
  23745. defaultType?: number;
  23746. }
  23747. /**
  23748. * A multi render target, like a render target provides the ability to render to a texture.
  23749. * Unlike the render target, it can render to several draw buffers in one draw.
  23750. * This is specially interesting in deferred rendering or for any effects requiring more than
  23751. * just one color from a single pass.
  23752. */
  23753. export class MultiRenderTarget extends RenderTargetTexture {
  23754. private _internalTextures;
  23755. private _textures;
  23756. private _multiRenderTargetOptions;
  23757. private _count;
  23758. /**
  23759. * Get if draw buffers are currently supported by the used hardware and browser.
  23760. */
  23761. get isSupported(): boolean;
  23762. /**
  23763. * Get the list of textures generated by the multi render target.
  23764. */
  23765. get textures(): Texture[];
  23766. /**
  23767. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23768. */
  23769. get count(): number;
  23770. /**
  23771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23772. */
  23773. get depthTexture(): Texture;
  23774. /**
  23775. * Set the wrapping mode on U of all the textures we are rendering to.
  23776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23777. */
  23778. set wrapU(wrap: number);
  23779. /**
  23780. * Set the wrapping mode on V of all the textures we are rendering to.
  23781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23782. */
  23783. set wrapV(wrap: number);
  23784. /**
  23785. * Instantiate a new multi render target texture.
  23786. * A multi render target, like a render target provides the ability to render to a texture.
  23787. * Unlike the render target, it can render to several draw buffers in one draw.
  23788. * This is specially interesting in deferred rendering or for any effects requiring more than
  23789. * just one color from a single pass.
  23790. * @param name Define the name of the texture
  23791. * @param size Define the size of the buffers to render to
  23792. * @param count Define the number of target we are rendering into
  23793. * @param scene Define the scene the texture belongs to
  23794. * @param options Define the options used to create the multi render target
  23795. */
  23796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23797. private _initTypes;
  23798. /** @hidden */
  23799. _rebuild(forceFullRebuild?: boolean): void;
  23800. private _createInternalTextures;
  23801. private _createTextures;
  23802. /**
  23803. * Replaces a texture within the MRT.
  23804. * @param texture The new texture to insert in the MRT
  23805. * @param index The index of the texture to replace
  23806. */
  23807. replaceTexture(texture: Texture, index: number): void;
  23808. /**
  23809. * Define the number of samples used if MSAA is enabled.
  23810. */
  23811. get samples(): number;
  23812. set samples(value: number);
  23813. /**
  23814. * Resize all the textures in the multi render target.
  23815. * Be careful as it will recreate all the data in the new texture.
  23816. * @param size Define the new size
  23817. */
  23818. resize(size: any): void;
  23819. /**
  23820. * Changes the number of render targets in this MRT
  23821. * Be careful as it will recreate all the data in the new texture.
  23822. * @param count new texture count
  23823. * @param options Specifies texture types and sampling modes for new textures
  23824. */
  23825. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23826. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23827. /**
  23828. * Dispose the render targets and their associated resources
  23829. */
  23830. dispose(): void;
  23831. /**
  23832. * Release all the underlying texture used as draw buffers.
  23833. */
  23834. releaseInternalTextures(): void;
  23835. }
  23836. }
  23837. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23838. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23840. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23841. /** @hidden */
  23842. export var imageProcessingPixelShader: {
  23843. name: string;
  23844. shader: string;
  23845. };
  23846. }
  23847. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23848. import { Nullable } from "babylonjs/types";
  23849. import { Color4 } from "babylonjs/Maths/math.color";
  23850. import { Camera } from "babylonjs/Cameras/camera";
  23851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23853. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23855. import { Engine } from "babylonjs/Engines/engine";
  23856. import "babylonjs/Shaders/imageProcessing.fragment";
  23857. import "babylonjs/Shaders/postprocess.vertex";
  23858. /**
  23859. * ImageProcessingPostProcess
  23860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23861. */
  23862. export class ImageProcessingPostProcess extends PostProcess {
  23863. /**
  23864. * Default configuration related to image processing available in the PBR Material.
  23865. */
  23866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23867. /**
  23868. * Gets the image processing configuration used either in this material.
  23869. */
  23870. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23871. /**
  23872. * Sets the Default image processing configuration used either in the this material.
  23873. *
  23874. * If sets to null, the scene one is in use.
  23875. */
  23876. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23877. /**
  23878. * Keep track of the image processing observer to allow dispose and replace.
  23879. */
  23880. private _imageProcessingObserver;
  23881. /**
  23882. * Attaches a new image processing configuration to the PBR Material.
  23883. * @param configuration
  23884. */
  23885. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23886. /**
  23887. * If the post process is supported.
  23888. */
  23889. get isSupported(): boolean;
  23890. /**
  23891. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23892. */
  23893. get colorCurves(): Nullable<ColorCurves>;
  23894. /**
  23895. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23896. */
  23897. set colorCurves(value: Nullable<ColorCurves>);
  23898. /**
  23899. * Gets wether the color curves effect is enabled.
  23900. */
  23901. get colorCurvesEnabled(): boolean;
  23902. /**
  23903. * Sets wether the color curves effect is enabled.
  23904. */
  23905. set colorCurvesEnabled(value: boolean);
  23906. /**
  23907. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23908. */
  23909. get colorGradingTexture(): Nullable<BaseTexture>;
  23910. /**
  23911. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23912. */
  23913. set colorGradingTexture(value: Nullable<BaseTexture>);
  23914. /**
  23915. * Gets wether the color grading effect is enabled.
  23916. */
  23917. get colorGradingEnabled(): boolean;
  23918. /**
  23919. * Gets wether the color grading effect is enabled.
  23920. */
  23921. set colorGradingEnabled(value: boolean);
  23922. /**
  23923. * Gets exposure used in the effect.
  23924. */
  23925. get exposure(): number;
  23926. /**
  23927. * Sets exposure used in the effect.
  23928. */
  23929. set exposure(value: number);
  23930. /**
  23931. * Gets wether tonemapping is enabled or not.
  23932. */
  23933. get toneMappingEnabled(): boolean;
  23934. /**
  23935. * Sets wether tonemapping is enabled or not
  23936. */
  23937. set toneMappingEnabled(value: boolean);
  23938. /**
  23939. * Gets the type of tone mapping effect.
  23940. */
  23941. get toneMappingType(): number;
  23942. /**
  23943. * Sets the type of tone mapping effect.
  23944. */
  23945. set toneMappingType(value: number);
  23946. /**
  23947. * Gets contrast used in the effect.
  23948. */
  23949. get contrast(): number;
  23950. /**
  23951. * Sets contrast used in the effect.
  23952. */
  23953. set contrast(value: number);
  23954. /**
  23955. * Gets Vignette stretch size.
  23956. */
  23957. get vignetteStretch(): number;
  23958. /**
  23959. * Sets Vignette stretch size.
  23960. */
  23961. set vignetteStretch(value: number);
  23962. /**
  23963. * Gets Vignette centre X Offset.
  23964. */
  23965. get vignetteCentreX(): number;
  23966. /**
  23967. * Sets Vignette centre X Offset.
  23968. */
  23969. set vignetteCentreX(value: number);
  23970. /**
  23971. * Gets Vignette centre Y Offset.
  23972. */
  23973. get vignetteCentreY(): number;
  23974. /**
  23975. * Sets Vignette centre Y Offset.
  23976. */
  23977. set vignetteCentreY(value: number);
  23978. /**
  23979. * Gets Vignette weight or intensity of the vignette effect.
  23980. */
  23981. get vignetteWeight(): number;
  23982. /**
  23983. * Sets Vignette weight or intensity of the vignette effect.
  23984. */
  23985. set vignetteWeight(value: number);
  23986. /**
  23987. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23988. * if vignetteEnabled is set to true.
  23989. */
  23990. get vignetteColor(): Color4;
  23991. /**
  23992. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23993. * if vignetteEnabled is set to true.
  23994. */
  23995. set vignetteColor(value: Color4);
  23996. /**
  23997. * Gets Camera field of view used by the Vignette effect.
  23998. */
  23999. get vignetteCameraFov(): number;
  24000. /**
  24001. * Sets Camera field of view used by the Vignette effect.
  24002. */
  24003. set vignetteCameraFov(value: number);
  24004. /**
  24005. * Gets the vignette blend mode allowing different kind of effect.
  24006. */
  24007. get vignetteBlendMode(): number;
  24008. /**
  24009. * Sets the vignette blend mode allowing different kind of effect.
  24010. */
  24011. set vignetteBlendMode(value: number);
  24012. /**
  24013. * Gets wether the vignette effect is enabled.
  24014. */
  24015. get vignetteEnabled(): boolean;
  24016. /**
  24017. * Sets wether the vignette effect is enabled.
  24018. */
  24019. set vignetteEnabled(value: boolean);
  24020. private _fromLinearSpace;
  24021. /**
  24022. * Gets wether the input of the processing is in Gamma or Linear Space.
  24023. */
  24024. get fromLinearSpace(): boolean;
  24025. /**
  24026. * Sets wether the input of the processing is in Gamma or Linear Space.
  24027. */
  24028. set fromLinearSpace(value: boolean);
  24029. /**
  24030. * Defines cache preventing GC.
  24031. */
  24032. private _defines;
  24033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24034. /**
  24035. * "ImageProcessingPostProcess"
  24036. * @returns "ImageProcessingPostProcess"
  24037. */
  24038. getClassName(): string;
  24039. /**
  24040. * @hidden
  24041. */
  24042. _updateParameters(): void;
  24043. dispose(camera?: Camera): void;
  24044. }
  24045. }
  24046. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24048. /**
  24049. * Interface for defining prepass effects in the prepass post-process pipeline
  24050. */
  24051. export interface PrePassEffectConfiguration {
  24052. /**
  24053. * Name of the effect
  24054. */
  24055. name: string;
  24056. /**
  24057. * Post process to attach for this effect
  24058. */
  24059. postProcess?: PostProcess;
  24060. /**
  24061. * Textures required in the MRT
  24062. */
  24063. texturesRequired: number[];
  24064. /**
  24065. * Is the effect enabled
  24066. */
  24067. enabled: boolean;
  24068. /**
  24069. * Disposes the effect configuration
  24070. */
  24071. dispose?: () => void;
  24072. /**
  24073. * Creates the associated post process
  24074. */
  24075. createPostProcess?: () => PostProcess;
  24076. }
  24077. }
  24078. declare module "babylonjs/Materials/fresnelParameters" {
  24079. import { DeepImmutable } from "babylonjs/types";
  24080. import { Color3 } from "babylonjs/Maths/math.color";
  24081. /**
  24082. * Options to be used when creating a FresnelParameters.
  24083. */
  24084. export type IFresnelParametersCreationOptions = {
  24085. /**
  24086. * Define the color used on edges (grazing angle)
  24087. */
  24088. leftColor?: Color3;
  24089. /**
  24090. * Define the color used on center
  24091. */
  24092. rightColor?: Color3;
  24093. /**
  24094. * Define bias applied to computed fresnel term
  24095. */
  24096. bias?: number;
  24097. /**
  24098. * Defined the power exponent applied to fresnel term
  24099. */
  24100. power?: number;
  24101. /**
  24102. * Define if the fresnel effect is enable or not.
  24103. */
  24104. isEnabled?: boolean;
  24105. };
  24106. /**
  24107. * Serialized format for FresnelParameters.
  24108. */
  24109. export type IFresnelParametersSerialized = {
  24110. /**
  24111. * Define the color used on edges (grazing angle) [as an array]
  24112. */
  24113. leftColor: number[];
  24114. /**
  24115. * Define the color used on center [as an array]
  24116. */
  24117. rightColor: number[];
  24118. /**
  24119. * Define bias applied to computed fresnel term
  24120. */
  24121. bias: number;
  24122. /**
  24123. * Defined the power exponent applied to fresnel term
  24124. */
  24125. power?: number;
  24126. /**
  24127. * Define if the fresnel effect is enable or not.
  24128. */
  24129. isEnabled: boolean;
  24130. };
  24131. /**
  24132. * This represents all the required information to add a fresnel effect on a material:
  24133. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24134. */
  24135. export class FresnelParameters {
  24136. private _isEnabled;
  24137. /**
  24138. * Define if the fresnel effect is enable or not.
  24139. */
  24140. get isEnabled(): boolean;
  24141. set isEnabled(value: boolean);
  24142. /**
  24143. * Define the color used on edges (grazing angle)
  24144. */
  24145. leftColor: Color3;
  24146. /**
  24147. * Define the color used on center
  24148. */
  24149. rightColor: Color3;
  24150. /**
  24151. * Define bias applied to computed fresnel term
  24152. */
  24153. bias: number;
  24154. /**
  24155. * Defined the power exponent applied to fresnel term
  24156. */
  24157. power: number;
  24158. /**
  24159. * Creates a new FresnelParameters object.
  24160. *
  24161. * @param options provide your own settings to optionally to override defaults
  24162. */
  24163. constructor(options?: IFresnelParametersCreationOptions);
  24164. /**
  24165. * Clones the current fresnel and its valuues
  24166. * @returns a clone fresnel configuration
  24167. */
  24168. clone(): FresnelParameters;
  24169. /**
  24170. * Determines equality between FresnelParameters objects
  24171. * @param otherFresnelParameters defines the second operand
  24172. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24173. */
  24174. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24175. /**
  24176. * Serializes the current fresnel parameters to a JSON representation.
  24177. * @return the JSON serialization
  24178. */
  24179. serialize(): IFresnelParametersSerialized;
  24180. /**
  24181. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24182. * @param parsedFresnelParameters Define the JSON representation
  24183. * @returns the parsed parameters
  24184. */
  24185. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24186. }
  24187. }
  24188. declare module "babylonjs/Materials/materialFlags" {
  24189. /**
  24190. * This groups all the flags used to control the materials channel.
  24191. */
  24192. export class MaterialFlags {
  24193. private static _DiffuseTextureEnabled;
  24194. /**
  24195. * Are diffuse textures enabled in the application.
  24196. */
  24197. static get DiffuseTextureEnabled(): boolean;
  24198. static set DiffuseTextureEnabled(value: boolean);
  24199. private static _DetailTextureEnabled;
  24200. /**
  24201. * Are detail textures enabled in the application.
  24202. */
  24203. static get DetailTextureEnabled(): boolean;
  24204. static set DetailTextureEnabled(value: boolean);
  24205. private static _AmbientTextureEnabled;
  24206. /**
  24207. * Are ambient textures enabled in the application.
  24208. */
  24209. static get AmbientTextureEnabled(): boolean;
  24210. static set AmbientTextureEnabled(value: boolean);
  24211. private static _OpacityTextureEnabled;
  24212. /**
  24213. * Are opacity textures enabled in the application.
  24214. */
  24215. static get OpacityTextureEnabled(): boolean;
  24216. static set OpacityTextureEnabled(value: boolean);
  24217. private static _ReflectionTextureEnabled;
  24218. /**
  24219. * Are reflection textures enabled in the application.
  24220. */
  24221. static get ReflectionTextureEnabled(): boolean;
  24222. static set ReflectionTextureEnabled(value: boolean);
  24223. private static _EmissiveTextureEnabled;
  24224. /**
  24225. * Are emissive textures enabled in the application.
  24226. */
  24227. static get EmissiveTextureEnabled(): boolean;
  24228. static set EmissiveTextureEnabled(value: boolean);
  24229. private static _SpecularTextureEnabled;
  24230. /**
  24231. * Are specular textures enabled in the application.
  24232. */
  24233. static get SpecularTextureEnabled(): boolean;
  24234. static set SpecularTextureEnabled(value: boolean);
  24235. private static _BumpTextureEnabled;
  24236. /**
  24237. * Are bump textures enabled in the application.
  24238. */
  24239. static get BumpTextureEnabled(): boolean;
  24240. static set BumpTextureEnabled(value: boolean);
  24241. private static _LightmapTextureEnabled;
  24242. /**
  24243. * Are lightmap textures enabled in the application.
  24244. */
  24245. static get LightmapTextureEnabled(): boolean;
  24246. static set LightmapTextureEnabled(value: boolean);
  24247. private static _RefractionTextureEnabled;
  24248. /**
  24249. * Are refraction textures enabled in the application.
  24250. */
  24251. static get RefractionTextureEnabled(): boolean;
  24252. static set RefractionTextureEnabled(value: boolean);
  24253. private static _ColorGradingTextureEnabled;
  24254. /**
  24255. * Are color grading textures enabled in the application.
  24256. */
  24257. static get ColorGradingTextureEnabled(): boolean;
  24258. static set ColorGradingTextureEnabled(value: boolean);
  24259. private static _FresnelEnabled;
  24260. /**
  24261. * Are fresnels enabled in the application.
  24262. */
  24263. static get FresnelEnabled(): boolean;
  24264. static set FresnelEnabled(value: boolean);
  24265. private static _ClearCoatTextureEnabled;
  24266. /**
  24267. * Are clear coat textures enabled in the application.
  24268. */
  24269. static get ClearCoatTextureEnabled(): boolean;
  24270. static set ClearCoatTextureEnabled(value: boolean);
  24271. private static _ClearCoatBumpTextureEnabled;
  24272. /**
  24273. * Are clear coat bump textures enabled in the application.
  24274. */
  24275. static get ClearCoatBumpTextureEnabled(): boolean;
  24276. static set ClearCoatBumpTextureEnabled(value: boolean);
  24277. private static _ClearCoatTintTextureEnabled;
  24278. /**
  24279. * Are clear coat tint textures enabled in the application.
  24280. */
  24281. static get ClearCoatTintTextureEnabled(): boolean;
  24282. static set ClearCoatTintTextureEnabled(value: boolean);
  24283. private static _SheenTextureEnabled;
  24284. /**
  24285. * Are sheen textures enabled in the application.
  24286. */
  24287. static get SheenTextureEnabled(): boolean;
  24288. static set SheenTextureEnabled(value: boolean);
  24289. private static _AnisotropicTextureEnabled;
  24290. /**
  24291. * Are anisotropic textures enabled in the application.
  24292. */
  24293. static get AnisotropicTextureEnabled(): boolean;
  24294. static set AnisotropicTextureEnabled(value: boolean);
  24295. private static _ThicknessTextureEnabled;
  24296. /**
  24297. * Are thickness textures enabled in the application.
  24298. */
  24299. static get ThicknessTextureEnabled(): boolean;
  24300. static set ThicknessTextureEnabled(value: boolean);
  24301. }
  24302. }
  24303. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24304. /** @hidden */
  24305. export var defaultFragmentDeclaration: {
  24306. name: string;
  24307. shader: string;
  24308. };
  24309. }
  24310. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24311. /** @hidden */
  24312. export var defaultUboDeclaration: {
  24313. name: string;
  24314. shader: string;
  24315. };
  24316. }
  24317. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24318. /** @hidden */
  24319. export var prePassDeclaration: {
  24320. name: string;
  24321. shader: string;
  24322. };
  24323. }
  24324. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24325. /** @hidden */
  24326. export var lightFragmentDeclaration: {
  24327. name: string;
  24328. shader: string;
  24329. };
  24330. }
  24331. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24332. /** @hidden */
  24333. export var lightUboDeclaration: {
  24334. name: string;
  24335. shader: string;
  24336. };
  24337. }
  24338. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24339. /** @hidden */
  24340. export var lightsFragmentFunctions: {
  24341. name: string;
  24342. shader: string;
  24343. };
  24344. }
  24345. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24346. /** @hidden */
  24347. export var shadowsFragmentFunctions: {
  24348. name: string;
  24349. shader: string;
  24350. };
  24351. }
  24352. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24353. /** @hidden */
  24354. export var fresnelFunction: {
  24355. name: string;
  24356. shader: string;
  24357. };
  24358. }
  24359. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24360. /** @hidden */
  24361. export var bumpFragmentMainFunctions: {
  24362. name: string;
  24363. shader: string;
  24364. };
  24365. }
  24366. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24367. /** @hidden */
  24368. export var bumpFragmentFunctions: {
  24369. name: string;
  24370. shader: string;
  24371. };
  24372. }
  24373. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24374. /** @hidden */
  24375. export var logDepthDeclaration: {
  24376. name: string;
  24377. shader: string;
  24378. };
  24379. }
  24380. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24381. /** @hidden */
  24382. export var bumpFragment: {
  24383. name: string;
  24384. shader: string;
  24385. };
  24386. }
  24387. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24388. /** @hidden */
  24389. export var depthPrePass: {
  24390. name: string;
  24391. shader: string;
  24392. };
  24393. }
  24394. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24395. /** @hidden */
  24396. export var lightFragment: {
  24397. name: string;
  24398. shader: string;
  24399. };
  24400. }
  24401. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24402. /** @hidden */
  24403. export var logDepthFragment: {
  24404. name: string;
  24405. shader: string;
  24406. };
  24407. }
  24408. declare module "babylonjs/Shaders/default.fragment" {
  24409. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24410. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24411. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24413. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24414. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24415. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24416. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24417. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24418. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24419. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24420. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24421. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24422. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24424. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24425. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24427. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24428. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24429. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24430. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24431. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24432. /** @hidden */
  24433. export var defaultPixelShader: {
  24434. name: string;
  24435. shader: string;
  24436. };
  24437. }
  24438. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24439. /** @hidden */
  24440. export var defaultVertexDeclaration: {
  24441. name: string;
  24442. shader: string;
  24443. };
  24444. }
  24445. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24446. /** @hidden */
  24447. export var prePassVertexDeclaration: {
  24448. name: string;
  24449. shader: string;
  24450. };
  24451. }
  24452. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24453. /** @hidden */
  24454. export var bumpVertexDeclaration: {
  24455. name: string;
  24456. shader: string;
  24457. };
  24458. }
  24459. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24460. /** @hidden */
  24461. export var prePassVertex: {
  24462. name: string;
  24463. shader: string;
  24464. };
  24465. }
  24466. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24467. /** @hidden */
  24468. export var bumpVertex: {
  24469. name: string;
  24470. shader: string;
  24471. };
  24472. }
  24473. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24474. /** @hidden */
  24475. export var fogVertex: {
  24476. name: string;
  24477. shader: string;
  24478. };
  24479. }
  24480. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24481. /** @hidden */
  24482. export var shadowsVertex: {
  24483. name: string;
  24484. shader: string;
  24485. };
  24486. }
  24487. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24488. /** @hidden */
  24489. export var pointCloudVertex: {
  24490. name: string;
  24491. shader: string;
  24492. };
  24493. }
  24494. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24495. /** @hidden */
  24496. export var logDepthVertex: {
  24497. name: string;
  24498. shader: string;
  24499. };
  24500. }
  24501. declare module "babylonjs/Shaders/default.vertex" {
  24502. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24503. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24507. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24508. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24510. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24515. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24519. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24520. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24521. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24522. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24523. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24524. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24525. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24526. /** @hidden */
  24527. export var defaultVertexShader: {
  24528. name: string;
  24529. shader: string;
  24530. };
  24531. }
  24532. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24533. import { Nullable } from "babylonjs/types";
  24534. import { Scene } from "babylonjs/scene";
  24535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24536. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24537. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24538. /**
  24539. * @hidden
  24540. */
  24541. export interface IMaterialDetailMapDefines {
  24542. DETAIL: boolean;
  24543. DETAILDIRECTUV: number;
  24544. DETAIL_NORMALBLENDMETHOD: number;
  24545. /** @hidden */
  24546. _areTexturesDirty: boolean;
  24547. }
  24548. /**
  24549. * Define the code related to the detail map parameters of a material
  24550. *
  24551. * Inspired from:
  24552. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  24553. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24554. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24555. */
  24556. export class DetailMapConfiguration {
  24557. private _texture;
  24558. /**
  24559. * The detail texture of the material.
  24560. */
  24561. texture: Nullable<BaseTexture>;
  24562. /**
  24563. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24564. * Bigger values mean stronger blending
  24565. */
  24566. diffuseBlendLevel: number;
  24567. /**
  24568. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24569. * Bigger values mean stronger blending. Only used with PBR materials
  24570. */
  24571. roughnessBlendLevel: number;
  24572. /**
  24573. * Defines how strong the bump effect from the detail map is
  24574. * Bigger values mean stronger effect
  24575. */
  24576. bumpLevel: number;
  24577. private _normalBlendMethod;
  24578. /**
  24579. * The method used to blend the bump and detail normals together
  24580. */
  24581. normalBlendMethod: number;
  24582. private _isEnabled;
  24583. /**
  24584. * Enable or disable the detail map on this material
  24585. */
  24586. isEnabled: boolean;
  24587. /** @hidden */
  24588. private _internalMarkAllSubMeshesAsTexturesDirty;
  24589. /** @hidden */
  24590. _markAllSubMeshesAsTexturesDirty(): void;
  24591. /**
  24592. * Instantiate a new detail map
  24593. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24594. */
  24595. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24596. /**
  24597. * Gets whether the submesh is ready to be used or not.
  24598. * @param defines the list of "defines" to update.
  24599. * @param scene defines the scene the material belongs to.
  24600. * @returns - boolean indicating that the submesh is ready or not.
  24601. */
  24602. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24603. /**
  24604. * Update the defines for detail map usage
  24605. * @param defines the list of "defines" to update.
  24606. * @param scene defines the scene the material belongs to.
  24607. */
  24608. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24609. /**
  24610. * Binds the material data.
  24611. * @param uniformBuffer defines the Uniform buffer to fill in.
  24612. * @param scene defines the scene the material belongs to.
  24613. * @param isFrozen defines whether the material is frozen or not.
  24614. */
  24615. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24616. /**
  24617. * Checks to see if a texture is used in the material.
  24618. * @param texture - Base texture to use.
  24619. * @returns - Boolean specifying if a texture is used in the material.
  24620. */
  24621. hasTexture(texture: BaseTexture): boolean;
  24622. /**
  24623. * Returns an array of the actively used textures.
  24624. * @param activeTextures Array of BaseTextures
  24625. */
  24626. getActiveTextures(activeTextures: BaseTexture[]): void;
  24627. /**
  24628. * Returns the animatable textures.
  24629. * @param animatables Array of animatable textures.
  24630. */
  24631. getAnimatables(animatables: IAnimatable[]): void;
  24632. /**
  24633. * Disposes the resources of the material.
  24634. * @param forceDisposeTextures - Forces the disposal of all textures.
  24635. */
  24636. dispose(forceDisposeTextures?: boolean): void;
  24637. /**
  24638. * Get the current class name useful for serialization or dynamic coding.
  24639. * @returns "DetailMap"
  24640. */
  24641. getClassName(): string;
  24642. /**
  24643. * Add the required uniforms to the current list.
  24644. * @param uniforms defines the current uniform list.
  24645. */
  24646. static AddUniforms(uniforms: string[]): void;
  24647. /**
  24648. * Add the required samplers to the current list.
  24649. * @param samplers defines the current sampler list.
  24650. */
  24651. static AddSamplers(samplers: string[]): void;
  24652. /**
  24653. * Add the required uniforms to the current buffer.
  24654. * @param uniformBuffer defines the current uniform buffer.
  24655. */
  24656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24657. /**
  24658. * Makes a duplicate of the current instance into another one.
  24659. * @param detailMap define the instance where to copy the info
  24660. */
  24661. copyTo(detailMap: DetailMapConfiguration): void;
  24662. /**
  24663. * Serializes this detail map instance
  24664. * @returns - An object with the serialized instance.
  24665. */
  24666. serialize(): any;
  24667. /**
  24668. * Parses a detail map setting from a serialized object.
  24669. * @param source - Serialized object.
  24670. * @param scene Defines the scene we are parsing for
  24671. * @param rootUrl Defines the rootUrl to load from
  24672. */
  24673. parse(source: any, scene: Scene, rootUrl: string): void;
  24674. }
  24675. }
  24676. declare module "babylonjs/Materials/standardMaterial" {
  24677. import { SmartArray } from "babylonjs/Misc/smartArray";
  24678. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Scene } from "babylonjs/scene";
  24681. import { Matrix } from "babylonjs/Maths/math.vector";
  24682. import { Color3 } from "babylonjs/Maths/math.color";
  24683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24685. import { Mesh } from "babylonjs/Meshes/mesh";
  24686. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24687. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24688. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24689. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24690. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24691. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24694. import "babylonjs/Shaders/default.fragment";
  24695. import "babylonjs/Shaders/default.vertex";
  24696. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24697. /** @hidden */
  24698. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24699. MAINUV1: boolean;
  24700. MAINUV2: boolean;
  24701. DIFFUSE: boolean;
  24702. DIFFUSEDIRECTUV: number;
  24703. DETAIL: boolean;
  24704. DETAILDIRECTUV: number;
  24705. DETAIL_NORMALBLENDMETHOD: number;
  24706. AMBIENT: boolean;
  24707. AMBIENTDIRECTUV: number;
  24708. OPACITY: boolean;
  24709. OPACITYDIRECTUV: number;
  24710. OPACITYRGB: boolean;
  24711. REFLECTION: boolean;
  24712. EMISSIVE: boolean;
  24713. EMISSIVEDIRECTUV: number;
  24714. SPECULAR: boolean;
  24715. SPECULARDIRECTUV: number;
  24716. BUMP: boolean;
  24717. BUMPDIRECTUV: number;
  24718. PARALLAX: boolean;
  24719. PARALLAXOCCLUSION: boolean;
  24720. SPECULAROVERALPHA: boolean;
  24721. CLIPPLANE: boolean;
  24722. CLIPPLANE2: boolean;
  24723. CLIPPLANE3: boolean;
  24724. CLIPPLANE4: boolean;
  24725. CLIPPLANE5: boolean;
  24726. CLIPPLANE6: boolean;
  24727. ALPHATEST: boolean;
  24728. DEPTHPREPASS: boolean;
  24729. ALPHAFROMDIFFUSE: boolean;
  24730. POINTSIZE: boolean;
  24731. FOG: boolean;
  24732. SPECULARTERM: boolean;
  24733. DIFFUSEFRESNEL: boolean;
  24734. OPACITYFRESNEL: boolean;
  24735. REFLECTIONFRESNEL: boolean;
  24736. REFRACTIONFRESNEL: boolean;
  24737. EMISSIVEFRESNEL: boolean;
  24738. FRESNEL: boolean;
  24739. NORMAL: boolean;
  24740. UV1: boolean;
  24741. UV2: boolean;
  24742. VERTEXCOLOR: boolean;
  24743. VERTEXALPHA: boolean;
  24744. NUM_BONE_INFLUENCERS: number;
  24745. BonesPerMesh: number;
  24746. BONETEXTURE: boolean;
  24747. BONES_VELOCITY_ENABLED: boolean;
  24748. INSTANCES: boolean;
  24749. THIN_INSTANCES: boolean;
  24750. GLOSSINESS: boolean;
  24751. ROUGHNESS: boolean;
  24752. EMISSIVEASILLUMINATION: boolean;
  24753. LINKEMISSIVEWITHDIFFUSE: boolean;
  24754. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24755. LIGHTMAP: boolean;
  24756. LIGHTMAPDIRECTUV: number;
  24757. OBJECTSPACE_NORMALMAP: boolean;
  24758. USELIGHTMAPASSHADOWMAP: boolean;
  24759. REFLECTIONMAP_3D: boolean;
  24760. REFLECTIONMAP_SPHERICAL: boolean;
  24761. REFLECTIONMAP_PLANAR: boolean;
  24762. REFLECTIONMAP_CUBIC: boolean;
  24763. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24764. REFLECTIONMAP_PROJECTION: boolean;
  24765. REFLECTIONMAP_SKYBOX: boolean;
  24766. REFLECTIONMAP_EXPLICIT: boolean;
  24767. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24768. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24769. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24770. INVERTCUBICMAP: boolean;
  24771. LOGARITHMICDEPTH: boolean;
  24772. REFRACTION: boolean;
  24773. REFRACTIONMAP_3D: boolean;
  24774. REFLECTIONOVERALPHA: boolean;
  24775. TWOSIDEDLIGHTING: boolean;
  24776. SHADOWFLOAT: boolean;
  24777. MORPHTARGETS: boolean;
  24778. MORPHTARGETS_NORMAL: boolean;
  24779. MORPHTARGETS_TANGENT: boolean;
  24780. MORPHTARGETS_UV: boolean;
  24781. NUM_MORPH_INFLUENCERS: number;
  24782. NONUNIFORMSCALING: boolean;
  24783. PREMULTIPLYALPHA: boolean;
  24784. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24785. ALPHABLEND: boolean;
  24786. PREPASS: boolean;
  24787. PREPASS_IRRADIANCE: boolean;
  24788. PREPASS_IRRADIANCE_INDEX: number;
  24789. PREPASS_ALBEDO: boolean;
  24790. PREPASS_ALBEDO_INDEX: number;
  24791. PREPASS_DEPTHNORMAL: boolean;
  24792. PREPASS_DEPTHNORMAL_INDEX: number;
  24793. PREPASS_POSITION: boolean;
  24794. PREPASS_POSITION_INDEX: number;
  24795. PREPASS_VELOCITY: boolean;
  24796. PREPASS_VELOCITY_INDEX: number;
  24797. PREPASS_REFLECTIVITY: boolean;
  24798. PREPASS_REFLECTIVITY_INDEX: number;
  24799. SCENE_MRT_COUNT: number;
  24800. RGBDLIGHTMAP: boolean;
  24801. RGBDREFLECTION: boolean;
  24802. RGBDREFRACTION: boolean;
  24803. IMAGEPROCESSING: boolean;
  24804. VIGNETTE: boolean;
  24805. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24806. VIGNETTEBLENDMODEOPAQUE: boolean;
  24807. TONEMAPPING: boolean;
  24808. TONEMAPPING_ACES: boolean;
  24809. CONTRAST: boolean;
  24810. COLORCURVES: boolean;
  24811. COLORGRADING: boolean;
  24812. COLORGRADING3D: boolean;
  24813. SAMPLER3DGREENDEPTH: boolean;
  24814. SAMPLER3DBGRMAP: boolean;
  24815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24816. MULTIVIEW: boolean;
  24817. /**
  24818. * If the reflection texture on this material is in linear color space
  24819. * @hidden
  24820. */
  24821. IS_REFLECTION_LINEAR: boolean;
  24822. /**
  24823. * If the refraction texture on this material is in linear color space
  24824. * @hidden
  24825. */
  24826. IS_REFRACTION_LINEAR: boolean;
  24827. EXPOSURE: boolean;
  24828. constructor();
  24829. setReflectionMode(modeToEnable: string): void;
  24830. }
  24831. /**
  24832. * This is the default material used in Babylon. It is the best trade off between quality
  24833. * and performances.
  24834. * @see https://doc.babylonjs.com/babylon101/materials
  24835. */
  24836. export class StandardMaterial extends PushMaterial {
  24837. private _diffuseTexture;
  24838. /**
  24839. * The basic texture of the material as viewed under a light.
  24840. */
  24841. diffuseTexture: Nullable<BaseTexture>;
  24842. private _ambientTexture;
  24843. /**
  24844. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24845. */
  24846. ambientTexture: Nullable<BaseTexture>;
  24847. private _opacityTexture;
  24848. /**
  24849. * Define the transparency of the material from a texture.
  24850. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24851. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24852. */
  24853. opacityTexture: Nullable<BaseTexture>;
  24854. private _reflectionTexture;
  24855. /**
  24856. * Define the texture used to display the reflection.
  24857. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24858. */
  24859. reflectionTexture: Nullable<BaseTexture>;
  24860. private _emissiveTexture;
  24861. /**
  24862. * Define texture of the material as if self lit.
  24863. * This will be mixed in the final result even in the absence of light.
  24864. */
  24865. emissiveTexture: Nullable<BaseTexture>;
  24866. private _specularTexture;
  24867. /**
  24868. * Define how the color and intensity of the highlight given by the light in the material.
  24869. */
  24870. specularTexture: Nullable<BaseTexture>;
  24871. private _bumpTexture;
  24872. /**
  24873. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24874. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  24875. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24876. */
  24877. bumpTexture: Nullable<BaseTexture>;
  24878. private _lightmapTexture;
  24879. /**
  24880. * Complex lighting can be computationally expensive to compute at runtime.
  24881. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24882. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24883. */
  24884. lightmapTexture: Nullable<BaseTexture>;
  24885. private _refractionTexture;
  24886. /**
  24887. * Define the texture used to display the refraction.
  24888. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24889. */
  24890. refractionTexture: Nullable<BaseTexture>;
  24891. /**
  24892. * The color of the material lit by the environmental background lighting.
  24893. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24894. */
  24895. ambientColor: Color3;
  24896. /**
  24897. * The basic color of the material as viewed under a light.
  24898. */
  24899. diffuseColor: Color3;
  24900. /**
  24901. * Define how the color and intensity of the highlight given by the light in the material.
  24902. */
  24903. specularColor: Color3;
  24904. /**
  24905. * Define the color of the material as if self lit.
  24906. * This will be mixed in the final result even in the absence of light.
  24907. */
  24908. emissiveColor: Color3;
  24909. /**
  24910. * Defines how sharp are the highlights in the material.
  24911. * The bigger the value the sharper giving a more glossy feeling to the result.
  24912. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24913. */
  24914. specularPower: number;
  24915. private _useAlphaFromDiffuseTexture;
  24916. /**
  24917. * Does the transparency come from the diffuse texture alpha channel.
  24918. */
  24919. useAlphaFromDiffuseTexture: boolean;
  24920. private _useEmissiveAsIllumination;
  24921. /**
  24922. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24923. */
  24924. useEmissiveAsIllumination: boolean;
  24925. private _linkEmissiveWithDiffuse;
  24926. /**
  24927. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24928. * the emissive level when the final color is close to one.
  24929. */
  24930. linkEmissiveWithDiffuse: boolean;
  24931. private _useSpecularOverAlpha;
  24932. /**
  24933. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24935. */
  24936. useSpecularOverAlpha: boolean;
  24937. private _useReflectionOverAlpha;
  24938. /**
  24939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24941. */
  24942. useReflectionOverAlpha: boolean;
  24943. private _disableLighting;
  24944. /**
  24945. * Does lights from the scene impacts this material.
  24946. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24947. */
  24948. disableLighting: boolean;
  24949. private _useObjectSpaceNormalMap;
  24950. /**
  24951. * Allows using an object space normal map (instead of tangent space).
  24952. */
  24953. useObjectSpaceNormalMap: boolean;
  24954. private _useParallax;
  24955. /**
  24956. * Is parallax enabled or not.
  24957. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24958. */
  24959. useParallax: boolean;
  24960. private _useParallaxOcclusion;
  24961. /**
  24962. * Is parallax occlusion enabled or not.
  24963. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24964. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24965. */
  24966. useParallaxOcclusion: boolean;
  24967. /**
  24968. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  24969. */
  24970. parallaxScaleBias: number;
  24971. private _roughness;
  24972. /**
  24973. * Helps to define how blurry the reflections should appears in the material.
  24974. */
  24975. roughness: number;
  24976. /**
  24977. * In case of refraction, define the value of the index of refraction.
  24978. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24979. */
  24980. indexOfRefraction: number;
  24981. /**
  24982. * Invert the refraction texture alongside the y axis.
  24983. * It can be useful with procedural textures or probe for instance.
  24984. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24985. */
  24986. invertRefractionY: boolean;
  24987. /**
  24988. * Defines the alpha limits in alpha test mode.
  24989. */
  24990. alphaCutOff: number;
  24991. private _useLightmapAsShadowmap;
  24992. /**
  24993. * In case of light mapping, define whether the map contains light or shadow informations.
  24994. */
  24995. useLightmapAsShadowmap: boolean;
  24996. private _diffuseFresnelParameters;
  24997. /**
  24998. * Define the diffuse fresnel parameters of the material.
  24999. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25000. */
  25001. diffuseFresnelParameters: FresnelParameters;
  25002. private _opacityFresnelParameters;
  25003. /**
  25004. * Define the opacity fresnel parameters of the material.
  25005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25006. */
  25007. opacityFresnelParameters: FresnelParameters;
  25008. private _reflectionFresnelParameters;
  25009. /**
  25010. * Define the reflection fresnel parameters of the material.
  25011. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25012. */
  25013. reflectionFresnelParameters: FresnelParameters;
  25014. private _refractionFresnelParameters;
  25015. /**
  25016. * Define the refraction fresnel parameters of the material.
  25017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25018. */
  25019. refractionFresnelParameters: FresnelParameters;
  25020. private _emissiveFresnelParameters;
  25021. /**
  25022. * Define the emissive fresnel parameters of the material.
  25023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25024. */
  25025. emissiveFresnelParameters: FresnelParameters;
  25026. private _useReflectionFresnelFromSpecular;
  25027. /**
  25028. * If true automatically deducts the fresnels values from the material specularity.
  25029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25030. */
  25031. useReflectionFresnelFromSpecular: boolean;
  25032. private _useGlossinessFromSpecularMapAlpha;
  25033. /**
  25034. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25035. */
  25036. useGlossinessFromSpecularMapAlpha: boolean;
  25037. private _maxSimultaneousLights;
  25038. /**
  25039. * Defines the maximum number of lights that can be used in the material
  25040. */
  25041. maxSimultaneousLights: number;
  25042. private _invertNormalMapX;
  25043. /**
  25044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25045. */
  25046. invertNormalMapX: boolean;
  25047. private _invertNormalMapY;
  25048. /**
  25049. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25050. */
  25051. invertNormalMapY: boolean;
  25052. private _twoSidedLighting;
  25053. /**
  25054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25055. */
  25056. twoSidedLighting: boolean;
  25057. /**
  25058. * Default configuration related to image processing available in the standard Material.
  25059. */
  25060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25061. /**
  25062. * Gets the image processing configuration used either in this material.
  25063. */
  25064. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25065. /**
  25066. * Sets the Default image processing configuration used either in the this material.
  25067. *
  25068. * If sets to null, the scene one is in use.
  25069. */
  25070. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25071. /**
  25072. * Keep track of the image processing observer to allow dispose and replace.
  25073. */
  25074. private _imageProcessingObserver;
  25075. /**
  25076. * Attaches a new image processing configuration to the Standard Material.
  25077. * @param configuration
  25078. */
  25079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25080. /**
  25081. * Defines additionnal PrePass parameters for the material.
  25082. */
  25083. readonly prePassConfiguration: PrePassConfiguration;
  25084. /**
  25085. * Gets wether the color curves effect is enabled.
  25086. */
  25087. get cameraColorCurvesEnabled(): boolean;
  25088. /**
  25089. * Sets wether the color curves effect is enabled.
  25090. */
  25091. set cameraColorCurvesEnabled(value: boolean);
  25092. /**
  25093. * Gets wether the color grading effect is enabled.
  25094. */
  25095. get cameraColorGradingEnabled(): boolean;
  25096. /**
  25097. * Gets wether the color grading effect is enabled.
  25098. */
  25099. set cameraColorGradingEnabled(value: boolean);
  25100. /**
  25101. * Gets wether tonemapping is enabled or not.
  25102. */
  25103. get cameraToneMappingEnabled(): boolean;
  25104. /**
  25105. * Sets wether tonemapping is enabled or not
  25106. */
  25107. set cameraToneMappingEnabled(value: boolean);
  25108. /**
  25109. * The camera exposure used on this material.
  25110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25111. * This corresponds to a photographic exposure.
  25112. */
  25113. get cameraExposure(): number;
  25114. /**
  25115. * The camera exposure used on this material.
  25116. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25117. * This corresponds to a photographic exposure.
  25118. */
  25119. set cameraExposure(value: number);
  25120. /**
  25121. * Gets The camera contrast used on this material.
  25122. */
  25123. get cameraContrast(): number;
  25124. /**
  25125. * Sets The camera contrast used on this material.
  25126. */
  25127. set cameraContrast(value: number);
  25128. /**
  25129. * Gets the Color Grading 2D Lookup Texture.
  25130. */
  25131. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25132. /**
  25133. * Sets the Color Grading 2D Lookup Texture.
  25134. */
  25135. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25136. /**
  25137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25139. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25141. */
  25142. get cameraColorCurves(): Nullable<ColorCurves>;
  25143. /**
  25144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25146. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25148. */
  25149. set cameraColorCurves(value: Nullable<ColorCurves>);
  25150. /**
  25151. * Can this material render to several textures at once
  25152. */
  25153. get canRenderToMRT(): boolean;
  25154. /**
  25155. * Defines the detail map parameters for the material.
  25156. */
  25157. readonly detailMap: DetailMapConfiguration;
  25158. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25159. protected _worldViewProjectionMatrix: Matrix;
  25160. protected _globalAmbientColor: Color3;
  25161. protected _useLogarithmicDepth: boolean;
  25162. protected _rebuildInParallel: boolean;
  25163. /**
  25164. * Instantiates a new standard material.
  25165. * This is the default material used in Babylon. It is the best trade off between quality
  25166. * and performances.
  25167. * @see https://doc.babylonjs.com/babylon101/materials
  25168. * @param name Define the name of the material in the scene
  25169. * @param scene Define the scene the material belong to
  25170. */
  25171. constructor(name: string, scene: Scene);
  25172. /**
  25173. * Gets a boolean indicating that current material needs to register RTT
  25174. */
  25175. get hasRenderTargetTextures(): boolean;
  25176. /**
  25177. * Gets the current class name of the material e.g. "StandardMaterial"
  25178. * Mainly use in serialization.
  25179. * @returns the class name
  25180. */
  25181. getClassName(): string;
  25182. /**
  25183. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25184. * You can try switching to logarithmic depth.
  25185. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25186. */
  25187. get useLogarithmicDepth(): boolean;
  25188. set useLogarithmicDepth(value: boolean);
  25189. /**
  25190. * Specifies if the material will require alpha blending
  25191. * @returns a boolean specifying if alpha blending is needed
  25192. */
  25193. needAlphaBlending(): boolean;
  25194. /**
  25195. * Specifies if this material should be rendered in alpha test mode
  25196. * @returns a boolean specifying if an alpha test is needed.
  25197. */
  25198. needAlphaTesting(): boolean;
  25199. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25200. /**
  25201. * Get the texture used for alpha test purpose.
  25202. * @returns the diffuse texture in case of the standard material.
  25203. */
  25204. getAlphaTestTexture(): Nullable<BaseTexture>;
  25205. /**
  25206. * Get if the submesh is ready to be used and all its information available.
  25207. * Child classes can use it to update shaders
  25208. * @param mesh defines the mesh to check
  25209. * @param subMesh defines which submesh to check
  25210. * @param useInstances specifies that instances should be used
  25211. * @returns a boolean indicating that the submesh is ready or not
  25212. */
  25213. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25214. /**
  25215. * Builds the material UBO layouts.
  25216. * Used internally during the effect preparation.
  25217. */
  25218. buildUniformLayout(): void;
  25219. /**
  25220. * Unbinds the material from the mesh
  25221. */
  25222. unbind(): void;
  25223. /**
  25224. * Binds the submesh to this material by preparing the effect and shader to draw
  25225. * @param world defines the world transformation matrix
  25226. * @param mesh defines the mesh containing the submesh
  25227. * @param subMesh defines the submesh to bind the material to
  25228. */
  25229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25230. /**
  25231. * Get the list of animatables in the material.
  25232. * @returns the list of animatables object used in the material
  25233. */
  25234. getAnimatables(): IAnimatable[];
  25235. /**
  25236. * Gets the active textures from the material
  25237. * @returns an array of textures
  25238. */
  25239. getActiveTextures(): BaseTexture[];
  25240. /**
  25241. * Specifies if the material uses a texture
  25242. * @param texture defines the texture to check against the material
  25243. * @returns a boolean specifying if the material uses the texture
  25244. */
  25245. hasTexture(texture: BaseTexture): boolean;
  25246. /**
  25247. * Disposes the material
  25248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25250. */
  25251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25252. /**
  25253. * Makes a duplicate of the material, and gives it a new name
  25254. * @param name defines the new name for the duplicated material
  25255. * @returns the cloned material
  25256. */
  25257. clone(name: string): StandardMaterial;
  25258. /**
  25259. * Serializes this material in a JSON representation
  25260. * @returns the serialized material object
  25261. */
  25262. serialize(): any;
  25263. /**
  25264. * Creates a standard material from parsed material data
  25265. * @param source defines the JSON representation of the material
  25266. * @param scene defines the hosting scene
  25267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25268. * @returns a new standard material
  25269. */
  25270. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25271. /**
  25272. * Are diffuse textures enabled in the application.
  25273. */
  25274. static get DiffuseTextureEnabled(): boolean;
  25275. static set DiffuseTextureEnabled(value: boolean);
  25276. /**
  25277. * Are detail textures enabled in the application.
  25278. */
  25279. static get DetailTextureEnabled(): boolean;
  25280. static set DetailTextureEnabled(value: boolean);
  25281. /**
  25282. * Are ambient textures enabled in the application.
  25283. */
  25284. static get AmbientTextureEnabled(): boolean;
  25285. static set AmbientTextureEnabled(value: boolean);
  25286. /**
  25287. * Are opacity textures enabled in the application.
  25288. */
  25289. static get OpacityTextureEnabled(): boolean;
  25290. static set OpacityTextureEnabled(value: boolean);
  25291. /**
  25292. * Are reflection textures enabled in the application.
  25293. */
  25294. static get ReflectionTextureEnabled(): boolean;
  25295. static set ReflectionTextureEnabled(value: boolean);
  25296. /**
  25297. * Are emissive textures enabled in the application.
  25298. */
  25299. static get EmissiveTextureEnabled(): boolean;
  25300. static set EmissiveTextureEnabled(value: boolean);
  25301. /**
  25302. * Are specular textures enabled in the application.
  25303. */
  25304. static get SpecularTextureEnabled(): boolean;
  25305. static set SpecularTextureEnabled(value: boolean);
  25306. /**
  25307. * Are bump textures enabled in the application.
  25308. */
  25309. static get BumpTextureEnabled(): boolean;
  25310. static set BumpTextureEnabled(value: boolean);
  25311. /**
  25312. * Are lightmap textures enabled in the application.
  25313. */
  25314. static get LightmapTextureEnabled(): boolean;
  25315. static set LightmapTextureEnabled(value: boolean);
  25316. /**
  25317. * Are refraction textures enabled in the application.
  25318. */
  25319. static get RefractionTextureEnabled(): boolean;
  25320. static set RefractionTextureEnabled(value: boolean);
  25321. /**
  25322. * Are color grading textures enabled in the application.
  25323. */
  25324. static get ColorGradingTextureEnabled(): boolean;
  25325. static set ColorGradingTextureEnabled(value: boolean);
  25326. /**
  25327. * Are fresnels enabled in the application.
  25328. */
  25329. static get FresnelEnabled(): boolean;
  25330. static set FresnelEnabled(value: boolean);
  25331. }
  25332. }
  25333. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25335. /** @hidden */
  25336. export var rgbdDecodePixelShader: {
  25337. name: string;
  25338. shader: string;
  25339. };
  25340. }
  25341. declare module "babylonjs/Misc/rgbdTextureTools" {
  25342. import "babylonjs/Shaders/rgbdDecode.fragment";
  25343. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25344. import { Texture } from "babylonjs/Materials/Textures/texture";
  25345. /**
  25346. * Class used to host RGBD texture specific utilities
  25347. */
  25348. export class RGBDTextureTools {
  25349. /**
  25350. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25351. * @param texture the texture to expand.
  25352. */
  25353. static ExpandRGBDTexture(texture: Texture): void;
  25354. }
  25355. }
  25356. declare module "babylonjs/Misc/brdfTextureTools" {
  25357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25358. import { Scene } from "babylonjs/scene";
  25359. /**
  25360. * Class used to host texture specific utilities
  25361. */
  25362. export class BRDFTextureTools {
  25363. /**
  25364. * Prevents texture cache collision
  25365. */
  25366. private static _instanceNumber;
  25367. /**
  25368. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25369. * @param scene defines the hosting scene
  25370. * @returns the environment BRDF texture
  25371. */
  25372. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25373. private static _environmentBRDFBase64Texture;
  25374. }
  25375. }
  25376. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25377. import { Nullable } from "babylonjs/types";
  25378. import { Color3 } from "babylonjs/Maths/math.color";
  25379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25381. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25382. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25383. import { Engine } from "babylonjs/Engines/engine";
  25384. import { Scene } from "babylonjs/scene";
  25385. /**
  25386. * @hidden
  25387. */
  25388. export interface IMaterialClearCoatDefines {
  25389. CLEARCOAT: boolean;
  25390. CLEARCOAT_DEFAULTIOR: boolean;
  25391. CLEARCOAT_TEXTURE: boolean;
  25392. CLEARCOAT_TEXTUREDIRECTUV: number;
  25393. CLEARCOAT_BUMP: boolean;
  25394. CLEARCOAT_BUMPDIRECTUV: number;
  25395. CLEARCOAT_REMAP_F0: boolean;
  25396. CLEARCOAT_TINT: boolean;
  25397. CLEARCOAT_TINT_TEXTURE: boolean;
  25398. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25399. /** @hidden */
  25400. _areTexturesDirty: boolean;
  25401. }
  25402. /**
  25403. * Define the code related to the clear coat parameters of the pbr material.
  25404. */
  25405. export class PBRClearCoatConfiguration {
  25406. /**
  25407. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25408. * The default fits with a polyurethane material.
  25409. */
  25410. private static readonly _DefaultIndexOfRefraction;
  25411. private _isEnabled;
  25412. /**
  25413. * Defines if the clear coat is enabled in the material.
  25414. */
  25415. isEnabled: boolean;
  25416. /**
  25417. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25418. */
  25419. intensity: number;
  25420. /**
  25421. * Defines the clear coat layer roughness.
  25422. */
  25423. roughness: number;
  25424. private _indexOfRefraction;
  25425. /**
  25426. * Defines the index of refraction of the clear coat.
  25427. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25428. * The default fits with a polyurethane material.
  25429. * Changing the default value is more performance intensive.
  25430. */
  25431. indexOfRefraction: number;
  25432. private _texture;
  25433. /**
  25434. * Stores the clear coat values in a texture.
  25435. */
  25436. texture: Nullable<BaseTexture>;
  25437. private _remapF0OnInterfaceChange;
  25438. /**
  25439. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25440. */
  25441. remapF0OnInterfaceChange: boolean;
  25442. private _bumpTexture;
  25443. /**
  25444. * Define the clear coat specific bump texture.
  25445. */
  25446. bumpTexture: Nullable<BaseTexture>;
  25447. private _isTintEnabled;
  25448. /**
  25449. * Defines if the clear coat tint is enabled in the material.
  25450. */
  25451. isTintEnabled: boolean;
  25452. /**
  25453. * Defines the clear coat tint of the material.
  25454. * This is only use if tint is enabled
  25455. */
  25456. tintColor: Color3;
  25457. /**
  25458. * Defines the distance at which the tint color should be found in the
  25459. * clear coat media.
  25460. * This is only use if tint is enabled
  25461. */
  25462. tintColorAtDistance: number;
  25463. /**
  25464. * Defines the clear coat layer thickness.
  25465. * This is only use if tint is enabled
  25466. */
  25467. tintThickness: number;
  25468. private _tintTexture;
  25469. /**
  25470. * Stores the clear tint values in a texture.
  25471. * rgb is tint
  25472. * a is a thickness factor
  25473. */
  25474. tintTexture: Nullable<BaseTexture>;
  25475. /** @hidden */
  25476. private _internalMarkAllSubMeshesAsTexturesDirty;
  25477. /** @hidden */
  25478. _markAllSubMeshesAsTexturesDirty(): void;
  25479. /**
  25480. * Instantiate a new istance of clear coat configuration.
  25481. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25482. */
  25483. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25484. /**
  25485. * Gets wehter the submesh is ready to be used or not.
  25486. * @param defines the list of "defines" to update.
  25487. * @param scene defines the scene the material belongs to.
  25488. * @param engine defines the engine the material belongs to.
  25489. * @param disableBumpMap defines wether the material disables bump or not.
  25490. * @returns - boolean indicating that the submesh is ready or not.
  25491. */
  25492. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25493. /**
  25494. * Checks to see if a texture is used in the material.
  25495. * @param defines the list of "defines" to update.
  25496. * @param scene defines the scene to the material belongs to.
  25497. */
  25498. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25499. /**
  25500. * Binds the material data.
  25501. * @param uniformBuffer defines the Uniform buffer to fill in.
  25502. * @param scene defines the scene the material belongs to.
  25503. * @param engine defines the engine the material belongs to.
  25504. * @param disableBumpMap defines wether the material disables bump or not.
  25505. * @param isFrozen defines wether the material is frozen or not.
  25506. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25507. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25508. */
  25509. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  25510. /**
  25511. * Checks to see if a texture is used in the material.
  25512. * @param texture - Base texture to use.
  25513. * @returns - Boolean specifying if a texture is used in the material.
  25514. */
  25515. hasTexture(texture: BaseTexture): boolean;
  25516. /**
  25517. * Returns an array of the actively used textures.
  25518. * @param activeTextures Array of BaseTextures
  25519. */
  25520. getActiveTextures(activeTextures: BaseTexture[]): void;
  25521. /**
  25522. * Returns the animatable textures.
  25523. * @param animatables Array of animatable textures.
  25524. */
  25525. getAnimatables(animatables: IAnimatable[]): void;
  25526. /**
  25527. * Disposes the resources of the material.
  25528. * @param forceDisposeTextures - Forces the disposal of all textures.
  25529. */
  25530. dispose(forceDisposeTextures?: boolean): void;
  25531. /**
  25532. * Get the current class name of the texture useful for serialization or dynamic coding.
  25533. * @returns "PBRClearCoatConfiguration"
  25534. */
  25535. getClassName(): string;
  25536. /**
  25537. * Add fallbacks to the effect fallbacks list.
  25538. * @param defines defines the Base texture to use.
  25539. * @param fallbacks defines the current fallback list.
  25540. * @param currentRank defines the current fallback rank.
  25541. * @returns the new fallback rank.
  25542. */
  25543. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25544. /**
  25545. * Add the required uniforms to the current list.
  25546. * @param uniforms defines the current uniform list.
  25547. */
  25548. static AddUniforms(uniforms: string[]): void;
  25549. /**
  25550. * Add the required samplers to the current list.
  25551. * @param samplers defines the current sampler list.
  25552. */
  25553. static AddSamplers(samplers: string[]): void;
  25554. /**
  25555. * Add the required uniforms to the current buffer.
  25556. * @param uniformBuffer defines the current uniform buffer.
  25557. */
  25558. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25559. /**
  25560. * Makes a duplicate of the current configuration into another one.
  25561. * @param clearCoatConfiguration define the config where to copy the info
  25562. */
  25563. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25564. /**
  25565. * Serializes this clear coat configuration.
  25566. * @returns - An object with the serialized config.
  25567. */
  25568. serialize(): any;
  25569. /**
  25570. * Parses a anisotropy Configuration from a serialized object.
  25571. * @param source - Serialized object.
  25572. * @param scene Defines the scene we are parsing for
  25573. * @param rootUrl Defines the rootUrl to load from
  25574. */
  25575. parse(source: any, scene: Scene, rootUrl: string): void;
  25576. }
  25577. }
  25578. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25579. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25581. import { Vector2 } from "babylonjs/Maths/math.vector";
  25582. import { Scene } from "babylonjs/scene";
  25583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25584. import { Nullable } from "babylonjs/types";
  25585. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25586. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25587. /**
  25588. * @hidden
  25589. */
  25590. export interface IMaterialAnisotropicDefines {
  25591. ANISOTROPIC: boolean;
  25592. ANISOTROPIC_TEXTURE: boolean;
  25593. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25594. MAINUV1: boolean;
  25595. _areTexturesDirty: boolean;
  25596. _needUVs: boolean;
  25597. }
  25598. /**
  25599. * Define the code related to the anisotropic parameters of the pbr material.
  25600. */
  25601. export class PBRAnisotropicConfiguration {
  25602. private _isEnabled;
  25603. /**
  25604. * Defines if the anisotropy is enabled in the material.
  25605. */
  25606. isEnabled: boolean;
  25607. /**
  25608. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25609. */
  25610. intensity: number;
  25611. /**
  25612. * Defines if the effect is along the tangents, bitangents or in between.
  25613. * By default, the effect is "strectching" the highlights along the tangents.
  25614. */
  25615. direction: Vector2;
  25616. private _texture;
  25617. /**
  25618. * Stores the anisotropy values in a texture.
  25619. * rg is direction (like normal from -1 to 1)
  25620. * b is a intensity
  25621. */
  25622. texture: Nullable<BaseTexture>;
  25623. /** @hidden */
  25624. private _internalMarkAllSubMeshesAsTexturesDirty;
  25625. /** @hidden */
  25626. _markAllSubMeshesAsTexturesDirty(): void;
  25627. /**
  25628. * Instantiate a new istance of anisotropy configuration.
  25629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25630. */
  25631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25632. /**
  25633. * Specifies that the submesh is ready to be used.
  25634. * @param defines the list of "defines" to update.
  25635. * @param scene defines the scene the material belongs to.
  25636. * @returns - boolean indicating that the submesh is ready or not.
  25637. */
  25638. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25639. /**
  25640. * Checks to see if a texture is used in the material.
  25641. * @param defines the list of "defines" to update.
  25642. * @param mesh the mesh we are preparing the defines for.
  25643. * @param scene defines the scene the material belongs to.
  25644. */
  25645. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25646. /**
  25647. * Binds the material data.
  25648. * @param uniformBuffer defines the Uniform buffer to fill in.
  25649. * @param scene defines the scene the material belongs to.
  25650. * @param isFrozen defines wether the material is frozen or not.
  25651. */
  25652. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25653. /**
  25654. * Checks to see if a texture is used in the material.
  25655. * @param texture - Base texture to use.
  25656. * @returns - Boolean specifying if a texture is used in the material.
  25657. */
  25658. hasTexture(texture: BaseTexture): boolean;
  25659. /**
  25660. * Returns an array of the actively used textures.
  25661. * @param activeTextures Array of BaseTextures
  25662. */
  25663. getActiveTextures(activeTextures: BaseTexture[]): void;
  25664. /**
  25665. * Returns the animatable textures.
  25666. * @param animatables Array of animatable textures.
  25667. */
  25668. getAnimatables(animatables: IAnimatable[]): void;
  25669. /**
  25670. * Disposes the resources of the material.
  25671. * @param forceDisposeTextures - Forces the disposal of all textures.
  25672. */
  25673. dispose(forceDisposeTextures?: boolean): void;
  25674. /**
  25675. * Get the current class name of the texture useful for serialization or dynamic coding.
  25676. * @returns "PBRAnisotropicConfiguration"
  25677. */
  25678. getClassName(): string;
  25679. /**
  25680. * Add fallbacks to the effect fallbacks list.
  25681. * @param defines defines the Base texture to use.
  25682. * @param fallbacks defines the current fallback list.
  25683. * @param currentRank defines the current fallback rank.
  25684. * @returns the new fallback rank.
  25685. */
  25686. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25687. /**
  25688. * Add the required uniforms to the current list.
  25689. * @param uniforms defines the current uniform list.
  25690. */
  25691. static AddUniforms(uniforms: string[]): void;
  25692. /**
  25693. * Add the required uniforms to the current buffer.
  25694. * @param uniformBuffer defines the current uniform buffer.
  25695. */
  25696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25697. /**
  25698. * Add the required samplers to the current list.
  25699. * @param samplers defines the current sampler list.
  25700. */
  25701. static AddSamplers(samplers: string[]): void;
  25702. /**
  25703. * Makes a duplicate of the current configuration into another one.
  25704. * @param anisotropicConfiguration define the config where to copy the info
  25705. */
  25706. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25707. /**
  25708. * Serializes this anisotropy configuration.
  25709. * @returns - An object with the serialized config.
  25710. */
  25711. serialize(): any;
  25712. /**
  25713. * Parses a anisotropy Configuration from a serialized object.
  25714. * @param source - Serialized object.
  25715. * @param scene Defines the scene we are parsing for
  25716. * @param rootUrl Defines the rootUrl to load from
  25717. */
  25718. parse(source: any, scene: Scene, rootUrl: string): void;
  25719. }
  25720. }
  25721. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25722. import { Scene } from "babylonjs/scene";
  25723. /**
  25724. * @hidden
  25725. */
  25726. export interface IMaterialBRDFDefines {
  25727. BRDF_V_HEIGHT_CORRELATED: boolean;
  25728. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25729. SPHERICAL_HARMONICS: boolean;
  25730. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25731. /** @hidden */
  25732. _areMiscDirty: boolean;
  25733. }
  25734. /**
  25735. * Define the code related to the BRDF parameters of the pbr material.
  25736. */
  25737. export class PBRBRDFConfiguration {
  25738. /**
  25739. * Default value used for the energy conservation.
  25740. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25741. */
  25742. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25743. /**
  25744. * Default value used for the Smith Visibility Height Correlated mode.
  25745. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25746. */
  25747. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25748. /**
  25749. * Default value used for the IBL diffuse part.
  25750. * This can help switching back to the polynomials mode globally which is a tiny bit
  25751. * less GPU intensive at the drawback of a lower quality.
  25752. */
  25753. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25754. /**
  25755. * Default value used for activating energy conservation for the specular workflow.
  25756. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25757. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25758. */
  25759. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25760. private _useEnergyConservation;
  25761. /**
  25762. * Defines if the material uses energy conservation.
  25763. */
  25764. useEnergyConservation: boolean;
  25765. private _useSmithVisibilityHeightCorrelated;
  25766. /**
  25767. * LEGACY Mode set to false
  25768. * Defines if the material uses height smith correlated visibility term.
  25769. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25770. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25771. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25772. * Not relying on height correlated will also disable energy conservation.
  25773. */
  25774. useSmithVisibilityHeightCorrelated: boolean;
  25775. private _useSphericalHarmonics;
  25776. /**
  25777. * LEGACY Mode set to false
  25778. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25779. * diffuse part of the IBL.
  25780. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25781. * to the ground truth.
  25782. */
  25783. useSphericalHarmonics: boolean;
  25784. private _useSpecularGlossinessInputEnergyConservation;
  25785. /**
  25786. * Defines if the material uses energy conservation, when the specular workflow is active.
  25787. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25788. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25789. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25790. */
  25791. useSpecularGlossinessInputEnergyConservation: boolean;
  25792. /** @hidden */
  25793. private _internalMarkAllSubMeshesAsMiscDirty;
  25794. /** @hidden */
  25795. _markAllSubMeshesAsMiscDirty(): void;
  25796. /**
  25797. * Instantiate a new istance of clear coat configuration.
  25798. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25799. */
  25800. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25801. /**
  25802. * Checks to see if a texture is used in the material.
  25803. * @param defines the list of "defines" to update.
  25804. */
  25805. prepareDefines(defines: IMaterialBRDFDefines): void;
  25806. /**
  25807. * Get the current class name of the texture useful for serialization or dynamic coding.
  25808. * @returns "PBRClearCoatConfiguration"
  25809. */
  25810. getClassName(): string;
  25811. /**
  25812. * Makes a duplicate of the current configuration into another one.
  25813. * @param brdfConfiguration define the config where to copy the info
  25814. */
  25815. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25816. /**
  25817. * Serializes this BRDF configuration.
  25818. * @returns - An object with the serialized config.
  25819. */
  25820. serialize(): any;
  25821. /**
  25822. * Parses a anisotropy Configuration from a serialized object.
  25823. * @param source - Serialized object.
  25824. * @param scene Defines the scene we are parsing for
  25825. * @param rootUrl Defines the rootUrl to load from
  25826. */
  25827. parse(source: any, scene: Scene, rootUrl: string): void;
  25828. }
  25829. }
  25830. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25831. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25832. import { Color3 } from "babylonjs/Maths/math.color";
  25833. import { Scene } from "babylonjs/scene";
  25834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25835. import { Nullable } from "babylonjs/types";
  25836. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25837. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25838. /**
  25839. * @hidden
  25840. */
  25841. export interface IMaterialSheenDefines {
  25842. SHEEN: boolean;
  25843. SHEEN_TEXTURE: boolean;
  25844. SHEEN_TEXTUREDIRECTUV: number;
  25845. SHEEN_LINKWITHALBEDO: boolean;
  25846. SHEEN_ROUGHNESS: boolean;
  25847. SHEEN_ALBEDOSCALING: boolean;
  25848. /** @hidden */
  25849. _areTexturesDirty: boolean;
  25850. }
  25851. /**
  25852. * Define the code related to the Sheen parameters of the pbr material.
  25853. */
  25854. export class PBRSheenConfiguration {
  25855. private _isEnabled;
  25856. /**
  25857. * Defines if the material uses sheen.
  25858. */
  25859. isEnabled: boolean;
  25860. private _linkSheenWithAlbedo;
  25861. /**
  25862. * Defines if the sheen is linked to the sheen color.
  25863. */
  25864. linkSheenWithAlbedo: boolean;
  25865. /**
  25866. * Defines the sheen intensity.
  25867. */
  25868. intensity: number;
  25869. /**
  25870. * Defines the sheen color.
  25871. */
  25872. color: Color3;
  25873. private _texture;
  25874. /**
  25875. * Stores the sheen tint values in a texture.
  25876. * rgb is tint
  25877. * a is a intensity or roughness if roughness has been defined
  25878. */
  25879. texture: Nullable<BaseTexture>;
  25880. private _roughness;
  25881. /**
  25882. * Defines the sheen roughness.
  25883. * It is not taken into account if linkSheenWithAlbedo is true.
  25884. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25885. */
  25886. roughness: Nullable<number>;
  25887. private _albedoScaling;
  25888. /**
  25889. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25890. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25891. * making it easier to setup and tweak the effect
  25892. */
  25893. albedoScaling: boolean;
  25894. /** @hidden */
  25895. private _internalMarkAllSubMeshesAsTexturesDirty;
  25896. /** @hidden */
  25897. _markAllSubMeshesAsTexturesDirty(): void;
  25898. /**
  25899. * Instantiate a new istance of clear coat configuration.
  25900. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25901. */
  25902. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25903. /**
  25904. * Specifies that the submesh is ready to be used.
  25905. * @param defines the list of "defines" to update.
  25906. * @param scene defines the scene the material belongs to.
  25907. * @returns - boolean indicating that the submesh is ready or not.
  25908. */
  25909. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25910. /**
  25911. * Checks to see if a texture is used in the material.
  25912. * @param defines the list of "defines" to update.
  25913. * @param scene defines the scene the material belongs to.
  25914. */
  25915. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25916. /**
  25917. * Binds the material data.
  25918. * @param uniformBuffer defines the Uniform buffer to fill in.
  25919. * @param scene defines the scene the material belongs to.
  25920. * @param isFrozen defines wether the material is frozen or not.
  25921. */
  25922. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25923. /**
  25924. * Checks to see if a texture is used in the material.
  25925. * @param texture - Base texture to use.
  25926. * @returns - Boolean specifying if a texture is used in the material.
  25927. */
  25928. hasTexture(texture: BaseTexture): boolean;
  25929. /**
  25930. * Returns an array of the actively used textures.
  25931. * @param activeTextures Array of BaseTextures
  25932. */
  25933. getActiveTextures(activeTextures: BaseTexture[]): void;
  25934. /**
  25935. * Returns the animatable textures.
  25936. * @param animatables Array of animatable textures.
  25937. */
  25938. getAnimatables(animatables: IAnimatable[]): void;
  25939. /**
  25940. * Disposes the resources of the material.
  25941. * @param forceDisposeTextures - Forces the disposal of all textures.
  25942. */
  25943. dispose(forceDisposeTextures?: boolean): void;
  25944. /**
  25945. * Get the current class name of the texture useful for serialization or dynamic coding.
  25946. * @returns "PBRSheenConfiguration"
  25947. */
  25948. getClassName(): string;
  25949. /**
  25950. * Add fallbacks to the effect fallbacks list.
  25951. * @param defines defines the Base texture to use.
  25952. * @param fallbacks defines the current fallback list.
  25953. * @param currentRank defines the current fallback rank.
  25954. * @returns the new fallback rank.
  25955. */
  25956. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25957. /**
  25958. * Add the required uniforms to the current list.
  25959. * @param uniforms defines the current uniform list.
  25960. */
  25961. static AddUniforms(uniforms: string[]): void;
  25962. /**
  25963. * Add the required uniforms to the current buffer.
  25964. * @param uniformBuffer defines the current uniform buffer.
  25965. */
  25966. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25967. /**
  25968. * Add the required samplers to the current list.
  25969. * @param samplers defines the current sampler list.
  25970. */
  25971. static AddSamplers(samplers: string[]): void;
  25972. /**
  25973. * Makes a duplicate of the current configuration into another one.
  25974. * @param sheenConfiguration define the config where to copy the info
  25975. */
  25976. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25977. /**
  25978. * Serializes this BRDF configuration.
  25979. * @returns - An object with the serialized config.
  25980. */
  25981. serialize(): any;
  25982. /**
  25983. * Parses a anisotropy Configuration from a serialized object.
  25984. * @param source - Serialized object.
  25985. * @param scene Defines the scene we are parsing for
  25986. * @param rootUrl Defines the rootUrl to load from
  25987. */
  25988. parse(source: any, scene: Scene, rootUrl: string): void;
  25989. }
  25990. }
  25991. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  25992. import { Nullable } from "babylonjs/types";
  25993. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25994. import { Color3 } from "babylonjs/Maths/math.color";
  25995. import { SmartArray } from "babylonjs/Misc/smartArray";
  25996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25997. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25998. import { Effect } from "babylonjs/Materials/effect";
  25999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26000. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26001. import { Engine } from "babylonjs/Engines/engine";
  26002. import { Scene } from "babylonjs/scene";
  26003. /**
  26004. * @hidden
  26005. */
  26006. export interface IMaterialSubSurfaceDefines {
  26007. SUBSURFACE: boolean;
  26008. SS_REFRACTION: boolean;
  26009. SS_TRANSLUCENCY: boolean;
  26010. SS_SCATTERING: boolean;
  26011. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26012. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26013. SS_REFRACTIONMAP_3D: boolean;
  26014. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26015. SS_LODINREFRACTIONALPHA: boolean;
  26016. SS_GAMMAREFRACTION: boolean;
  26017. SS_RGBDREFRACTION: boolean;
  26018. SS_LINEARSPECULARREFRACTION: boolean;
  26019. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26020. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26021. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26022. /** @hidden */
  26023. _areTexturesDirty: boolean;
  26024. }
  26025. /**
  26026. * Define the code related to the sub surface parameters of the pbr material.
  26027. */
  26028. export class PBRSubSurfaceConfiguration {
  26029. private _isRefractionEnabled;
  26030. /**
  26031. * Defines if the refraction is enabled in the material.
  26032. */
  26033. isRefractionEnabled: boolean;
  26034. private _isTranslucencyEnabled;
  26035. /**
  26036. * Defines if the translucency is enabled in the material.
  26037. */
  26038. isTranslucencyEnabled: boolean;
  26039. private _isScatteringEnabled;
  26040. /**
  26041. * Defines if the sub surface scattering is enabled in the material.
  26042. */
  26043. isScatteringEnabled: boolean;
  26044. private _scatteringDiffusionProfileIndex;
  26045. /**
  26046. * Diffusion profile for subsurface scattering.
  26047. * Useful for better scattering in the skins or foliages.
  26048. */
  26049. get scatteringDiffusionProfile(): Nullable<Color3>;
  26050. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26051. /**
  26052. * Defines the refraction intensity of the material.
  26053. * The refraction when enabled replaces the Diffuse part of the material.
  26054. * The intensity helps transitionning between diffuse and refraction.
  26055. */
  26056. refractionIntensity: number;
  26057. /**
  26058. * Defines the translucency intensity of the material.
  26059. * When translucency has been enabled, this defines how much of the "translucency"
  26060. * is addded to the diffuse part of the material.
  26061. */
  26062. translucencyIntensity: number;
  26063. /**
  26064. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26065. */
  26066. useAlbedoToTintRefraction: boolean;
  26067. private _thicknessTexture;
  26068. /**
  26069. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26070. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26071. * 0 would mean minimumThickness
  26072. * 1 would mean maximumThickness
  26073. * The other channels might be use as a mask to vary the different effects intensity.
  26074. */
  26075. thicknessTexture: Nullable<BaseTexture>;
  26076. private _refractionTexture;
  26077. /**
  26078. * Defines the texture to use for refraction.
  26079. */
  26080. refractionTexture: Nullable<BaseTexture>;
  26081. private _indexOfRefraction;
  26082. /**
  26083. * Index of refraction of the material base layer.
  26084. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26085. *
  26086. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26087. *
  26088. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26089. */
  26090. indexOfRefraction: number;
  26091. private _volumeIndexOfRefraction;
  26092. /**
  26093. * Index of refraction of the material's volume.
  26094. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26095. *
  26096. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26097. * the volume will use the same IOR as the surface.
  26098. */
  26099. get volumeIndexOfRefraction(): number;
  26100. set volumeIndexOfRefraction(value: number);
  26101. private _invertRefractionY;
  26102. /**
  26103. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26104. */
  26105. invertRefractionY: boolean;
  26106. private _linkRefractionWithTransparency;
  26107. /**
  26108. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26109. * Materials half opaque for instance using refraction could benefit from this control.
  26110. */
  26111. linkRefractionWithTransparency: boolean;
  26112. /**
  26113. * Defines the minimum thickness stored in the thickness map.
  26114. * If no thickness map is defined, this value will be used to simulate thickness.
  26115. */
  26116. minimumThickness: number;
  26117. /**
  26118. * Defines the maximum thickness stored in the thickness map.
  26119. */
  26120. maximumThickness: number;
  26121. /**
  26122. * Defines the volume tint of the material.
  26123. * This is used for both translucency and scattering.
  26124. */
  26125. tintColor: Color3;
  26126. /**
  26127. * Defines the distance at which the tint color should be found in the media.
  26128. * This is used for refraction only.
  26129. */
  26130. tintColorAtDistance: number;
  26131. /**
  26132. * Defines how far each channel transmit through the media.
  26133. * It is defined as a color to simplify it selection.
  26134. */
  26135. diffusionDistance: Color3;
  26136. private _useMaskFromThicknessTexture;
  26137. /**
  26138. * Stores the intensity of the different subsurface effects in the thickness texture.
  26139. * * the green channel is the translucency intensity.
  26140. * * the blue channel is the scattering intensity.
  26141. * * the alpha channel is the refraction intensity.
  26142. */
  26143. useMaskFromThicknessTexture: boolean;
  26144. private _scene;
  26145. /** @hidden */
  26146. private _internalMarkAllSubMeshesAsTexturesDirty;
  26147. private _internalMarkScenePrePassDirty;
  26148. /** @hidden */
  26149. _markAllSubMeshesAsTexturesDirty(): void;
  26150. /** @hidden */
  26151. _markScenePrePassDirty(): void;
  26152. /**
  26153. * Instantiate a new istance of sub surface configuration.
  26154. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26155. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26156. * @param scene The scene
  26157. */
  26158. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26159. /**
  26160. * Gets wehter the submesh is ready to be used or not.
  26161. * @param defines the list of "defines" to update.
  26162. * @param scene defines the scene the material belongs to.
  26163. * @returns - boolean indicating that the submesh is ready or not.
  26164. */
  26165. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26166. /**
  26167. * Checks to see if a texture is used in the material.
  26168. * @param defines the list of "defines" to update.
  26169. * @param scene defines the scene to the material belongs to.
  26170. */
  26171. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26172. /**
  26173. * Binds the material data.
  26174. * @param uniformBuffer defines the Uniform buffer to fill in.
  26175. * @param scene defines the scene the material belongs to.
  26176. * @param engine defines the engine the material belongs to.
  26177. * @param isFrozen defines whether the material is frozen or not.
  26178. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26179. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26180. */
  26181. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26182. /**
  26183. * Unbinds the material from the mesh.
  26184. * @param activeEffect defines the effect that should be unbound from.
  26185. * @returns true if unbound, otherwise false
  26186. */
  26187. unbind(activeEffect: Effect): boolean;
  26188. /**
  26189. * Returns the texture used for refraction or null if none is used.
  26190. * @param scene defines the scene the material belongs to.
  26191. * @returns - Refraction texture if present. If no refraction texture and refraction
  26192. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26193. */
  26194. private _getRefractionTexture;
  26195. /**
  26196. * Returns true if alpha blending should be disabled.
  26197. */
  26198. get disableAlphaBlending(): boolean;
  26199. /**
  26200. * Fills the list of render target textures.
  26201. * @param renderTargets the list of render targets to update
  26202. */
  26203. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26204. /**
  26205. * Checks to see if a texture is used in the material.
  26206. * @param texture - Base texture to use.
  26207. * @returns - Boolean specifying if a texture is used in the material.
  26208. */
  26209. hasTexture(texture: BaseTexture): boolean;
  26210. /**
  26211. * Gets a boolean indicating that current material needs to register RTT
  26212. * @returns true if this uses a render target otherwise false.
  26213. */
  26214. hasRenderTargetTextures(): boolean;
  26215. /**
  26216. * Returns an array of the actively used textures.
  26217. * @param activeTextures Array of BaseTextures
  26218. */
  26219. getActiveTextures(activeTextures: BaseTexture[]): void;
  26220. /**
  26221. * Returns the animatable textures.
  26222. * @param animatables Array of animatable textures.
  26223. */
  26224. getAnimatables(animatables: IAnimatable[]): void;
  26225. /**
  26226. * Disposes the resources of the material.
  26227. * @param forceDisposeTextures - Forces the disposal of all textures.
  26228. */
  26229. dispose(forceDisposeTextures?: boolean): void;
  26230. /**
  26231. * Get the current class name of the texture useful for serialization or dynamic coding.
  26232. * @returns "PBRSubSurfaceConfiguration"
  26233. */
  26234. getClassName(): string;
  26235. /**
  26236. * Add fallbacks to the effect fallbacks list.
  26237. * @param defines defines the Base texture to use.
  26238. * @param fallbacks defines the current fallback list.
  26239. * @param currentRank defines the current fallback rank.
  26240. * @returns the new fallback rank.
  26241. */
  26242. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26243. /**
  26244. * Add the required uniforms to the current list.
  26245. * @param uniforms defines the current uniform list.
  26246. */
  26247. static AddUniforms(uniforms: string[]): void;
  26248. /**
  26249. * Add the required samplers to the current list.
  26250. * @param samplers defines the current sampler list.
  26251. */
  26252. static AddSamplers(samplers: string[]): void;
  26253. /**
  26254. * Add the required uniforms to the current buffer.
  26255. * @param uniformBuffer defines the current uniform buffer.
  26256. */
  26257. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26258. /**
  26259. * Makes a duplicate of the current configuration into another one.
  26260. * @param configuration define the config where to copy the info
  26261. */
  26262. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26263. /**
  26264. * Serializes this Sub Surface configuration.
  26265. * @returns - An object with the serialized config.
  26266. */
  26267. serialize(): any;
  26268. /**
  26269. * Parses a anisotropy Configuration from a serialized object.
  26270. * @param source - Serialized object.
  26271. * @param scene Defines the scene we are parsing for
  26272. * @param rootUrl Defines the rootUrl to load from
  26273. */
  26274. parse(source: any, scene: Scene, rootUrl: string): void;
  26275. }
  26276. }
  26277. declare module "babylonjs/Maths/sphericalPolynomial" {
  26278. import { Vector3 } from "babylonjs/Maths/math.vector";
  26279. import { Color3 } from "babylonjs/Maths/math.color";
  26280. /**
  26281. * Class representing spherical harmonics coefficients to the 3rd degree
  26282. */
  26283. export class SphericalHarmonics {
  26284. /**
  26285. * Defines whether or not the harmonics have been prescaled for rendering.
  26286. */
  26287. preScaled: boolean;
  26288. /**
  26289. * The l0,0 coefficients of the spherical harmonics
  26290. */
  26291. l00: Vector3;
  26292. /**
  26293. * The l1,-1 coefficients of the spherical harmonics
  26294. */
  26295. l1_1: Vector3;
  26296. /**
  26297. * The l1,0 coefficients of the spherical harmonics
  26298. */
  26299. l10: Vector3;
  26300. /**
  26301. * The l1,1 coefficients of the spherical harmonics
  26302. */
  26303. l11: Vector3;
  26304. /**
  26305. * The l2,-2 coefficients of the spherical harmonics
  26306. */
  26307. l2_2: Vector3;
  26308. /**
  26309. * The l2,-1 coefficients of the spherical harmonics
  26310. */
  26311. l2_1: Vector3;
  26312. /**
  26313. * The l2,0 coefficients of the spherical harmonics
  26314. */
  26315. l20: Vector3;
  26316. /**
  26317. * The l2,1 coefficients of the spherical harmonics
  26318. */
  26319. l21: Vector3;
  26320. /**
  26321. * The l2,2 coefficients of the spherical harmonics
  26322. */
  26323. l22: Vector3;
  26324. /**
  26325. * Adds a light to the spherical harmonics
  26326. * @param direction the direction of the light
  26327. * @param color the color of the light
  26328. * @param deltaSolidAngle the delta solid angle of the light
  26329. */
  26330. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26331. /**
  26332. * Scales the spherical harmonics by the given amount
  26333. * @param scale the amount to scale
  26334. */
  26335. scaleInPlace(scale: number): void;
  26336. /**
  26337. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26338. *
  26339. * ```
  26340. * E_lm = A_l * L_lm
  26341. * ```
  26342. *
  26343. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26344. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26345. * the scaling factors are given in equation 9.
  26346. */
  26347. convertIncidentRadianceToIrradiance(): void;
  26348. /**
  26349. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26350. *
  26351. * ```
  26352. * L = (1/pi) * E * rho
  26353. * ```
  26354. *
  26355. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26356. */
  26357. convertIrradianceToLambertianRadiance(): void;
  26358. /**
  26359. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26360. * required operations at run time.
  26361. *
  26362. * This is simply done by scaling back the SH with Ylm constants parameter.
  26363. * The trigonometric part being applied by the shader at run time.
  26364. */
  26365. preScaleForRendering(): void;
  26366. /**
  26367. * Constructs a spherical harmonics from an array.
  26368. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26369. * @returns the spherical harmonics
  26370. */
  26371. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26372. /**
  26373. * Gets the spherical harmonics from polynomial
  26374. * @param polynomial the spherical polynomial
  26375. * @returns the spherical harmonics
  26376. */
  26377. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26378. }
  26379. /**
  26380. * Class representing spherical polynomial coefficients to the 3rd degree
  26381. */
  26382. export class SphericalPolynomial {
  26383. private _harmonics;
  26384. /**
  26385. * The spherical harmonics used to create the polynomials.
  26386. */
  26387. get preScaledHarmonics(): SphericalHarmonics;
  26388. /**
  26389. * The x coefficients of the spherical polynomial
  26390. */
  26391. x: Vector3;
  26392. /**
  26393. * The y coefficients of the spherical polynomial
  26394. */
  26395. y: Vector3;
  26396. /**
  26397. * The z coefficients of the spherical polynomial
  26398. */
  26399. z: Vector3;
  26400. /**
  26401. * The xx coefficients of the spherical polynomial
  26402. */
  26403. xx: Vector3;
  26404. /**
  26405. * The yy coefficients of the spherical polynomial
  26406. */
  26407. yy: Vector3;
  26408. /**
  26409. * The zz coefficients of the spherical polynomial
  26410. */
  26411. zz: Vector3;
  26412. /**
  26413. * The xy coefficients of the spherical polynomial
  26414. */
  26415. xy: Vector3;
  26416. /**
  26417. * The yz coefficients of the spherical polynomial
  26418. */
  26419. yz: Vector3;
  26420. /**
  26421. * The zx coefficients of the spherical polynomial
  26422. */
  26423. zx: Vector3;
  26424. /**
  26425. * Adds an ambient color to the spherical polynomial
  26426. * @param color the color to add
  26427. */
  26428. addAmbient(color: Color3): void;
  26429. /**
  26430. * Scales the spherical polynomial by the given amount
  26431. * @param scale the amount to scale
  26432. */
  26433. scaleInPlace(scale: number): void;
  26434. /**
  26435. * Gets the spherical polynomial from harmonics
  26436. * @param harmonics the spherical harmonics
  26437. * @returns the spherical polynomial
  26438. */
  26439. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26440. /**
  26441. * Constructs a spherical polynomial from an array.
  26442. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26443. * @returns the spherical polynomial
  26444. */
  26445. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26446. }
  26447. }
  26448. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26449. import { Nullable } from "babylonjs/types";
  26450. /**
  26451. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26452. */
  26453. export interface CubeMapInfo {
  26454. /**
  26455. * The pixel array for the front face.
  26456. * This is stored in format, left to right, up to down format.
  26457. */
  26458. front: Nullable<ArrayBufferView>;
  26459. /**
  26460. * The pixel array for the back face.
  26461. * This is stored in format, left to right, up to down format.
  26462. */
  26463. back: Nullable<ArrayBufferView>;
  26464. /**
  26465. * The pixel array for the left face.
  26466. * This is stored in format, left to right, up to down format.
  26467. */
  26468. left: Nullable<ArrayBufferView>;
  26469. /**
  26470. * The pixel array for the right face.
  26471. * This is stored in format, left to right, up to down format.
  26472. */
  26473. right: Nullable<ArrayBufferView>;
  26474. /**
  26475. * The pixel array for the up face.
  26476. * This is stored in format, left to right, up to down format.
  26477. */
  26478. up: Nullable<ArrayBufferView>;
  26479. /**
  26480. * The pixel array for the down face.
  26481. * This is stored in format, left to right, up to down format.
  26482. */
  26483. down: Nullable<ArrayBufferView>;
  26484. /**
  26485. * The size of the cubemap stored.
  26486. *
  26487. * Each faces will be size * size pixels.
  26488. */
  26489. size: number;
  26490. /**
  26491. * The format of the texture.
  26492. *
  26493. * RGBA, RGB.
  26494. */
  26495. format: number;
  26496. /**
  26497. * The type of the texture data.
  26498. *
  26499. * UNSIGNED_INT, FLOAT.
  26500. */
  26501. type: number;
  26502. /**
  26503. * Specifies whether the texture is in gamma space.
  26504. */
  26505. gammaSpace: boolean;
  26506. }
  26507. /**
  26508. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26509. */
  26510. export class PanoramaToCubeMapTools {
  26511. private static FACE_LEFT;
  26512. private static FACE_RIGHT;
  26513. private static FACE_FRONT;
  26514. private static FACE_BACK;
  26515. private static FACE_DOWN;
  26516. private static FACE_UP;
  26517. /**
  26518. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26519. *
  26520. * @param float32Array The source data.
  26521. * @param inputWidth The width of the input panorama.
  26522. * @param inputHeight The height of the input panorama.
  26523. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26524. * @return The cubemap data
  26525. */
  26526. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26527. private static CreateCubemapTexture;
  26528. private static CalcProjectionSpherical;
  26529. }
  26530. }
  26531. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26532. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26534. import { Nullable } from "babylonjs/types";
  26535. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26536. /**
  26537. * Helper class dealing with the extraction of spherical polynomial dataArray
  26538. * from a cube map.
  26539. */
  26540. export class CubeMapToSphericalPolynomialTools {
  26541. private static FileFaces;
  26542. /**
  26543. * Converts a texture to the according Spherical Polynomial data.
  26544. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26545. *
  26546. * @param texture The texture to extract the information from.
  26547. * @return The Spherical Polynomial data.
  26548. */
  26549. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26550. /**
  26551. * Converts a cubemap to the according Spherical Polynomial data.
  26552. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26553. *
  26554. * @param cubeInfo The Cube map to extract the information from.
  26555. * @return The Spherical Polynomial data.
  26556. */
  26557. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26558. }
  26559. }
  26560. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26561. import { Nullable } from "babylonjs/types";
  26562. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26563. module "babylonjs/Materials/Textures/baseTexture" {
  26564. interface BaseTexture {
  26565. /**
  26566. * Get the polynomial representation of the texture data.
  26567. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26568. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26569. */
  26570. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26571. }
  26572. }
  26573. }
  26574. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26575. /** @hidden */
  26576. export var pbrFragmentDeclaration: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26582. /** @hidden */
  26583. export var pbrUboDeclaration: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26589. /** @hidden */
  26590. export var pbrFragmentExtraDeclaration: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26596. /** @hidden */
  26597. export var pbrFragmentSamplersDeclaration: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26603. /** @hidden */
  26604. export var subSurfaceScatteringFunctions: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26610. /** @hidden */
  26611. export var importanceSampling: {
  26612. name: string;
  26613. shader: string;
  26614. };
  26615. }
  26616. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26617. /** @hidden */
  26618. export var pbrHelperFunctions: {
  26619. name: string;
  26620. shader: string;
  26621. };
  26622. }
  26623. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26624. /** @hidden */
  26625. export var harmonicsFunctions: {
  26626. name: string;
  26627. shader: string;
  26628. };
  26629. }
  26630. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26631. /** @hidden */
  26632. export var pbrDirectLightingSetupFunctions: {
  26633. name: string;
  26634. shader: string;
  26635. };
  26636. }
  26637. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26638. /** @hidden */
  26639. export var pbrDirectLightingFalloffFunctions: {
  26640. name: string;
  26641. shader: string;
  26642. };
  26643. }
  26644. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26645. /** @hidden */
  26646. export var pbrBRDFFunctions: {
  26647. name: string;
  26648. shader: string;
  26649. };
  26650. }
  26651. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26652. /** @hidden */
  26653. export var hdrFilteringFunctions: {
  26654. name: string;
  26655. shader: string;
  26656. };
  26657. }
  26658. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26659. /** @hidden */
  26660. export var pbrDirectLightingFunctions: {
  26661. name: string;
  26662. shader: string;
  26663. };
  26664. }
  26665. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26666. /** @hidden */
  26667. export var pbrIBLFunctions: {
  26668. name: string;
  26669. shader: string;
  26670. };
  26671. }
  26672. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26673. /** @hidden */
  26674. export var pbrBlockAlbedoOpacity: {
  26675. name: string;
  26676. shader: string;
  26677. };
  26678. }
  26679. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26680. /** @hidden */
  26681. export var pbrBlockReflectivity: {
  26682. name: string;
  26683. shader: string;
  26684. };
  26685. }
  26686. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26687. /** @hidden */
  26688. export var pbrBlockAmbientOcclusion: {
  26689. name: string;
  26690. shader: string;
  26691. };
  26692. }
  26693. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26694. /** @hidden */
  26695. export var pbrBlockAlphaFresnel: {
  26696. name: string;
  26697. shader: string;
  26698. };
  26699. }
  26700. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26701. /** @hidden */
  26702. export var pbrBlockAnisotropic: {
  26703. name: string;
  26704. shader: string;
  26705. };
  26706. }
  26707. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26708. /** @hidden */
  26709. export var pbrBlockReflection: {
  26710. name: string;
  26711. shader: string;
  26712. };
  26713. }
  26714. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26715. /** @hidden */
  26716. export var pbrBlockSheen: {
  26717. name: string;
  26718. shader: string;
  26719. };
  26720. }
  26721. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26722. /** @hidden */
  26723. export var pbrBlockClearcoat: {
  26724. name: string;
  26725. shader: string;
  26726. };
  26727. }
  26728. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26729. /** @hidden */
  26730. export var pbrBlockSubSurface: {
  26731. name: string;
  26732. shader: string;
  26733. };
  26734. }
  26735. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26736. /** @hidden */
  26737. export var pbrBlockNormalGeometric: {
  26738. name: string;
  26739. shader: string;
  26740. };
  26741. }
  26742. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26743. /** @hidden */
  26744. export var pbrBlockNormalFinal: {
  26745. name: string;
  26746. shader: string;
  26747. };
  26748. }
  26749. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26750. /** @hidden */
  26751. export var pbrBlockLightmapInit: {
  26752. name: string;
  26753. shader: string;
  26754. };
  26755. }
  26756. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26757. /** @hidden */
  26758. export var pbrBlockGeometryInfo: {
  26759. name: string;
  26760. shader: string;
  26761. };
  26762. }
  26763. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26764. /** @hidden */
  26765. export var pbrBlockReflectance0: {
  26766. name: string;
  26767. shader: string;
  26768. };
  26769. }
  26770. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26771. /** @hidden */
  26772. export var pbrBlockReflectance: {
  26773. name: string;
  26774. shader: string;
  26775. };
  26776. }
  26777. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26778. /** @hidden */
  26779. export var pbrBlockDirectLighting: {
  26780. name: string;
  26781. shader: string;
  26782. };
  26783. }
  26784. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26785. /** @hidden */
  26786. export var pbrBlockFinalLitComponents: {
  26787. name: string;
  26788. shader: string;
  26789. };
  26790. }
  26791. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26792. /** @hidden */
  26793. export var pbrBlockFinalUnlitComponents: {
  26794. name: string;
  26795. shader: string;
  26796. };
  26797. }
  26798. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26799. /** @hidden */
  26800. export var pbrBlockFinalColorComposition: {
  26801. name: string;
  26802. shader: string;
  26803. };
  26804. }
  26805. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26806. /** @hidden */
  26807. export var pbrBlockImageProcessing: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26813. /** @hidden */
  26814. export var pbrDebug: {
  26815. name: string;
  26816. shader: string;
  26817. };
  26818. }
  26819. declare module "babylonjs/Shaders/pbr.fragment" {
  26820. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26821. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26822. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26823. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26824. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26825. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26826. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26827. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26829. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26830. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26831. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26832. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26833. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26834. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26835. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26836. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26837. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26838. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26839. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26840. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26841. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26842. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26843. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26844. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26845. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26846. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26847. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26848. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26849. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26850. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26851. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26852. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26853. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26854. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26855. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26856. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26857. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26858. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26859. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26860. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26861. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26862. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26863. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26864. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26865. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26866. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26867. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26868. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26869. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26870. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26871. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26872. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26873. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26874. /** @hidden */
  26875. export var pbrPixelShader: {
  26876. name: string;
  26877. shader: string;
  26878. };
  26879. }
  26880. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26881. /** @hidden */
  26882. export var pbrVertexDeclaration: {
  26883. name: string;
  26884. shader: string;
  26885. };
  26886. }
  26887. declare module "babylonjs/Shaders/pbr.vertex" {
  26888. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26889. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26890. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26891. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26893. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26894. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26895. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26896. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26897. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26898. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26899. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26900. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26901. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26902. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26904. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26905. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26906. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26907. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26909. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26910. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26911. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26912. /** @hidden */
  26913. export var pbrVertexShader: {
  26914. name: string;
  26915. shader: string;
  26916. };
  26917. }
  26918. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26919. import { Nullable } from "babylonjs/types";
  26920. import { Scene } from "babylonjs/scene";
  26921. import { Matrix } from "babylonjs/Maths/math.vector";
  26922. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26924. import { Mesh } from "babylonjs/Meshes/mesh";
  26925. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26926. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26927. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26928. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26929. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26930. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26931. import { Color3 } from "babylonjs/Maths/math.color";
  26932. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26933. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26934. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26935. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26938. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26939. import "babylonjs/Shaders/pbr.fragment";
  26940. import "babylonjs/Shaders/pbr.vertex";
  26941. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26942. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  26943. /**
  26944. * Manages the defines for the PBR Material.
  26945. * @hidden
  26946. */
  26947. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26948. PBR: boolean;
  26949. NUM_SAMPLES: string;
  26950. REALTIME_FILTERING: boolean;
  26951. MAINUV1: boolean;
  26952. MAINUV2: boolean;
  26953. UV1: boolean;
  26954. UV2: boolean;
  26955. ALBEDO: boolean;
  26956. GAMMAALBEDO: boolean;
  26957. ALBEDODIRECTUV: number;
  26958. VERTEXCOLOR: boolean;
  26959. DETAIL: boolean;
  26960. DETAILDIRECTUV: number;
  26961. DETAIL_NORMALBLENDMETHOD: number;
  26962. AMBIENT: boolean;
  26963. AMBIENTDIRECTUV: number;
  26964. AMBIENTINGRAYSCALE: boolean;
  26965. OPACITY: boolean;
  26966. VERTEXALPHA: boolean;
  26967. OPACITYDIRECTUV: number;
  26968. OPACITYRGB: boolean;
  26969. ALPHATEST: boolean;
  26970. DEPTHPREPASS: boolean;
  26971. ALPHABLEND: boolean;
  26972. ALPHAFROMALBEDO: boolean;
  26973. ALPHATESTVALUE: string;
  26974. SPECULAROVERALPHA: boolean;
  26975. RADIANCEOVERALPHA: boolean;
  26976. ALPHAFRESNEL: boolean;
  26977. LINEARALPHAFRESNEL: boolean;
  26978. PREMULTIPLYALPHA: boolean;
  26979. EMISSIVE: boolean;
  26980. EMISSIVEDIRECTUV: number;
  26981. REFLECTIVITY: boolean;
  26982. REFLECTIVITYDIRECTUV: number;
  26983. SPECULARTERM: boolean;
  26984. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26985. MICROSURFACEAUTOMATIC: boolean;
  26986. LODBASEDMICROSFURACE: boolean;
  26987. MICROSURFACEMAP: boolean;
  26988. MICROSURFACEMAPDIRECTUV: number;
  26989. METALLICWORKFLOW: boolean;
  26990. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26991. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26992. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26993. AOSTOREINMETALMAPRED: boolean;
  26994. METALLIC_REFLECTANCE: boolean;
  26995. METALLIC_REFLECTANCEDIRECTUV: number;
  26996. ENVIRONMENTBRDF: boolean;
  26997. ENVIRONMENTBRDF_RGBD: boolean;
  26998. NORMAL: boolean;
  26999. TANGENT: boolean;
  27000. BUMP: boolean;
  27001. BUMPDIRECTUV: number;
  27002. OBJECTSPACE_NORMALMAP: boolean;
  27003. PARALLAX: boolean;
  27004. PARALLAXOCCLUSION: boolean;
  27005. NORMALXYSCALE: boolean;
  27006. LIGHTMAP: boolean;
  27007. LIGHTMAPDIRECTUV: number;
  27008. USELIGHTMAPASSHADOWMAP: boolean;
  27009. GAMMALIGHTMAP: boolean;
  27010. RGBDLIGHTMAP: boolean;
  27011. REFLECTION: boolean;
  27012. REFLECTIONMAP_3D: boolean;
  27013. REFLECTIONMAP_SPHERICAL: boolean;
  27014. REFLECTIONMAP_PLANAR: boolean;
  27015. REFLECTIONMAP_CUBIC: boolean;
  27016. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27017. REFLECTIONMAP_PROJECTION: boolean;
  27018. REFLECTIONMAP_SKYBOX: boolean;
  27019. REFLECTIONMAP_EXPLICIT: boolean;
  27020. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27021. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27022. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27023. INVERTCUBICMAP: boolean;
  27024. USESPHERICALFROMREFLECTIONMAP: boolean;
  27025. USEIRRADIANCEMAP: boolean;
  27026. SPHERICAL_HARMONICS: boolean;
  27027. USESPHERICALINVERTEX: boolean;
  27028. REFLECTIONMAP_OPPOSITEZ: boolean;
  27029. LODINREFLECTIONALPHA: boolean;
  27030. GAMMAREFLECTION: boolean;
  27031. RGBDREFLECTION: boolean;
  27032. LINEARSPECULARREFLECTION: boolean;
  27033. RADIANCEOCCLUSION: boolean;
  27034. HORIZONOCCLUSION: boolean;
  27035. INSTANCES: boolean;
  27036. THIN_INSTANCES: boolean;
  27037. PREPASS: boolean;
  27038. PREPASS_IRRADIANCE: boolean;
  27039. PREPASS_IRRADIANCE_INDEX: number;
  27040. PREPASS_ALBEDO: boolean;
  27041. PREPASS_ALBEDO_INDEX: number;
  27042. PREPASS_DEPTHNORMAL: boolean;
  27043. PREPASS_DEPTHNORMAL_INDEX: number;
  27044. PREPASS_POSITION: boolean;
  27045. PREPASS_POSITION_INDEX: number;
  27046. PREPASS_VELOCITY: boolean;
  27047. PREPASS_VELOCITY_INDEX: number;
  27048. PREPASS_REFLECTIVITY: boolean;
  27049. PREPASS_REFLECTIVITY_INDEX: number;
  27050. SCENE_MRT_COUNT: number;
  27051. NUM_BONE_INFLUENCERS: number;
  27052. BonesPerMesh: number;
  27053. BONETEXTURE: boolean;
  27054. BONES_VELOCITY_ENABLED: boolean;
  27055. NONUNIFORMSCALING: boolean;
  27056. MORPHTARGETS: boolean;
  27057. MORPHTARGETS_NORMAL: boolean;
  27058. MORPHTARGETS_TANGENT: boolean;
  27059. MORPHTARGETS_UV: boolean;
  27060. NUM_MORPH_INFLUENCERS: number;
  27061. IMAGEPROCESSING: boolean;
  27062. VIGNETTE: boolean;
  27063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27064. VIGNETTEBLENDMODEOPAQUE: boolean;
  27065. TONEMAPPING: boolean;
  27066. TONEMAPPING_ACES: boolean;
  27067. CONTRAST: boolean;
  27068. COLORCURVES: boolean;
  27069. COLORGRADING: boolean;
  27070. COLORGRADING3D: boolean;
  27071. SAMPLER3DGREENDEPTH: boolean;
  27072. SAMPLER3DBGRMAP: boolean;
  27073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27074. EXPOSURE: boolean;
  27075. MULTIVIEW: boolean;
  27076. USEPHYSICALLIGHTFALLOFF: boolean;
  27077. USEGLTFLIGHTFALLOFF: boolean;
  27078. TWOSIDEDLIGHTING: boolean;
  27079. SHADOWFLOAT: boolean;
  27080. CLIPPLANE: boolean;
  27081. CLIPPLANE2: boolean;
  27082. CLIPPLANE3: boolean;
  27083. CLIPPLANE4: boolean;
  27084. CLIPPLANE5: boolean;
  27085. CLIPPLANE6: boolean;
  27086. POINTSIZE: boolean;
  27087. FOG: boolean;
  27088. LOGARITHMICDEPTH: boolean;
  27089. FORCENORMALFORWARD: boolean;
  27090. SPECULARAA: boolean;
  27091. CLEARCOAT: boolean;
  27092. CLEARCOAT_DEFAULTIOR: boolean;
  27093. CLEARCOAT_TEXTURE: boolean;
  27094. CLEARCOAT_TEXTUREDIRECTUV: number;
  27095. CLEARCOAT_BUMP: boolean;
  27096. CLEARCOAT_BUMPDIRECTUV: number;
  27097. CLEARCOAT_REMAP_F0: boolean;
  27098. CLEARCOAT_TINT: boolean;
  27099. CLEARCOAT_TINT_TEXTURE: boolean;
  27100. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27101. ANISOTROPIC: boolean;
  27102. ANISOTROPIC_TEXTURE: boolean;
  27103. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27104. BRDF_V_HEIGHT_CORRELATED: boolean;
  27105. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27106. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27107. SHEEN: boolean;
  27108. SHEEN_TEXTURE: boolean;
  27109. SHEEN_TEXTUREDIRECTUV: number;
  27110. SHEEN_LINKWITHALBEDO: boolean;
  27111. SHEEN_ROUGHNESS: boolean;
  27112. SHEEN_ALBEDOSCALING: boolean;
  27113. SUBSURFACE: boolean;
  27114. SS_REFRACTION: boolean;
  27115. SS_TRANSLUCENCY: boolean;
  27116. SS_SCATTERING: boolean;
  27117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27119. SS_REFRACTIONMAP_3D: boolean;
  27120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27121. SS_LODINREFRACTIONALPHA: boolean;
  27122. SS_GAMMAREFRACTION: boolean;
  27123. SS_RGBDREFRACTION: boolean;
  27124. SS_LINEARSPECULARREFRACTION: boolean;
  27125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27126. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27127. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27128. UNLIT: boolean;
  27129. DEBUGMODE: number;
  27130. /**
  27131. * Initializes the PBR Material defines.
  27132. */
  27133. constructor();
  27134. /**
  27135. * Resets the PBR Material defines.
  27136. */
  27137. reset(): void;
  27138. }
  27139. /**
  27140. * The Physically based material base class of BJS.
  27141. *
  27142. * This offers the main features of a standard PBR material.
  27143. * For more information, please refer to the documentation :
  27144. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27145. */
  27146. export abstract class PBRBaseMaterial extends PushMaterial {
  27147. /**
  27148. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27149. */
  27150. static readonly PBRMATERIAL_OPAQUE: number;
  27151. /**
  27152. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27153. */
  27154. static readonly PBRMATERIAL_ALPHATEST: number;
  27155. /**
  27156. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27157. */
  27158. static readonly PBRMATERIAL_ALPHABLEND: number;
  27159. /**
  27160. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27161. * They are also discarded below the alpha cutoff threshold to improve performances.
  27162. */
  27163. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27164. /**
  27165. * Defines the default value of how much AO map is occluding the analytical lights
  27166. * (point spot...).
  27167. */
  27168. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27169. /**
  27170. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27171. */
  27172. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27173. /**
  27174. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27175. * to enhance interoperability with other engines.
  27176. */
  27177. static readonly LIGHTFALLOFF_GLTF: number;
  27178. /**
  27179. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27180. * to enhance interoperability with other materials.
  27181. */
  27182. static readonly LIGHTFALLOFF_STANDARD: number;
  27183. /**
  27184. * Intensity of the direct lights e.g. the four lights available in your scene.
  27185. * This impacts both the direct diffuse and specular highlights.
  27186. */
  27187. protected _directIntensity: number;
  27188. /**
  27189. * Intensity of the emissive part of the material.
  27190. * This helps controlling the emissive effect without modifying the emissive color.
  27191. */
  27192. protected _emissiveIntensity: number;
  27193. /**
  27194. * Intensity of the environment e.g. how much the environment will light the object
  27195. * either through harmonics for rough material or through the refelction for shiny ones.
  27196. */
  27197. protected _environmentIntensity: number;
  27198. /**
  27199. * This is a special control allowing the reduction of the specular highlights coming from the
  27200. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27201. */
  27202. protected _specularIntensity: number;
  27203. /**
  27204. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27205. */
  27206. private _lightingInfos;
  27207. /**
  27208. * Debug Control allowing disabling the bump map on this material.
  27209. */
  27210. protected _disableBumpMap: boolean;
  27211. /**
  27212. * AKA Diffuse Texture in standard nomenclature.
  27213. */
  27214. protected _albedoTexture: Nullable<BaseTexture>;
  27215. /**
  27216. * AKA Occlusion Texture in other nomenclature.
  27217. */
  27218. protected _ambientTexture: Nullable<BaseTexture>;
  27219. /**
  27220. * AKA Occlusion Texture Intensity in other nomenclature.
  27221. */
  27222. protected _ambientTextureStrength: number;
  27223. /**
  27224. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27225. * 1 means it completely occludes it
  27226. * 0 mean it has no impact
  27227. */
  27228. protected _ambientTextureImpactOnAnalyticalLights: number;
  27229. /**
  27230. * Stores the alpha values in a texture.
  27231. */
  27232. protected _opacityTexture: Nullable<BaseTexture>;
  27233. /**
  27234. * Stores the reflection values in a texture.
  27235. */
  27236. protected _reflectionTexture: Nullable<BaseTexture>;
  27237. /**
  27238. * Stores the emissive values in a texture.
  27239. */
  27240. protected _emissiveTexture: Nullable<BaseTexture>;
  27241. /**
  27242. * AKA Specular texture in other nomenclature.
  27243. */
  27244. protected _reflectivityTexture: Nullable<BaseTexture>;
  27245. /**
  27246. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27247. */
  27248. protected _metallicTexture: Nullable<BaseTexture>;
  27249. /**
  27250. * Specifies the metallic scalar of the metallic/roughness workflow.
  27251. * Can also be used to scale the metalness values of the metallic texture.
  27252. */
  27253. protected _metallic: Nullable<number>;
  27254. /**
  27255. * Specifies the roughness scalar of the metallic/roughness workflow.
  27256. * Can also be used to scale the roughness values of the metallic texture.
  27257. */
  27258. protected _roughness: Nullable<number>;
  27259. /**
  27260. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27261. * By default the indexOfrefraction is used to compute F0;
  27262. *
  27263. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27264. *
  27265. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27266. * F90 = metallicReflectanceColor;
  27267. */
  27268. protected _metallicF0Factor: number;
  27269. /**
  27270. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27271. * By default the F90 is always 1;
  27272. *
  27273. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27274. *
  27275. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27276. * F90 = metallicReflectanceColor;
  27277. */
  27278. protected _metallicReflectanceColor: Color3;
  27279. /**
  27280. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27281. * This is multiply against the scalar values defined in the material.
  27282. */
  27283. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27284. /**
  27285. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27286. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27287. */
  27288. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27289. /**
  27290. * Stores surface normal data used to displace a mesh in a texture.
  27291. */
  27292. protected _bumpTexture: Nullable<BaseTexture>;
  27293. /**
  27294. * Stores the pre-calculated light information of a mesh in a texture.
  27295. */
  27296. protected _lightmapTexture: Nullable<BaseTexture>;
  27297. /**
  27298. * The color of a material in ambient lighting.
  27299. */
  27300. protected _ambientColor: Color3;
  27301. /**
  27302. * AKA Diffuse Color in other nomenclature.
  27303. */
  27304. protected _albedoColor: Color3;
  27305. /**
  27306. * AKA Specular Color in other nomenclature.
  27307. */
  27308. protected _reflectivityColor: Color3;
  27309. /**
  27310. * The color applied when light is reflected from a material.
  27311. */
  27312. protected _reflectionColor: Color3;
  27313. /**
  27314. * The color applied when light is emitted from a material.
  27315. */
  27316. protected _emissiveColor: Color3;
  27317. /**
  27318. * AKA Glossiness in other nomenclature.
  27319. */
  27320. protected _microSurface: number;
  27321. /**
  27322. * Specifies that the material will use the light map as a show map.
  27323. */
  27324. protected _useLightmapAsShadowmap: boolean;
  27325. /**
  27326. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27327. * makes the reflect vector face the model (under horizon).
  27328. */
  27329. protected _useHorizonOcclusion: boolean;
  27330. /**
  27331. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27332. * too much the area relying on ambient texture to define their ambient occlusion.
  27333. */
  27334. protected _useRadianceOcclusion: boolean;
  27335. /**
  27336. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27337. */
  27338. protected _useAlphaFromAlbedoTexture: boolean;
  27339. /**
  27340. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27341. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27342. */
  27343. protected _useSpecularOverAlpha: boolean;
  27344. /**
  27345. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27346. */
  27347. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27348. /**
  27349. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27350. */
  27351. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27352. /**
  27353. * Specifies if the metallic texture contains the roughness information in its green channel.
  27354. */
  27355. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27356. /**
  27357. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27358. */
  27359. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27360. /**
  27361. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27362. */
  27363. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27364. /**
  27365. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27366. */
  27367. protected _useAmbientInGrayScale: boolean;
  27368. /**
  27369. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27370. * The material will try to infer what glossiness each pixel should be.
  27371. */
  27372. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27373. /**
  27374. * Defines the falloff type used in this material.
  27375. * It by default is Physical.
  27376. */
  27377. protected _lightFalloff: number;
  27378. /**
  27379. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27380. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27381. */
  27382. protected _useRadianceOverAlpha: boolean;
  27383. /**
  27384. * Allows using an object space normal map (instead of tangent space).
  27385. */
  27386. protected _useObjectSpaceNormalMap: boolean;
  27387. /**
  27388. * Allows using the bump map in parallax mode.
  27389. */
  27390. protected _useParallax: boolean;
  27391. /**
  27392. * Allows using the bump map in parallax occlusion mode.
  27393. */
  27394. protected _useParallaxOcclusion: boolean;
  27395. /**
  27396. * Controls the scale bias of the parallax mode.
  27397. */
  27398. protected _parallaxScaleBias: number;
  27399. /**
  27400. * If sets to true, disables all the lights affecting the material.
  27401. */
  27402. protected _disableLighting: boolean;
  27403. /**
  27404. * Number of Simultaneous lights allowed on the material.
  27405. */
  27406. protected _maxSimultaneousLights: number;
  27407. /**
  27408. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27409. */
  27410. protected _invertNormalMapX: boolean;
  27411. /**
  27412. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27413. */
  27414. protected _invertNormalMapY: boolean;
  27415. /**
  27416. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27417. */
  27418. protected _twoSidedLighting: boolean;
  27419. /**
  27420. * Defines the alpha limits in alpha test mode.
  27421. */
  27422. protected _alphaCutOff: number;
  27423. /**
  27424. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27425. */
  27426. protected _forceAlphaTest: boolean;
  27427. /**
  27428. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27429. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27430. */
  27431. protected _useAlphaFresnel: boolean;
  27432. /**
  27433. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27434. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27435. */
  27436. protected _useLinearAlphaFresnel: boolean;
  27437. /**
  27438. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27439. * from cos thetav and roughness:
  27440. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27441. */
  27442. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27443. /**
  27444. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27445. */
  27446. protected _forceIrradianceInFragment: boolean;
  27447. private _realTimeFiltering;
  27448. /**
  27449. * Enables realtime filtering on the texture.
  27450. */
  27451. get realTimeFiltering(): boolean;
  27452. set realTimeFiltering(b: boolean);
  27453. private _realTimeFilteringQuality;
  27454. /**
  27455. * Quality switch for realtime filtering
  27456. */
  27457. get realTimeFilteringQuality(): number;
  27458. set realTimeFilteringQuality(n: number);
  27459. /**
  27460. * Can this material render to several textures at once
  27461. */
  27462. get canRenderToMRT(): boolean;
  27463. /**
  27464. * Force normal to face away from face.
  27465. */
  27466. protected _forceNormalForward: boolean;
  27467. /**
  27468. * Enables specular anti aliasing in the PBR shader.
  27469. * It will both interacts on the Geometry for analytical and IBL lighting.
  27470. * It also prefilter the roughness map based on the bump values.
  27471. */
  27472. protected _enableSpecularAntiAliasing: boolean;
  27473. /**
  27474. * Default configuration related to image processing available in the PBR Material.
  27475. */
  27476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27477. /**
  27478. * Keep track of the image processing observer to allow dispose and replace.
  27479. */
  27480. private _imageProcessingObserver;
  27481. /**
  27482. * Attaches a new image processing configuration to the PBR Material.
  27483. * @param configuration
  27484. */
  27485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27486. /**
  27487. * Stores the available render targets.
  27488. */
  27489. private _renderTargets;
  27490. /**
  27491. * Sets the global ambient color for the material used in lighting calculations.
  27492. */
  27493. private _globalAmbientColor;
  27494. /**
  27495. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27496. */
  27497. private _useLogarithmicDepth;
  27498. /**
  27499. * If set to true, no lighting calculations will be applied.
  27500. */
  27501. private _unlit;
  27502. private _debugMode;
  27503. /**
  27504. * @hidden
  27505. * This is reserved for the inspector.
  27506. * Defines the material debug mode.
  27507. * It helps seeing only some components of the material while troubleshooting.
  27508. */
  27509. debugMode: number;
  27510. /**
  27511. * @hidden
  27512. * This is reserved for the inspector.
  27513. * Specify from where on screen the debug mode should start.
  27514. * The value goes from -1 (full screen) to 1 (not visible)
  27515. * It helps with side by side comparison against the final render
  27516. * This defaults to -1
  27517. */
  27518. private debugLimit;
  27519. /**
  27520. * @hidden
  27521. * This is reserved for the inspector.
  27522. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27523. * You can use the factor to better multiply the final value.
  27524. */
  27525. private debugFactor;
  27526. /**
  27527. * Defines the clear coat layer parameters for the material.
  27528. */
  27529. readonly clearCoat: PBRClearCoatConfiguration;
  27530. /**
  27531. * Defines the anisotropic parameters for the material.
  27532. */
  27533. readonly anisotropy: PBRAnisotropicConfiguration;
  27534. /**
  27535. * Defines the BRDF parameters for the material.
  27536. */
  27537. readonly brdf: PBRBRDFConfiguration;
  27538. /**
  27539. * Defines the Sheen parameters for the material.
  27540. */
  27541. readonly sheen: PBRSheenConfiguration;
  27542. /**
  27543. * Defines the SubSurface parameters for the material.
  27544. */
  27545. readonly subSurface: PBRSubSurfaceConfiguration;
  27546. /**
  27547. * Defines additionnal PrePass parameters for the material.
  27548. */
  27549. readonly prePassConfiguration: PrePassConfiguration;
  27550. /**
  27551. * Defines the detail map parameters for the material.
  27552. */
  27553. readonly detailMap: DetailMapConfiguration;
  27554. protected _rebuildInParallel: boolean;
  27555. /**
  27556. * Instantiates a new PBRMaterial instance.
  27557. *
  27558. * @param name The material name
  27559. * @param scene The scene the material will be use in.
  27560. */
  27561. constructor(name: string, scene: Scene);
  27562. /**
  27563. * Gets a boolean indicating that current material needs to register RTT
  27564. */
  27565. get hasRenderTargetTextures(): boolean;
  27566. /**
  27567. * Gets the name of the material class.
  27568. */
  27569. getClassName(): string;
  27570. /**
  27571. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27572. */
  27573. get useLogarithmicDepth(): boolean;
  27574. /**
  27575. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27576. */
  27577. set useLogarithmicDepth(value: boolean);
  27578. /**
  27579. * Returns true if alpha blending should be disabled.
  27580. */
  27581. protected get _disableAlphaBlending(): boolean;
  27582. /**
  27583. * Specifies whether or not this material should be rendered in alpha blend mode.
  27584. */
  27585. needAlphaBlending(): boolean;
  27586. /**
  27587. * Specifies whether or not this material should be rendered in alpha test mode.
  27588. */
  27589. needAlphaTesting(): boolean;
  27590. /**
  27591. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27592. */
  27593. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27594. /**
  27595. * Gets the texture used for the alpha test.
  27596. */
  27597. getAlphaTestTexture(): Nullable<BaseTexture>;
  27598. /**
  27599. * Specifies that the submesh is ready to be used.
  27600. * @param mesh - BJS mesh.
  27601. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27602. * @param useInstances - Specifies that instances should be used.
  27603. * @returns - boolean indicating that the submesh is ready or not.
  27604. */
  27605. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27606. /**
  27607. * Specifies if the material uses metallic roughness workflow.
  27608. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27609. */
  27610. isMetallicWorkflow(): boolean;
  27611. private _prepareEffect;
  27612. private _prepareDefines;
  27613. /**
  27614. * Force shader compilation
  27615. */
  27616. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27617. /**
  27618. * Initializes the uniform buffer layout for the shader.
  27619. */
  27620. buildUniformLayout(): void;
  27621. /**
  27622. * Unbinds the material from the mesh
  27623. */
  27624. unbind(): void;
  27625. /**
  27626. * Binds the submesh data.
  27627. * @param world - The world matrix.
  27628. * @param mesh - The BJS mesh.
  27629. * @param subMesh - A submesh of the BJS mesh.
  27630. */
  27631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27632. /**
  27633. * Returns the animatable textures.
  27634. * @returns - Array of animatable textures.
  27635. */
  27636. getAnimatables(): IAnimatable[];
  27637. /**
  27638. * Returns the texture used for reflections.
  27639. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27640. */
  27641. private _getReflectionTexture;
  27642. /**
  27643. * Returns an array of the actively used textures.
  27644. * @returns - Array of BaseTextures
  27645. */
  27646. getActiveTextures(): BaseTexture[];
  27647. /**
  27648. * Checks to see if a texture is used in the material.
  27649. * @param texture - Base texture to use.
  27650. * @returns - Boolean specifying if a texture is used in the material.
  27651. */
  27652. hasTexture(texture: BaseTexture): boolean;
  27653. /**
  27654. * Sets the required values to the prepass renderer.
  27655. * @param prePassRenderer defines the prepass renderer to setup
  27656. */
  27657. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27658. /**
  27659. * Disposes the resources of the material.
  27660. * @param forceDisposeEffect - Forces the disposal of effects.
  27661. * @param forceDisposeTextures - Forces the disposal of all textures.
  27662. */
  27663. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27664. }
  27665. }
  27666. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27667. import { Nullable } from "babylonjs/types";
  27668. import { Scene } from "babylonjs/scene";
  27669. import { Color3 } from "babylonjs/Maths/math.color";
  27670. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27671. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27673. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27674. /**
  27675. * The Physically based material of BJS.
  27676. *
  27677. * This offers the main features of a standard PBR material.
  27678. * For more information, please refer to the documentation :
  27679. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27680. */
  27681. export class PBRMaterial extends PBRBaseMaterial {
  27682. /**
  27683. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27684. */
  27685. static readonly PBRMATERIAL_OPAQUE: number;
  27686. /**
  27687. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27688. */
  27689. static readonly PBRMATERIAL_ALPHATEST: number;
  27690. /**
  27691. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27692. */
  27693. static readonly PBRMATERIAL_ALPHABLEND: number;
  27694. /**
  27695. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27696. * They are also discarded below the alpha cutoff threshold to improve performances.
  27697. */
  27698. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27699. /**
  27700. * Defines the default value of how much AO map is occluding the analytical lights
  27701. * (point spot...).
  27702. */
  27703. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27704. /**
  27705. * Intensity of the direct lights e.g. the four lights available in your scene.
  27706. * This impacts both the direct diffuse and specular highlights.
  27707. */
  27708. directIntensity: number;
  27709. /**
  27710. * Intensity of the emissive part of the material.
  27711. * This helps controlling the emissive effect without modifying the emissive color.
  27712. */
  27713. emissiveIntensity: number;
  27714. /**
  27715. * Intensity of the environment e.g. how much the environment will light the object
  27716. * either through harmonics for rough material or through the refelction for shiny ones.
  27717. */
  27718. environmentIntensity: number;
  27719. /**
  27720. * This is a special control allowing the reduction of the specular highlights coming from the
  27721. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27722. */
  27723. specularIntensity: number;
  27724. /**
  27725. * Debug Control allowing disabling the bump map on this material.
  27726. */
  27727. disableBumpMap: boolean;
  27728. /**
  27729. * AKA Diffuse Texture in standard nomenclature.
  27730. */
  27731. albedoTexture: BaseTexture;
  27732. /**
  27733. * AKA Occlusion Texture in other nomenclature.
  27734. */
  27735. ambientTexture: BaseTexture;
  27736. /**
  27737. * AKA Occlusion Texture Intensity in other nomenclature.
  27738. */
  27739. ambientTextureStrength: number;
  27740. /**
  27741. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27742. * 1 means it completely occludes it
  27743. * 0 mean it has no impact
  27744. */
  27745. ambientTextureImpactOnAnalyticalLights: number;
  27746. /**
  27747. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27748. */
  27749. opacityTexture: BaseTexture;
  27750. /**
  27751. * Stores the reflection values in a texture.
  27752. */
  27753. reflectionTexture: Nullable<BaseTexture>;
  27754. /**
  27755. * Stores the emissive values in a texture.
  27756. */
  27757. emissiveTexture: BaseTexture;
  27758. /**
  27759. * AKA Specular texture in other nomenclature.
  27760. */
  27761. reflectivityTexture: BaseTexture;
  27762. /**
  27763. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27764. */
  27765. metallicTexture: BaseTexture;
  27766. /**
  27767. * Specifies the metallic scalar of the metallic/roughness workflow.
  27768. * Can also be used to scale the metalness values of the metallic texture.
  27769. */
  27770. metallic: Nullable<number>;
  27771. /**
  27772. * Specifies the roughness scalar of the metallic/roughness workflow.
  27773. * Can also be used to scale the roughness values of the metallic texture.
  27774. */
  27775. roughness: Nullable<number>;
  27776. /**
  27777. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27778. * By default the indexOfrefraction is used to compute F0;
  27779. *
  27780. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27781. *
  27782. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27783. * F90 = metallicReflectanceColor;
  27784. */
  27785. metallicF0Factor: number;
  27786. /**
  27787. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27788. * By default the F90 is always 1;
  27789. *
  27790. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27791. *
  27792. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27793. * F90 = metallicReflectanceColor;
  27794. */
  27795. metallicReflectanceColor: Color3;
  27796. /**
  27797. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27798. * This is multiply against the scalar values defined in the material.
  27799. */
  27800. metallicReflectanceTexture: Nullable<BaseTexture>;
  27801. /**
  27802. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27803. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27804. */
  27805. microSurfaceTexture: BaseTexture;
  27806. /**
  27807. * Stores surface normal data used to displace a mesh in a texture.
  27808. */
  27809. bumpTexture: BaseTexture;
  27810. /**
  27811. * Stores the pre-calculated light information of a mesh in a texture.
  27812. */
  27813. lightmapTexture: BaseTexture;
  27814. /**
  27815. * Stores the refracted light information in a texture.
  27816. */
  27817. get refractionTexture(): Nullable<BaseTexture>;
  27818. set refractionTexture(value: Nullable<BaseTexture>);
  27819. /**
  27820. * The color of a material in ambient lighting.
  27821. */
  27822. ambientColor: Color3;
  27823. /**
  27824. * AKA Diffuse Color in other nomenclature.
  27825. */
  27826. albedoColor: Color3;
  27827. /**
  27828. * AKA Specular Color in other nomenclature.
  27829. */
  27830. reflectivityColor: Color3;
  27831. /**
  27832. * The color reflected from the material.
  27833. */
  27834. reflectionColor: Color3;
  27835. /**
  27836. * The color emitted from the material.
  27837. */
  27838. emissiveColor: Color3;
  27839. /**
  27840. * AKA Glossiness in other nomenclature.
  27841. */
  27842. microSurface: number;
  27843. /**
  27844. * Index of refraction of the material base layer.
  27845. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27846. *
  27847. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27848. *
  27849. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27850. */
  27851. get indexOfRefraction(): number;
  27852. set indexOfRefraction(value: number);
  27853. /**
  27854. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27855. */
  27856. get invertRefractionY(): boolean;
  27857. set invertRefractionY(value: boolean);
  27858. /**
  27859. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27860. * Materials half opaque for instance using refraction could benefit from this control.
  27861. */
  27862. get linkRefractionWithTransparency(): boolean;
  27863. set linkRefractionWithTransparency(value: boolean);
  27864. /**
  27865. * If true, the light map contains occlusion information instead of lighting info.
  27866. */
  27867. useLightmapAsShadowmap: boolean;
  27868. /**
  27869. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27870. */
  27871. useAlphaFromAlbedoTexture: boolean;
  27872. /**
  27873. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27874. */
  27875. forceAlphaTest: boolean;
  27876. /**
  27877. * Defines the alpha limits in alpha test mode.
  27878. */
  27879. alphaCutOff: number;
  27880. /**
  27881. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27882. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27883. */
  27884. useSpecularOverAlpha: boolean;
  27885. /**
  27886. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27887. */
  27888. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27889. /**
  27890. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27891. */
  27892. useRoughnessFromMetallicTextureAlpha: boolean;
  27893. /**
  27894. * Specifies if the metallic texture contains the roughness information in its green channel.
  27895. */
  27896. useRoughnessFromMetallicTextureGreen: boolean;
  27897. /**
  27898. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27899. */
  27900. useMetallnessFromMetallicTextureBlue: boolean;
  27901. /**
  27902. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27903. */
  27904. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27905. /**
  27906. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27907. */
  27908. useAmbientInGrayScale: boolean;
  27909. /**
  27910. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27911. * The material will try to infer what glossiness each pixel should be.
  27912. */
  27913. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27914. /**
  27915. * BJS is using an harcoded light falloff based on a manually sets up range.
  27916. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27917. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27918. */
  27919. get usePhysicalLightFalloff(): boolean;
  27920. /**
  27921. * BJS is using an harcoded light falloff based on a manually sets up range.
  27922. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27923. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27924. */
  27925. set usePhysicalLightFalloff(value: boolean);
  27926. /**
  27927. * In order to support the falloff compatibility with gltf, a special mode has been added
  27928. * to reproduce the gltf light falloff.
  27929. */
  27930. get useGLTFLightFalloff(): boolean;
  27931. /**
  27932. * In order to support the falloff compatibility with gltf, a special mode has been added
  27933. * to reproduce the gltf light falloff.
  27934. */
  27935. set useGLTFLightFalloff(value: boolean);
  27936. /**
  27937. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27938. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27939. */
  27940. useRadianceOverAlpha: boolean;
  27941. /**
  27942. * Allows using an object space normal map (instead of tangent space).
  27943. */
  27944. useObjectSpaceNormalMap: boolean;
  27945. /**
  27946. * Allows using the bump map in parallax mode.
  27947. */
  27948. useParallax: boolean;
  27949. /**
  27950. * Allows using the bump map in parallax occlusion mode.
  27951. */
  27952. useParallaxOcclusion: boolean;
  27953. /**
  27954. * Controls the scale bias of the parallax mode.
  27955. */
  27956. parallaxScaleBias: number;
  27957. /**
  27958. * If sets to true, disables all the lights affecting the material.
  27959. */
  27960. disableLighting: boolean;
  27961. /**
  27962. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27963. */
  27964. forceIrradianceInFragment: boolean;
  27965. /**
  27966. * Number of Simultaneous lights allowed on the material.
  27967. */
  27968. maxSimultaneousLights: number;
  27969. /**
  27970. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27971. */
  27972. invertNormalMapX: boolean;
  27973. /**
  27974. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27975. */
  27976. invertNormalMapY: boolean;
  27977. /**
  27978. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27979. */
  27980. twoSidedLighting: boolean;
  27981. /**
  27982. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27983. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27984. */
  27985. useAlphaFresnel: boolean;
  27986. /**
  27987. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27988. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27989. */
  27990. useLinearAlphaFresnel: boolean;
  27991. /**
  27992. * Let user defines the brdf lookup texture used for IBL.
  27993. * A default 8bit version is embedded but you could point at :
  27994. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27995. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27996. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27997. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27998. */
  27999. environmentBRDFTexture: Nullable<BaseTexture>;
  28000. /**
  28001. * Force normal to face away from face.
  28002. */
  28003. forceNormalForward: boolean;
  28004. /**
  28005. * Enables specular anti aliasing in the PBR shader.
  28006. * It will both interacts on the Geometry for analytical and IBL lighting.
  28007. * It also prefilter the roughness map based on the bump values.
  28008. */
  28009. enableSpecularAntiAliasing: boolean;
  28010. /**
  28011. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28012. * makes the reflect vector face the model (under horizon).
  28013. */
  28014. useHorizonOcclusion: boolean;
  28015. /**
  28016. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28017. * too much the area relying on ambient texture to define their ambient occlusion.
  28018. */
  28019. useRadianceOcclusion: boolean;
  28020. /**
  28021. * If set to true, no lighting calculations will be applied.
  28022. */
  28023. unlit: boolean;
  28024. /**
  28025. * Gets the image processing configuration used either in this material.
  28026. */
  28027. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28028. /**
  28029. * Sets the Default image processing configuration used either in the this material.
  28030. *
  28031. * If sets to null, the scene one is in use.
  28032. */
  28033. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28034. /**
  28035. * Gets wether the color curves effect is enabled.
  28036. */
  28037. get cameraColorCurvesEnabled(): boolean;
  28038. /**
  28039. * Sets wether the color curves effect is enabled.
  28040. */
  28041. set cameraColorCurvesEnabled(value: boolean);
  28042. /**
  28043. * Gets wether the color grading effect is enabled.
  28044. */
  28045. get cameraColorGradingEnabled(): boolean;
  28046. /**
  28047. * Gets wether the color grading effect is enabled.
  28048. */
  28049. set cameraColorGradingEnabled(value: boolean);
  28050. /**
  28051. * Gets wether tonemapping is enabled or not.
  28052. */
  28053. get cameraToneMappingEnabled(): boolean;
  28054. /**
  28055. * Sets wether tonemapping is enabled or not
  28056. */
  28057. set cameraToneMappingEnabled(value: boolean);
  28058. /**
  28059. * The camera exposure used on this material.
  28060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28061. * This corresponds to a photographic exposure.
  28062. */
  28063. get cameraExposure(): number;
  28064. /**
  28065. * The camera exposure used on this material.
  28066. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28067. * This corresponds to a photographic exposure.
  28068. */
  28069. set cameraExposure(value: number);
  28070. /**
  28071. * Gets The camera contrast used on this material.
  28072. */
  28073. get cameraContrast(): number;
  28074. /**
  28075. * Sets The camera contrast used on this material.
  28076. */
  28077. set cameraContrast(value: number);
  28078. /**
  28079. * Gets the Color Grading 2D Lookup Texture.
  28080. */
  28081. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28082. /**
  28083. * Sets the Color Grading 2D Lookup Texture.
  28084. */
  28085. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28086. /**
  28087. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28088. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28089. * 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;
  28090. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28091. */
  28092. get cameraColorCurves(): Nullable<ColorCurves>;
  28093. /**
  28094. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28095. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28096. * 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;
  28097. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28098. */
  28099. set cameraColorCurves(value: Nullable<ColorCurves>);
  28100. /**
  28101. * Instantiates a new PBRMaterial instance.
  28102. *
  28103. * @param name The material name
  28104. * @param scene The scene the material will be use in.
  28105. */
  28106. constructor(name: string, scene: Scene);
  28107. /**
  28108. * Returns the name of this material class.
  28109. */
  28110. getClassName(): string;
  28111. /**
  28112. * Makes a duplicate of the current material.
  28113. * @param name - name to use for the new material.
  28114. */
  28115. clone(name: string): PBRMaterial;
  28116. /**
  28117. * Serializes this PBR Material.
  28118. * @returns - An object with the serialized material.
  28119. */
  28120. serialize(): any;
  28121. /**
  28122. * Parses a PBR Material from a serialized object.
  28123. * @param source - Serialized object.
  28124. * @param scene - BJS scene instance.
  28125. * @param rootUrl - url for the scene object
  28126. * @returns - PBRMaterial
  28127. */
  28128. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28129. }
  28130. }
  28131. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28132. /** @hidden */
  28133. export var mrtFragmentDeclaration: {
  28134. name: string;
  28135. shader: string;
  28136. };
  28137. }
  28138. declare module "babylonjs/Shaders/geometry.fragment" {
  28139. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28140. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28141. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28142. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28143. /** @hidden */
  28144. export var geometryPixelShader: {
  28145. name: string;
  28146. shader: string;
  28147. };
  28148. }
  28149. declare module "babylonjs/Shaders/geometry.vertex" {
  28150. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28151. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28152. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28153. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28154. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28155. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28156. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28157. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28158. /** @hidden */
  28159. export var geometryVertexShader: {
  28160. name: string;
  28161. shader: string;
  28162. };
  28163. }
  28164. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28165. import { Matrix } from "babylonjs/Maths/math.vector";
  28166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28168. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28169. import { Effect } from "babylonjs/Materials/effect";
  28170. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28171. import { Scene } from "babylonjs/scene";
  28172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28173. import { Nullable } from "babylonjs/types";
  28174. import "babylonjs/Shaders/geometry.fragment";
  28175. import "babylonjs/Shaders/geometry.vertex";
  28176. /** @hidden */
  28177. interface ISavedTransformationMatrix {
  28178. world: Matrix;
  28179. viewProjection: Matrix;
  28180. }
  28181. /**
  28182. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28183. */
  28184. export class GeometryBufferRenderer {
  28185. /**
  28186. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28187. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28188. */
  28189. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28190. /**
  28191. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28192. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28193. */
  28194. static readonly POSITION_TEXTURE_TYPE: number;
  28195. /**
  28196. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28197. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28198. */
  28199. static readonly VELOCITY_TEXTURE_TYPE: number;
  28200. /**
  28201. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28202. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28203. */
  28204. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28205. /**
  28206. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28207. * in order to compute objects velocities when enableVelocity is set to "true"
  28208. * @hidden
  28209. */
  28210. _previousTransformationMatrices: {
  28211. [index: number]: ISavedTransformationMatrix;
  28212. };
  28213. /**
  28214. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28215. * in order to compute objects velocities when enableVelocity is set to "true"
  28216. * @hidden
  28217. */
  28218. _previousBonesTransformationMatrices: {
  28219. [index: number]: Float32Array;
  28220. };
  28221. /**
  28222. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28223. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28224. */
  28225. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28226. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28227. renderTransparentMeshes: boolean;
  28228. private _scene;
  28229. private _resizeObserver;
  28230. private _multiRenderTarget;
  28231. private _ratio;
  28232. private _enablePosition;
  28233. private _enableVelocity;
  28234. private _enableReflectivity;
  28235. private _positionIndex;
  28236. private _velocityIndex;
  28237. private _reflectivityIndex;
  28238. private _depthNormalIndex;
  28239. private _linkedWithPrePass;
  28240. private _prePassRenderer;
  28241. private _attachments;
  28242. protected _effect: Effect;
  28243. protected _cachedDefines: string;
  28244. /**
  28245. * @hidden
  28246. * Sets up internal structures to share outputs with PrePassRenderer
  28247. * This method should only be called by the PrePassRenderer itself
  28248. */
  28249. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28250. /**
  28251. * @hidden
  28252. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28253. * This method should only be called by the PrePassRenderer itself
  28254. */
  28255. _unlinkPrePassRenderer(): void;
  28256. /**
  28257. * @hidden
  28258. * Resets the geometry buffer layout
  28259. */
  28260. _resetLayout(): void;
  28261. /**
  28262. * @hidden
  28263. * Replaces a texture in the geometry buffer renderer
  28264. * Useful when linking textures of the prepass renderer
  28265. */
  28266. _forceTextureType(geometryBufferType: number, index: number): void;
  28267. /**
  28268. * @hidden
  28269. * Sets texture attachments
  28270. * Useful when linking textures of the prepass renderer
  28271. */
  28272. _setAttachments(attachments: number[]): void;
  28273. /**
  28274. * @hidden
  28275. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28276. * Useful when linking textures of the prepass renderer
  28277. */
  28278. _linkInternalTexture(internalTexture: InternalTexture): void;
  28279. /**
  28280. * Gets the render list (meshes to be rendered) used in the G buffer.
  28281. */
  28282. get renderList(): Nullable<AbstractMesh[]>;
  28283. /**
  28284. * Set the render list (meshes to be rendered) used in the G buffer.
  28285. */
  28286. set renderList(meshes: Nullable<AbstractMesh[]>);
  28287. /**
  28288. * Gets wether or not G buffer are supported by the running hardware.
  28289. * This requires draw buffer supports
  28290. */
  28291. get isSupported(): boolean;
  28292. /**
  28293. * Returns the index of the given texture type in the G-Buffer textures array
  28294. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28295. * @returns the index of the given texture type in the G-Buffer textures array
  28296. */
  28297. getTextureIndex(textureType: number): number;
  28298. /**
  28299. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28300. */
  28301. get enablePosition(): boolean;
  28302. /**
  28303. * Sets whether or not objects positions are enabled for the G buffer.
  28304. */
  28305. set enablePosition(enable: boolean);
  28306. /**
  28307. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28308. */
  28309. get enableVelocity(): boolean;
  28310. /**
  28311. * Sets wether or not objects velocities are enabled for the G buffer.
  28312. */
  28313. set enableVelocity(enable: boolean);
  28314. /**
  28315. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28316. */
  28317. get enableReflectivity(): boolean;
  28318. /**
  28319. * Sets wether or not objects roughness are enabled for the G buffer.
  28320. */
  28321. set enableReflectivity(enable: boolean);
  28322. /**
  28323. * Gets the scene associated with the buffer.
  28324. */
  28325. get scene(): Scene;
  28326. /**
  28327. * Gets the ratio used by the buffer during its creation.
  28328. * How big is the buffer related to the main canvas.
  28329. */
  28330. get ratio(): number;
  28331. /** @hidden */
  28332. static _SceneComponentInitialization: (scene: Scene) => void;
  28333. /**
  28334. * Creates a new G Buffer for the scene
  28335. * @param scene The scene the buffer belongs to
  28336. * @param ratio How big is the buffer related to the main canvas.
  28337. */
  28338. constructor(scene: Scene, ratio?: number);
  28339. /**
  28340. * Checks wether everything is ready to render a submesh to the G buffer.
  28341. * @param subMesh the submesh to check readiness for
  28342. * @param useInstances is the mesh drawn using instance or not
  28343. * @returns true if ready otherwise false
  28344. */
  28345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28346. /**
  28347. * Gets the current underlying G Buffer.
  28348. * @returns the buffer
  28349. */
  28350. getGBuffer(): MultiRenderTarget;
  28351. /**
  28352. * Gets the number of samples used to render the buffer (anti aliasing).
  28353. */
  28354. get samples(): number;
  28355. /**
  28356. * Sets the number of samples used to render the buffer (anti aliasing).
  28357. */
  28358. set samples(value: number);
  28359. /**
  28360. * Disposes the renderer and frees up associated resources.
  28361. */
  28362. dispose(): void;
  28363. private _assignRenderTargetIndices;
  28364. protected _createRenderTargets(): void;
  28365. private _copyBonesTransformationMatrices;
  28366. }
  28367. }
  28368. declare module "babylonjs/Rendering/prePassRenderer" {
  28369. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28370. import { Scene } from "babylonjs/scene";
  28371. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28372. import { Effect } from "babylonjs/Materials/effect";
  28373. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28375. import { Material } from "babylonjs/Materials/material";
  28376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28377. /**
  28378. * Renders a pre pass of the scene
  28379. * This means every mesh in the scene will be rendered to a render target texture
  28380. * And then this texture will be composited to the rendering canvas with post processes
  28381. * It is necessary for effects like subsurface scattering or deferred shading
  28382. */
  28383. export class PrePassRenderer {
  28384. /** @hidden */
  28385. static _SceneComponentInitialization: (scene: Scene) => void;
  28386. private _textureFormats;
  28387. /**
  28388. * To save performance, we can excluded skinned meshes from the prepass
  28389. */
  28390. excludedSkinnedMesh: AbstractMesh[];
  28391. /**
  28392. * Force material to be excluded from the prepass
  28393. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28394. * and you don't want a material to show in the effect.
  28395. */
  28396. excludedMaterials: Material[];
  28397. private _textureIndices;
  28398. private _scene;
  28399. private _engine;
  28400. private _isDirty;
  28401. /**
  28402. * Number of textures in the multi render target texture where the scene is directly rendered
  28403. */
  28404. mrtCount: number;
  28405. /**
  28406. * The render target where the scene is directly rendered
  28407. */
  28408. prePassRT: MultiRenderTarget;
  28409. private _multiRenderAttachments;
  28410. private _defaultAttachments;
  28411. private _clearAttachments;
  28412. private _postProcesses;
  28413. private readonly _clearColor;
  28414. /**
  28415. * Image processing post process for composition
  28416. */
  28417. imageProcessingPostProcess: ImageProcessingPostProcess;
  28418. /**
  28419. * Configuration for prepass effects
  28420. */
  28421. private _effectConfigurations;
  28422. private _mrtFormats;
  28423. private _mrtLayout;
  28424. private _enabled;
  28425. /**
  28426. * Indicates if the prepass is enabled
  28427. */
  28428. get enabled(): boolean;
  28429. /**
  28430. * How many samples are used for MSAA of the scene render target
  28431. */
  28432. get samples(): number;
  28433. set samples(n: number);
  28434. private _geometryBuffer;
  28435. private _useGeometryBufferFallback;
  28436. /**
  28437. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28438. */
  28439. get useGeometryBufferFallback(): boolean;
  28440. set useGeometryBufferFallback(value: boolean);
  28441. /**
  28442. * Instanciates a prepass renderer
  28443. * @param scene The scene
  28444. */
  28445. constructor(scene: Scene);
  28446. private _initializeAttachments;
  28447. private _createCompositionEffect;
  28448. /**
  28449. * Indicates if rendering a prepass is supported
  28450. */
  28451. get isSupported(): boolean;
  28452. /**
  28453. * Sets the proper output textures to draw in the engine.
  28454. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28455. * @param subMesh Submesh on which the effect is applied
  28456. */
  28457. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28458. /**
  28459. * @hidden
  28460. */
  28461. _beforeCameraDraw(): void;
  28462. /**
  28463. * @hidden
  28464. */
  28465. _afterCameraDraw(): void;
  28466. private _checkRTSize;
  28467. private _bindFrameBuffer;
  28468. /**
  28469. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28470. */
  28471. clear(): void;
  28472. private _setState;
  28473. private _updateGeometryBufferLayout;
  28474. /**
  28475. * Adds an effect configuration to the prepass.
  28476. * If an effect has already been added, it won't add it twice and will return the configuration
  28477. * already present.
  28478. * @param cfg the effect configuration
  28479. * @return the effect configuration now used by the prepass
  28480. */
  28481. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28482. /**
  28483. * Returns the index of a texture in the multi render target texture array.
  28484. * @param type Texture type
  28485. * @return The index
  28486. */
  28487. getIndex(type: number): number;
  28488. private _enable;
  28489. private _disable;
  28490. private _resetLayout;
  28491. private _resetPostProcessChain;
  28492. private _bindPostProcessChain;
  28493. /**
  28494. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28495. */
  28496. markAsDirty(): void;
  28497. /**
  28498. * Enables a texture on the MultiRenderTarget for prepass
  28499. */
  28500. private _enableTextures;
  28501. private _update;
  28502. private _markAllMaterialsAsPrePassDirty;
  28503. /**
  28504. * Disposes the prepass renderer.
  28505. */
  28506. dispose(): void;
  28507. }
  28508. }
  28509. declare module "babylonjs/PostProcesses/postProcess" {
  28510. import { Nullable } from "babylonjs/types";
  28511. import { SmartArray } from "babylonjs/Misc/smartArray";
  28512. import { Observable } from "babylonjs/Misc/observable";
  28513. import { Vector2 } from "babylonjs/Maths/math.vector";
  28514. import { Camera } from "babylonjs/Cameras/camera";
  28515. import { Effect } from "babylonjs/Materials/effect";
  28516. import "babylonjs/Shaders/postprocess.vertex";
  28517. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28518. import { Engine } from "babylonjs/Engines/engine";
  28519. import { Color4 } from "babylonjs/Maths/math.color";
  28520. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28521. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28522. import { Scene } from "babylonjs/scene";
  28523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28524. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28525. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28526. /**
  28527. * Size options for a post process
  28528. */
  28529. export type PostProcessOptions = {
  28530. width: number;
  28531. height: number;
  28532. };
  28533. /**
  28534. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28535. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28536. */
  28537. export class PostProcess {
  28538. /**
  28539. * Gets or sets the unique id of the post process
  28540. */
  28541. uniqueId: number;
  28542. /** Name of the PostProcess. */
  28543. name: string;
  28544. /**
  28545. * Width of the texture to apply the post process on
  28546. */
  28547. width: number;
  28548. /**
  28549. * Height of the texture to apply the post process on
  28550. */
  28551. height: number;
  28552. /**
  28553. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28554. */
  28555. nodeMaterialSource: Nullable<NodeMaterial>;
  28556. /**
  28557. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28558. * @hidden
  28559. */
  28560. _outputTexture: Nullable<InternalTexture>;
  28561. /**
  28562. * Sampling mode used by the shader
  28563. * See https://doc.babylonjs.com/classes/3.1/texture
  28564. */
  28565. renderTargetSamplingMode: number;
  28566. /**
  28567. * Clear color to use when screen clearing
  28568. */
  28569. clearColor: Color4;
  28570. /**
  28571. * If the buffer needs to be cleared before applying the post process. (default: true)
  28572. * Should be set to false if shader will overwrite all previous pixels.
  28573. */
  28574. autoClear: boolean;
  28575. /**
  28576. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28577. */
  28578. alphaMode: number;
  28579. /**
  28580. * Sets the setAlphaBlendConstants of the babylon engine
  28581. */
  28582. alphaConstants: Color4;
  28583. /**
  28584. * Animations to be used for the post processing
  28585. */
  28586. animations: import("babylonjs/Animations/animation").Animation[];
  28587. /**
  28588. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28589. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28590. */
  28591. enablePixelPerfectMode: boolean;
  28592. /**
  28593. * Force the postprocess to be applied without taking in account viewport
  28594. */
  28595. forceFullscreenViewport: boolean;
  28596. /**
  28597. * List of inspectable custom properties (used by the Inspector)
  28598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28599. */
  28600. inspectableCustomProperties: IInspectable[];
  28601. /**
  28602. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28603. *
  28604. * | Value | Type | Description |
  28605. * | ----- | ----------------------------------- | ----------- |
  28606. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28607. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28608. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28609. *
  28610. */
  28611. scaleMode: number;
  28612. /**
  28613. * Force textures to be a power of two (default: false)
  28614. */
  28615. alwaysForcePOT: boolean;
  28616. private _samples;
  28617. /**
  28618. * Number of sample textures (default: 1)
  28619. */
  28620. get samples(): number;
  28621. set samples(n: number);
  28622. /**
  28623. * Modify the scale of the post process to be the same as the viewport (default: false)
  28624. */
  28625. adaptScaleToCurrentViewport: boolean;
  28626. private _camera;
  28627. protected _scene: Scene;
  28628. private _engine;
  28629. private _options;
  28630. private _reusable;
  28631. private _textureType;
  28632. private _textureFormat;
  28633. /**
  28634. * Smart array of input and output textures for the post process.
  28635. * @hidden
  28636. */
  28637. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28638. /**
  28639. * The index in _textures that corresponds to the output texture.
  28640. * @hidden
  28641. */
  28642. _currentRenderTextureInd: number;
  28643. private _effect;
  28644. private _samplers;
  28645. private _fragmentUrl;
  28646. private _vertexUrl;
  28647. private _parameters;
  28648. private _scaleRatio;
  28649. protected _indexParameters: any;
  28650. private _shareOutputWithPostProcess;
  28651. private _texelSize;
  28652. private _forcedOutputTexture;
  28653. /**
  28654. * Prepass configuration in case this post process needs a texture from prepass
  28655. * @hidden
  28656. */
  28657. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28658. /**
  28659. * Returns the fragment url or shader name used in the post process.
  28660. * @returns the fragment url or name in the shader store.
  28661. */
  28662. getEffectName(): string;
  28663. /**
  28664. * An event triggered when the postprocess is activated.
  28665. */
  28666. onActivateObservable: Observable<Camera>;
  28667. private _onActivateObserver;
  28668. /**
  28669. * A function that is added to the onActivateObservable
  28670. */
  28671. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28672. /**
  28673. * An event triggered when the postprocess changes its size.
  28674. */
  28675. onSizeChangedObservable: Observable<PostProcess>;
  28676. private _onSizeChangedObserver;
  28677. /**
  28678. * A function that is added to the onSizeChangedObservable
  28679. */
  28680. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28681. /**
  28682. * An event triggered when the postprocess applies its effect.
  28683. */
  28684. onApplyObservable: Observable<Effect>;
  28685. private _onApplyObserver;
  28686. /**
  28687. * A function that is added to the onApplyObservable
  28688. */
  28689. set onApply(callback: (effect: Effect) => void);
  28690. /**
  28691. * An event triggered before rendering the postprocess
  28692. */
  28693. onBeforeRenderObservable: Observable<Effect>;
  28694. private _onBeforeRenderObserver;
  28695. /**
  28696. * A function that is added to the onBeforeRenderObservable
  28697. */
  28698. set onBeforeRender(callback: (effect: Effect) => void);
  28699. /**
  28700. * An event triggered after rendering the postprocess
  28701. */
  28702. onAfterRenderObservable: Observable<Effect>;
  28703. private _onAfterRenderObserver;
  28704. /**
  28705. * A function that is added to the onAfterRenderObservable
  28706. */
  28707. set onAfterRender(callback: (efect: Effect) => void);
  28708. /**
  28709. * 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
  28710. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28711. */
  28712. get inputTexture(): InternalTexture;
  28713. set inputTexture(value: InternalTexture);
  28714. /**
  28715. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28716. * the only way to unset it is to use this function to restore its internal state
  28717. */
  28718. restoreDefaultInputTexture(): void;
  28719. /**
  28720. * Gets the camera which post process is applied to.
  28721. * @returns The camera the post process is applied to.
  28722. */
  28723. getCamera(): Camera;
  28724. /**
  28725. * Gets the texel size of the postprocess.
  28726. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28727. */
  28728. get texelSize(): Vector2;
  28729. /**
  28730. * Creates a new instance PostProcess
  28731. * @param name The name of the PostProcess.
  28732. * @param fragmentUrl The url of the fragment shader to be used.
  28733. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28734. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28735. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28736. * @param camera The camera to apply the render pass to.
  28737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28738. * @param engine The engine which the post process will be applied. (default: current engine)
  28739. * @param reusable If the post process can be reused on the same frame. (default: false)
  28740. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28741. * @param textureType Type of textures used when performing the post process. (default: 0)
  28742. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28743. * @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
  28744. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28745. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28746. */
  28747. 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);
  28748. /**
  28749. * Gets a string identifying the name of the class
  28750. * @returns "PostProcess" string
  28751. */
  28752. getClassName(): string;
  28753. /**
  28754. * Gets the engine which this post process belongs to.
  28755. * @returns The engine the post process was enabled with.
  28756. */
  28757. getEngine(): Engine;
  28758. /**
  28759. * The effect that is created when initializing the post process.
  28760. * @returns The created effect corresponding the the postprocess.
  28761. */
  28762. getEffect(): Effect;
  28763. /**
  28764. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28765. * @param postProcess The post process to share the output with.
  28766. * @returns This post process.
  28767. */
  28768. shareOutputWith(postProcess: PostProcess): PostProcess;
  28769. /**
  28770. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28771. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28772. */
  28773. useOwnOutput(): void;
  28774. /**
  28775. * Updates the effect with the current post process compile time values and recompiles the shader.
  28776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28779. * @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
  28780. * @param onCompiled Called when the shader has been compiled.
  28781. * @param onError Called if there is an error when compiling a shader.
  28782. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28783. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28784. */
  28785. 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;
  28786. /**
  28787. * The post process is reusable if it can be used multiple times within one frame.
  28788. * @returns If the post process is reusable
  28789. */
  28790. isReusable(): boolean;
  28791. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28792. markTextureDirty(): void;
  28793. /**
  28794. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28795. * 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.
  28796. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28797. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28798. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28799. * @returns The target texture that was bound to be written to.
  28800. */
  28801. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28802. /**
  28803. * If the post process is supported.
  28804. */
  28805. get isSupported(): boolean;
  28806. /**
  28807. * The aspect ratio of the output texture.
  28808. */
  28809. get aspectRatio(): number;
  28810. /**
  28811. * Get a value indicating if the post-process is ready to be used
  28812. * @returns true if the post-process is ready (shader is compiled)
  28813. */
  28814. isReady(): boolean;
  28815. /**
  28816. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28817. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28818. */
  28819. apply(): Nullable<Effect>;
  28820. private _disposeTextures;
  28821. /**
  28822. * Sets the required values to the prepass renderer.
  28823. * @param prePassRenderer defines the prepass renderer to setup.
  28824. * @returns true if the pre pass is needed.
  28825. */
  28826. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28827. /**
  28828. * Disposes the post process.
  28829. * @param camera The camera to dispose the post process on.
  28830. */
  28831. dispose(camera?: Camera): void;
  28832. /**
  28833. * Serializes the particle system to a JSON object
  28834. * @returns the JSON object
  28835. */
  28836. serialize(): any;
  28837. /**
  28838. * Creates a material from parsed material data
  28839. * @param parsedPostProcess defines parsed post process data
  28840. * @param scene defines the hosting scene
  28841. * @param rootUrl defines the root URL to use to load textures
  28842. * @returns a new post process
  28843. */
  28844. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28845. }
  28846. }
  28847. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28848. /** @hidden */
  28849. export var kernelBlurVaryingDeclaration: {
  28850. name: string;
  28851. shader: string;
  28852. };
  28853. }
  28854. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28855. /** @hidden */
  28856. export var kernelBlurFragment: {
  28857. name: string;
  28858. shader: string;
  28859. };
  28860. }
  28861. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28862. /** @hidden */
  28863. export var kernelBlurFragment2: {
  28864. name: string;
  28865. shader: string;
  28866. };
  28867. }
  28868. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28869. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28870. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28871. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28872. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28873. /** @hidden */
  28874. export var kernelBlurPixelShader: {
  28875. name: string;
  28876. shader: string;
  28877. };
  28878. }
  28879. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28880. /** @hidden */
  28881. export var kernelBlurVertex: {
  28882. name: string;
  28883. shader: string;
  28884. };
  28885. }
  28886. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28887. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28888. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28889. /** @hidden */
  28890. export var kernelBlurVertexShader: {
  28891. name: string;
  28892. shader: string;
  28893. };
  28894. }
  28895. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28896. import { Vector2 } from "babylonjs/Maths/math.vector";
  28897. import { Nullable } from "babylonjs/types";
  28898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28899. import { Camera } from "babylonjs/Cameras/camera";
  28900. import { Effect } from "babylonjs/Materials/effect";
  28901. import { Engine } from "babylonjs/Engines/engine";
  28902. import "babylonjs/Shaders/kernelBlur.fragment";
  28903. import "babylonjs/Shaders/kernelBlur.vertex";
  28904. import { Scene } from "babylonjs/scene";
  28905. /**
  28906. * The Blur Post Process which blurs an image based on a kernel and direction.
  28907. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28908. */
  28909. export class BlurPostProcess extends PostProcess {
  28910. private blockCompilation;
  28911. protected _kernel: number;
  28912. protected _idealKernel: number;
  28913. protected _packedFloat: boolean;
  28914. private _staticDefines;
  28915. /** The direction in which to blur the image. */
  28916. direction: Vector2;
  28917. /**
  28918. * Sets the length in pixels of the blur sample region
  28919. */
  28920. set kernel(v: number);
  28921. /**
  28922. * Gets the length in pixels of the blur sample region
  28923. */
  28924. get kernel(): number;
  28925. /**
  28926. * Sets wether or not the blur needs to unpack/repack floats
  28927. */
  28928. set packedFloat(v: boolean);
  28929. /**
  28930. * Gets wether or not the blur is unpacking/repacking floats
  28931. */
  28932. get packedFloat(): boolean;
  28933. /**
  28934. * Gets a string identifying the name of the class
  28935. * @returns "BlurPostProcess" string
  28936. */
  28937. getClassName(): string;
  28938. /**
  28939. * Creates a new instance BlurPostProcess
  28940. * @param name The name of the effect.
  28941. * @param direction The direction in which to blur the image.
  28942. * @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.
  28943. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28944. * @param camera The camera to apply the render pass to.
  28945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28946. * @param engine The engine which the post process will be applied. (default: current engine)
  28947. * @param reusable If the post process can be reused on the same frame. (default: false)
  28948. * @param textureType Type of textures used when performing the post process. (default: 0)
  28949. * @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)
  28950. */
  28951. 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);
  28952. /**
  28953. * Updates the effect with the current post process compile time values and recompiles the shader.
  28954. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28955. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28956. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28957. * @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
  28958. * @param onCompiled Called when the shader has been compiled.
  28959. * @param onError Called if there is an error when compiling a shader.
  28960. */
  28961. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28962. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28963. /**
  28964. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28965. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28966. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28967. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28968. * The gaps between physical kernels are compensated for in the weighting of the samples
  28969. * @param idealKernel Ideal blur kernel.
  28970. * @return Nearest best kernel.
  28971. */
  28972. protected _nearestBestKernel(idealKernel: number): number;
  28973. /**
  28974. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28975. * @param x The point on the Gaussian distribution to sample.
  28976. * @return the value of the Gaussian function at x.
  28977. */
  28978. protected _gaussianWeight(x: number): number;
  28979. /**
  28980. * Generates a string that can be used as a floating point number in GLSL.
  28981. * @param x Value to print.
  28982. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28983. * @return GLSL float string.
  28984. */
  28985. protected _glslFloat(x: number, decimalFigures?: number): string;
  28986. /** @hidden */
  28987. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28988. }
  28989. }
  28990. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  28991. import { Scene } from "babylonjs/scene";
  28992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28993. import { Plane } from "babylonjs/Maths/math.plane";
  28994. /**
  28995. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28996. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28997. * You can then easily use it as a reflectionTexture on a flat surface.
  28998. * In case the surface is not a plane, please consider relying on reflection probes.
  28999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29000. */
  29001. export class MirrorTexture extends RenderTargetTexture {
  29002. private scene;
  29003. /**
  29004. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29005. * 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.
  29006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29007. */
  29008. mirrorPlane: Plane;
  29009. /**
  29010. * Define the blur ratio used to blur the reflection if needed.
  29011. */
  29012. set blurRatio(value: number);
  29013. get blurRatio(): number;
  29014. /**
  29015. * Define the adaptive blur kernel used to blur the reflection if needed.
  29016. * This will autocompute the closest best match for the `blurKernel`
  29017. */
  29018. set adaptiveBlurKernel(value: number);
  29019. /**
  29020. * Define the blur kernel used to blur the reflection if needed.
  29021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29022. */
  29023. set blurKernel(value: number);
  29024. /**
  29025. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29027. */
  29028. set blurKernelX(value: number);
  29029. get blurKernelX(): number;
  29030. /**
  29031. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29033. */
  29034. set blurKernelY(value: number);
  29035. get blurKernelY(): number;
  29036. private _autoComputeBlurKernel;
  29037. protected _onRatioRescale(): void;
  29038. private _updateGammaSpace;
  29039. private _imageProcessingConfigChangeObserver;
  29040. private _transformMatrix;
  29041. private _mirrorMatrix;
  29042. private _savedViewMatrix;
  29043. private _blurX;
  29044. private _blurY;
  29045. private _adaptiveBlurKernel;
  29046. private _blurKernelX;
  29047. private _blurKernelY;
  29048. private _blurRatio;
  29049. /**
  29050. * Instantiates a Mirror Texture.
  29051. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29052. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29053. * You can then easily use it as a reflectionTexture on a flat surface.
  29054. * In case the surface is not a plane, please consider relying on reflection probes.
  29055. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29056. * @param name
  29057. * @param size
  29058. * @param scene
  29059. * @param generateMipMaps
  29060. * @param type
  29061. * @param samplingMode
  29062. * @param generateDepthBuffer
  29063. */
  29064. constructor(name: string, size: number | {
  29065. width: number;
  29066. height: number;
  29067. } | {
  29068. ratio: number;
  29069. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29070. private _preparePostProcesses;
  29071. /**
  29072. * Clone the mirror texture.
  29073. * @returns the cloned texture
  29074. */
  29075. clone(): MirrorTexture;
  29076. /**
  29077. * Serialize the texture to a JSON representation you could use in Parse later on
  29078. * @returns the serialized JSON representation
  29079. */
  29080. serialize(): any;
  29081. /**
  29082. * Dispose the texture and release its associated resources.
  29083. */
  29084. dispose(): void;
  29085. }
  29086. }
  29087. declare module "babylonjs/Materials/Textures/texture" {
  29088. import { Observable } from "babylonjs/Misc/observable";
  29089. import { Nullable } from "babylonjs/types";
  29090. import { Matrix } from "babylonjs/Maths/math.vector";
  29091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29092. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29093. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29094. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29095. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29097. import { Scene } from "babylonjs/scene";
  29098. /**
  29099. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29100. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29101. */
  29102. export class Texture extends BaseTexture {
  29103. /**
  29104. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29105. */
  29106. static SerializeBuffers: boolean;
  29107. /** @hidden */
  29108. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29109. /** @hidden */
  29110. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29111. /** @hidden */
  29112. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29113. /** nearest is mag = nearest and min = nearest and mip = linear */
  29114. static readonly NEAREST_SAMPLINGMODE: number;
  29115. /** nearest is mag = nearest and min = nearest and mip = linear */
  29116. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29117. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29118. static readonly BILINEAR_SAMPLINGMODE: number;
  29119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29120. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29121. /** Trilinear is mag = linear and min = linear and mip = linear */
  29122. static readonly TRILINEAR_SAMPLINGMODE: number;
  29123. /** Trilinear is mag = linear and min = linear and mip = linear */
  29124. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29125. /** mag = nearest and min = nearest and mip = nearest */
  29126. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29127. /** mag = nearest and min = linear and mip = nearest */
  29128. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29129. /** mag = nearest and min = linear and mip = linear */
  29130. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29131. /** mag = nearest and min = linear and mip = none */
  29132. static readonly NEAREST_LINEAR: number;
  29133. /** mag = nearest and min = nearest and mip = none */
  29134. static readonly NEAREST_NEAREST: number;
  29135. /** mag = linear and min = nearest and mip = nearest */
  29136. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29137. /** mag = linear and min = nearest and mip = linear */
  29138. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29139. /** mag = linear and min = linear and mip = none */
  29140. static readonly LINEAR_LINEAR: number;
  29141. /** mag = linear and min = nearest and mip = none */
  29142. static readonly LINEAR_NEAREST: number;
  29143. /** Explicit coordinates mode */
  29144. static readonly EXPLICIT_MODE: number;
  29145. /** Spherical coordinates mode */
  29146. static readonly SPHERICAL_MODE: number;
  29147. /** Planar coordinates mode */
  29148. static readonly PLANAR_MODE: number;
  29149. /** Cubic coordinates mode */
  29150. static readonly CUBIC_MODE: number;
  29151. /** Projection coordinates mode */
  29152. static readonly PROJECTION_MODE: number;
  29153. /** Inverse Cubic coordinates mode */
  29154. static readonly SKYBOX_MODE: number;
  29155. /** Inverse Cubic coordinates mode */
  29156. static readonly INVCUBIC_MODE: number;
  29157. /** Equirectangular coordinates mode */
  29158. static readonly EQUIRECTANGULAR_MODE: number;
  29159. /** Equirectangular Fixed coordinates mode */
  29160. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29161. /** Equirectangular Fixed Mirrored coordinates mode */
  29162. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29163. /** Texture is not repeating outside of 0..1 UVs */
  29164. static readonly CLAMP_ADDRESSMODE: number;
  29165. /** Texture is repeating outside of 0..1 UVs */
  29166. static readonly WRAP_ADDRESSMODE: number;
  29167. /** Texture is repeating and mirrored */
  29168. static readonly MIRROR_ADDRESSMODE: number;
  29169. /**
  29170. * 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
  29171. */
  29172. static UseSerializedUrlIfAny: boolean;
  29173. /**
  29174. * Define the url of the texture.
  29175. */
  29176. url: Nullable<string>;
  29177. /**
  29178. * Define an offset on the texture to offset the u coordinates of the UVs
  29179. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29180. */
  29181. uOffset: number;
  29182. /**
  29183. * Define an offset on the texture to offset the v coordinates of the UVs
  29184. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29185. */
  29186. vOffset: number;
  29187. /**
  29188. * Define an offset on the texture to scale the u coordinates of the UVs
  29189. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29190. */
  29191. uScale: number;
  29192. /**
  29193. * Define an offset on the texture to scale the v coordinates of the UVs
  29194. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29195. */
  29196. vScale: number;
  29197. /**
  29198. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29199. * @see https://doc.babylonjs.com/how_to/more_materials
  29200. */
  29201. uAng: number;
  29202. /**
  29203. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29204. * @see https://doc.babylonjs.com/how_to/more_materials
  29205. */
  29206. vAng: number;
  29207. /**
  29208. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29209. * @see https://doc.babylonjs.com/how_to/more_materials
  29210. */
  29211. wAng: number;
  29212. /**
  29213. * Defines the center of rotation (U)
  29214. */
  29215. uRotationCenter: number;
  29216. /**
  29217. * Defines the center of rotation (V)
  29218. */
  29219. vRotationCenter: number;
  29220. /**
  29221. * Defines the center of rotation (W)
  29222. */
  29223. wRotationCenter: number;
  29224. /**
  29225. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29226. */
  29227. homogeneousRotationInUVTransform: boolean;
  29228. /**
  29229. * Are mip maps generated for this texture or not.
  29230. */
  29231. get noMipmap(): boolean;
  29232. /**
  29233. * List of inspectable custom properties (used by the Inspector)
  29234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29235. */
  29236. inspectableCustomProperties: Nullable<IInspectable[]>;
  29237. private _noMipmap;
  29238. /** @hidden */
  29239. _invertY: boolean;
  29240. private _rowGenerationMatrix;
  29241. private _cachedTextureMatrix;
  29242. private _projectionModeMatrix;
  29243. private _t0;
  29244. private _t1;
  29245. private _t2;
  29246. private _cachedUOffset;
  29247. private _cachedVOffset;
  29248. private _cachedUScale;
  29249. private _cachedVScale;
  29250. private _cachedUAng;
  29251. private _cachedVAng;
  29252. private _cachedWAng;
  29253. private _cachedProjectionMatrixId;
  29254. private _cachedURotationCenter;
  29255. private _cachedVRotationCenter;
  29256. private _cachedWRotationCenter;
  29257. private _cachedHomogeneousRotationInUVTransform;
  29258. private _cachedCoordinatesMode;
  29259. /** @hidden */
  29260. protected _initialSamplingMode: number;
  29261. /** @hidden */
  29262. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29263. private _deleteBuffer;
  29264. protected _format: Nullable<number>;
  29265. private _delayedOnLoad;
  29266. private _delayedOnError;
  29267. private _mimeType?;
  29268. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29269. get mimeType(): string | undefined;
  29270. /**
  29271. * Observable triggered once the texture has been loaded.
  29272. */
  29273. onLoadObservable: Observable<Texture>;
  29274. protected _isBlocking: boolean;
  29275. /**
  29276. * Is the texture preventing material to render while loading.
  29277. * If false, a default texture will be used instead of the loading one during the preparation step.
  29278. */
  29279. set isBlocking(value: boolean);
  29280. get isBlocking(): boolean;
  29281. /**
  29282. * Get the current sampling mode associated with the texture.
  29283. */
  29284. get samplingMode(): number;
  29285. /**
  29286. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29287. */
  29288. get invertY(): boolean;
  29289. /**
  29290. * Instantiates a new texture.
  29291. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29292. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29293. * @param url defines the url of the picture to load as a texture
  29294. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29295. * @param noMipmap defines if the texture will require mip maps or not
  29296. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29297. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29298. * @param onLoad defines a callback triggered when the texture has been loaded
  29299. * @param onError defines a callback triggered when an error occurred during the loading session
  29300. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29301. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29302. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29303. * @param mimeType defines an optional mime type information
  29304. */
  29305. 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);
  29306. /**
  29307. * Update the url (and optional buffer) of this texture if url was null during construction.
  29308. * @param url the url of the texture
  29309. * @param buffer the buffer of the texture (defaults to null)
  29310. * @param onLoad callback called when the texture is loaded (defaults to null)
  29311. */
  29312. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29313. /**
  29314. * Finish the loading sequence of a texture flagged as delayed load.
  29315. * @hidden
  29316. */
  29317. delayLoad(): void;
  29318. private _prepareRowForTextureGeneration;
  29319. /**
  29320. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29321. * @returns the transform matrix of the texture.
  29322. */
  29323. getTextureMatrix(uBase?: number): Matrix;
  29324. /**
  29325. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29326. * @returns The reflection texture transform
  29327. */
  29328. getReflectionTextureMatrix(): Matrix;
  29329. /**
  29330. * Clones the texture.
  29331. * @returns the cloned texture
  29332. */
  29333. clone(): Texture;
  29334. /**
  29335. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29336. * @returns The JSON representation of the texture
  29337. */
  29338. serialize(): any;
  29339. /**
  29340. * Get the current class name of the texture useful for serialization or dynamic coding.
  29341. * @returns "Texture"
  29342. */
  29343. getClassName(): string;
  29344. /**
  29345. * Dispose the texture and release its associated resources.
  29346. */
  29347. dispose(): void;
  29348. /**
  29349. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29350. * @param parsedTexture Define the JSON representation of the texture
  29351. * @param scene Define the scene the parsed texture should be instantiated in
  29352. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29353. * @returns The parsed texture if successful
  29354. */
  29355. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29356. /**
  29357. * Creates a texture from its base 64 representation.
  29358. * @param data Define the base64 payload without the data: prefix
  29359. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29360. * @param scene Define the scene the texture should belong to
  29361. * @param noMipmap Forces the texture to not create mip map information if true
  29362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29364. * @param onLoad define a callback triggered when the texture has been loaded
  29365. * @param onError define a callback triggered when an error occurred during the loading session
  29366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29367. * @returns the created texture
  29368. */
  29369. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29370. /**
  29371. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29372. * @param data Define the base64 payload without the data: prefix
  29373. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29374. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29375. * @param scene Define the scene the texture should belong to
  29376. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29377. * @param noMipmap Forces the texture to not create mip map information if true
  29378. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29379. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29380. * @param onLoad define a callback triggered when the texture has been loaded
  29381. * @param onError define a callback triggered when an error occurred during the loading session
  29382. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29383. * @returns the created texture
  29384. */
  29385. 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;
  29386. }
  29387. }
  29388. declare module "babylonjs/PostProcesses/postProcessManager" {
  29389. import { Nullable } from "babylonjs/types";
  29390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29391. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29392. import { Scene } from "babylonjs/scene";
  29393. /**
  29394. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29395. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29396. */
  29397. export class PostProcessManager {
  29398. private _scene;
  29399. private _indexBuffer;
  29400. private _vertexBuffers;
  29401. /**
  29402. * Creates a new instance PostProcess
  29403. * @param scene The scene that the post process is associated with.
  29404. */
  29405. constructor(scene: Scene);
  29406. private _prepareBuffers;
  29407. private _buildIndexBuffer;
  29408. /**
  29409. * Rebuilds the vertex buffers of the manager.
  29410. * @hidden
  29411. */
  29412. _rebuild(): void;
  29413. /**
  29414. * Prepares a frame to be run through a post process.
  29415. * @param sourceTexture The input texture to the post procesess. (default: null)
  29416. * @param postProcesses An array of post processes to be run. (default: null)
  29417. * @returns True if the post processes were able to be run.
  29418. * @hidden
  29419. */
  29420. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29421. /**
  29422. * Manually render a set of post processes to a texture.
  29423. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29424. * @param postProcesses An array of post processes to be run.
  29425. * @param targetTexture The target texture to render to.
  29426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29427. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29428. * @param lodLevel defines which lod of the texture to render to
  29429. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29430. */
  29431. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29432. /**
  29433. * Finalize the result of the output of the postprocesses.
  29434. * @param doNotPresent If true the result will not be displayed to the screen.
  29435. * @param targetTexture The target texture to render to.
  29436. * @param faceIndex The index of the face to bind the target texture to.
  29437. * @param postProcesses The array of post processes to render.
  29438. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29439. * @hidden
  29440. */
  29441. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29442. /**
  29443. * Disposes of the post process manager.
  29444. */
  29445. dispose(): void;
  29446. }
  29447. }
  29448. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29449. import { Observable } from "babylonjs/Misc/observable";
  29450. import { SmartArray } from "babylonjs/Misc/smartArray";
  29451. import { Nullable, Immutable } from "babylonjs/types";
  29452. import { Camera } from "babylonjs/Cameras/camera";
  29453. import { Scene } from "babylonjs/scene";
  29454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29455. import { Color4 } from "babylonjs/Maths/math.color";
  29456. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29458. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29460. import { Texture } from "babylonjs/Materials/Textures/texture";
  29461. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29462. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29463. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29464. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29465. import { Engine } from "babylonjs/Engines/engine";
  29466. /**
  29467. * This Helps creating a texture that will be created from a camera in your scene.
  29468. * It is basically a dynamic texture that could be used to create special effects for instance.
  29469. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29470. */
  29471. export class RenderTargetTexture extends Texture {
  29472. /**
  29473. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29474. */
  29475. static readonly REFRESHRATE_RENDER_ONCE: number;
  29476. /**
  29477. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29478. */
  29479. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29480. /**
  29481. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29482. * the central point of your effect and can save a lot of performances.
  29483. */
  29484. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29485. /**
  29486. * Use this predicate to dynamically define the list of mesh you want to render.
  29487. * If set, the renderList property will be overwritten.
  29488. */
  29489. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29490. private _renderList;
  29491. /**
  29492. * Use this list to define the list of mesh you want to render.
  29493. */
  29494. get renderList(): Nullable<Array<AbstractMesh>>;
  29495. set renderList(value: Nullable<Array<AbstractMesh>>);
  29496. /**
  29497. * Use this function to overload the renderList array at rendering time.
  29498. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29499. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29500. * the cube (if the RTT is a cube, else layerOrFace=0).
  29501. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29502. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29503. * hold dummy elements!
  29504. */
  29505. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29506. private _hookArray;
  29507. /**
  29508. * Define if particles should be rendered in your texture.
  29509. */
  29510. renderParticles: boolean;
  29511. /**
  29512. * Define if sprites should be rendered in your texture.
  29513. */
  29514. renderSprites: boolean;
  29515. /**
  29516. * Define the camera used to render the texture.
  29517. */
  29518. activeCamera: Nullable<Camera>;
  29519. /**
  29520. * Override the mesh isReady function with your own one.
  29521. */
  29522. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29523. /**
  29524. * Override the render function of the texture with your own one.
  29525. */
  29526. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29527. /**
  29528. * Define if camera post processes should be use while rendering the texture.
  29529. */
  29530. useCameraPostProcesses: boolean;
  29531. /**
  29532. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29533. */
  29534. ignoreCameraViewport: boolean;
  29535. private _postProcessManager;
  29536. private _postProcesses;
  29537. private _resizeObserver;
  29538. /**
  29539. * An event triggered when the texture is unbind.
  29540. */
  29541. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29542. /**
  29543. * An event triggered when the texture is unbind.
  29544. */
  29545. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29546. private _onAfterUnbindObserver;
  29547. /**
  29548. * Set a after unbind callback in the texture.
  29549. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29550. */
  29551. set onAfterUnbind(callback: () => void);
  29552. /**
  29553. * An event triggered before rendering the texture
  29554. */
  29555. onBeforeRenderObservable: Observable<number>;
  29556. private _onBeforeRenderObserver;
  29557. /**
  29558. * Set a before render callback in the texture.
  29559. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29560. */
  29561. set onBeforeRender(callback: (faceIndex: number) => void);
  29562. /**
  29563. * An event triggered after rendering the texture
  29564. */
  29565. onAfterRenderObservable: Observable<number>;
  29566. private _onAfterRenderObserver;
  29567. /**
  29568. * Set a after render callback in the texture.
  29569. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29570. */
  29571. set onAfterRender(callback: (faceIndex: number) => void);
  29572. /**
  29573. * An event triggered after the texture clear
  29574. */
  29575. onClearObservable: Observable<Engine>;
  29576. private _onClearObserver;
  29577. /**
  29578. * Set a clear callback in the texture.
  29579. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29580. */
  29581. set onClear(callback: (Engine: Engine) => void);
  29582. /**
  29583. * An event triggered when the texture is resized.
  29584. */
  29585. onResizeObservable: Observable<RenderTargetTexture>;
  29586. /**
  29587. * Define the clear color of the Render Target if it should be different from the scene.
  29588. */
  29589. clearColor: Color4;
  29590. protected _size: number | {
  29591. width: number;
  29592. height: number;
  29593. layers?: number;
  29594. };
  29595. protected _initialSizeParameter: number | {
  29596. width: number;
  29597. height: number;
  29598. } | {
  29599. ratio: number;
  29600. };
  29601. protected _sizeRatio: Nullable<number>;
  29602. /** @hidden */
  29603. _generateMipMaps: boolean;
  29604. protected _renderingManager: RenderingManager;
  29605. /** @hidden */
  29606. _waitingRenderList?: string[];
  29607. protected _doNotChangeAspectRatio: boolean;
  29608. protected _currentRefreshId: number;
  29609. protected _refreshRate: number;
  29610. protected _textureMatrix: Matrix;
  29611. protected _samples: number;
  29612. protected _renderTargetOptions: RenderTargetCreationOptions;
  29613. /**
  29614. * Gets render target creation options that were used.
  29615. */
  29616. get renderTargetOptions(): RenderTargetCreationOptions;
  29617. protected _onRatioRescale(): void;
  29618. /**
  29619. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29620. * It must define where the camera used to render the texture is set
  29621. */
  29622. boundingBoxPosition: Vector3;
  29623. private _boundingBoxSize;
  29624. /**
  29625. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29626. * When defined, the cubemap will switch to local mode
  29627. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29628. * @example https://www.babylonjs-playground.com/#RNASML
  29629. */
  29630. set boundingBoxSize(value: Vector3);
  29631. get boundingBoxSize(): Vector3;
  29632. /**
  29633. * In case the RTT has been created with a depth texture, get the associated
  29634. * depth texture.
  29635. * Otherwise, return null.
  29636. */
  29637. get depthStencilTexture(): Nullable<InternalTexture>;
  29638. /**
  29639. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29640. * or used a shadow, depth texture...
  29641. * @param name The friendly name of the texture
  29642. * @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)
  29643. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29644. * @param generateMipMaps True if mip maps need to be generated after render.
  29645. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29646. * @param type The type of the buffer in the RTT (int, half float, float...)
  29647. * @param isCube True if a cube texture needs to be created
  29648. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29649. * @param generateDepthBuffer True to generate a depth buffer
  29650. * @param generateStencilBuffer True to generate a stencil buffer
  29651. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29652. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29653. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29654. */
  29655. constructor(name: string, size: number | {
  29656. width: number;
  29657. height: number;
  29658. layers?: number;
  29659. } | {
  29660. ratio: number;
  29661. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29662. /**
  29663. * Creates a depth stencil texture.
  29664. * This is only available in WebGL 2 or with the depth texture extension available.
  29665. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29666. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29667. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29668. */
  29669. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29670. private _processSizeParameter;
  29671. /**
  29672. * Define the number of samples to use in case of MSAA.
  29673. * It defaults to one meaning no MSAA has been enabled.
  29674. */
  29675. get samples(): number;
  29676. set samples(value: number);
  29677. /**
  29678. * Resets the refresh counter of the texture and start bak from scratch.
  29679. * Could be useful to regenerate the texture if it is setup to render only once.
  29680. */
  29681. resetRefreshCounter(): void;
  29682. /**
  29683. * Define the refresh rate of the texture or the rendering frequency.
  29684. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29685. */
  29686. get refreshRate(): number;
  29687. set refreshRate(value: number);
  29688. /**
  29689. * Adds a post process to the render target rendering passes.
  29690. * @param postProcess define the post process to add
  29691. */
  29692. addPostProcess(postProcess: PostProcess): void;
  29693. /**
  29694. * Clear all the post processes attached to the render target
  29695. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29696. */
  29697. clearPostProcesses(dispose?: boolean): void;
  29698. /**
  29699. * Remove one of the post process from the list of attached post processes to the texture
  29700. * @param postProcess define the post process to remove from the list
  29701. */
  29702. removePostProcess(postProcess: PostProcess): void;
  29703. /** @hidden */
  29704. _shouldRender(): boolean;
  29705. /**
  29706. * Gets the actual render size of the texture.
  29707. * @returns the width of the render size
  29708. */
  29709. getRenderSize(): number;
  29710. /**
  29711. * Gets the actual render width of the texture.
  29712. * @returns the width of the render size
  29713. */
  29714. getRenderWidth(): number;
  29715. /**
  29716. * Gets the actual render height of the texture.
  29717. * @returns the height of the render size
  29718. */
  29719. getRenderHeight(): number;
  29720. /**
  29721. * Gets the actual number of layers of the texture.
  29722. * @returns the number of layers
  29723. */
  29724. getRenderLayers(): number;
  29725. /**
  29726. * Get if the texture can be rescaled or not.
  29727. */
  29728. get canRescale(): boolean;
  29729. /**
  29730. * Resize the texture using a ratio.
  29731. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29732. */
  29733. scale(ratio: number): void;
  29734. /**
  29735. * Get the texture reflection matrix used to rotate/transform the reflection.
  29736. * @returns the reflection matrix
  29737. */
  29738. getReflectionTextureMatrix(): Matrix;
  29739. /**
  29740. * Resize the texture to a new desired size.
  29741. * Be carrefull as it will recreate all the data in the new texture.
  29742. * @param size Define the new size. It can be:
  29743. * - a number for squared texture,
  29744. * - an object containing { width: number, height: number }
  29745. * - or an object containing a ratio { ratio: number }
  29746. */
  29747. resize(size: number | {
  29748. width: number;
  29749. height: number;
  29750. } | {
  29751. ratio: number;
  29752. }): void;
  29753. private _defaultRenderListPrepared;
  29754. /**
  29755. * Renders all the objects from the render list into the texture.
  29756. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29757. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29758. */
  29759. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29760. private _bestReflectionRenderTargetDimension;
  29761. private _prepareRenderingManager;
  29762. /**
  29763. * @hidden
  29764. * @param faceIndex face index to bind to if this is a cubetexture
  29765. * @param layer defines the index of the texture to bind in the array
  29766. */
  29767. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29768. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29769. private renderToTarget;
  29770. /**
  29771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29772. * This allowed control for front to back rendering or reversly depending of the special needs.
  29773. *
  29774. * @param renderingGroupId The rendering group id corresponding to its index
  29775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29778. */
  29779. 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;
  29780. /**
  29781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29782. *
  29783. * @param renderingGroupId The rendering group id corresponding to its index
  29784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29785. */
  29786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29787. /**
  29788. * Clones the texture.
  29789. * @returns the cloned texture
  29790. */
  29791. clone(): RenderTargetTexture;
  29792. /**
  29793. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29794. * @returns The JSON representation of the texture
  29795. */
  29796. serialize(): any;
  29797. /**
  29798. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29799. */
  29800. disposeFramebufferObjects(): void;
  29801. /**
  29802. * Dispose the texture and release its associated resources.
  29803. */
  29804. dispose(): void;
  29805. /** @hidden */
  29806. _rebuild(): void;
  29807. /**
  29808. * Clear the info related to rendering groups preventing retention point in material dispose.
  29809. */
  29810. freeRenderingGroups(): void;
  29811. /**
  29812. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29813. * @returns the view count
  29814. */
  29815. getViewCount(): number;
  29816. }
  29817. }
  29818. declare module "babylonjs/Misc/guid" {
  29819. /**
  29820. * Class used to manipulate GUIDs
  29821. */
  29822. export class GUID {
  29823. /**
  29824. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29825. * Be aware Math.random() could cause collisions, but:
  29826. * "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"
  29827. * @returns a pseudo random id
  29828. */
  29829. static RandomId(): string;
  29830. }
  29831. }
  29832. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29833. import { Nullable } from "babylonjs/types";
  29834. import { Scene } from "babylonjs/scene";
  29835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29836. import { Material } from "babylonjs/Materials/material";
  29837. import { Effect } from "babylonjs/Materials/effect";
  29838. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29839. /**
  29840. * Options to be used when creating a shadow depth material
  29841. */
  29842. export interface IIOptionShadowDepthMaterial {
  29843. /** Variables in the vertex shader code that need to have their names remapped.
  29844. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29845. * "var_name" should be either: worldPos or vNormalW
  29846. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29847. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29848. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29849. */
  29850. remappedVariables?: string[];
  29851. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29852. standalone?: boolean;
  29853. }
  29854. /**
  29855. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29856. */
  29857. export class ShadowDepthWrapper {
  29858. private _scene;
  29859. private _options?;
  29860. private _baseMaterial;
  29861. private _onEffectCreatedObserver;
  29862. private _subMeshToEffect;
  29863. private _subMeshToDepthEffect;
  29864. private _meshes;
  29865. /** @hidden */
  29866. _matriceNames: any;
  29867. /** Gets the standalone status of the wrapper */
  29868. get standalone(): boolean;
  29869. /** Gets the base material the wrapper is built upon */
  29870. get baseMaterial(): Material;
  29871. /**
  29872. * Instantiate a new shadow depth wrapper.
  29873. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29874. * generate the shadow depth map. For more information, please refer to the documentation:
  29875. * https://doc.babylonjs.com/babylon101/shadows
  29876. * @param baseMaterial Material to wrap
  29877. * @param scene Define the scene the material belongs to
  29878. * @param options Options used to create the wrapper
  29879. */
  29880. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29881. /**
  29882. * Gets the effect to use to generate the depth map
  29883. * @param subMesh subMesh to get the effect for
  29884. * @param shadowGenerator shadow generator to get the effect for
  29885. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29886. */
  29887. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29888. /**
  29889. * Specifies that the submesh is ready to be used for depth rendering
  29890. * @param subMesh submesh to check
  29891. * @param defines the list of defines to take into account when checking the effect
  29892. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29893. * @param useInstances specifies that instances should be used
  29894. * @returns a boolean indicating that the submesh is ready or not
  29895. */
  29896. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29897. /**
  29898. * Disposes the resources
  29899. */
  29900. dispose(): void;
  29901. private _makeEffect;
  29902. }
  29903. }
  29904. declare module "babylonjs/Materials/material" {
  29905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29906. import { SmartArray } from "babylonjs/Misc/smartArray";
  29907. import { Observable } from "babylonjs/Misc/observable";
  29908. import { Nullable } from "babylonjs/types";
  29909. import { Scene } from "babylonjs/scene";
  29910. import { Matrix } from "babylonjs/Maths/math.vector";
  29911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29913. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29914. import { Effect } from "babylonjs/Materials/effect";
  29915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29917. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29918. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29919. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29920. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29921. import { Mesh } from "babylonjs/Meshes/mesh";
  29922. import { Animation } from "babylonjs/Animations/animation";
  29923. /**
  29924. * Options for compiling materials.
  29925. */
  29926. export interface IMaterialCompilationOptions {
  29927. /**
  29928. * Defines whether clip planes are enabled.
  29929. */
  29930. clipPlane: boolean;
  29931. /**
  29932. * Defines whether instances are enabled.
  29933. */
  29934. useInstances: boolean;
  29935. }
  29936. /**
  29937. * Options passed when calling customShaderNameResolve
  29938. */
  29939. export interface ICustomShaderNameResolveOptions {
  29940. /**
  29941. * 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
  29942. */
  29943. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29944. }
  29945. /**
  29946. * Base class for the main features of a material in Babylon.js
  29947. */
  29948. export class Material implements IAnimatable {
  29949. /**
  29950. * Returns the triangle fill mode
  29951. */
  29952. static readonly TriangleFillMode: number;
  29953. /**
  29954. * Returns the wireframe mode
  29955. */
  29956. static readonly WireFrameFillMode: number;
  29957. /**
  29958. * Returns the point fill mode
  29959. */
  29960. static readonly PointFillMode: number;
  29961. /**
  29962. * Returns the point list draw mode
  29963. */
  29964. static readonly PointListDrawMode: number;
  29965. /**
  29966. * Returns the line list draw mode
  29967. */
  29968. static readonly LineListDrawMode: number;
  29969. /**
  29970. * Returns the line loop draw mode
  29971. */
  29972. static readonly LineLoopDrawMode: number;
  29973. /**
  29974. * Returns the line strip draw mode
  29975. */
  29976. static readonly LineStripDrawMode: number;
  29977. /**
  29978. * Returns the triangle strip draw mode
  29979. */
  29980. static readonly TriangleStripDrawMode: number;
  29981. /**
  29982. * Returns the triangle fan draw mode
  29983. */
  29984. static readonly TriangleFanDrawMode: number;
  29985. /**
  29986. * Stores the clock-wise side orientation
  29987. */
  29988. static readonly ClockWiseSideOrientation: number;
  29989. /**
  29990. * Stores the counter clock-wise side orientation
  29991. */
  29992. static readonly CounterClockWiseSideOrientation: number;
  29993. /**
  29994. * The dirty texture flag value
  29995. */
  29996. static readonly TextureDirtyFlag: number;
  29997. /**
  29998. * The dirty light flag value
  29999. */
  30000. static readonly LightDirtyFlag: number;
  30001. /**
  30002. * The dirty fresnel flag value
  30003. */
  30004. static readonly FresnelDirtyFlag: number;
  30005. /**
  30006. * The dirty attribute flag value
  30007. */
  30008. static readonly AttributesDirtyFlag: number;
  30009. /**
  30010. * The dirty misc flag value
  30011. */
  30012. static readonly MiscDirtyFlag: number;
  30013. /**
  30014. * The dirty prepass flag value
  30015. */
  30016. static readonly PrePassDirtyFlag: number;
  30017. /**
  30018. * The all dirty flag value
  30019. */
  30020. static readonly AllDirtyFlag: number;
  30021. /**
  30022. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30023. */
  30024. static readonly MATERIAL_OPAQUE: number;
  30025. /**
  30026. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30027. */
  30028. static readonly MATERIAL_ALPHATEST: number;
  30029. /**
  30030. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30031. */
  30032. static readonly MATERIAL_ALPHABLEND: number;
  30033. /**
  30034. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30035. * They are also discarded below the alpha cutoff threshold to improve performances.
  30036. */
  30037. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30038. /**
  30039. * The Whiteout method is used to blend normals.
  30040. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30041. */
  30042. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30043. /**
  30044. * The Reoriented Normal Mapping method is used to blend normals.
  30045. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30046. */
  30047. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30048. /**
  30049. * Custom callback helping to override the default shader used in the material.
  30050. */
  30051. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30052. /**
  30053. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30054. */
  30055. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30056. /**
  30057. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30058. * This means that the material can keep using a previous shader while a new one is being compiled.
  30059. * This is mostly used when shader parallel compilation is supported (true by default)
  30060. */
  30061. allowShaderHotSwapping: boolean;
  30062. /**
  30063. * The ID of the material
  30064. */
  30065. id: string;
  30066. /**
  30067. * Gets or sets the unique id of the material
  30068. */
  30069. uniqueId: number;
  30070. /**
  30071. * The name of the material
  30072. */
  30073. name: string;
  30074. /**
  30075. * Gets or sets user defined metadata
  30076. */
  30077. metadata: any;
  30078. /**
  30079. * For internal use only. Please do not use.
  30080. */
  30081. reservedDataStore: any;
  30082. /**
  30083. * Specifies if the ready state should be checked on each call
  30084. */
  30085. checkReadyOnEveryCall: boolean;
  30086. /**
  30087. * Specifies if the ready state should be checked once
  30088. */
  30089. checkReadyOnlyOnce: boolean;
  30090. /**
  30091. * The state of the material
  30092. */
  30093. state: string;
  30094. /**
  30095. * If the material can be rendered to several textures with MRT extension
  30096. */
  30097. get canRenderToMRT(): boolean;
  30098. /**
  30099. * The alpha value of the material
  30100. */
  30101. protected _alpha: number;
  30102. /**
  30103. * List of inspectable custom properties (used by the Inspector)
  30104. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30105. */
  30106. inspectableCustomProperties: IInspectable[];
  30107. /**
  30108. * Sets the alpha value of the material
  30109. */
  30110. set alpha(value: number);
  30111. /**
  30112. * Gets the alpha value of the material
  30113. */
  30114. get alpha(): number;
  30115. /**
  30116. * Specifies if back face culling is enabled
  30117. */
  30118. protected _backFaceCulling: boolean;
  30119. /**
  30120. * Sets the back-face culling state
  30121. */
  30122. set backFaceCulling(value: boolean);
  30123. /**
  30124. * Gets the back-face culling state
  30125. */
  30126. get backFaceCulling(): boolean;
  30127. /**
  30128. * Stores the value for side orientation
  30129. */
  30130. sideOrientation: number;
  30131. /**
  30132. * Callback triggered when the material is compiled
  30133. */
  30134. onCompiled: Nullable<(effect: Effect) => void>;
  30135. /**
  30136. * Callback triggered when an error occurs
  30137. */
  30138. onError: Nullable<(effect: Effect, errors: string) => void>;
  30139. /**
  30140. * Callback triggered to get the render target textures
  30141. */
  30142. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30143. /**
  30144. * Gets a boolean indicating that current material needs to register RTT
  30145. */
  30146. get hasRenderTargetTextures(): boolean;
  30147. /**
  30148. * Specifies if the material should be serialized
  30149. */
  30150. doNotSerialize: boolean;
  30151. /**
  30152. * @hidden
  30153. */
  30154. _storeEffectOnSubMeshes: boolean;
  30155. /**
  30156. * Stores the animations for the material
  30157. */
  30158. animations: Nullable<Array<Animation>>;
  30159. /**
  30160. * An event triggered when the material is disposed
  30161. */
  30162. onDisposeObservable: Observable<Material>;
  30163. /**
  30164. * An observer which watches for dispose events
  30165. */
  30166. private _onDisposeObserver;
  30167. private _onUnBindObservable;
  30168. /**
  30169. * Called during a dispose event
  30170. */
  30171. set onDispose(callback: () => void);
  30172. private _onBindObservable;
  30173. /**
  30174. * An event triggered when the material is bound
  30175. */
  30176. get onBindObservable(): Observable<AbstractMesh>;
  30177. /**
  30178. * An observer which watches for bind events
  30179. */
  30180. private _onBindObserver;
  30181. /**
  30182. * Called during a bind event
  30183. */
  30184. set onBind(callback: (Mesh: AbstractMesh) => void);
  30185. /**
  30186. * An event triggered when the material is unbound
  30187. */
  30188. get onUnBindObservable(): Observable<Material>;
  30189. protected _onEffectCreatedObservable: Nullable<Observable<{
  30190. effect: Effect;
  30191. subMesh: Nullable<SubMesh>;
  30192. }>>;
  30193. /**
  30194. * An event triggered when the effect is (re)created
  30195. */
  30196. get onEffectCreatedObservable(): Observable<{
  30197. effect: Effect;
  30198. subMesh: Nullable<SubMesh>;
  30199. }>;
  30200. /**
  30201. * Stores the value of the alpha mode
  30202. */
  30203. private _alphaMode;
  30204. /**
  30205. * Sets the value of the alpha mode.
  30206. *
  30207. * | Value | Type | Description |
  30208. * | --- | --- | --- |
  30209. * | 0 | ALPHA_DISABLE | |
  30210. * | 1 | ALPHA_ADD | |
  30211. * | 2 | ALPHA_COMBINE | |
  30212. * | 3 | ALPHA_SUBTRACT | |
  30213. * | 4 | ALPHA_MULTIPLY | |
  30214. * | 5 | ALPHA_MAXIMIZED | |
  30215. * | 6 | ALPHA_ONEONE | |
  30216. * | 7 | ALPHA_PREMULTIPLIED | |
  30217. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30218. * | 9 | ALPHA_INTERPOLATE | |
  30219. * | 10 | ALPHA_SCREENMODE | |
  30220. *
  30221. */
  30222. set alphaMode(value: number);
  30223. /**
  30224. * Gets the value of the alpha mode
  30225. */
  30226. get alphaMode(): number;
  30227. /**
  30228. * Stores the state of the need depth pre-pass value
  30229. */
  30230. private _needDepthPrePass;
  30231. /**
  30232. * Sets the need depth pre-pass value
  30233. */
  30234. set needDepthPrePass(value: boolean);
  30235. /**
  30236. * Gets the depth pre-pass value
  30237. */
  30238. get needDepthPrePass(): boolean;
  30239. /**
  30240. * Specifies if depth writing should be disabled
  30241. */
  30242. disableDepthWrite: boolean;
  30243. /**
  30244. * Specifies if color writing should be disabled
  30245. */
  30246. disableColorWrite: boolean;
  30247. /**
  30248. * Specifies if depth writing should be forced
  30249. */
  30250. forceDepthWrite: boolean;
  30251. /**
  30252. * Specifies the depth function that should be used. 0 means the default engine function
  30253. */
  30254. depthFunction: number;
  30255. /**
  30256. * Specifies if there should be a separate pass for culling
  30257. */
  30258. separateCullingPass: boolean;
  30259. /**
  30260. * Stores the state specifing if fog should be enabled
  30261. */
  30262. private _fogEnabled;
  30263. /**
  30264. * Sets the state for enabling fog
  30265. */
  30266. set fogEnabled(value: boolean);
  30267. /**
  30268. * Gets the value of the fog enabled state
  30269. */
  30270. get fogEnabled(): boolean;
  30271. /**
  30272. * Stores the size of points
  30273. */
  30274. pointSize: number;
  30275. /**
  30276. * Stores the z offset value
  30277. */
  30278. zOffset: number;
  30279. get wireframe(): boolean;
  30280. /**
  30281. * Sets the state of wireframe mode
  30282. */
  30283. set wireframe(value: boolean);
  30284. /**
  30285. * Gets the value specifying if point clouds are enabled
  30286. */
  30287. get pointsCloud(): boolean;
  30288. /**
  30289. * Sets the state of point cloud mode
  30290. */
  30291. set pointsCloud(value: boolean);
  30292. /**
  30293. * Gets the material fill mode
  30294. */
  30295. get fillMode(): number;
  30296. /**
  30297. * Sets the material fill mode
  30298. */
  30299. set fillMode(value: number);
  30300. /**
  30301. * @hidden
  30302. * Stores the effects for the material
  30303. */
  30304. _effect: Nullable<Effect>;
  30305. /**
  30306. * Specifies if uniform buffers should be used
  30307. */
  30308. private _useUBO;
  30309. /**
  30310. * Stores a reference to the scene
  30311. */
  30312. private _scene;
  30313. /**
  30314. * Stores the fill mode state
  30315. */
  30316. private _fillMode;
  30317. /**
  30318. * Specifies if the depth write state should be cached
  30319. */
  30320. private _cachedDepthWriteState;
  30321. /**
  30322. * Specifies if the color write state should be cached
  30323. */
  30324. private _cachedColorWriteState;
  30325. /**
  30326. * Specifies if the depth function state should be cached
  30327. */
  30328. private _cachedDepthFunctionState;
  30329. /**
  30330. * Stores the uniform buffer
  30331. */
  30332. protected _uniformBuffer: UniformBuffer;
  30333. /** @hidden */
  30334. _indexInSceneMaterialArray: number;
  30335. /** @hidden */
  30336. meshMap: Nullable<{
  30337. [id: string]: AbstractMesh | undefined;
  30338. }>;
  30339. /**
  30340. * Creates a material instance
  30341. * @param name defines the name of the material
  30342. * @param scene defines the scene to reference
  30343. * @param doNotAdd specifies if the material should be added to the scene
  30344. */
  30345. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30346. /**
  30347. * Returns a string representation of the current material
  30348. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30349. * @returns a string with material information
  30350. */
  30351. toString(fullDetails?: boolean): string;
  30352. /**
  30353. * Gets the class name of the material
  30354. * @returns a string with the class name of the material
  30355. */
  30356. getClassName(): string;
  30357. /**
  30358. * Specifies if updates for the material been locked
  30359. */
  30360. get isFrozen(): boolean;
  30361. /**
  30362. * Locks updates for the material
  30363. */
  30364. freeze(): void;
  30365. /**
  30366. * Unlocks updates for the material
  30367. */
  30368. unfreeze(): void;
  30369. /**
  30370. * Specifies if the material is ready to be used
  30371. * @param mesh defines the mesh to check
  30372. * @param useInstances specifies if instances should be used
  30373. * @returns a boolean indicating if the material is ready to be used
  30374. */
  30375. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30376. /**
  30377. * Specifies that the submesh is ready to be used
  30378. * @param mesh defines the mesh to check
  30379. * @param subMesh defines which submesh to check
  30380. * @param useInstances specifies that instances should be used
  30381. * @returns a boolean indicating that the submesh is ready or not
  30382. */
  30383. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30384. /**
  30385. * Returns the material effect
  30386. * @returns the effect associated with the material
  30387. */
  30388. getEffect(): Nullable<Effect>;
  30389. /**
  30390. * Returns the current scene
  30391. * @returns a Scene
  30392. */
  30393. getScene(): Scene;
  30394. /**
  30395. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30396. */
  30397. protected _forceAlphaTest: boolean;
  30398. /**
  30399. * The transparency mode of the material.
  30400. */
  30401. protected _transparencyMode: Nullable<number>;
  30402. /**
  30403. * Gets the current transparency mode.
  30404. */
  30405. get transparencyMode(): Nullable<number>;
  30406. /**
  30407. * Sets the transparency mode of the material.
  30408. *
  30409. * | Value | Type | Description |
  30410. * | ----- | ----------------------------------- | ----------- |
  30411. * | 0 | OPAQUE | |
  30412. * | 1 | ALPHATEST | |
  30413. * | 2 | ALPHABLEND | |
  30414. * | 3 | ALPHATESTANDBLEND | |
  30415. *
  30416. */
  30417. set transparencyMode(value: Nullable<number>);
  30418. /**
  30419. * Returns true if alpha blending should be disabled.
  30420. */
  30421. protected get _disableAlphaBlending(): boolean;
  30422. /**
  30423. * Specifies whether or not this material should be rendered in alpha blend mode.
  30424. * @returns a boolean specifying if alpha blending is needed
  30425. */
  30426. needAlphaBlending(): boolean;
  30427. /**
  30428. * Specifies if the mesh will require alpha blending
  30429. * @param mesh defines the mesh to check
  30430. * @returns a boolean specifying if alpha blending is needed for the mesh
  30431. */
  30432. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30433. /**
  30434. * Specifies whether or not this material should be rendered in alpha test mode.
  30435. * @returns a boolean specifying if an alpha test is needed.
  30436. */
  30437. needAlphaTesting(): boolean;
  30438. /**
  30439. * Specifies if material alpha testing should be turned on for the mesh
  30440. * @param mesh defines the mesh to check
  30441. */
  30442. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30443. /**
  30444. * Gets the texture used for the alpha test
  30445. * @returns the texture to use for alpha testing
  30446. */
  30447. getAlphaTestTexture(): Nullable<BaseTexture>;
  30448. /**
  30449. * Marks the material to indicate that it needs to be re-calculated
  30450. */
  30451. markDirty(): void;
  30452. /** @hidden */
  30453. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30454. /**
  30455. * Binds the material to the mesh
  30456. * @param world defines the world transformation matrix
  30457. * @param mesh defines the mesh to bind the material to
  30458. */
  30459. bind(world: Matrix, mesh?: Mesh): void;
  30460. /**
  30461. * Binds the submesh to the material
  30462. * @param world defines the world transformation matrix
  30463. * @param mesh defines the mesh containing the submesh
  30464. * @param subMesh defines the submesh to bind the material to
  30465. */
  30466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30467. /**
  30468. * Binds the world matrix to the material
  30469. * @param world defines the world transformation matrix
  30470. */
  30471. bindOnlyWorldMatrix(world: Matrix): void;
  30472. /**
  30473. * Binds the scene's uniform buffer to the effect.
  30474. * @param effect defines the effect to bind to the scene uniform buffer
  30475. * @param sceneUbo defines the uniform buffer storing scene data
  30476. */
  30477. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30478. /**
  30479. * Binds the view matrix to the effect
  30480. * @param effect defines the effect to bind the view matrix to
  30481. */
  30482. bindView(effect: Effect): void;
  30483. /**
  30484. * Binds the view projection matrix to the effect
  30485. * @param effect defines the effect to bind the view projection matrix to
  30486. */
  30487. bindViewProjection(effect: Effect): void;
  30488. /**
  30489. * Processes to execute after binding the material to a mesh
  30490. * @param mesh defines the rendered mesh
  30491. */
  30492. protected _afterBind(mesh?: Mesh): void;
  30493. /**
  30494. * Unbinds the material from the mesh
  30495. */
  30496. unbind(): void;
  30497. /**
  30498. * Gets the active textures from the material
  30499. * @returns an array of textures
  30500. */
  30501. getActiveTextures(): BaseTexture[];
  30502. /**
  30503. * Specifies if the material uses a texture
  30504. * @param texture defines the texture to check against the material
  30505. * @returns a boolean specifying if the material uses the texture
  30506. */
  30507. hasTexture(texture: BaseTexture): boolean;
  30508. /**
  30509. * Makes a duplicate of the material, and gives it a new name
  30510. * @param name defines the new name for the duplicated material
  30511. * @returns the cloned material
  30512. */
  30513. clone(name: string): Nullable<Material>;
  30514. /**
  30515. * Gets the meshes bound to the material
  30516. * @returns an array of meshes bound to the material
  30517. */
  30518. getBindedMeshes(): AbstractMesh[];
  30519. /**
  30520. * Force shader compilation
  30521. * @param mesh defines the mesh associated with this material
  30522. * @param onCompiled defines a function to execute once the material is compiled
  30523. * @param options defines the options to configure the compilation
  30524. * @param onError defines a function to execute if the material fails compiling
  30525. */
  30526. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30527. /**
  30528. * Force shader compilation
  30529. * @param mesh defines the mesh that will use this material
  30530. * @param options defines additional options for compiling the shaders
  30531. * @returns a promise that resolves when the compilation completes
  30532. */
  30533. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30534. private static readonly _AllDirtyCallBack;
  30535. private static readonly _ImageProcessingDirtyCallBack;
  30536. private static readonly _TextureDirtyCallBack;
  30537. private static readonly _FresnelDirtyCallBack;
  30538. private static readonly _MiscDirtyCallBack;
  30539. private static readonly _PrePassDirtyCallBack;
  30540. private static readonly _LightsDirtyCallBack;
  30541. private static readonly _AttributeDirtyCallBack;
  30542. private static _FresnelAndMiscDirtyCallBack;
  30543. private static _TextureAndMiscDirtyCallBack;
  30544. private static readonly _DirtyCallbackArray;
  30545. private static readonly _RunDirtyCallBacks;
  30546. /**
  30547. * Marks a define in the material to indicate that it needs to be re-computed
  30548. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30549. */
  30550. markAsDirty(flag: number): void;
  30551. /**
  30552. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30553. * @param func defines a function which checks material defines against the submeshes
  30554. */
  30555. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30556. /**
  30557. * Indicates that the scene should check if the rendering now needs a prepass
  30558. */
  30559. protected _markScenePrePassDirty(): void;
  30560. /**
  30561. * Indicates that we need to re-calculated for all submeshes
  30562. */
  30563. protected _markAllSubMeshesAsAllDirty(): void;
  30564. /**
  30565. * Indicates that image processing needs to be re-calculated for all submeshes
  30566. */
  30567. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30568. /**
  30569. * Indicates that textures need to be re-calculated for all submeshes
  30570. */
  30571. protected _markAllSubMeshesAsTexturesDirty(): void;
  30572. /**
  30573. * Indicates that fresnel needs to be re-calculated for all submeshes
  30574. */
  30575. protected _markAllSubMeshesAsFresnelDirty(): void;
  30576. /**
  30577. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30578. */
  30579. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30580. /**
  30581. * Indicates that lights need to be re-calculated for all submeshes
  30582. */
  30583. protected _markAllSubMeshesAsLightsDirty(): void;
  30584. /**
  30585. * Indicates that attributes need to be re-calculated for all submeshes
  30586. */
  30587. protected _markAllSubMeshesAsAttributesDirty(): void;
  30588. /**
  30589. * Indicates that misc needs to be re-calculated for all submeshes
  30590. */
  30591. protected _markAllSubMeshesAsMiscDirty(): void;
  30592. /**
  30593. * Indicates that prepass needs to be re-calculated for all submeshes
  30594. */
  30595. protected _markAllSubMeshesAsPrePassDirty(): void;
  30596. /**
  30597. * Indicates that textures and misc need to be re-calculated for all submeshes
  30598. */
  30599. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30600. /**
  30601. * Sets the required values to the prepass renderer.
  30602. * @param prePassRenderer defines the prepass renderer to setup.
  30603. * @returns true if the pre pass is needed.
  30604. */
  30605. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30606. /**
  30607. * Disposes the material
  30608. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30609. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30610. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30611. */
  30612. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30613. /** @hidden */
  30614. private releaseVertexArrayObject;
  30615. /**
  30616. * Serializes this material
  30617. * @returns the serialized material object
  30618. */
  30619. serialize(): any;
  30620. /**
  30621. * Creates a material from parsed material data
  30622. * @param parsedMaterial defines parsed material data
  30623. * @param scene defines the hosting scene
  30624. * @param rootUrl defines the root URL to use to load textures
  30625. * @returns a new material
  30626. */
  30627. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30628. }
  30629. }
  30630. declare module "babylonjs/Materials/multiMaterial" {
  30631. import { Nullable } from "babylonjs/types";
  30632. import { Scene } from "babylonjs/scene";
  30633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30634. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30636. import { Material } from "babylonjs/Materials/material";
  30637. /**
  30638. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30639. * separate meshes. This can be use to improve performances.
  30640. * @see https://doc.babylonjs.com/how_to/multi_materials
  30641. */
  30642. export class MultiMaterial extends Material {
  30643. private _subMaterials;
  30644. /**
  30645. * Gets or Sets the list of Materials used within the multi material.
  30646. * They need to be ordered according to the submeshes order in the associated mesh
  30647. */
  30648. get subMaterials(): Nullable<Material>[];
  30649. set subMaterials(value: Nullable<Material>[]);
  30650. /**
  30651. * Function used to align with Node.getChildren()
  30652. * @returns the list of Materials used within the multi material
  30653. */
  30654. getChildren(): Nullable<Material>[];
  30655. /**
  30656. * Instantiates a new Multi Material
  30657. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30658. * separate meshes. This can be use to improve performances.
  30659. * @see https://doc.babylonjs.com/how_to/multi_materials
  30660. * @param name Define the name in the scene
  30661. * @param scene Define the scene the material belongs to
  30662. */
  30663. constructor(name: string, scene: Scene);
  30664. private _hookArray;
  30665. /**
  30666. * Get one of the submaterial by its index in the submaterials array
  30667. * @param index The index to look the sub material at
  30668. * @returns The Material if the index has been defined
  30669. */
  30670. getSubMaterial(index: number): Nullable<Material>;
  30671. /**
  30672. * Get the list of active textures for the whole sub materials list.
  30673. * @returns All the textures that will be used during the rendering
  30674. */
  30675. getActiveTextures(): BaseTexture[];
  30676. /**
  30677. * Gets the current class name of the material e.g. "MultiMaterial"
  30678. * Mainly use in serialization.
  30679. * @returns the class name
  30680. */
  30681. getClassName(): string;
  30682. /**
  30683. * Checks if the material is ready to render the requested sub mesh
  30684. * @param mesh Define the mesh the submesh belongs to
  30685. * @param subMesh Define the sub mesh to look readyness for
  30686. * @param useInstances Define whether or not the material is used with instances
  30687. * @returns true if ready, otherwise false
  30688. */
  30689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30690. /**
  30691. * Clones the current material and its related sub materials
  30692. * @param name Define the name of the newly cloned material
  30693. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30694. * @returns the cloned material
  30695. */
  30696. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30697. /**
  30698. * Serializes the materials into a JSON representation.
  30699. * @returns the JSON representation
  30700. */
  30701. serialize(): any;
  30702. /**
  30703. * Dispose the material and release its associated resources
  30704. * @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)
  30705. * @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)
  30706. * @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)
  30707. */
  30708. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30709. /**
  30710. * Creates a MultiMaterial from parsed MultiMaterial data.
  30711. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30712. * @param scene defines the hosting scene
  30713. * @returns a new MultiMaterial
  30714. */
  30715. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30716. }
  30717. }
  30718. declare module "babylonjs/Meshes/subMesh" {
  30719. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30720. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30721. import { Engine } from "babylonjs/Engines/engine";
  30722. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30723. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30724. import { Effect } from "babylonjs/Materials/effect";
  30725. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30726. import { Plane } from "babylonjs/Maths/math.plane";
  30727. import { Collider } from "babylonjs/Collisions/collider";
  30728. import { Material } from "babylonjs/Materials/material";
  30729. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30731. import { Mesh } from "babylonjs/Meshes/mesh";
  30732. import { Ray } from "babylonjs/Culling/ray";
  30733. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30734. /**
  30735. * Defines a subdivision inside a mesh
  30736. */
  30737. export class SubMesh implements ICullable {
  30738. /** the material index to use */
  30739. materialIndex: number;
  30740. /** vertex index start */
  30741. verticesStart: number;
  30742. /** vertices count */
  30743. verticesCount: number;
  30744. /** index start */
  30745. indexStart: number;
  30746. /** indices count */
  30747. indexCount: number;
  30748. /** @hidden */
  30749. _materialDefines: Nullable<MaterialDefines>;
  30750. /** @hidden */
  30751. _materialEffect: Nullable<Effect>;
  30752. /** @hidden */
  30753. _effectOverride: Nullable<Effect>;
  30754. /**
  30755. * Gets material defines used by the effect associated to the sub mesh
  30756. */
  30757. get materialDefines(): Nullable<MaterialDefines>;
  30758. /**
  30759. * Sets material defines used by the effect associated to the sub mesh
  30760. */
  30761. set materialDefines(defines: Nullable<MaterialDefines>);
  30762. /**
  30763. * Gets associated effect
  30764. */
  30765. get effect(): Nullable<Effect>;
  30766. /**
  30767. * Sets associated effect (effect used to render this submesh)
  30768. * @param effect defines the effect to associate with
  30769. * @param defines defines the set of defines used to compile this effect
  30770. */
  30771. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30772. /** @hidden */
  30773. _linesIndexCount: number;
  30774. private _mesh;
  30775. private _renderingMesh;
  30776. private _boundingInfo;
  30777. private _linesIndexBuffer;
  30778. /** @hidden */
  30779. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30780. /** @hidden */
  30781. _trianglePlanes: Plane[];
  30782. /** @hidden */
  30783. _lastColliderTransformMatrix: Nullable<Matrix>;
  30784. /** @hidden */
  30785. _renderId: number;
  30786. /** @hidden */
  30787. _alphaIndex: number;
  30788. /** @hidden */
  30789. _distanceToCamera: number;
  30790. /** @hidden */
  30791. _id: number;
  30792. private _currentMaterial;
  30793. /**
  30794. * Add a new submesh to a mesh
  30795. * @param materialIndex defines the material index to use
  30796. * @param verticesStart defines vertex index start
  30797. * @param verticesCount defines vertices count
  30798. * @param indexStart defines index start
  30799. * @param indexCount defines indices count
  30800. * @param mesh defines the parent mesh
  30801. * @param renderingMesh defines an optional rendering mesh
  30802. * @param createBoundingBox defines if bounding box should be created for this submesh
  30803. * @returns the new submesh
  30804. */
  30805. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30806. /**
  30807. * Creates a new submesh
  30808. * @param materialIndex defines the material index to use
  30809. * @param verticesStart defines vertex index start
  30810. * @param verticesCount defines vertices count
  30811. * @param indexStart defines index start
  30812. * @param indexCount defines indices count
  30813. * @param mesh defines the parent mesh
  30814. * @param renderingMesh defines an optional rendering mesh
  30815. * @param createBoundingBox defines if bounding box should be created for this submesh
  30816. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30817. */
  30818. constructor(
  30819. /** the material index to use */
  30820. materialIndex: number,
  30821. /** vertex index start */
  30822. verticesStart: number,
  30823. /** vertices count */
  30824. verticesCount: number,
  30825. /** index start */
  30826. indexStart: number,
  30827. /** indices count */
  30828. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30829. /**
  30830. * Returns true if this submesh covers the entire parent mesh
  30831. * @ignorenaming
  30832. */
  30833. get IsGlobal(): boolean;
  30834. /**
  30835. * Returns the submesh BoudingInfo object
  30836. * @returns current bounding info (or mesh's one if the submesh is global)
  30837. */
  30838. getBoundingInfo(): BoundingInfo;
  30839. /**
  30840. * Sets the submesh BoundingInfo
  30841. * @param boundingInfo defines the new bounding info to use
  30842. * @returns the SubMesh
  30843. */
  30844. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30845. /**
  30846. * Returns the mesh of the current submesh
  30847. * @return the parent mesh
  30848. */
  30849. getMesh(): AbstractMesh;
  30850. /**
  30851. * Returns the rendering mesh of the submesh
  30852. * @returns the rendering mesh (could be different from parent mesh)
  30853. */
  30854. getRenderingMesh(): Mesh;
  30855. /**
  30856. * Returns the replacement mesh of the submesh
  30857. * @returns the replacement mesh (could be different from parent mesh)
  30858. */
  30859. getReplacementMesh(): Nullable<AbstractMesh>;
  30860. /**
  30861. * Returns the effective mesh of the submesh
  30862. * @returns the effective mesh (could be different from parent mesh)
  30863. */
  30864. getEffectiveMesh(): AbstractMesh;
  30865. /**
  30866. * Returns the submesh material
  30867. * @returns null or the current material
  30868. */
  30869. getMaterial(): Nullable<Material>;
  30870. private _IsMultiMaterial;
  30871. /**
  30872. * Sets a new updated BoundingInfo object to the submesh
  30873. * @param data defines an optional position array to use to determine the bounding info
  30874. * @returns the SubMesh
  30875. */
  30876. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30877. /** @hidden */
  30878. _checkCollision(collider: Collider): boolean;
  30879. /**
  30880. * Updates the submesh BoundingInfo
  30881. * @param world defines the world matrix to use to update the bounding info
  30882. * @returns the submesh
  30883. */
  30884. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30885. /**
  30886. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30887. * @param frustumPlanes defines the frustum planes
  30888. * @returns true if the submesh is intersecting with the frustum
  30889. */
  30890. isInFrustum(frustumPlanes: Plane[]): boolean;
  30891. /**
  30892. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30893. * @param frustumPlanes defines the frustum planes
  30894. * @returns true if the submesh is inside the frustum
  30895. */
  30896. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30897. /**
  30898. * Renders the submesh
  30899. * @param enableAlphaMode defines if alpha needs to be used
  30900. * @returns the submesh
  30901. */
  30902. render(enableAlphaMode: boolean): SubMesh;
  30903. /**
  30904. * @hidden
  30905. */
  30906. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30907. /**
  30908. * Checks if the submesh intersects with a ray
  30909. * @param ray defines the ray to test
  30910. * @returns true is the passed ray intersects the submesh bounding box
  30911. */
  30912. canIntersects(ray: Ray): boolean;
  30913. /**
  30914. * Intersects current submesh with a ray
  30915. * @param ray defines the ray to test
  30916. * @param positions defines mesh's positions array
  30917. * @param indices defines mesh's indices array
  30918. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30919. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30920. * @returns intersection info or null if no intersection
  30921. */
  30922. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30923. /** @hidden */
  30924. private _intersectLines;
  30925. /** @hidden */
  30926. private _intersectUnIndexedLines;
  30927. /** @hidden */
  30928. private _intersectTriangles;
  30929. /** @hidden */
  30930. private _intersectUnIndexedTriangles;
  30931. /** @hidden */
  30932. _rebuild(): void;
  30933. /**
  30934. * Creates a new submesh from the passed mesh
  30935. * @param newMesh defines the new hosting mesh
  30936. * @param newRenderingMesh defines an optional rendering mesh
  30937. * @returns the new submesh
  30938. */
  30939. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30940. /**
  30941. * Release associated resources
  30942. */
  30943. dispose(): void;
  30944. /**
  30945. * Gets the class name
  30946. * @returns the string "SubMesh".
  30947. */
  30948. getClassName(): string;
  30949. /**
  30950. * Creates a new submesh from indices data
  30951. * @param materialIndex the index of the main mesh material
  30952. * @param startIndex the index where to start the copy in the mesh indices array
  30953. * @param indexCount the number of indices to copy then from the startIndex
  30954. * @param mesh the main mesh to create the submesh from
  30955. * @param renderingMesh the optional rendering mesh
  30956. * @returns a new submesh
  30957. */
  30958. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30959. }
  30960. }
  30961. declare module "babylonjs/Loading/sceneLoaderFlags" {
  30962. /**
  30963. * Class used to represent data loading progression
  30964. */
  30965. export class SceneLoaderFlags {
  30966. private static _ForceFullSceneLoadingForIncremental;
  30967. private static _ShowLoadingScreen;
  30968. private static _CleanBoneMatrixWeights;
  30969. private static _loggingLevel;
  30970. /**
  30971. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30972. */
  30973. static get ForceFullSceneLoadingForIncremental(): boolean;
  30974. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30975. /**
  30976. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30977. */
  30978. static get ShowLoadingScreen(): boolean;
  30979. static set ShowLoadingScreen(value: boolean);
  30980. /**
  30981. * Defines the current logging level (while loading the scene)
  30982. * @ignorenaming
  30983. */
  30984. static get loggingLevel(): number;
  30985. static set loggingLevel(value: number);
  30986. /**
  30987. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30988. */
  30989. static get CleanBoneMatrixWeights(): boolean;
  30990. static set CleanBoneMatrixWeights(value: boolean);
  30991. }
  30992. }
  30993. declare module "babylonjs/Meshes/geometry" {
  30994. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30995. import { Scene } from "babylonjs/scene";
  30996. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  30997. import { Engine } from "babylonjs/Engines/engine";
  30998. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  30999. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31000. import { Effect } from "babylonjs/Materials/effect";
  31001. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31002. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31003. import { Mesh } from "babylonjs/Meshes/mesh";
  31004. /**
  31005. * Class used to store geometry data (vertex buffers + index buffer)
  31006. */
  31007. export class Geometry implements IGetSetVerticesData {
  31008. /**
  31009. * Gets or sets the ID of the geometry
  31010. */
  31011. id: string;
  31012. /**
  31013. * Gets or sets the unique ID of the geometry
  31014. */
  31015. uniqueId: number;
  31016. /**
  31017. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31018. */
  31019. delayLoadState: number;
  31020. /**
  31021. * Gets the file containing the data to load when running in delay load state
  31022. */
  31023. delayLoadingFile: Nullable<string>;
  31024. /**
  31025. * Callback called when the geometry is updated
  31026. */
  31027. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31028. private _scene;
  31029. private _engine;
  31030. private _meshes;
  31031. private _totalVertices;
  31032. /** @hidden */
  31033. _indices: IndicesArray;
  31034. /** @hidden */
  31035. _vertexBuffers: {
  31036. [key: string]: VertexBuffer;
  31037. };
  31038. private _isDisposed;
  31039. private _extend;
  31040. private _boundingBias;
  31041. /** @hidden */
  31042. _delayInfo: Array<string>;
  31043. private _indexBuffer;
  31044. private _indexBufferIsUpdatable;
  31045. /** @hidden */
  31046. _boundingInfo: Nullable<BoundingInfo>;
  31047. /** @hidden */
  31048. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31049. /** @hidden */
  31050. _softwareSkinningFrameId: number;
  31051. private _vertexArrayObjects;
  31052. private _updatable;
  31053. /** @hidden */
  31054. _positions: Nullable<Vector3[]>;
  31055. /**
  31056. * 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
  31057. */
  31058. get boundingBias(): Vector2;
  31059. /**
  31060. * 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
  31061. */
  31062. set boundingBias(value: Vector2);
  31063. /**
  31064. * Static function used to attach a new empty geometry to a mesh
  31065. * @param mesh defines the mesh to attach the geometry to
  31066. * @returns the new Geometry
  31067. */
  31068. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31069. /** Get the list of meshes using this geometry */
  31070. get meshes(): Mesh[];
  31071. /**
  31072. * 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
  31073. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31074. */
  31075. useBoundingInfoFromGeometry: boolean;
  31076. /**
  31077. * Creates a new geometry
  31078. * @param id defines the unique ID
  31079. * @param scene defines the hosting scene
  31080. * @param vertexData defines the VertexData used to get geometry data
  31081. * @param updatable defines if geometry must be updatable (false by default)
  31082. * @param mesh defines the mesh that will be associated with the geometry
  31083. */
  31084. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31085. /**
  31086. * Gets the current extend of the geometry
  31087. */
  31088. get extend(): {
  31089. minimum: Vector3;
  31090. maximum: Vector3;
  31091. };
  31092. /**
  31093. * Gets the hosting scene
  31094. * @returns the hosting Scene
  31095. */
  31096. getScene(): Scene;
  31097. /**
  31098. * Gets the hosting engine
  31099. * @returns the hosting Engine
  31100. */
  31101. getEngine(): Engine;
  31102. /**
  31103. * Defines if the geometry is ready to use
  31104. * @returns true if the geometry is ready to be used
  31105. */
  31106. isReady(): boolean;
  31107. /**
  31108. * Gets a value indicating that the geometry should not be serialized
  31109. */
  31110. get doNotSerialize(): boolean;
  31111. /** @hidden */
  31112. _rebuild(): void;
  31113. /**
  31114. * Affects all geometry data in one call
  31115. * @param vertexData defines the geometry data
  31116. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31117. */
  31118. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31119. /**
  31120. * Set specific vertex data
  31121. * @param kind defines the data kind (Position, normal, etc...)
  31122. * @param data defines the vertex data to use
  31123. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31124. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31125. */
  31126. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31127. /**
  31128. * Removes a specific vertex data
  31129. * @param kind defines the data kind (Position, normal, etc...)
  31130. */
  31131. removeVerticesData(kind: string): void;
  31132. /**
  31133. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31134. * @param buffer defines the vertex buffer to use
  31135. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31136. */
  31137. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31138. /**
  31139. * Update a specific vertex buffer
  31140. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31141. * It will do nothing if the buffer is not updatable
  31142. * @param kind defines the data kind (Position, normal, etc...)
  31143. * @param data defines the data to use
  31144. * @param offset defines the offset in the target buffer where to store the data
  31145. * @param useBytes set to true if the offset is in bytes
  31146. */
  31147. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31148. /**
  31149. * Update a specific vertex buffer
  31150. * This function will create a new buffer if the current one is not updatable
  31151. * @param kind defines the data kind (Position, normal, etc...)
  31152. * @param data defines the data to use
  31153. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31154. */
  31155. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31156. private _updateBoundingInfo;
  31157. /** @hidden */
  31158. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31159. /**
  31160. * Gets total number of vertices
  31161. * @returns the total number of vertices
  31162. */
  31163. getTotalVertices(): number;
  31164. /**
  31165. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31166. * @param kind defines the data kind (Position, normal, etc...)
  31167. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31168. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31169. * @returns a float array containing vertex data
  31170. */
  31171. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31172. /**
  31173. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31174. * @param kind defines the data kind (Position, normal, etc...)
  31175. * @returns true if the vertex buffer with the specified kind is updatable
  31176. */
  31177. isVertexBufferUpdatable(kind: string): boolean;
  31178. /**
  31179. * Gets a specific vertex buffer
  31180. * @param kind defines the data kind (Position, normal, etc...)
  31181. * @returns a VertexBuffer
  31182. */
  31183. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31184. /**
  31185. * Returns all vertex buffers
  31186. * @return an object holding all vertex buffers indexed by kind
  31187. */
  31188. getVertexBuffers(): Nullable<{
  31189. [key: string]: VertexBuffer;
  31190. }>;
  31191. /**
  31192. * Gets a boolean indicating if specific vertex buffer is present
  31193. * @param kind defines the data kind (Position, normal, etc...)
  31194. * @returns true if data is present
  31195. */
  31196. isVerticesDataPresent(kind: string): boolean;
  31197. /**
  31198. * Gets a list of all attached data kinds (Position, normal, etc...)
  31199. * @returns a list of string containing all kinds
  31200. */
  31201. getVerticesDataKinds(): string[];
  31202. /**
  31203. * Update index buffer
  31204. * @param indices defines the indices to store in the index buffer
  31205. * @param offset defines the offset in the target buffer where to store the data
  31206. * @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)
  31207. */
  31208. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31209. /**
  31210. * Creates a new index buffer
  31211. * @param indices defines the indices to store in the index buffer
  31212. * @param totalVertices defines the total number of vertices (could be null)
  31213. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31214. */
  31215. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31216. /**
  31217. * Return the total number of indices
  31218. * @returns the total number of indices
  31219. */
  31220. getTotalIndices(): number;
  31221. /**
  31222. * Gets the index buffer array
  31223. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31224. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31225. * @returns the index buffer array
  31226. */
  31227. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31228. /**
  31229. * Gets the index buffer
  31230. * @return the index buffer
  31231. */
  31232. getIndexBuffer(): Nullable<DataBuffer>;
  31233. /** @hidden */
  31234. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31235. /**
  31236. * Release the associated resources for a specific mesh
  31237. * @param mesh defines the source mesh
  31238. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31239. */
  31240. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31241. /**
  31242. * Apply current geometry to a given mesh
  31243. * @param mesh defines the mesh to apply geometry to
  31244. */
  31245. applyToMesh(mesh: Mesh): void;
  31246. private _updateExtend;
  31247. private _applyToMesh;
  31248. private notifyUpdate;
  31249. /**
  31250. * Load the geometry if it was flagged as delay loaded
  31251. * @param scene defines the hosting scene
  31252. * @param onLoaded defines a callback called when the geometry is loaded
  31253. */
  31254. load(scene: Scene, onLoaded?: () => void): void;
  31255. private _queueLoad;
  31256. /**
  31257. * Invert the geometry to move from a right handed system to a left handed one.
  31258. */
  31259. toLeftHanded(): void;
  31260. /** @hidden */
  31261. _resetPointsArrayCache(): void;
  31262. /** @hidden */
  31263. _generatePointsArray(): boolean;
  31264. /**
  31265. * Gets a value indicating if the geometry is disposed
  31266. * @returns true if the geometry was disposed
  31267. */
  31268. isDisposed(): boolean;
  31269. private _disposeVertexArrayObjects;
  31270. /**
  31271. * Free all associated resources
  31272. */
  31273. dispose(): void;
  31274. /**
  31275. * Clone the current geometry into a new geometry
  31276. * @param id defines the unique ID of the new geometry
  31277. * @returns a new geometry object
  31278. */
  31279. copy(id: string): Geometry;
  31280. /**
  31281. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31282. * @return a JSON representation of the current geometry data (without the vertices data)
  31283. */
  31284. serialize(): any;
  31285. private toNumberArray;
  31286. /**
  31287. * Serialize all vertices data into a JSON oject
  31288. * @returns a JSON representation of the current geometry data
  31289. */
  31290. serializeVerticeData(): any;
  31291. /**
  31292. * Extracts a clone of a mesh geometry
  31293. * @param mesh defines the source mesh
  31294. * @param id defines the unique ID of the new geometry object
  31295. * @returns the new geometry object
  31296. */
  31297. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31298. /**
  31299. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31300. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31301. * Be aware Math.random() could cause collisions, but:
  31302. * "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"
  31303. * @returns a string containing a new GUID
  31304. */
  31305. static RandomId(): string;
  31306. /** @hidden */
  31307. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31308. private static _CleanMatricesWeights;
  31309. /**
  31310. * Create a new geometry from persisted data (Using .babylon file format)
  31311. * @param parsedVertexData defines the persisted data
  31312. * @param scene defines the hosting scene
  31313. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31314. * @returns the new geometry object
  31315. */
  31316. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31317. }
  31318. }
  31319. declare module "babylonjs/Meshes/mesh.vertexData" {
  31320. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31321. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31322. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31323. import { Geometry } from "babylonjs/Meshes/geometry";
  31324. import { Mesh } from "babylonjs/Meshes/mesh";
  31325. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31326. /**
  31327. * Define an interface for all classes that will get and set the data on vertices
  31328. */
  31329. export interface IGetSetVerticesData {
  31330. /**
  31331. * Gets a boolean indicating if specific vertex data is present
  31332. * @param kind defines the vertex data kind to use
  31333. * @returns true is data kind is present
  31334. */
  31335. isVerticesDataPresent(kind: string): boolean;
  31336. /**
  31337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31338. * @param kind defines the data kind (Position, normal, etc...)
  31339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31341. * @returns a float array containing vertex data
  31342. */
  31343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31344. /**
  31345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31346. * @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.
  31347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31348. * @returns the indices array or an empty array if the mesh has no geometry
  31349. */
  31350. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31351. /**
  31352. * Set specific vertex data
  31353. * @param kind defines the data kind (Position, normal, etc...)
  31354. * @param data defines the vertex data to use
  31355. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31356. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31357. */
  31358. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31359. /**
  31360. * Update a specific associated vertex buffer
  31361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31362. * - VertexBuffer.PositionKind
  31363. * - VertexBuffer.UVKind
  31364. * - VertexBuffer.UV2Kind
  31365. * - VertexBuffer.UV3Kind
  31366. * - VertexBuffer.UV4Kind
  31367. * - VertexBuffer.UV5Kind
  31368. * - VertexBuffer.UV6Kind
  31369. * - VertexBuffer.ColorKind
  31370. * - VertexBuffer.MatricesIndicesKind
  31371. * - VertexBuffer.MatricesIndicesExtraKind
  31372. * - VertexBuffer.MatricesWeightsKind
  31373. * - VertexBuffer.MatricesWeightsExtraKind
  31374. * @param data defines the data source
  31375. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31376. * @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)
  31377. */
  31378. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31379. /**
  31380. * Creates a new index buffer
  31381. * @param indices defines the indices to store in the index buffer
  31382. * @param totalVertices defines the total number of vertices (could be null)
  31383. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31384. */
  31385. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31386. }
  31387. /**
  31388. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31389. */
  31390. export class VertexData {
  31391. /**
  31392. * Mesh side orientation : usually the external or front surface
  31393. */
  31394. static readonly FRONTSIDE: number;
  31395. /**
  31396. * Mesh side orientation : usually the internal or back surface
  31397. */
  31398. static readonly BACKSIDE: number;
  31399. /**
  31400. * Mesh side orientation : both internal and external or front and back surfaces
  31401. */
  31402. static readonly DOUBLESIDE: number;
  31403. /**
  31404. * Mesh side orientation : by default, `FRONTSIDE`
  31405. */
  31406. static readonly DEFAULTSIDE: number;
  31407. /**
  31408. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31409. */
  31410. positions: Nullable<FloatArray>;
  31411. /**
  31412. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31413. */
  31414. normals: Nullable<FloatArray>;
  31415. /**
  31416. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31417. */
  31418. tangents: Nullable<FloatArray>;
  31419. /**
  31420. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31421. */
  31422. uvs: Nullable<FloatArray>;
  31423. /**
  31424. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31425. */
  31426. uvs2: Nullable<FloatArray>;
  31427. /**
  31428. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31429. */
  31430. uvs3: Nullable<FloatArray>;
  31431. /**
  31432. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31433. */
  31434. uvs4: Nullable<FloatArray>;
  31435. /**
  31436. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31437. */
  31438. uvs5: Nullable<FloatArray>;
  31439. /**
  31440. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31441. */
  31442. uvs6: Nullable<FloatArray>;
  31443. /**
  31444. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31445. */
  31446. colors: Nullable<FloatArray>;
  31447. /**
  31448. * 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).
  31449. */
  31450. matricesIndices: Nullable<FloatArray>;
  31451. /**
  31452. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31453. */
  31454. matricesWeights: Nullable<FloatArray>;
  31455. /**
  31456. * An array extending the number of possible indices
  31457. */
  31458. matricesIndicesExtra: Nullable<FloatArray>;
  31459. /**
  31460. * An array extending the number of possible weights when the number of indices is extended
  31461. */
  31462. matricesWeightsExtra: Nullable<FloatArray>;
  31463. /**
  31464. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31465. */
  31466. indices: Nullable<IndicesArray>;
  31467. /**
  31468. * Uses the passed data array to set the set the values for the specified kind of data
  31469. * @param data a linear array of floating numbers
  31470. * @param kind the type of data that is being set, eg positions, colors etc
  31471. */
  31472. set(data: FloatArray, kind: string): void;
  31473. /**
  31474. * Associates the vertexData to the passed Mesh.
  31475. * Sets it as updatable or not (default `false`)
  31476. * @param mesh the mesh the vertexData is applied to
  31477. * @param updatable when used and having the value true allows new data to update the vertexData
  31478. * @returns the VertexData
  31479. */
  31480. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31481. /**
  31482. * Associates the vertexData to the passed Geometry.
  31483. * Sets it as updatable or not (default `false`)
  31484. * @param geometry the geometry the vertexData is applied to
  31485. * @param updatable when used and having the value true allows new data to update the vertexData
  31486. * @returns VertexData
  31487. */
  31488. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31489. /**
  31490. * Updates the associated mesh
  31491. * @param mesh the mesh to be updated
  31492. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31493. * @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
  31494. * @returns VertexData
  31495. */
  31496. updateMesh(mesh: Mesh): VertexData;
  31497. /**
  31498. * Updates the associated geometry
  31499. * @param geometry the geometry to be updated
  31500. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31501. * @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
  31502. * @returns VertexData.
  31503. */
  31504. updateGeometry(geometry: Geometry): VertexData;
  31505. private _applyTo;
  31506. private _update;
  31507. /**
  31508. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31509. * @param matrix the transforming matrix
  31510. * @returns the VertexData
  31511. */
  31512. transform(matrix: Matrix): VertexData;
  31513. /**
  31514. * Merges the passed VertexData into the current one
  31515. * @param other the VertexData to be merged into the current one
  31516. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31517. * @returns the modified VertexData
  31518. */
  31519. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31520. private _mergeElement;
  31521. private _validate;
  31522. /**
  31523. * Serializes the VertexData
  31524. * @returns a serialized object
  31525. */
  31526. serialize(): any;
  31527. /**
  31528. * Extracts the vertexData from a mesh
  31529. * @param mesh the mesh from which to extract the VertexData
  31530. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31531. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31532. * @returns the object VertexData associated to the passed mesh
  31533. */
  31534. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31535. /**
  31536. * Extracts the vertexData from the geometry
  31537. * @param geometry the geometry from which to extract the VertexData
  31538. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31539. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31540. * @returns the object VertexData associated to the passed mesh
  31541. */
  31542. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31543. private static _ExtractFrom;
  31544. /**
  31545. * Creates the VertexData for a Ribbon
  31546. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31547. * * pathArray array of paths, each of which an array of successive Vector3
  31548. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31549. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31550. * * 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
  31551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31552. * * 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)
  31553. * * 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)
  31554. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31555. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31556. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31557. * @returns the VertexData of the ribbon
  31558. */
  31559. static CreateRibbon(options: {
  31560. pathArray: Vector3[][];
  31561. closeArray?: boolean;
  31562. closePath?: boolean;
  31563. offset?: number;
  31564. sideOrientation?: number;
  31565. frontUVs?: Vector4;
  31566. backUVs?: Vector4;
  31567. invertUV?: boolean;
  31568. uvs?: Vector2[];
  31569. colors?: Color4[];
  31570. }): VertexData;
  31571. /**
  31572. * Creates the VertexData for a box
  31573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31574. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31575. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31576. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31577. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31578. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31579. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31581. * * 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)
  31582. * * 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)
  31583. * @returns the VertexData of the box
  31584. */
  31585. static CreateBox(options: {
  31586. size?: number;
  31587. width?: number;
  31588. height?: number;
  31589. depth?: number;
  31590. faceUV?: Vector4[];
  31591. faceColors?: Color4[];
  31592. sideOrientation?: number;
  31593. frontUVs?: Vector4;
  31594. backUVs?: Vector4;
  31595. }): VertexData;
  31596. /**
  31597. * Creates the VertexData for a tiled box
  31598. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31599. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31600. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31601. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31603. * @returns the VertexData of the box
  31604. */
  31605. static CreateTiledBox(options: {
  31606. pattern?: number;
  31607. width?: number;
  31608. height?: number;
  31609. depth?: number;
  31610. tileSize?: number;
  31611. tileWidth?: number;
  31612. tileHeight?: number;
  31613. alignHorizontal?: number;
  31614. alignVertical?: number;
  31615. faceUV?: Vector4[];
  31616. faceColors?: Color4[];
  31617. sideOrientation?: number;
  31618. }): VertexData;
  31619. /**
  31620. * Creates the VertexData for a tiled plane
  31621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31622. * * pattern a limited pattern arrangement depending on the number
  31623. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31624. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31625. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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. * @returns the VertexData of the tiled plane
  31630. */
  31631. static CreateTiledPlane(options: {
  31632. pattern?: number;
  31633. tileSize?: number;
  31634. tileWidth?: number;
  31635. tileHeight?: number;
  31636. size?: number;
  31637. width?: number;
  31638. height?: number;
  31639. alignHorizontal?: number;
  31640. alignVertical?: number;
  31641. sideOrientation?: number;
  31642. frontUVs?: Vector4;
  31643. backUVs?: Vector4;
  31644. }): VertexData;
  31645. /**
  31646. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31647. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31648. * * segments sets the number of horizontal strips optional, default 32
  31649. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31650. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31651. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31652. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31653. * * 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
  31654. * * 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
  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 ellipsoid
  31659. */
  31660. static CreateSphere(options: {
  31661. segments?: number;
  31662. diameter?: number;
  31663. diameterX?: number;
  31664. diameterY?: number;
  31665. diameterZ?: number;
  31666. arc?: number;
  31667. slice?: number;
  31668. sideOrientation?: number;
  31669. frontUVs?: Vector4;
  31670. backUVs?: Vector4;
  31671. }): VertexData;
  31672. /**
  31673. * Creates the VertexData for a cylinder, cone or prism
  31674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31675. * * height sets the height (y direction) of the cylinder, optional, default 2
  31676. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31677. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31678. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31680. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31681. * * 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
  31682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31683. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31684. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31685. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31687. * * 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)
  31688. * * 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)
  31689. * @returns the VertexData of the cylinder, cone or prism
  31690. */
  31691. static CreateCylinder(options: {
  31692. height?: number;
  31693. diameterTop?: number;
  31694. diameterBottom?: number;
  31695. diameter?: number;
  31696. tessellation?: number;
  31697. subdivisions?: number;
  31698. arc?: number;
  31699. faceColors?: Color4[];
  31700. faceUV?: Vector4[];
  31701. hasRings?: boolean;
  31702. enclose?: boolean;
  31703. sideOrientation?: number;
  31704. frontUVs?: Vector4;
  31705. backUVs?: Vector4;
  31706. }): VertexData;
  31707. /**
  31708. * Creates the VertexData for a torus
  31709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31710. * * diameter the diameter of the torus, optional default 1
  31711. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31712. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31714. * * 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)
  31715. * * 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)
  31716. * @returns the VertexData of the torus
  31717. */
  31718. static CreateTorus(options: {
  31719. diameter?: number;
  31720. thickness?: number;
  31721. tessellation?: number;
  31722. sideOrientation?: number;
  31723. frontUVs?: Vector4;
  31724. backUVs?: Vector4;
  31725. }): VertexData;
  31726. /**
  31727. * Creates the VertexData of the LineSystem
  31728. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31729. * - lines an array of lines, each line being an array of successive Vector3
  31730. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31731. * @returns the VertexData of the LineSystem
  31732. */
  31733. static CreateLineSystem(options: {
  31734. lines: Vector3[][];
  31735. colors?: Nullable<Color4[][]>;
  31736. }): VertexData;
  31737. /**
  31738. * Create the VertexData for a DashedLines
  31739. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31740. * - points an array successive Vector3
  31741. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31742. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31743. * - dashNb the intended total number of dashes, optional, default 200
  31744. * @returns the VertexData for the DashedLines
  31745. */
  31746. static CreateDashedLines(options: {
  31747. points: Vector3[];
  31748. dashSize?: number;
  31749. gapSize?: number;
  31750. dashNb?: number;
  31751. }): VertexData;
  31752. /**
  31753. * Creates the VertexData for a Ground
  31754. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31755. * - width the width (x direction) of the ground, optional, default 1
  31756. * - height the height (z direction) of the ground, optional, default 1
  31757. * - subdivisions the number of subdivisions per side, optional, default 1
  31758. * @returns the VertexData of the Ground
  31759. */
  31760. static CreateGround(options: {
  31761. width?: number;
  31762. height?: number;
  31763. subdivisions?: number;
  31764. subdivisionsX?: number;
  31765. subdivisionsY?: number;
  31766. }): VertexData;
  31767. /**
  31768. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31769. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31770. * * xmin the ground minimum X coordinate, optional, default -1
  31771. * * zmin the ground minimum Z coordinate, optional, default -1
  31772. * * xmax the ground maximum X coordinate, optional, default 1
  31773. * * zmax the ground maximum Z coordinate, optional, default 1
  31774. * * 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}
  31775. * * 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}
  31776. * @returns the VertexData of the TiledGround
  31777. */
  31778. static CreateTiledGround(options: {
  31779. xmin: number;
  31780. zmin: number;
  31781. xmax: number;
  31782. zmax: number;
  31783. subdivisions?: {
  31784. w: number;
  31785. h: number;
  31786. };
  31787. precision?: {
  31788. w: number;
  31789. h: number;
  31790. };
  31791. }): VertexData;
  31792. /**
  31793. * Creates the VertexData of the Ground designed from a heightmap
  31794. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31795. * * width the width (x direction) of the ground
  31796. * * height the height (z direction) of the ground
  31797. * * subdivisions the number of subdivisions per side
  31798. * * minHeight the minimum altitude on the ground, optional, default 0
  31799. * * maxHeight the maximum altitude on the ground, optional default 1
  31800. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31801. * * buffer the array holding the image color data
  31802. * * bufferWidth the width of image
  31803. * * bufferHeight the height of image
  31804. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31805. * @returns the VertexData of the Ground designed from a heightmap
  31806. */
  31807. static CreateGroundFromHeightMap(options: {
  31808. width: number;
  31809. height: number;
  31810. subdivisions: number;
  31811. minHeight: number;
  31812. maxHeight: number;
  31813. colorFilter: Color3;
  31814. buffer: Uint8Array;
  31815. bufferWidth: number;
  31816. bufferHeight: number;
  31817. alphaFilter: number;
  31818. }): VertexData;
  31819. /**
  31820. * Creates the VertexData for a Plane
  31821. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31822. * * size sets the width and height of the plane to the value of size, optional default 1
  31823. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31824. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31826. * * 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)
  31827. * * 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)
  31828. * @returns the VertexData of the box
  31829. */
  31830. static CreatePlane(options: {
  31831. size?: number;
  31832. width?: number;
  31833. height?: number;
  31834. sideOrientation?: number;
  31835. frontUVs?: Vector4;
  31836. backUVs?: Vector4;
  31837. }): VertexData;
  31838. /**
  31839. * Creates the VertexData of the Disc or regular Polygon
  31840. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31841. * * radius the radius of the disc, optional default 0.5
  31842. * * tessellation the number of polygon sides, optional, default 64
  31843. * * 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
  31844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31845. * * 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)
  31846. * * 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)
  31847. * @returns the VertexData of the box
  31848. */
  31849. static CreateDisc(options: {
  31850. radius?: number;
  31851. tessellation?: number;
  31852. arc?: number;
  31853. sideOrientation?: number;
  31854. frontUVs?: Vector4;
  31855. backUVs?: Vector4;
  31856. }): VertexData;
  31857. /**
  31858. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31859. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31860. * @param polygon a mesh built from polygonTriangulation.build()
  31861. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31862. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31863. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31864. * @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)
  31865. * @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)
  31866. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31867. * @returns the VertexData of the Polygon
  31868. */
  31869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31870. /**
  31871. * Creates the VertexData of the IcoSphere
  31872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31873. * * radius the radius of the IcoSphere, optional default 1
  31874. * * radiusX allows stretching in the x direction, optional, default radius
  31875. * * radiusY allows stretching in the y direction, optional, default radius
  31876. * * radiusZ allows stretching in the z direction, optional, default radius
  31877. * * flat when true creates a flat shaded mesh, optional, default true
  31878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31880. * * 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)
  31881. * * 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)
  31882. * @returns the VertexData of the IcoSphere
  31883. */
  31884. static CreateIcoSphere(options: {
  31885. radius?: number;
  31886. radiusX?: number;
  31887. radiusY?: number;
  31888. radiusZ?: number;
  31889. flat?: boolean;
  31890. subdivisions?: number;
  31891. sideOrientation?: number;
  31892. frontUVs?: Vector4;
  31893. backUVs?: Vector4;
  31894. }): VertexData;
  31895. /**
  31896. * Creates the VertexData for a Polyhedron
  31897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31898. * * type provided types are:
  31899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31900. * * 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)
  31901. * * size the size of the IcoSphere, optional default 1
  31902. * * sizeX allows stretching in the x direction, optional, default size
  31903. * * sizeY allows stretching in the y direction, optional, default size
  31904. * * sizeZ allows stretching in the z direction, optional, default size
  31905. * * 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
  31906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31908. * * flat when true creates a flat shaded mesh, optional, default true
  31909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31911. * * 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)
  31912. * * 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)
  31913. * @returns the VertexData of the Polyhedron
  31914. */
  31915. static CreatePolyhedron(options: {
  31916. type?: number;
  31917. size?: number;
  31918. sizeX?: number;
  31919. sizeY?: number;
  31920. sizeZ?: number;
  31921. custom?: any;
  31922. faceUV?: Vector4[];
  31923. faceColors?: Color4[];
  31924. flat?: boolean;
  31925. sideOrientation?: number;
  31926. frontUVs?: Vector4;
  31927. backUVs?: Vector4;
  31928. }): VertexData;
  31929. /**
  31930. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31931. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31932. * @returns the VertexData of the Capsule
  31933. */
  31934. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31935. /**
  31936. * Creates the VertexData for a TorusKnot
  31937. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31938. * * radius the radius of the torus knot, optional, default 2
  31939. * * tube the thickness of the tube, optional, default 0.5
  31940. * * radialSegments the number of sides on each tube segments, optional, default 32
  31941. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31942. * * p the number of windings around the z axis, optional, default 2
  31943. * * q the number of windings around the x axis, optional, default 3
  31944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31945. * * 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)
  31946. * * 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)
  31947. * @returns the VertexData of the Torus Knot
  31948. */
  31949. static CreateTorusKnot(options: {
  31950. radius?: number;
  31951. tube?: number;
  31952. radialSegments?: number;
  31953. tubularSegments?: number;
  31954. p?: number;
  31955. q?: number;
  31956. sideOrientation?: number;
  31957. frontUVs?: Vector4;
  31958. backUVs?: Vector4;
  31959. }): VertexData;
  31960. /**
  31961. * Compute normals for given positions and indices
  31962. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31963. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31964. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31965. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31966. * * facetNormals : optional array of facet normals (vector3)
  31967. * * facetPositions : optional array of facet positions (vector3)
  31968. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31969. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31970. * * bInfo : optional bounding info, required for facetPartitioning computation
  31971. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31972. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31973. * * useRightHandedSystem: optional boolean to for right handed system computation
  31974. * * depthSort : optional boolean to enable the facet depth sort computation
  31975. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31976. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31977. */
  31978. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31979. facetNormals?: any;
  31980. facetPositions?: any;
  31981. facetPartitioning?: any;
  31982. ratio?: number;
  31983. bInfo?: any;
  31984. bbSize?: Vector3;
  31985. subDiv?: any;
  31986. useRightHandedSystem?: boolean;
  31987. depthSort?: boolean;
  31988. distanceTo?: Vector3;
  31989. depthSortedFacets?: any;
  31990. }): void;
  31991. /** @hidden */
  31992. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31993. /**
  31994. * Applies VertexData created from the imported parameters to the geometry
  31995. * @param parsedVertexData the parsed data from an imported file
  31996. * @param geometry the geometry to apply the VertexData to
  31997. */
  31998. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31999. }
  32000. }
  32001. declare module "babylonjs/Morph/morphTarget" {
  32002. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32003. import { Observable } from "babylonjs/Misc/observable";
  32004. import { Nullable, FloatArray } from "babylonjs/types";
  32005. import { Scene } from "babylonjs/scene";
  32006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32007. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32008. /**
  32009. * Defines a target to use with MorphTargetManager
  32010. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32011. */
  32012. export class MorphTarget implements IAnimatable {
  32013. /** defines the name of the target */
  32014. name: string;
  32015. /**
  32016. * Gets or sets the list of animations
  32017. */
  32018. animations: import("babylonjs/Animations/animation").Animation[];
  32019. private _scene;
  32020. private _positions;
  32021. private _normals;
  32022. private _tangents;
  32023. private _uvs;
  32024. private _influence;
  32025. private _uniqueId;
  32026. /**
  32027. * Observable raised when the influence changes
  32028. */
  32029. onInfluenceChanged: Observable<boolean>;
  32030. /** @hidden */
  32031. _onDataLayoutChanged: Observable<void>;
  32032. /**
  32033. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32034. */
  32035. get influence(): number;
  32036. set influence(influence: number);
  32037. /**
  32038. * Gets or sets the id of the morph Target
  32039. */
  32040. id: string;
  32041. private _animationPropertiesOverride;
  32042. /**
  32043. * Gets or sets the animation properties override
  32044. */
  32045. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32046. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32047. /**
  32048. * Creates a new MorphTarget
  32049. * @param name defines the name of the target
  32050. * @param influence defines the influence to use
  32051. * @param scene defines the scene the morphtarget belongs to
  32052. */
  32053. constructor(
  32054. /** defines the name of the target */
  32055. name: string, influence?: number, scene?: Nullable<Scene>);
  32056. /**
  32057. * Gets the unique ID of this manager
  32058. */
  32059. get uniqueId(): number;
  32060. /**
  32061. * Gets a boolean defining if the target contains position data
  32062. */
  32063. get hasPositions(): boolean;
  32064. /**
  32065. * Gets a boolean defining if the target contains normal data
  32066. */
  32067. get hasNormals(): boolean;
  32068. /**
  32069. * Gets a boolean defining if the target contains tangent data
  32070. */
  32071. get hasTangents(): boolean;
  32072. /**
  32073. * Gets a boolean defining if the target contains texture coordinates data
  32074. */
  32075. get hasUVs(): boolean;
  32076. /**
  32077. * Affects position data to this target
  32078. * @param data defines the position data to use
  32079. */
  32080. setPositions(data: Nullable<FloatArray>): void;
  32081. /**
  32082. * Gets the position data stored in this target
  32083. * @returns a FloatArray containing the position data (or null if not present)
  32084. */
  32085. getPositions(): Nullable<FloatArray>;
  32086. /**
  32087. * Affects normal data to this target
  32088. * @param data defines the normal data to use
  32089. */
  32090. setNormals(data: Nullable<FloatArray>): void;
  32091. /**
  32092. * Gets the normal data stored in this target
  32093. * @returns a FloatArray containing the normal data (or null if not present)
  32094. */
  32095. getNormals(): Nullable<FloatArray>;
  32096. /**
  32097. * Affects tangent data to this target
  32098. * @param data defines the tangent data to use
  32099. */
  32100. setTangents(data: Nullable<FloatArray>): void;
  32101. /**
  32102. * Gets the tangent data stored in this target
  32103. * @returns a FloatArray containing the tangent data (or null if not present)
  32104. */
  32105. getTangents(): Nullable<FloatArray>;
  32106. /**
  32107. * Affects texture coordinates data to this target
  32108. * @param data defines the texture coordinates data to use
  32109. */
  32110. setUVs(data: Nullable<FloatArray>): void;
  32111. /**
  32112. * Gets the texture coordinates data stored in this target
  32113. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32114. */
  32115. getUVs(): Nullable<FloatArray>;
  32116. /**
  32117. * Clone the current target
  32118. * @returns a new MorphTarget
  32119. */
  32120. clone(): MorphTarget;
  32121. /**
  32122. * Serializes the current target into a Serialization object
  32123. * @returns the serialized object
  32124. */
  32125. serialize(): any;
  32126. /**
  32127. * Returns the string "MorphTarget"
  32128. * @returns "MorphTarget"
  32129. */
  32130. getClassName(): string;
  32131. /**
  32132. * Creates a new target from serialized data
  32133. * @param serializationObject defines the serialized data to use
  32134. * @returns a new MorphTarget
  32135. */
  32136. static Parse(serializationObject: any): MorphTarget;
  32137. /**
  32138. * Creates a MorphTarget from mesh data
  32139. * @param mesh defines the source mesh
  32140. * @param name defines the name to use for the new target
  32141. * @param influence defines the influence to attach to the target
  32142. * @returns a new MorphTarget
  32143. */
  32144. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32145. }
  32146. }
  32147. declare module "babylonjs/Morph/morphTargetManager" {
  32148. import { Nullable } from "babylonjs/types";
  32149. import { Scene } from "babylonjs/scene";
  32150. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32151. /**
  32152. * This class is used to deform meshes using morphing between different targets
  32153. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32154. */
  32155. export class MorphTargetManager {
  32156. private _targets;
  32157. private _targetInfluenceChangedObservers;
  32158. private _targetDataLayoutChangedObservers;
  32159. private _activeTargets;
  32160. private _scene;
  32161. private _influences;
  32162. private _supportsNormals;
  32163. private _supportsTangents;
  32164. private _supportsUVs;
  32165. private _vertexCount;
  32166. private _uniqueId;
  32167. private _tempInfluences;
  32168. /**
  32169. * Gets or sets a boolean indicating if normals must be morphed
  32170. */
  32171. enableNormalMorphing: boolean;
  32172. /**
  32173. * Gets or sets a boolean indicating if tangents must be morphed
  32174. */
  32175. enableTangentMorphing: boolean;
  32176. /**
  32177. * Gets or sets a boolean indicating if UV must be morphed
  32178. */
  32179. enableUVMorphing: boolean;
  32180. /**
  32181. * Creates a new MorphTargetManager
  32182. * @param scene defines the current scene
  32183. */
  32184. constructor(scene?: Nullable<Scene>);
  32185. /**
  32186. * Gets the unique ID of this manager
  32187. */
  32188. get uniqueId(): number;
  32189. /**
  32190. * Gets the number of vertices handled by this manager
  32191. */
  32192. get vertexCount(): number;
  32193. /**
  32194. * Gets a boolean indicating if this manager supports morphing of normals
  32195. */
  32196. get supportsNormals(): boolean;
  32197. /**
  32198. * Gets a boolean indicating if this manager supports morphing of tangents
  32199. */
  32200. get supportsTangents(): boolean;
  32201. /**
  32202. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32203. */
  32204. get supportsUVs(): boolean;
  32205. /**
  32206. * Gets the number of targets stored in this manager
  32207. */
  32208. get numTargets(): number;
  32209. /**
  32210. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32211. */
  32212. get numInfluencers(): number;
  32213. /**
  32214. * Gets the list of influences (one per target)
  32215. */
  32216. get influences(): Float32Array;
  32217. /**
  32218. * Gets the active target at specified index. An active target is a target with an influence > 0
  32219. * @param index defines the index to check
  32220. * @returns the requested target
  32221. */
  32222. getActiveTarget(index: number): MorphTarget;
  32223. /**
  32224. * Gets the target at specified index
  32225. * @param index defines the index to check
  32226. * @returns the requested target
  32227. */
  32228. getTarget(index: number): MorphTarget;
  32229. /**
  32230. * Add a new target to this manager
  32231. * @param target defines the target to add
  32232. */
  32233. addTarget(target: MorphTarget): void;
  32234. /**
  32235. * Removes a target from the manager
  32236. * @param target defines the target to remove
  32237. */
  32238. removeTarget(target: MorphTarget): void;
  32239. /**
  32240. * Clone the current manager
  32241. * @returns a new MorphTargetManager
  32242. */
  32243. clone(): MorphTargetManager;
  32244. /**
  32245. * Serializes the current manager into a Serialization object
  32246. * @returns the serialized object
  32247. */
  32248. serialize(): any;
  32249. private _syncActiveTargets;
  32250. /**
  32251. * Syncrhonize the targets with all the meshes using this morph target manager
  32252. */
  32253. synchronize(): void;
  32254. /**
  32255. * Creates a new MorphTargetManager from serialized data
  32256. * @param serializationObject defines the serialized data
  32257. * @param scene defines the hosting scene
  32258. * @returns the new MorphTargetManager
  32259. */
  32260. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32261. }
  32262. }
  32263. declare module "babylonjs/Meshes/meshLODLevel" {
  32264. import { Mesh } from "babylonjs/Meshes/mesh";
  32265. import { Nullable } from "babylonjs/types";
  32266. /**
  32267. * Class used to represent a specific level of detail of a mesh
  32268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32269. */
  32270. export class MeshLODLevel {
  32271. /** Defines the distance where this level should start being displayed */
  32272. distance: number;
  32273. /** Defines the mesh to use to render this level */
  32274. mesh: Nullable<Mesh>;
  32275. /**
  32276. * Creates a new LOD level
  32277. * @param distance defines the distance where this level should star being displayed
  32278. * @param mesh defines the mesh to use to render this level
  32279. */
  32280. constructor(
  32281. /** Defines the distance where this level should start being displayed */
  32282. distance: number,
  32283. /** Defines the mesh to use to render this level */
  32284. mesh: Nullable<Mesh>);
  32285. }
  32286. }
  32287. declare module "babylonjs/Misc/canvasGenerator" {
  32288. /**
  32289. * Helper class used to generate a canvas to manipulate images
  32290. */
  32291. export class CanvasGenerator {
  32292. /**
  32293. * Create a new canvas (or offscreen canvas depending on the context)
  32294. * @param width defines the expected width
  32295. * @param height defines the expected height
  32296. * @return a new canvas or offscreen canvas
  32297. */
  32298. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32299. }
  32300. }
  32301. declare module "babylonjs/Meshes/groundMesh" {
  32302. import { Scene } from "babylonjs/scene";
  32303. import { Vector3 } from "babylonjs/Maths/math.vector";
  32304. import { Mesh } from "babylonjs/Meshes/mesh";
  32305. /**
  32306. * Mesh representing the gorund
  32307. */
  32308. export class GroundMesh extends Mesh {
  32309. /** If octree should be generated */
  32310. generateOctree: boolean;
  32311. private _heightQuads;
  32312. /** @hidden */
  32313. _subdivisionsX: number;
  32314. /** @hidden */
  32315. _subdivisionsY: number;
  32316. /** @hidden */
  32317. _width: number;
  32318. /** @hidden */
  32319. _height: number;
  32320. /** @hidden */
  32321. _minX: number;
  32322. /** @hidden */
  32323. _maxX: number;
  32324. /** @hidden */
  32325. _minZ: number;
  32326. /** @hidden */
  32327. _maxZ: number;
  32328. constructor(name: string, scene: Scene);
  32329. /**
  32330. * "GroundMesh"
  32331. * @returns "GroundMesh"
  32332. */
  32333. getClassName(): string;
  32334. /**
  32335. * The minimum of x and y subdivisions
  32336. */
  32337. get subdivisions(): number;
  32338. /**
  32339. * X subdivisions
  32340. */
  32341. get subdivisionsX(): number;
  32342. /**
  32343. * Y subdivisions
  32344. */
  32345. get subdivisionsY(): number;
  32346. /**
  32347. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32348. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32349. * @param chunksCount the number of subdivisions for x and y
  32350. * @param octreeBlocksSize (Default: 32)
  32351. */
  32352. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32353. /**
  32354. * Returns a height (y) value in the Worl system :
  32355. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32356. * @param x x coordinate
  32357. * @param z z coordinate
  32358. * @returns the ground y position if (x, z) are outside the ground surface.
  32359. */
  32360. getHeightAtCoordinates(x: number, z: number): number;
  32361. /**
  32362. * Returns a normalized vector (Vector3) orthogonal to the ground
  32363. * at the ground coordinates (x, z) expressed in the World system.
  32364. * @param x x coordinate
  32365. * @param z z coordinate
  32366. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32367. */
  32368. getNormalAtCoordinates(x: number, z: number): Vector3;
  32369. /**
  32370. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32371. * at the ground coordinates (x, z) expressed in the World system.
  32372. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32373. * @param x x coordinate
  32374. * @param z z coordinate
  32375. * @param ref vector to store the result
  32376. * @returns the GroundMesh.
  32377. */
  32378. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32379. /**
  32380. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32381. * if the ground has been updated.
  32382. * This can be used in the render loop.
  32383. * @returns the GroundMesh.
  32384. */
  32385. updateCoordinateHeights(): GroundMesh;
  32386. private _getFacetAt;
  32387. private _initHeightQuads;
  32388. private _computeHeightQuads;
  32389. /**
  32390. * Serializes this ground mesh
  32391. * @param serializationObject object to write serialization to
  32392. */
  32393. serialize(serializationObject: any): void;
  32394. /**
  32395. * Parses a serialized ground mesh
  32396. * @param parsedMesh the serialized mesh
  32397. * @param scene the scene to create the ground mesh in
  32398. * @returns the created ground mesh
  32399. */
  32400. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32401. }
  32402. }
  32403. declare module "babylonjs/Physics/physicsJoint" {
  32404. import { Vector3 } from "babylonjs/Maths/math.vector";
  32405. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32406. /**
  32407. * Interface for Physics-Joint data
  32408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32409. */
  32410. export interface PhysicsJointData {
  32411. /**
  32412. * The main pivot of the joint
  32413. */
  32414. mainPivot?: Vector3;
  32415. /**
  32416. * The connected pivot of the joint
  32417. */
  32418. connectedPivot?: Vector3;
  32419. /**
  32420. * The main axis of the joint
  32421. */
  32422. mainAxis?: Vector3;
  32423. /**
  32424. * The connected axis of the joint
  32425. */
  32426. connectedAxis?: Vector3;
  32427. /**
  32428. * The collision of the joint
  32429. */
  32430. collision?: boolean;
  32431. /**
  32432. * Native Oimo/Cannon/Energy data
  32433. */
  32434. nativeParams?: any;
  32435. }
  32436. /**
  32437. * This is a holder class for the physics joint created by the physics plugin
  32438. * It holds a set of functions to control the underlying joint
  32439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32440. */
  32441. export class PhysicsJoint {
  32442. /**
  32443. * The type of the physics joint
  32444. */
  32445. type: number;
  32446. /**
  32447. * The data for the physics joint
  32448. */
  32449. jointData: PhysicsJointData;
  32450. private _physicsJoint;
  32451. protected _physicsPlugin: IPhysicsEnginePlugin;
  32452. /**
  32453. * Initializes the physics joint
  32454. * @param type The type of the physics joint
  32455. * @param jointData The data for the physics joint
  32456. */
  32457. constructor(
  32458. /**
  32459. * The type of the physics joint
  32460. */
  32461. type: number,
  32462. /**
  32463. * The data for the physics joint
  32464. */
  32465. jointData: PhysicsJointData);
  32466. /**
  32467. * Gets the physics joint
  32468. */
  32469. get physicsJoint(): any;
  32470. /**
  32471. * Sets the physics joint
  32472. */
  32473. set physicsJoint(newJoint: any);
  32474. /**
  32475. * Sets the physics plugin
  32476. */
  32477. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32478. /**
  32479. * Execute a function that is physics-plugin specific.
  32480. * @param {Function} func the function that will be executed.
  32481. * It accepts two parameters: the physics world and the physics joint
  32482. */
  32483. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32484. /**
  32485. * Distance-Joint type
  32486. */
  32487. static DistanceJoint: number;
  32488. /**
  32489. * Hinge-Joint type
  32490. */
  32491. static HingeJoint: number;
  32492. /**
  32493. * Ball-and-Socket joint type
  32494. */
  32495. static BallAndSocketJoint: number;
  32496. /**
  32497. * Wheel-Joint type
  32498. */
  32499. static WheelJoint: number;
  32500. /**
  32501. * Slider-Joint type
  32502. */
  32503. static SliderJoint: number;
  32504. /**
  32505. * Prismatic-Joint type
  32506. */
  32507. static PrismaticJoint: number;
  32508. /**
  32509. * Universal-Joint type
  32510. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32511. */
  32512. static UniversalJoint: number;
  32513. /**
  32514. * Hinge-Joint 2 type
  32515. */
  32516. static Hinge2Joint: number;
  32517. /**
  32518. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32519. */
  32520. static PointToPointJoint: number;
  32521. /**
  32522. * Spring-Joint type
  32523. */
  32524. static SpringJoint: number;
  32525. /**
  32526. * Lock-Joint type
  32527. */
  32528. static LockJoint: number;
  32529. }
  32530. /**
  32531. * A class representing a physics distance joint
  32532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32533. */
  32534. export class DistanceJoint extends PhysicsJoint {
  32535. /**
  32536. *
  32537. * @param jointData The data for the Distance-Joint
  32538. */
  32539. constructor(jointData: DistanceJointData);
  32540. /**
  32541. * Update the predefined distance.
  32542. * @param maxDistance The maximum preferred distance
  32543. * @param minDistance The minimum preferred distance
  32544. */
  32545. updateDistance(maxDistance: number, minDistance?: number): void;
  32546. }
  32547. /**
  32548. * Represents a Motor-Enabled Joint
  32549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32550. */
  32551. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32552. /**
  32553. * Initializes the Motor-Enabled Joint
  32554. * @param type The type of the joint
  32555. * @param jointData The physica joint data for the joint
  32556. */
  32557. constructor(type: number, jointData: PhysicsJointData);
  32558. /**
  32559. * Set the motor values.
  32560. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32561. * @param force the force to apply
  32562. * @param maxForce max force for this motor.
  32563. */
  32564. setMotor(force?: number, maxForce?: number): void;
  32565. /**
  32566. * Set the motor's limits.
  32567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32568. * @param upperLimit The upper limit of the motor
  32569. * @param lowerLimit The lower limit of the motor
  32570. */
  32571. setLimit(upperLimit: number, lowerLimit?: number): void;
  32572. }
  32573. /**
  32574. * This class represents a single physics Hinge-Joint
  32575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32576. */
  32577. export class HingeJoint extends MotorEnabledJoint {
  32578. /**
  32579. * Initializes the Hinge-Joint
  32580. * @param jointData The joint data for the Hinge-Joint
  32581. */
  32582. constructor(jointData: PhysicsJointData);
  32583. /**
  32584. * Set the motor values.
  32585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32586. * @param {number} force the force to apply
  32587. * @param {number} maxForce max force for this motor.
  32588. */
  32589. setMotor(force?: number, maxForce?: number): void;
  32590. /**
  32591. * Set the motor's limits.
  32592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32593. * @param upperLimit The upper limit of the motor
  32594. * @param lowerLimit The lower limit of the motor
  32595. */
  32596. setLimit(upperLimit: number, lowerLimit?: number): void;
  32597. }
  32598. /**
  32599. * This class represents a dual hinge physics joint (same as wheel joint)
  32600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32601. */
  32602. export class Hinge2Joint extends MotorEnabledJoint {
  32603. /**
  32604. * Initializes the Hinge2-Joint
  32605. * @param jointData The joint data for the Hinge2-Joint
  32606. */
  32607. constructor(jointData: PhysicsJointData);
  32608. /**
  32609. * Set the motor values.
  32610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32611. * @param {number} targetSpeed the speed the motor is to reach
  32612. * @param {number} maxForce max force for this motor.
  32613. * @param {motorIndex} the motor's index, 0 or 1.
  32614. */
  32615. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32616. /**
  32617. * Set the motor limits.
  32618. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32619. * @param {number} upperLimit the upper limit
  32620. * @param {number} lowerLimit lower limit
  32621. * @param {motorIndex} the motor's index, 0 or 1.
  32622. */
  32623. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32624. }
  32625. /**
  32626. * Interface for a motor enabled joint
  32627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32628. */
  32629. export interface IMotorEnabledJoint {
  32630. /**
  32631. * Physics joint
  32632. */
  32633. physicsJoint: any;
  32634. /**
  32635. * Sets the motor of the motor-enabled joint
  32636. * @param force The force of the motor
  32637. * @param maxForce The maximum force of the motor
  32638. * @param motorIndex The index of the motor
  32639. */
  32640. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32641. /**
  32642. * Sets the limit of the motor
  32643. * @param upperLimit The upper limit of the motor
  32644. * @param lowerLimit The lower limit of the motor
  32645. * @param motorIndex The index of the motor
  32646. */
  32647. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32648. }
  32649. /**
  32650. * Joint data for a Distance-Joint
  32651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32652. */
  32653. export interface DistanceJointData extends PhysicsJointData {
  32654. /**
  32655. * Max distance the 2 joint objects can be apart
  32656. */
  32657. maxDistance: number;
  32658. }
  32659. /**
  32660. * Joint data from a spring joint
  32661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32662. */
  32663. export interface SpringJointData extends PhysicsJointData {
  32664. /**
  32665. * Length of the spring
  32666. */
  32667. length: number;
  32668. /**
  32669. * Stiffness of the spring
  32670. */
  32671. stiffness: number;
  32672. /**
  32673. * Damping of the spring
  32674. */
  32675. damping: number;
  32676. /** this callback will be called when applying the force to the impostors. */
  32677. forceApplicationCallback: () => void;
  32678. }
  32679. }
  32680. declare module "babylonjs/Physics/physicsRaycastResult" {
  32681. import { Vector3 } from "babylonjs/Maths/math.vector";
  32682. /**
  32683. * Holds the data for the raycast result
  32684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32685. */
  32686. export class PhysicsRaycastResult {
  32687. private _hasHit;
  32688. private _hitDistance;
  32689. private _hitNormalWorld;
  32690. private _hitPointWorld;
  32691. private _rayFromWorld;
  32692. private _rayToWorld;
  32693. /**
  32694. * Gets if there was a hit
  32695. */
  32696. get hasHit(): boolean;
  32697. /**
  32698. * Gets the distance from the hit
  32699. */
  32700. get hitDistance(): number;
  32701. /**
  32702. * Gets the hit normal/direction in the world
  32703. */
  32704. get hitNormalWorld(): Vector3;
  32705. /**
  32706. * Gets the hit point in the world
  32707. */
  32708. get hitPointWorld(): Vector3;
  32709. /**
  32710. * Gets the ray "start point" of the ray in the world
  32711. */
  32712. get rayFromWorld(): Vector3;
  32713. /**
  32714. * Gets the ray "end point" of the ray in the world
  32715. */
  32716. get rayToWorld(): Vector3;
  32717. /**
  32718. * Sets the hit data (normal & point in world space)
  32719. * @param hitNormalWorld defines the normal in world space
  32720. * @param hitPointWorld defines the point in world space
  32721. */
  32722. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32723. /**
  32724. * Sets the distance from the start point to the hit point
  32725. * @param distance
  32726. */
  32727. setHitDistance(distance: number): void;
  32728. /**
  32729. * Calculates the distance manually
  32730. */
  32731. calculateHitDistance(): void;
  32732. /**
  32733. * Resets all the values to default
  32734. * @param from The from point on world space
  32735. * @param to The to point on world space
  32736. */
  32737. reset(from?: Vector3, to?: Vector3): void;
  32738. }
  32739. /**
  32740. * Interface for the size containing width and height
  32741. */
  32742. interface IXYZ {
  32743. /**
  32744. * X
  32745. */
  32746. x: number;
  32747. /**
  32748. * Y
  32749. */
  32750. y: number;
  32751. /**
  32752. * Z
  32753. */
  32754. z: number;
  32755. }
  32756. }
  32757. declare module "babylonjs/Physics/IPhysicsEngine" {
  32758. import { Nullable } from "babylonjs/types";
  32759. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32761. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32762. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32764. /**
  32765. * Interface used to describe a physics joint
  32766. */
  32767. export interface PhysicsImpostorJoint {
  32768. /** Defines the main impostor to which the joint is linked */
  32769. mainImpostor: PhysicsImpostor;
  32770. /** Defines the impostor that is connected to the main impostor using this joint */
  32771. connectedImpostor: PhysicsImpostor;
  32772. /** Defines the joint itself */
  32773. joint: PhysicsJoint;
  32774. }
  32775. /** @hidden */
  32776. export interface IPhysicsEnginePlugin {
  32777. world: any;
  32778. name: string;
  32779. setGravity(gravity: Vector3): void;
  32780. setTimeStep(timeStep: number): void;
  32781. getTimeStep(): number;
  32782. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32783. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32784. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32785. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32786. removePhysicsBody(impostor: PhysicsImpostor): void;
  32787. generateJoint(joint: PhysicsImpostorJoint): void;
  32788. removeJoint(joint: PhysicsImpostorJoint): void;
  32789. isSupported(): boolean;
  32790. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32791. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32792. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32796. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32797. getBodyMass(impostor: PhysicsImpostor): number;
  32798. getBodyFriction(impostor: PhysicsImpostor): number;
  32799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32800. getBodyRestitution(impostor: PhysicsImpostor): number;
  32801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32802. getBodyPressure?(impostor: PhysicsImpostor): number;
  32803. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32804. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32805. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32806. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32807. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32808. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32809. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32810. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32811. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32812. sleepBody(impostor: PhysicsImpostor): void;
  32813. wakeUpBody(impostor: PhysicsImpostor): void;
  32814. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32815. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32816. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32817. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32818. getRadius(impostor: PhysicsImpostor): number;
  32819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32820. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32821. dispose(): void;
  32822. }
  32823. /**
  32824. * Interface used to define a physics engine
  32825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32826. */
  32827. export interface IPhysicsEngine {
  32828. /**
  32829. * Gets the gravity vector used by the simulation
  32830. */
  32831. gravity: Vector3;
  32832. /**
  32833. * Sets the gravity vector used by the simulation
  32834. * @param gravity defines the gravity vector to use
  32835. */
  32836. setGravity(gravity: Vector3): void;
  32837. /**
  32838. * Set the time step of the physics engine.
  32839. * Default is 1/60.
  32840. * To slow it down, enter 1/600 for example.
  32841. * To speed it up, 1/30
  32842. * @param newTimeStep the new timestep to apply to this world.
  32843. */
  32844. setTimeStep(newTimeStep: number): void;
  32845. /**
  32846. * Get the time step of the physics engine.
  32847. * @returns the current time step
  32848. */
  32849. getTimeStep(): number;
  32850. /**
  32851. * Set the sub time step of the physics engine.
  32852. * Default is 0 meaning there is no sub steps
  32853. * To increase physics resolution precision, set a small value (like 1 ms)
  32854. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32855. */
  32856. setSubTimeStep(subTimeStep: number): void;
  32857. /**
  32858. * Get the sub time step of the physics engine.
  32859. * @returns the current sub time step
  32860. */
  32861. getSubTimeStep(): number;
  32862. /**
  32863. * Release all resources
  32864. */
  32865. dispose(): void;
  32866. /**
  32867. * Gets the name of the current physics plugin
  32868. * @returns the name of the plugin
  32869. */
  32870. getPhysicsPluginName(): string;
  32871. /**
  32872. * Adding a new impostor for the impostor tracking.
  32873. * This will be done by the impostor itself.
  32874. * @param impostor the impostor to add
  32875. */
  32876. addImpostor(impostor: PhysicsImpostor): void;
  32877. /**
  32878. * Remove an impostor from the engine.
  32879. * This impostor and its mesh will not longer be updated by the physics engine.
  32880. * @param impostor the impostor to remove
  32881. */
  32882. removeImpostor(impostor: PhysicsImpostor): void;
  32883. /**
  32884. * Add a joint to the physics engine
  32885. * @param mainImpostor defines the main impostor to which the joint is added.
  32886. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32887. * @param joint defines the joint that will connect both impostors.
  32888. */
  32889. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32890. /**
  32891. * Removes a joint from the simulation
  32892. * @param mainImpostor defines the impostor used with the joint
  32893. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32894. * @param joint defines the joint to remove
  32895. */
  32896. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32897. /**
  32898. * Gets the current plugin used to run the simulation
  32899. * @returns current plugin
  32900. */
  32901. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32902. /**
  32903. * Gets the list of physic impostors
  32904. * @returns an array of PhysicsImpostor
  32905. */
  32906. getImpostors(): Array<PhysicsImpostor>;
  32907. /**
  32908. * Gets the impostor for a physics enabled object
  32909. * @param object defines the object impersonated by the impostor
  32910. * @returns the PhysicsImpostor or null if not found
  32911. */
  32912. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32913. /**
  32914. * Gets the impostor for a physics body object
  32915. * @param body defines physics body used by the impostor
  32916. * @returns the PhysicsImpostor or null if not found
  32917. */
  32918. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32919. /**
  32920. * Does a raycast in the physics world
  32921. * @param from when should the ray start?
  32922. * @param to when should the ray end?
  32923. * @returns PhysicsRaycastResult
  32924. */
  32925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32926. /**
  32927. * Called by the scene. No need to call it.
  32928. * @param delta defines the timespam between frames
  32929. */
  32930. _step(delta: number): void;
  32931. }
  32932. }
  32933. declare module "babylonjs/Physics/physicsImpostor" {
  32934. import { Nullable, IndicesArray } from "babylonjs/types";
  32935. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32936. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32938. import { Scene } from "babylonjs/scene";
  32939. import { Bone } from "babylonjs/Bones/bone";
  32940. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32941. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32942. import { Space } from "babylonjs/Maths/math.axis";
  32943. /**
  32944. * The interface for the physics imposter parameters
  32945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32946. */
  32947. export interface PhysicsImpostorParameters {
  32948. /**
  32949. * The mass of the physics imposter
  32950. */
  32951. mass: number;
  32952. /**
  32953. * The friction of the physics imposter
  32954. */
  32955. friction?: number;
  32956. /**
  32957. * The coefficient of restitution of the physics imposter
  32958. */
  32959. restitution?: number;
  32960. /**
  32961. * The native options of the physics imposter
  32962. */
  32963. nativeOptions?: any;
  32964. /**
  32965. * Specifies if the parent should be ignored
  32966. */
  32967. ignoreParent?: boolean;
  32968. /**
  32969. * Specifies if bi-directional transformations should be disabled
  32970. */
  32971. disableBidirectionalTransformation?: boolean;
  32972. /**
  32973. * The pressure inside the physics imposter, soft object only
  32974. */
  32975. pressure?: number;
  32976. /**
  32977. * The stiffness the physics imposter, soft object only
  32978. */
  32979. stiffness?: number;
  32980. /**
  32981. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32982. */
  32983. velocityIterations?: number;
  32984. /**
  32985. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32986. */
  32987. positionIterations?: number;
  32988. /**
  32989. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32990. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32991. * Add to fix multiple points
  32992. */
  32993. fixedPoints?: number;
  32994. /**
  32995. * The collision margin around a soft object
  32996. */
  32997. margin?: number;
  32998. /**
  32999. * The collision margin around a soft object
  33000. */
  33001. damping?: number;
  33002. /**
  33003. * The path for a rope based on an extrusion
  33004. */
  33005. path?: any;
  33006. /**
  33007. * The shape of an extrusion used for a rope based on an extrusion
  33008. */
  33009. shape?: any;
  33010. }
  33011. /**
  33012. * Interface for a physics-enabled object
  33013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33014. */
  33015. export interface IPhysicsEnabledObject {
  33016. /**
  33017. * The position of the physics-enabled object
  33018. */
  33019. position: Vector3;
  33020. /**
  33021. * The rotation of the physics-enabled object
  33022. */
  33023. rotationQuaternion: Nullable<Quaternion>;
  33024. /**
  33025. * The scale of the physics-enabled object
  33026. */
  33027. scaling: Vector3;
  33028. /**
  33029. * The rotation of the physics-enabled object
  33030. */
  33031. rotation?: Vector3;
  33032. /**
  33033. * The parent of the physics-enabled object
  33034. */
  33035. parent?: any;
  33036. /**
  33037. * The bounding info of the physics-enabled object
  33038. * @returns The bounding info of the physics-enabled object
  33039. */
  33040. getBoundingInfo(): BoundingInfo;
  33041. /**
  33042. * Computes the world matrix
  33043. * @param force Specifies if the world matrix should be computed by force
  33044. * @returns A world matrix
  33045. */
  33046. computeWorldMatrix(force: boolean): Matrix;
  33047. /**
  33048. * Gets the world matrix
  33049. * @returns A world matrix
  33050. */
  33051. getWorldMatrix?(): Matrix;
  33052. /**
  33053. * Gets the child meshes
  33054. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33055. * @returns An array of abstract meshes
  33056. */
  33057. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33058. /**
  33059. * Gets the vertex data
  33060. * @param kind The type of vertex data
  33061. * @returns A nullable array of numbers, or a float32 array
  33062. */
  33063. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33064. /**
  33065. * Gets the indices from the mesh
  33066. * @returns A nullable array of index arrays
  33067. */
  33068. getIndices?(): Nullable<IndicesArray>;
  33069. /**
  33070. * Gets the scene from the mesh
  33071. * @returns the indices array or null
  33072. */
  33073. getScene?(): Scene;
  33074. /**
  33075. * Gets the absolute position from the mesh
  33076. * @returns the absolute position
  33077. */
  33078. getAbsolutePosition(): Vector3;
  33079. /**
  33080. * Gets the absolute pivot point from the mesh
  33081. * @returns the absolute pivot point
  33082. */
  33083. getAbsolutePivotPoint(): Vector3;
  33084. /**
  33085. * Rotates the mesh
  33086. * @param axis The axis of rotation
  33087. * @param amount The amount of rotation
  33088. * @param space The space of the rotation
  33089. * @returns The rotation transform node
  33090. */
  33091. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33092. /**
  33093. * Translates the mesh
  33094. * @param axis The axis of translation
  33095. * @param distance The distance of translation
  33096. * @param space The space of the translation
  33097. * @returns The transform node
  33098. */
  33099. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33100. /**
  33101. * Sets the absolute position of the mesh
  33102. * @param absolutePosition The absolute position of the mesh
  33103. * @returns The transform node
  33104. */
  33105. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33106. /**
  33107. * Gets the class name of the mesh
  33108. * @returns The class name
  33109. */
  33110. getClassName(): string;
  33111. }
  33112. /**
  33113. * Represents a physics imposter
  33114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33115. */
  33116. export class PhysicsImpostor {
  33117. /**
  33118. * The physics-enabled object used as the physics imposter
  33119. */
  33120. object: IPhysicsEnabledObject;
  33121. /**
  33122. * The type of the physics imposter
  33123. */
  33124. type: number;
  33125. private _options;
  33126. private _scene?;
  33127. /**
  33128. * The default object size of the imposter
  33129. */
  33130. static DEFAULT_OBJECT_SIZE: Vector3;
  33131. /**
  33132. * The identity quaternion of the imposter
  33133. */
  33134. static IDENTITY_QUATERNION: Quaternion;
  33135. /** @hidden */
  33136. _pluginData: any;
  33137. private _physicsEngine;
  33138. private _physicsBody;
  33139. private _bodyUpdateRequired;
  33140. private _onBeforePhysicsStepCallbacks;
  33141. private _onAfterPhysicsStepCallbacks;
  33142. /** @hidden */
  33143. _onPhysicsCollideCallbacks: Array<{
  33144. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33145. otherImpostors: Array<PhysicsImpostor>;
  33146. }>;
  33147. private _deltaPosition;
  33148. private _deltaRotation;
  33149. private _deltaRotationConjugated;
  33150. /** @hidden */
  33151. _isFromLine: boolean;
  33152. private _parent;
  33153. private _isDisposed;
  33154. private static _tmpVecs;
  33155. private static _tmpQuat;
  33156. /**
  33157. * Specifies if the physics imposter is disposed
  33158. */
  33159. get isDisposed(): boolean;
  33160. /**
  33161. * Gets the mass of the physics imposter
  33162. */
  33163. get mass(): number;
  33164. set mass(value: number);
  33165. /**
  33166. * Gets the coefficient of friction
  33167. */
  33168. get friction(): number;
  33169. /**
  33170. * Sets the coefficient of friction
  33171. */
  33172. set friction(value: number);
  33173. /**
  33174. * Gets the coefficient of restitution
  33175. */
  33176. get restitution(): number;
  33177. /**
  33178. * Sets the coefficient of restitution
  33179. */
  33180. set restitution(value: number);
  33181. /**
  33182. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33183. */
  33184. get pressure(): number;
  33185. /**
  33186. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33187. */
  33188. set pressure(value: number);
  33189. /**
  33190. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33191. */
  33192. get stiffness(): number;
  33193. /**
  33194. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33195. */
  33196. set stiffness(value: number);
  33197. /**
  33198. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33199. */
  33200. get velocityIterations(): number;
  33201. /**
  33202. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33203. */
  33204. set velocityIterations(value: number);
  33205. /**
  33206. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33207. */
  33208. get positionIterations(): number;
  33209. /**
  33210. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33211. */
  33212. set positionIterations(value: number);
  33213. /**
  33214. * The unique id of the physics imposter
  33215. * set by the physics engine when adding this impostor to the array
  33216. */
  33217. uniqueId: number;
  33218. /**
  33219. * @hidden
  33220. */
  33221. soft: boolean;
  33222. /**
  33223. * @hidden
  33224. */
  33225. segments: number;
  33226. private _joints;
  33227. /**
  33228. * Initializes the physics imposter
  33229. * @param object The physics-enabled object used as the physics imposter
  33230. * @param type The type of the physics imposter
  33231. * @param _options The options for the physics imposter
  33232. * @param _scene The Babylon scene
  33233. */
  33234. constructor(
  33235. /**
  33236. * The physics-enabled object used as the physics imposter
  33237. */
  33238. object: IPhysicsEnabledObject,
  33239. /**
  33240. * The type of the physics imposter
  33241. */
  33242. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33243. /**
  33244. * This function will completly initialize this impostor.
  33245. * It will create a new body - but only if this mesh has no parent.
  33246. * If it has, this impostor will not be used other than to define the impostor
  33247. * of the child mesh.
  33248. * @hidden
  33249. */
  33250. _init(): void;
  33251. private _getPhysicsParent;
  33252. /**
  33253. * Should a new body be generated.
  33254. * @returns boolean specifying if body initialization is required
  33255. */
  33256. isBodyInitRequired(): boolean;
  33257. /**
  33258. * Sets the updated scaling
  33259. * @param updated Specifies if the scaling is updated
  33260. */
  33261. setScalingUpdated(): void;
  33262. /**
  33263. * Force a regeneration of this or the parent's impostor's body.
  33264. * Use under cautious - This will remove all joints already implemented.
  33265. */
  33266. forceUpdate(): void;
  33267. /**
  33268. * Gets the body that holds this impostor. Either its own, or its parent.
  33269. */
  33270. get physicsBody(): any;
  33271. /**
  33272. * Get the parent of the physics imposter
  33273. * @returns Physics imposter or null
  33274. */
  33275. get parent(): Nullable<PhysicsImpostor>;
  33276. /**
  33277. * Sets the parent of the physics imposter
  33278. */
  33279. set parent(value: Nullable<PhysicsImpostor>);
  33280. /**
  33281. * Set the physics body. Used mainly by the physics engine/plugin
  33282. */
  33283. set physicsBody(physicsBody: any);
  33284. /**
  33285. * Resets the update flags
  33286. */
  33287. resetUpdateFlags(): void;
  33288. /**
  33289. * Gets the object extend size
  33290. * @returns the object extend size
  33291. */
  33292. getObjectExtendSize(): Vector3;
  33293. /**
  33294. * Gets the object center
  33295. * @returns The object center
  33296. */
  33297. getObjectCenter(): Vector3;
  33298. /**
  33299. * Get a specific parameter from the options parameters
  33300. * @param paramName The object parameter name
  33301. * @returns The object parameter
  33302. */
  33303. getParam(paramName: string): any;
  33304. /**
  33305. * Sets a specific parameter in the options given to the physics plugin
  33306. * @param paramName The parameter name
  33307. * @param value The value of the parameter
  33308. */
  33309. setParam(paramName: string, value: number): void;
  33310. /**
  33311. * Specifically change the body's mass option. Won't recreate the physics body object
  33312. * @param mass The mass of the physics imposter
  33313. */
  33314. setMass(mass: number): void;
  33315. /**
  33316. * Gets the linear velocity
  33317. * @returns linear velocity or null
  33318. */
  33319. getLinearVelocity(): Nullable<Vector3>;
  33320. /**
  33321. * Sets the linear velocity
  33322. * @param velocity linear velocity or null
  33323. */
  33324. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33325. /**
  33326. * Gets the angular velocity
  33327. * @returns angular velocity or null
  33328. */
  33329. getAngularVelocity(): Nullable<Vector3>;
  33330. /**
  33331. * Sets the angular velocity
  33332. * @param velocity The velocity or null
  33333. */
  33334. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33335. /**
  33336. * Execute a function with the physics plugin native code
  33337. * Provide a function the will have two variables - the world object and the physics body object
  33338. * @param func The function to execute with the physics plugin native code
  33339. */
  33340. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33341. /**
  33342. * Register a function that will be executed before the physics world is stepping forward
  33343. * @param func The function to execute before the physics world is stepped forward
  33344. */
  33345. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33346. /**
  33347. * Unregister a function that will be executed before the physics world is stepping forward
  33348. * @param func The function to execute before the physics world is stepped forward
  33349. */
  33350. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33351. /**
  33352. * Register a function that will be executed after the physics step
  33353. * @param func The function to execute after physics step
  33354. */
  33355. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33356. /**
  33357. * Unregisters a function that will be executed after the physics step
  33358. * @param func The function to execute after physics step
  33359. */
  33360. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33361. /**
  33362. * register a function that will be executed when this impostor collides against a different body
  33363. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33364. * @param func Callback that is executed on collision
  33365. */
  33366. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33367. /**
  33368. * Unregisters the physics imposter on contact
  33369. * @param collideAgainst The physics object to collide against
  33370. * @param func Callback to execute on collision
  33371. */
  33372. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33373. private _tmpQuat;
  33374. private _tmpQuat2;
  33375. /**
  33376. * Get the parent rotation
  33377. * @returns The parent rotation
  33378. */
  33379. getParentsRotation(): Quaternion;
  33380. /**
  33381. * this function is executed by the physics engine.
  33382. */
  33383. beforeStep: () => void;
  33384. /**
  33385. * this function is executed by the physics engine
  33386. */
  33387. afterStep: () => void;
  33388. /**
  33389. * Legacy collision detection event support
  33390. */
  33391. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33392. /**
  33393. * event and body object due to cannon's event-based architecture.
  33394. */
  33395. onCollide: (e: {
  33396. body: any;
  33397. }) => void;
  33398. /**
  33399. * Apply a force
  33400. * @param force The force to apply
  33401. * @param contactPoint The contact point for the force
  33402. * @returns The physics imposter
  33403. */
  33404. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33405. /**
  33406. * Apply an impulse
  33407. * @param force The impulse force
  33408. * @param contactPoint The contact point for the impulse force
  33409. * @returns The physics imposter
  33410. */
  33411. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33412. /**
  33413. * A help function to create a joint
  33414. * @param otherImpostor A physics imposter used to create a joint
  33415. * @param jointType The type of joint
  33416. * @param jointData The data for the joint
  33417. * @returns The physics imposter
  33418. */
  33419. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33420. /**
  33421. * Add a joint to this impostor with a different impostor
  33422. * @param otherImpostor A physics imposter used to add a joint
  33423. * @param joint The joint to add
  33424. * @returns The physics imposter
  33425. */
  33426. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33427. /**
  33428. * Add an anchor to a cloth impostor
  33429. * @param otherImpostor rigid impostor to anchor to
  33430. * @param width ratio across width from 0 to 1
  33431. * @param height ratio up height from 0 to 1
  33432. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33433. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33434. * @returns impostor the soft imposter
  33435. */
  33436. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33437. /**
  33438. * Add a hook to a rope impostor
  33439. * @param otherImpostor rigid impostor to anchor to
  33440. * @param length ratio across rope from 0 to 1
  33441. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33442. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33443. * @returns impostor the rope imposter
  33444. */
  33445. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33446. /**
  33447. * Will keep this body still, in a sleep mode.
  33448. * @returns the physics imposter
  33449. */
  33450. sleep(): PhysicsImpostor;
  33451. /**
  33452. * Wake the body up.
  33453. * @returns The physics imposter
  33454. */
  33455. wakeUp(): PhysicsImpostor;
  33456. /**
  33457. * Clones the physics imposter
  33458. * @param newObject The physics imposter clones to this physics-enabled object
  33459. * @returns A nullable physics imposter
  33460. */
  33461. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33462. /**
  33463. * Disposes the physics imposter
  33464. */
  33465. dispose(): void;
  33466. /**
  33467. * Sets the delta position
  33468. * @param position The delta position amount
  33469. */
  33470. setDeltaPosition(position: Vector3): void;
  33471. /**
  33472. * Sets the delta rotation
  33473. * @param rotation The delta rotation amount
  33474. */
  33475. setDeltaRotation(rotation: Quaternion): void;
  33476. /**
  33477. * Gets the box size of the physics imposter and stores the result in the input parameter
  33478. * @param result Stores the box size
  33479. * @returns The physics imposter
  33480. */
  33481. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33482. /**
  33483. * Gets the radius of the physics imposter
  33484. * @returns Radius of the physics imposter
  33485. */
  33486. getRadius(): number;
  33487. /**
  33488. * Sync a bone with this impostor
  33489. * @param bone The bone to sync to the impostor.
  33490. * @param boneMesh The mesh that the bone is influencing.
  33491. * @param jointPivot The pivot of the joint / bone in local space.
  33492. * @param distToJoint Optional distance from the impostor to the joint.
  33493. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33494. */
  33495. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33496. /**
  33497. * Sync impostor to a bone
  33498. * @param bone The bone that the impostor will be synced to.
  33499. * @param boneMesh The mesh that the bone is influencing.
  33500. * @param jointPivot The pivot of the joint / bone in local space.
  33501. * @param distToJoint Optional distance from the impostor to the joint.
  33502. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33503. * @param boneAxis Optional vector3 axis the bone is aligned with
  33504. */
  33505. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33506. /**
  33507. * No-Imposter type
  33508. */
  33509. static NoImpostor: number;
  33510. /**
  33511. * Sphere-Imposter type
  33512. */
  33513. static SphereImpostor: number;
  33514. /**
  33515. * Box-Imposter type
  33516. */
  33517. static BoxImpostor: number;
  33518. /**
  33519. * Plane-Imposter type
  33520. */
  33521. static PlaneImpostor: number;
  33522. /**
  33523. * Mesh-imposter type
  33524. */
  33525. static MeshImpostor: number;
  33526. /**
  33527. * Capsule-Impostor type (Ammo.js plugin only)
  33528. */
  33529. static CapsuleImpostor: number;
  33530. /**
  33531. * Cylinder-Imposter type
  33532. */
  33533. static CylinderImpostor: number;
  33534. /**
  33535. * Particle-Imposter type
  33536. */
  33537. static ParticleImpostor: number;
  33538. /**
  33539. * Heightmap-Imposter type
  33540. */
  33541. static HeightmapImpostor: number;
  33542. /**
  33543. * ConvexHull-Impostor type (Ammo.js plugin only)
  33544. */
  33545. static ConvexHullImpostor: number;
  33546. /**
  33547. * Custom-Imposter type (Ammo.js plugin only)
  33548. */
  33549. static CustomImpostor: number;
  33550. /**
  33551. * Rope-Imposter type
  33552. */
  33553. static RopeImpostor: number;
  33554. /**
  33555. * Cloth-Imposter type
  33556. */
  33557. static ClothImpostor: number;
  33558. /**
  33559. * Softbody-Imposter type
  33560. */
  33561. static SoftbodyImpostor: number;
  33562. }
  33563. }
  33564. declare module "babylonjs/Meshes/mesh" {
  33565. import { Observable } from "babylonjs/Misc/observable";
  33566. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33567. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33568. import { Camera } from "babylonjs/Cameras/camera";
  33569. import { Scene } from "babylonjs/scene";
  33570. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33571. import { Color4 } from "babylonjs/Maths/math.color";
  33572. import { Engine } from "babylonjs/Engines/engine";
  33573. import { Node } from "babylonjs/node";
  33574. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33575. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33576. import { Buffer } from "babylonjs/Meshes/buffer";
  33577. import { Geometry } from "babylonjs/Meshes/geometry";
  33578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33580. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33581. import { Effect } from "babylonjs/Materials/effect";
  33582. import { Material } from "babylonjs/Materials/material";
  33583. import { Skeleton } from "babylonjs/Bones/skeleton";
  33584. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33585. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33586. import { Path3D } from "babylonjs/Maths/math.path";
  33587. import { Plane } from "babylonjs/Maths/math.plane";
  33588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33589. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33590. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33591. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33592. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33593. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33594. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33595. /**
  33596. * @hidden
  33597. **/
  33598. export class _CreationDataStorage {
  33599. closePath?: boolean;
  33600. closeArray?: boolean;
  33601. idx: number[];
  33602. dashSize: number;
  33603. gapSize: number;
  33604. path3D: Path3D;
  33605. pathArray: Vector3[][];
  33606. arc: number;
  33607. radius: number;
  33608. cap: number;
  33609. tessellation: number;
  33610. }
  33611. /**
  33612. * @hidden
  33613. **/
  33614. class _InstanceDataStorage {
  33615. visibleInstances: any;
  33616. batchCache: _InstancesBatch;
  33617. instancesBufferSize: number;
  33618. instancesBuffer: Nullable<Buffer>;
  33619. instancesData: Float32Array;
  33620. overridenInstanceCount: number;
  33621. isFrozen: boolean;
  33622. previousBatch: Nullable<_InstancesBatch>;
  33623. hardwareInstancedRendering: boolean;
  33624. sideOrientation: number;
  33625. manualUpdate: boolean;
  33626. previousRenderId: number;
  33627. }
  33628. /**
  33629. * @hidden
  33630. **/
  33631. export class _InstancesBatch {
  33632. mustReturn: boolean;
  33633. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33634. renderSelf: boolean[];
  33635. hardwareInstancedRendering: boolean[];
  33636. }
  33637. /**
  33638. * @hidden
  33639. **/
  33640. class _ThinInstanceDataStorage {
  33641. instancesCount: number;
  33642. matrixBuffer: Nullable<Buffer>;
  33643. matrixBufferSize: number;
  33644. matrixData: Nullable<Float32Array>;
  33645. boundingVectors: Array<Vector3>;
  33646. worldMatrices: Nullable<Matrix[]>;
  33647. }
  33648. /**
  33649. * Class used to represent renderable models
  33650. */
  33651. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33652. /**
  33653. * Mesh side orientation : usually the external or front surface
  33654. */
  33655. static readonly FRONTSIDE: number;
  33656. /**
  33657. * Mesh side orientation : usually the internal or back surface
  33658. */
  33659. static readonly BACKSIDE: number;
  33660. /**
  33661. * Mesh side orientation : both internal and external or front and back surfaces
  33662. */
  33663. static readonly DOUBLESIDE: number;
  33664. /**
  33665. * Mesh side orientation : by default, `FRONTSIDE`
  33666. */
  33667. static readonly DEFAULTSIDE: number;
  33668. /**
  33669. * Mesh cap setting : no cap
  33670. */
  33671. static readonly NO_CAP: number;
  33672. /**
  33673. * Mesh cap setting : one cap at the beginning of the mesh
  33674. */
  33675. static readonly CAP_START: number;
  33676. /**
  33677. * Mesh cap setting : one cap at the end of the mesh
  33678. */
  33679. static readonly CAP_END: number;
  33680. /**
  33681. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33682. */
  33683. static readonly CAP_ALL: number;
  33684. /**
  33685. * Mesh pattern setting : no flip or rotate
  33686. */
  33687. static readonly NO_FLIP: number;
  33688. /**
  33689. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33690. */
  33691. static readonly FLIP_TILE: number;
  33692. /**
  33693. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33694. */
  33695. static readonly ROTATE_TILE: number;
  33696. /**
  33697. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33698. */
  33699. static readonly FLIP_ROW: number;
  33700. /**
  33701. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33702. */
  33703. static readonly ROTATE_ROW: number;
  33704. /**
  33705. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33706. */
  33707. static readonly FLIP_N_ROTATE_TILE: number;
  33708. /**
  33709. * Mesh pattern setting : rotate pattern and rotate
  33710. */
  33711. static readonly FLIP_N_ROTATE_ROW: number;
  33712. /**
  33713. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33714. */
  33715. static readonly CENTER: number;
  33716. /**
  33717. * Mesh tile positioning : part tiles on left
  33718. */
  33719. static readonly LEFT: number;
  33720. /**
  33721. * Mesh tile positioning : part tiles on right
  33722. */
  33723. static readonly RIGHT: number;
  33724. /**
  33725. * Mesh tile positioning : part tiles on top
  33726. */
  33727. static readonly TOP: number;
  33728. /**
  33729. * Mesh tile positioning : part tiles on bottom
  33730. */
  33731. static readonly BOTTOM: number;
  33732. /**
  33733. * Gets the default side orientation.
  33734. * @param orientation the orientation to value to attempt to get
  33735. * @returns the default orientation
  33736. * @hidden
  33737. */
  33738. static _GetDefaultSideOrientation(orientation?: number): number;
  33739. private _internalMeshDataInfo;
  33740. get computeBonesUsingShaders(): boolean;
  33741. set computeBonesUsingShaders(value: boolean);
  33742. /**
  33743. * An event triggered before rendering the mesh
  33744. */
  33745. get onBeforeRenderObservable(): Observable<Mesh>;
  33746. /**
  33747. * An event triggered before binding the mesh
  33748. */
  33749. get onBeforeBindObservable(): Observable<Mesh>;
  33750. /**
  33751. * An event triggered after rendering the mesh
  33752. */
  33753. get onAfterRenderObservable(): Observable<Mesh>;
  33754. /**
  33755. * An event triggered before drawing the mesh
  33756. */
  33757. get onBeforeDrawObservable(): Observable<Mesh>;
  33758. private _onBeforeDrawObserver;
  33759. /**
  33760. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33761. */
  33762. set onBeforeDraw(callback: () => void);
  33763. get hasInstances(): boolean;
  33764. get hasThinInstances(): boolean;
  33765. /**
  33766. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33767. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33768. */
  33769. delayLoadState: number;
  33770. /**
  33771. * Gets the list of instances created from this mesh
  33772. * it is not supposed to be modified manually.
  33773. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33774. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33775. */
  33776. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33777. /**
  33778. * Gets the file containing delay loading data for this mesh
  33779. */
  33780. delayLoadingFile: string;
  33781. /** @hidden */
  33782. _binaryInfo: any;
  33783. /**
  33784. * User defined function used to change how LOD level selection is done
  33785. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33786. */
  33787. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33788. /**
  33789. * Gets or sets the morph target manager
  33790. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33791. */
  33792. get morphTargetManager(): Nullable<MorphTargetManager>;
  33793. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33794. /** @hidden */
  33795. _creationDataStorage: Nullable<_CreationDataStorage>;
  33796. /** @hidden */
  33797. _geometry: Nullable<Geometry>;
  33798. /** @hidden */
  33799. _delayInfo: Array<string>;
  33800. /** @hidden */
  33801. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33802. /** @hidden */
  33803. _instanceDataStorage: _InstanceDataStorage;
  33804. /** @hidden */
  33805. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33806. private _effectiveMaterial;
  33807. /** @hidden */
  33808. _shouldGenerateFlatShading: boolean;
  33809. /** @hidden */
  33810. _originalBuilderSideOrientation: number;
  33811. /**
  33812. * Use this property to change the original side orientation defined at construction time
  33813. */
  33814. overrideMaterialSideOrientation: Nullable<number>;
  33815. /**
  33816. * Gets the source mesh (the one used to clone this one from)
  33817. */
  33818. get source(): Nullable<Mesh>;
  33819. /**
  33820. * Gets the list of clones of this mesh
  33821. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33822. * Note that useClonedMeshMap=true is the default setting
  33823. */
  33824. get cloneMeshMap(): Nullable<{
  33825. [id: string]: Mesh | undefined;
  33826. }>;
  33827. /**
  33828. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33829. */
  33830. get isUnIndexed(): boolean;
  33831. set isUnIndexed(value: boolean);
  33832. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33833. get worldMatrixInstancedBuffer(): Float32Array;
  33834. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33835. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33836. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33837. /**
  33838. * @constructor
  33839. * @param name The value used by scene.getMeshByName() to do a lookup.
  33840. * @param scene The scene to add this mesh to.
  33841. * @param parent The parent of this mesh, if it has one
  33842. * @param source An optional Mesh from which geometry is shared, cloned.
  33843. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33844. * When false, achieved by calling a clone(), also passing False.
  33845. * This will make creation of children, recursive.
  33846. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33847. */
  33848. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33849. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33850. doNotInstantiate: boolean;
  33851. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33852. /**
  33853. * Gets the class name
  33854. * @returns the string "Mesh".
  33855. */
  33856. getClassName(): string;
  33857. /** @hidden */
  33858. get _isMesh(): boolean;
  33859. /**
  33860. * Returns a description of this mesh
  33861. * @param fullDetails define if full details about this mesh must be used
  33862. * @returns a descriptive string representing this mesh
  33863. */
  33864. toString(fullDetails?: boolean): string;
  33865. /** @hidden */
  33866. _unBindEffect(): void;
  33867. /**
  33868. * Gets a boolean indicating if this mesh has LOD
  33869. */
  33870. get hasLODLevels(): boolean;
  33871. /**
  33872. * Gets the list of MeshLODLevel associated with the current mesh
  33873. * @returns an array of MeshLODLevel
  33874. */
  33875. getLODLevels(): MeshLODLevel[];
  33876. private _sortLODLevels;
  33877. /**
  33878. * Add a mesh as LOD level triggered at the given distance.
  33879. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33880. * @param distance The distance from the center of the object to show this level
  33881. * @param mesh The mesh to be added as LOD level (can be null)
  33882. * @return This mesh (for chaining)
  33883. */
  33884. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33885. /**
  33886. * Returns the LOD level mesh at the passed distance or null if not found.
  33887. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33888. * @param distance The distance from the center of the object to show this level
  33889. * @returns a Mesh or `null`
  33890. */
  33891. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33892. /**
  33893. * Remove a mesh from the LOD array
  33894. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33895. * @param mesh defines the mesh to be removed
  33896. * @return This mesh (for chaining)
  33897. */
  33898. removeLODLevel(mesh: Mesh): Mesh;
  33899. /**
  33900. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33901. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33902. * @param camera defines the camera to use to compute distance
  33903. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33904. * @return This mesh (for chaining)
  33905. */
  33906. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33907. /**
  33908. * Gets the mesh internal Geometry object
  33909. */
  33910. get geometry(): Nullable<Geometry>;
  33911. /**
  33912. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33913. * @returns the total number of vertices
  33914. */
  33915. getTotalVertices(): number;
  33916. /**
  33917. * Returns the content of an associated vertex buffer
  33918. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33919. * - VertexBuffer.PositionKind
  33920. * - VertexBuffer.UVKind
  33921. * - VertexBuffer.UV2Kind
  33922. * - VertexBuffer.UV3Kind
  33923. * - VertexBuffer.UV4Kind
  33924. * - VertexBuffer.UV5Kind
  33925. * - VertexBuffer.UV6Kind
  33926. * - VertexBuffer.ColorKind
  33927. * - VertexBuffer.MatricesIndicesKind
  33928. * - VertexBuffer.MatricesIndicesExtraKind
  33929. * - VertexBuffer.MatricesWeightsKind
  33930. * - VertexBuffer.MatricesWeightsExtraKind
  33931. * @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
  33932. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33933. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33934. */
  33935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33936. /**
  33937. * Returns the mesh VertexBuffer object from the requested `kind`
  33938. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33939. * - VertexBuffer.PositionKind
  33940. * - VertexBuffer.NormalKind
  33941. * - VertexBuffer.UVKind
  33942. * - VertexBuffer.UV2Kind
  33943. * - VertexBuffer.UV3Kind
  33944. * - VertexBuffer.UV4Kind
  33945. * - VertexBuffer.UV5Kind
  33946. * - VertexBuffer.UV6Kind
  33947. * - VertexBuffer.ColorKind
  33948. * - VertexBuffer.MatricesIndicesKind
  33949. * - VertexBuffer.MatricesIndicesExtraKind
  33950. * - VertexBuffer.MatricesWeightsKind
  33951. * - VertexBuffer.MatricesWeightsExtraKind
  33952. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33953. */
  33954. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33955. /**
  33956. * Tests if a specific vertex buffer is associated with this mesh
  33957. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33958. * - VertexBuffer.PositionKind
  33959. * - VertexBuffer.NormalKind
  33960. * - VertexBuffer.UVKind
  33961. * - VertexBuffer.UV2Kind
  33962. * - VertexBuffer.UV3Kind
  33963. * - VertexBuffer.UV4Kind
  33964. * - VertexBuffer.UV5Kind
  33965. * - VertexBuffer.UV6Kind
  33966. * - VertexBuffer.ColorKind
  33967. * - VertexBuffer.MatricesIndicesKind
  33968. * - VertexBuffer.MatricesIndicesExtraKind
  33969. * - VertexBuffer.MatricesWeightsKind
  33970. * - VertexBuffer.MatricesWeightsExtraKind
  33971. * @returns a boolean
  33972. */
  33973. isVerticesDataPresent(kind: string): boolean;
  33974. /**
  33975. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33976. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33977. * - VertexBuffer.PositionKind
  33978. * - VertexBuffer.UVKind
  33979. * - VertexBuffer.UV2Kind
  33980. * - VertexBuffer.UV3Kind
  33981. * - VertexBuffer.UV4Kind
  33982. * - VertexBuffer.UV5Kind
  33983. * - VertexBuffer.UV6Kind
  33984. * - VertexBuffer.ColorKind
  33985. * - VertexBuffer.MatricesIndicesKind
  33986. * - VertexBuffer.MatricesIndicesExtraKind
  33987. * - VertexBuffer.MatricesWeightsKind
  33988. * - VertexBuffer.MatricesWeightsExtraKind
  33989. * @returns a boolean
  33990. */
  33991. isVertexBufferUpdatable(kind: string): boolean;
  33992. /**
  33993. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33994. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33995. * - VertexBuffer.PositionKind
  33996. * - VertexBuffer.NormalKind
  33997. * - VertexBuffer.UVKind
  33998. * - VertexBuffer.UV2Kind
  33999. * - VertexBuffer.UV3Kind
  34000. * - VertexBuffer.UV4Kind
  34001. * - VertexBuffer.UV5Kind
  34002. * - VertexBuffer.UV6Kind
  34003. * - VertexBuffer.ColorKind
  34004. * - VertexBuffer.MatricesIndicesKind
  34005. * - VertexBuffer.MatricesIndicesExtraKind
  34006. * - VertexBuffer.MatricesWeightsKind
  34007. * - VertexBuffer.MatricesWeightsExtraKind
  34008. * @returns an array of strings
  34009. */
  34010. getVerticesDataKinds(): string[];
  34011. /**
  34012. * Returns a positive integer : the total number of indices in this mesh geometry.
  34013. * @returns the numner of indices or zero if the mesh has no geometry.
  34014. */
  34015. getTotalIndices(): number;
  34016. /**
  34017. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34018. * @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.
  34019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34020. * @returns the indices array or an empty array if the mesh has no geometry
  34021. */
  34022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34023. get isBlocked(): boolean;
  34024. /**
  34025. * Determine if the current mesh is ready to be rendered
  34026. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34027. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34028. * @returns true if all associated assets are ready (material, textures, shaders)
  34029. */
  34030. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34031. /**
  34032. * 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.
  34033. */
  34034. get areNormalsFrozen(): boolean;
  34035. /**
  34036. * 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.
  34037. * @returns the current mesh
  34038. */
  34039. freezeNormals(): Mesh;
  34040. /**
  34041. * 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
  34042. * @returns the current mesh
  34043. */
  34044. unfreezeNormals(): Mesh;
  34045. /**
  34046. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34047. */
  34048. set overridenInstanceCount(count: number);
  34049. /** @hidden */
  34050. _preActivate(): Mesh;
  34051. /** @hidden */
  34052. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34053. /** @hidden */
  34054. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34055. protected _afterComputeWorldMatrix(): void;
  34056. /** @hidden */
  34057. _postActivate(): void;
  34058. /**
  34059. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34060. * This means the mesh underlying bounding box and sphere are recomputed.
  34061. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34062. * @returns the current mesh
  34063. */
  34064. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34065. /** @hidden */
  34066. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34067. /**
  34068. * This function will subdivide the mesh into multiple submeshes
  34069. * @param count defines the expected number of submeshes
  34070. */
  34071. subdivide(count: number): void;
  34072. /**
  34073. * Copy a FloatArray into a specific associated vertex buffer
  34074. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34075. * - VertexBuffer.PositionKind
  34076. * - VertexBuffer.UVKind
  34077. * - VertexBuffer.UV2Kind
  34078. * - VertexBuffer.UV3Kind
  34079. * - VertexBuffer.UV4Kind
  34080. * - VertexBuffer.UV5Kind
  34081. * - VertexBuffer.UV6Kind
  34082. * - VertexBuffer.ColorKind
  34083. * - VertexBuffer.MatricesIndicesKind
  34084. * - VertexBuffer.MatricesIndicesExtraKind
  34085. * - VertexBuffer.MatricesWeightsKind
  34086. * - VertexBuffer.MatricesWeightsExtraKind
  34087. * @param data defines the data source
  34088. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34089. * @param stride defines the data stride size (can be null)
  34090. * @returns the current mesh
  34091. */
  34092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34093. /**
  34094. * Delete a vertex buffer associated with this mesh
  34095. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34096. * - VertexBuffer.PositionKind
  34097. * - VertexBuffer.UVKind
  34098. * - VertexBuffer.UV2Kind
  34099. * - VertexBuffer.UV3Kind
  34100. * - VertexBuffer.UV4Kind
  34101. * - VertexBuffer.UV5Kind
  34102. * - VertexBuffer.UV6Kind
  34103. * - VertexBuffer.ColorKind
  34104. * - VertexBuffer.MatricesIndicesKind
  34105. * - VertexBuffer.MatricesIndicesExtraKind
  34106. * - VertexBuffer.MatricesWeightsKind
  34107. * - VertexBuffer.MatricesWeightsExtraKind
  34108. */
  34109. removeVerticesData(kind: string): void;
  34110. /**
  34111. * Flags an associated vertex buffer as updatable
  34112. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34113. * - VertexBuffer.PositionKind
  34114. * - VertexBuffer.UVKind
  34115. * - VertexBuffer.UV2Kind
  34116. * - VertexBuffer.UV3Kind
  34117. * - VertexBuffer.UV4Kind
  34118. * - VertexBuffer.UV5Kind
  34119. * - VertexBuffer.UV6Kind
  34120. * - VertexBuffer.ColorKind
  34121. * - VertexBuffer.MatricesIndicesKind
  34122. * - VertexBuffer.MatricesIndicesExtraKind
  34123. * - VertexBuffer.MatricesWeightsKind
  34124. * - VertexBuffer.MatricesWeightsExtraKind
  34125. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34126. */
  34127. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34128. /**
  34129. * Sets the mesh global Vertex Buffer
  34130. * @param buffer defines the buffer to use
  34131. * @returns the current mesh
  34132. */
  34133. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34134. /**
  34135. * Update a specific associated vertex buffer
  34136. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34137. * - VertexBuffer.PositionKind
  34138. * - VertexBuffer.UVKind
  34139. * - VertexBuffer.UV2Kind
  34140. * - VertexBuffer.UV3Kind
  34141. * - VertexBuffer.UV4Kind
  34142. * - VertexBuffer.UV5Kind
  34143. * - VertexBuffer.UV6Kind
  34144. * - VertexBuffer.ColorKind
  34145. * - VertexBuffer.MatricesIndicesKind
  34146. * - VertexBuffer.MatricesIndicesExtraKind
  34147. * - VertexBuffer.MatricesWeightsKind
  34148. * - VertexBuffer.MatricesWeightsExtraKind
  34149. * @param data defines the data source
  34150. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34151. * @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)
  34152. * @returns the current mesh
  34153. */
  34154. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34155. /**
  34156. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34157. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34158. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34159. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34160. * @returns the current mesh
  34161. */
  34162. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34163. /**
  34164. * Creates a un-shared specific occurence of the geometry for the mesh.
  34165. * @returns the current mesh
  34166. */
  34167. makeGeometryUnique(): Mesh;
  34168. /**
  34169. * Set the index buffer of this mesh
  34170. * @param indices defines the source data
  34171. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34172. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34173. * @returns the current mesh
  34174. */
  34175. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34176. /**
  34177. * Update the current index buffer
  34178. * @param indices defines the source data
  34179. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34180. * @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)
  34181. * @returns the current mesh
  34182. */
  34183. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34184. /**
  34185. * Invert the geometry to move from a right handed system to a left handed one.
  34186. * @returns the current mesh
  34187. */
  34188. toLeftHanded(): Mesh;
  34189. /** @hidden */
  34190. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34191. /** @hidden */
  34192. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34193. /**
  34194. * Registers for this mesh a javascript function called just before the rendering process
  34195. * @param func defines the function to call before rendering this mesh
  34196. * @returns the current mesh
  34197. */
  34198. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34199. /**
  34200. * Disposes a previously registered javascript function called before the rendering
  34201. * @param func defines the function to remove
  34202. * @returns the current mesh
  34203. */
  34204. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34205. /**
  34206. * Registers for this mesh a javascript function called just after the rendering is complete
  34207. * @param func defines the function to call after rendering this mesh
  34208. * @returns the current mesh
  34209. */
  34210. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34211. /**
  34212. * Disposes a previously registered javascript function called after the rendering.
  34213. * @param func defines the function to remove
  34214. * @returns the current mesh
  34215. */
  34216. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34217. /** @hidden */
  34218. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34219. /** @hidden */
  34220. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34221. /** @hidden */
  34222. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34223. /** @hidden */
  34224. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34225. /** @hidden */
  34226. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34227. /** @hidden */
  34228. _rebuild(): void;
  34229. /** @hidden */
  34230. _freeze(): void;
  34231. /** @hidden */
  34232. _unFreeze(): void;
  34233. /**
  34234. * 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
  34235. * @param subMesh defines the subMesh to render
  34236. * @param enableAlphaMode defines if alpha mode can be changed
  34237. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34238. * @returns the current mesh
  34239. */
  34240. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34241. private _onBeforeDraw;
  34242. /**
  34243. * Renormalize the mesh and patch it up if there are no weights
  34244. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34245. * However in the case of zero weights then we set just a single influence to 1.
  34246. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34247. */
  34248. cleanMatrixWeights(): void;
  34249. private normalizeSkinFourWeights;
  34250. private normalizeSkinWeightsAndExtra;
  34251. /**
  34252. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34253. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34254. * the user know there was an issue with importing the mesh
  34255. * @returns a validation object with skinned, valid and report string
  34256. */
  34257. validateSkinning(): {
  34258. skinned: boolean;
  34259. valid: boolean;
  34260. report: string;
  34261. };
  34262. /** @hidden */
  34263. _checkDelayState(): Mesh;
  34264. private _queueLoad;
  34265. /**
  34266. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34267. * A mesh is in the frustum if its bounding box intersects the frustum
  34268. * @param frustumPlanes defines the frustum to test
  34269. * @returns true if the mesh is in the frustum planes
  34270. */
  34271. isInFrustum(frustumPlanes: Plane[]): boolean;
  34272. /**
  34273. * Sets the mesh material by the material or multiMaterial `id` property
  34274. * @param id is a string identifying the material or the multiMaterial
  34275. * @returns the current mesh
  34276. */
  34277. setMaterialByID(id: string): Mesh;
  34278. /**
  34279. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34280. * @returns an array of IAnimatable
  34281. */
  34282. getAnimatables(): IAnimatable[];
  34283. /**
  34284. * Modifies the mesh geometry according to the passed transformation matrix.
  34285. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34286. * The mesh normals are modified using the same transformation.
  34287. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34288. * @param transform defines the transform matrix to use
  34289. * @see https://doc.babylonjs.com/resources/baking_transformations
  34290. * @returns the current mesh
  34291. */
  34292. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34293. /**
  34294. * Modifies the mesh geometry according to its own current World Matrix.
  34295. * The mesh World Matrix is then reset.
  34296. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34298. * @see https://doc.babylonjs.com/resources/baking_transformations
  34299. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34300. * @returns the current mesh
  34301. */
  34302. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34303. /** @hidden */
  34304. get _positions(): Nullable<Vector3[]>;
  34305. /** @hidden */
  34306. _resetPointsArrayCache(): Mesh;
  34307. /** @hidden */
  34308. _generatePointsArray(): boolean;
  34309. /**
  34310. * Returns a new Mesh object generated from the current mesh properties.
  34311. * This method must not get confused with createInstance()
  34312. * @param name is a string, the name given to the new mesh
  34313. * @param newParent can be any Node object (default `null`)
  34314. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34315. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34316. * @returns a new mesh
  34317. */
  34318. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34319. /**
  34320. * Releases resources associated with this mesh.
  34321. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34322. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34323. */
  34324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34325. /** @hidden */
  34326. _disposeInstanceSpecificData(): void;
  34327. /** @hidden */
  34328. _disposeThinInstanceSpecificData(): void;
  34329. /**
  34330. * Modifies the mesh geometry according to a displacement map.
  34331. * 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.
  34332. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34333. * @param url is a string, the URL from the image file is to be downloaded.
  34334. * @param minHeight is the lower limit of the displacement.
  34335. * @param maxHeight is the upper limit of the displacement.
  34336. * @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.
  34337. * @param uvOffset is an optional vector2 used to offset UV.
  34338. * @param uvScale is an optional vector2 used to scale UV.
  34339. * @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.
  34340. * @returns the Mesh.
  34341. */
  34342. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34343. /**
  34344. * Modifies the mesh geometry according to a displacementMap buffer.
  34345. * 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.
  34346. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34347. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34348. * @param heightMapWidth is the width of the buffer image.
  34349. * @param heightMapHeight is the height of the buffer image.
  34350. * @param minHeight is the lower limit of the displacement.
  34351. * @param maxHeight is the upper limit of the displacement.
  34352. * @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.
  34353. * @param uvOffset is an optional vector2 used to offset UV.
  34354. * @param uvScale is an optional vector2 used to scale UV.
  34355. * @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.
  34356. * @returns the Mesh.
  34357. */
  34358. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34359. /**
  34360. * Modify the mesh to get a flat shading rendering.
  34361. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34362. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34363. * @returns current mesh
  34364. */
  34365. convertToFlatShadedMesh(): Mesh;
  34366. /**
  34367. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34368. * In other words, more vertices, no more indices and a single bigger VBO.
  34369. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34370. * @returns current mesh
  34371. */
  34372. convertToUnIndexedMesh(): Mesh;
  34373. /**
  34374. * Inverses facet orientations.
  34375. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34376. * @param flipNormals will also inverts the normals
  34377. * @returns current mesh
  34378. */
  34379. flipFaces(flipNormals?: boolean): Mesh;
  34380. /**
  34381. * Increase the number of facets and hence vertices in a mesh
  34382. * Vertex normals are interpolated from existing vertex normals
  34383. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34384. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34385. */
  34386. increaseVertices(numberPerEdge: number): void;
  34387. /**
  34388. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34389. * This will undo any application of covertToFlatShadedMesh
  34390. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34391. */
  34392. forceSharedVertices(): void;
  34393. /** @hidden */
  34394. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34395. /** @hidden */
  34396. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34397. /**
  34398. * Creates a new InstancedMesh object from the mesh model.
  34399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34400. * @param name defines the name of the new instance
  34401. * @returns a new InstancedMesh
  34402. */
  34403. createInstance(name: string): InstancedMesh;
  34404. /**
  34405. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34406. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34407. * @returns the current mesh
  34408. */
  34409. synchronizeInstances(): Mesh;
  34410. /**
  34411. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34412. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34413. * This should be used together with the simplification to avoid disappearing triangles.
  34414. * @param successCallback an optional success callback to be called after the optimization finished.
  34415. * @returns the current mesh
  34416. */
  34417. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34418. /**
  34419. * Serialize current mesh
  34420. * @param serializationObject defines the object which will receive the serialization data
  34421. */
  34422. serialize(serializationObject: any): void;
  34423. /** @hidden */
  34424. _syncGeometryWithMorphTargetManager(): void;
  34425. /** @hidden */
  34426. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34427. /**
  34428. * Returns a new Mesh object parsed from the source provided.
  34429. * @param parsedMesh is the source
  34430. * @param scene defines the hosting scene
  34431. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34432. * @returns a new Mesh
  34433. */
  34434. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34435. /**
  34436. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34438. * @param name defines the name of the mesh to create
  34439. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34440. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34441. * @param closePath creates a seam between the first and the last points of each path of the path array
  34442. * @param offset is taken in account only if the `pathArray` is containing a single path
  34443. * @param scene defines the hosting scene
  34444. * @param updatable defines if the mesh must be flagged as updatable
  34445. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34446. * @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)
  34447. * @returns a new Mesh
  34448. */
  34449. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34450. /**
  34451. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34452. * @param name defines the name of the mesh to create
  34453. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34454. * @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
  34455. * @param scene defines the hosting scene
  34456. * @param updatable defines if the mesh must be flagged as updatable
  34457. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34458. * @returns a new Mesh
  34459. */
  34460. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34461. /**
  34462. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34463. * @param name defines the name of the mesh to create
  34464. * @param size sets the size (float) of each box side (default 1)
  34465. * @param scene defines the hosting scene
  34466. * @param updatable defines if the mesh must be flagged as updatable
  34467. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34468. * @returns a new Mesh
  34469. */
  34470. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34471. /**
  34472. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34473. * @param name defines the name of the mesh to create
  34474. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34475. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34476. * @param scene defines the hosting scene
  34477. * @param updatable defines if the mesh must be flagged as updatable
  34478. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34479. * @returns a new Mesh
  34480. */
  34481. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34482. /**
  34483. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34484. * @param name defines the name of the mesh to create
  34485. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34486. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34487. * @param scene defines the hosting scene
  34488. * @returns a new Mesh
  34489. */
  34490. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34491. /**
  34492. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34493. * @param name defines the name of the mesh to create
  34494. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34495. * @param diameterTop set the top cap diameter (floats, default 1)
  34496. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34497. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34498. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34499. * @param scene defines the hosting scene
  34500. * @param updatable defines if the mesh must be flagged as updatable
  34501. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34502. * @returns a new Mesh
  34503. */
  34504. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34505. /**
  34506. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34507. * @param name defines the name of the mesh to create
  34508. * @param diameter sets the diameter size (float) of the torus (default 1)
  34509. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34510. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34511. * @param scene defines the hosting scene
  34512. * @param updatable defines if the mesh must be flagged as updatable
  34513. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34514. * @returns a new Mesh
  34515. */
  34516. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34517. /**
  34518. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34519. * @param name defines the name of the mesh to create
  34520. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34521. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34522. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34523. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34524. * @param p the number of windings on X axis (positive integers, default 2)
  34525. * @param q the number of windings on Y axis (positive integers, default 3)
  34526. * @param scene defines the hosting scene
  34527. * @param updatable defines if the mesh must be flagged as updatable
  34528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34529. * @returns a new Mesh
  34530. */
  34531. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34532. /**
  34533. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34534. * @param name defines the name of the mesh to create
  34535. * @param points is an array successive Vector3
  34536. * @param scene defines the hosting scene
  34537. * @param updatable defines if the mesh must be flagged as updatable
  34538. * @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).
  34539. * @returns a new Mesh
  34540. */
  34541. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34542. /**
  34543. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34544. * @param name defines the name of the mesh to create
  34545. * @param points is an array successive Vector3
  34546. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34547. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34548. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34549. * @param scene defines the hosting scene
  34550. * @param updatable defines if the mesh must be flagged as updatable
  34551. * @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)
  34552. * @returns a new Mesh
  34553. */
  34554. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34555. /**
  34556. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34557. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34558. * 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.
  34559. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34560. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34561. * Remember you can only change the shape positions, not their number when updating a polygon.
  34562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34563. * @param name defines the name of the mesh to create
  34564. * @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
  34565. * @param scene defines the hosting scene
  34566. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34567. * @param updatable defines if the mesh must be flagged as updatable
  34568. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34569. * @param earcutInjection can be used to inject your own earcut reference
  34570. * @returns a new Mesh
  34571. */
  34572. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34573. /**
  34574. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34576. * @param name defines the name of the mesh to create
  34577. * @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
  34578. * @param depth defines the height of extrusion
  34579. * @param scene defines the hosting scene
  34580. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34581. * @param updatable defines if the mesh must be flagged as updatable
  34582. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34583. * @param earcutInjection can be used to inject your own earcut reference
  34584. * @returns a new Mesh
  34585. */
  34586. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34587. /**
  34588. * Creates an extruded shape mesh.
  34589. * 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
  34590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34592. * @param name defines the name of the mesh to create
  34593. * @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
  34594. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34595. * @param scale is the value to scale the shape
  34596. * @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
  34597. * @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
  34598. * @param scene defines the hosting scene
  34599. * @param updatable defines if the mesh must be flagged as updatable
  34600. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34601. * @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)
  34602. * @returns a new Mesh
  34603. */
  34604. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34605. /**
  34606. * Creates an custom extruded shape mesh.
  34607. * The custom extrusion is a parametric shape.
  34608. * It has no predefined shape. Its final shape will depend on the input parameters.
  34609. * Please consider using the same method from the MeshBuilder class instead
  34610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34611. * @param name defines the name of the mesh to create
  34612. * @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
  34613. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34614. * @param scaleFunction is a custom Javascript function called on each path point
  34615. * @param rotationFunction is a custom Javascript function called on each path point
  34616. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34617. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34618. * @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
  34619. * @param scene defines the hosting scene
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34622. * @param 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)
  34623. * @returns a new Mesh
  34624. */
  34625. 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;
  34626. /**
  34627. * Creates lathe mesh.
  34628. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34629. * Please consider using the same method from the MeshBuilder class instead
  34630. * @param name defines the name of the mesh to create
  34631. * @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
  34632. * @param radius is the radius value of the lathe
  34633. * @param tessellation is the side number of the lathe.
  34634. * @param scene defines the hosting scene
  34635. * @param updatable defines if the mesh must be flagged as updatable
  34636. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34637. * @returns a new Mesh
  34638. */
  34639. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34640. /**
  34641. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34642. * @param name defines the name of the mesh to create
  34643. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34644. * @param scene defines the hosting scene
  34645. * @param updatable defines if the mesh must be flagged as updatable
  34646. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34647. * @returns a new Mesh
  34648. */
  34649. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34650. /**
  34651. * Creates a ground mesh.
  34652. * Please consider using the same method from the MeshBuilder class instead
  34653. * @param name defines the name of the mesh to create
  34654. * @param width set the width of the ground
  34655. * @param height set the height of the ground
  34656. * @param subdivisions sets the number of subdivisions per side
  34657. * @param scene defines the hosting scene
  34658. * @param updatable defines if the mesh must be flagged as updatable
  34659. * @returns a new Mesh
  34660. */
  34661. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34662. /**
  34663. * Creates a tiled ground mesh.
  34664. * Please consider using the same method from the MeshBuilder class instead
  34665. * @param name defines the name of the mesh to create
  34666. * @param xmin set the ground minimum X coordinate
  34667. * @param zmin set the ground minimum Y coordinate
  34668. * @param xmax set the ground maximum X coordinate
  34669. * @param zmax set the ground maximum Z coordinate
  34670. * @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
  34671. * @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
  34672. * @param scene defines the hosting scene
  34673. * @param updatable defines if the mesh must be flagged as updatable
  34674. * @returns a new Mesh
  34675. */
  34676. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34677. w: number;
  34678. h: number;
  34679. }, precision: {
  34680. w: number;
  34681. h: number;
  34682. }, scene: Scene, updatable?: boolean): Mesh;
  34683. /**
  34684. * Creates a ground mesh from a height map.
  34685. * Please consider using the same method from the MeshBuilder class instead
  34686. * @see https://doc.babylonjs.com/babylon101/height_map
  34687. * @param name defines the name of the mesh to create
  34688. * @param url sets the URL of the height map image resource
  34689. * @param width set the ground width size
  34690. * @param height set the ground height size
  34691. * @param subdivisions sets the number of subdivision per side
  34692. * @param minHeight is the minimum altitude on the ground
  34693. * @param maxHeight is the maximum altitude on the ground
  34694. * @param scene defines the hosting scene
  34695. * @param updatable defines if the mesh must be flagged as updatable
  34696. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34697. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34698. * @returns a new Mesh
  34699. */
  34700. 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;
  34701. /**
  34702. * Creates a tube mesh.
  34703. * The tube is a parametric shape.
  34704. * It has no predefined shape. Its final shape will depend on the input parameters.
  34705. * Please consider using the same method from the MeshBuilder class instead
  34706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34707. * @param name defines the name of the mesh to create
  34708. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34709. * @param radius sets the tube radius size
  34710. * @param tessellation is the number of sides on the tubular surface
  34711. * @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
  34712. * @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
  34713. * @param scene defines the hosting scene
  34714. * @param updatable defines if the mesh must be flagged as updatable
  34715. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34716. * @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)
  34717. * @returns a new Mesh
  34718. */
  34719. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34720. (i: number, distance: number): number;
  34721. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34722. /**
  34723. * Creates a polyhedron mesh.
  34724. * Please consider using the same method from the MeshBuilder class instead.
  34725. * * 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
  34726. * * The parameter `size` (positive float, default 1) sets the polygon size
  34727. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34728. * * 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`
  34729. * * 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
  34730. * * 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)`)
  34731. * * 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
  34732. * * 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
  34733. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34736. * @param name defines the name of the mesh to create
  34737. * @param options defines the options used to create the mesh
  34738. * @param scene defines the hosting scene
  34739. * @returns a new Mesh
  34740. */
  34741. static CreatePolyhedron(name: string, options: {
  34742. type?: number;
  34743. size?: number;
  34744. sizeX?: number;
  34745. sizeY?: number;
  34746. sizeZ?: number;
  34747. custom?: any;
  34748. faceUV?: Vector4[];
  34749. faceColors?: Color4[];
  34750. updatable?: boolean;
  34751. sideOrientation?: number;
  34752. }, scene: Scene): Mesh;
  34753. /**
  34754. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34755. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34756. * * 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`)
  34757. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34758. * * 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
  34759. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34762. * @param name defines the name of the mesh
  34763. * @param options defines the options used to create the mesh
  34764. * @param scene defines the hosting scene
  34765. * @returns a new Mesh
  34766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34767. */
  34768. static CreateIcoSphere(name: string, options: {
  34769. radius?: number;
  34770. flat?: boolean;
  34771. subdivisions?: number;
  34772. sideOrientation?: number;
  34773. updatable?: boolean;
  34774. }, scene: Scene): Mesh;
  34775. /**
  34776. * Creates a decal mesh.
  34777. * Please consider using the same method from the MeshBuilder class instead.
  34778. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34779. * @param name defines the name of the mesh
  34780. * @param sourceMesh defines the mesh receiving the decal
  34781. * @param position sets the position of the decal in world coordinates
  34782. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34783. * @param size sets the decal scaling
  34784. * @param angle sets the angle to rotate the decal
  34785. * @returns a new Mesh
  34786. */
  34787. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34788. /** Creates a Capsule Mesh
  34789. * @param name defines the name of the mesh.
  34790. * @param options the constructors options used to shape the mesh.
  34791. * @param scene defines the scene the mesh is scoped to.
  34792. * @returns the capsule mesh
  34793. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34794. */
  34795. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34796. /**
  34797. * Prepare internal position array for software CPU skinning
  34798. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34799. */
  34800. setPositionsForCPUSkinning(): Float32Array;
  34801. /**
  34802. * Prepare internal normal array for software CPU skinning
  34803. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34804. */
  34805. setNormalsForCPUSkinning(): Float32Array;
  34806. /**
  34807. * Updates the vertex buffer by applying transformation from the bones
  34808. * @param skeleton defines the skeleton to apply to current mesh
  34809. * @returns the current mesh
  34810. */
  34811. applySkeleton(skeleton: Skeleton): Mesh;
  34812. /**
  34813. * 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
  34814. * @param meshes defines the list of meshes to scan
  34815. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34816. */
  34817. static MinMax(meshes: AbstractMesh[]): {
  34818. min: Vector3;
  34819. max: Vector3;
  34820. };
  34821. /**
  34822. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34823. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34824. * @returns a vector3
  34825. */
  34826. static Center(meshesOrMinMaxVector: {
  34827. min: Vector3;
  34828. max: Vector3;
  34829. } | AbstractMesh[]): Vector3;
  34830. /**
  34831. * Merge the array of meshes into a single mesh for performance reasons.
  34832. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34833. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34834. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34835. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34836. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34837. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34838. * @returns a new mesh
  34839. */
  34840. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34841. /** @hidden */
  34842. addInstance(instance: InstancedMesh): void;
  34843. /** @hidden */
  34844. removeInstance(instance: InstancedMesh): void;
  34845. }
  34846. }
  34847. declare module "babylonjs/Cameras/camera" {
  34848. import { SmartArray } from "babylonjs/Misc/smartArray";
  34849. import { Observable } from "babylonjs/Misc/observable";
  34850. import { Nullable } from "babylonjs/types";
  34851. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34852. import { Scene } from "babylonjs/scene";
  34853. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34854. import { Node } from "babylonjs/node";
  34855. import { Mesh } from "babylonjs/Meshes/mesh";
  34856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34857. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34858. import { Viewport } from "babylonjs/Maths/math.viewport";
  34859. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34861. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34862. import { Ray } from "babylonjs/Culling/ray";
  34863. /**
  34864. * This is the base class of all the camera used in the application.
  34865. * @see https://doc.babylonjs.com/features/cameras
  34866. */
  34867. export class Camera extends Node {
  34868. /** @hidden */
  34869. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34870. /**
  34871. * This is the default projection mode used by the cameras.
  34872. * It helps recreating a feeling of perspective and better appreciate depth.
  34873. * This is the best way to simulate real life cameras.
  34874. */
  34875. static readonly PERSPECTIVE_CAMERA: number;
  34876. /**
  34877. * This helps creating camera with an orthographic mode.
  34878. * 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.
  34879. */
  34880. static readonly ORTHOGRAPHIC_CAMERA: number;
  34881. /**
  34882. * This is the default FOV mode for perspective cameras.
  34883. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34884. */
  34885. static readonly FOVMODE_VERTICAL_FIXED: number;
  34886. /**
  34887. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34888. */
  34889. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34890. /**
  34891. * This specifies ther is no need for a camera rig.
  34892. * Basically only one eye is rendered corresponding to the camera.
  34893. */
  34894. static readonly RIG_MODE_NONE: number;
  34895. /**
  34896. * Simulates a camera Rig with one blue eye and one red eye.
  34897. * This can be use with 3d blue and red glasses.
  34898. */
  34899. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34900. /**
  34901. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34902. */
  34903. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34904. /**
  34905. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34906. */
  34907. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34908. /**
  34909. * Defines that both eyes of the camera will be rendered over under each other.
  34910. */
  34911. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34912. /**
  34913. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34914. */
  34915. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34916. /**
  34917. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34918. */
  34919. static readonly RIG_MODE_VR: number;
  34920. /**
  34921. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34922. */
  34923. static readonly RIG_MODE_WEBVR: number;
  34924. /**
  34925. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  34926. */
  34927. static readonly RIG_MODE_CUSTOM: number;
  34928. /**
  34929. * Defines if by default attaching controls should prevent the default javascript event to continue.
  34930. */
  34931. static ForceAttachControlToAlwaysPreventDefault: boolean;
  34932. /**
  34933. * Define the input manager associated with the camera.
  34934. */
  34935. inputs: CameraInputsManager<Camera>;
  34936. /** @hidden */
  34937. _position: Vector3;
  34938. /**
  34939. * Define the current local position of the camera in the scene
  34940. */
  34941. get position(): Vector3;
  34942. set position(newPosition: Vector3);
  34943. protected _upVector: Vector3;
  34944. /**
  34945. * The vector the camera should consider as up.
  34946. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34947. */
  34948. set upVector(vec: Vector3);
  34949. get upVector(): Vector3;
  34950. /**
  34951. * Define the current limit on the left side for an orthographic camera
  34952. * In scene unit
  34953. */
  34954. orthoLeft: Nullable<number>;
  34955. /**
  34956. * Define the current limit on the right side for an orthographic camera
  34957. * In scene unit
  34958. */
  34959. orthoRight: Nullable<number>;
  34960. /**
  34961. * Define the current limit on the bottom side for an orthographic camera
  34962. * In scene unit
  34963. */
  34964. orthoBottom: Nullable<number>;
  34965. /**
  34966. * Define the current limit on the top side for an orthographic camera
  34967. * In scene unit
  34968. */
  34969. orthoTop: Nullable<number>;
  34970. /**
  34971. * Field Of View is set in Radians. (default is 0.8)
  34972. */
  34973. fov: number;
  34974. /**
  34975. * Define the minimum distance the camera can see from.
  34976. * This is important to note that the depth buffer are not infinite and the closer it starts
  34977. * the more your scene might encounter depth fighting issue.
  34978. */
  34979. minZ: number;
  34980. /**
  34981. * Define the maximum distance the camera can see to.
  34982. * This is important to note that the depth buffer are not infinite and the further it end
  34983. * the more your scene might encounter depth fighting issue.
  34984. */
  34985. maxZ: number;
  34986. /**
  34987. * Define the default inertia of the camera.
  34988. * This helps giving a smooth feeling to the camera movement.
  34989. */
  34990. inertia: number;
  34991. /**
  34992. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34993. */
  34994. mode: number;
  34995. /**
  34996. * Define whether the camera is intermediate.
  34997. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34998. */
  34999. isIntermediate: boolean;
  35000. /**
  35001. * Define the viewport of the camera.
  35002. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35003. */
  35004. viewport: Viewport;
  35005. /**
  35006. * Restricts the camera to viewing objects with the same layerMask.
  35007. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35008. */
  35009. layerMask: number;
  35010. /**
  35011. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35012. */
  35013. fovMode: number;
  35014. /**
  35015. * Rig mode of the camera.
  35016. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35017. * This is normally controlled byt the camera themselves as internal use.
  35018. */
  35019. cameraRigMode: number;
  35020. /**
  35021. * Defines the distance between both "eyes" in case of a RIG
  35022. */
  35023. interaxialDistance: number;
  35024. /**
  35025. * Defines if stereoscopic rendering is done side by side or over under.
  35026. */
  35027. isStereoscopicSideBySide: boolean;
  35028. /**
  35029. * 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
  35030. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35031. * else in the scene. (Eg. security camera)
  35032. *
  35033. * 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)
  35034. */
  35035. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35036. /**
  35037. * When set, the camera will render to this render target instead of the default canvas
  35038. *
  35039. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35040. */
  35041. outputRenderTarget: Nullable<RenderTargetTexture>;
  35042. /**
  35043. * Observable triggered when the camera view matrix has changed.
  35044. */
  35045. onViewMatrixChangedObservable: Observable<Camera>;
  35046. /**
  35047. * Observable triggered when the camera Projection matrix has changed.
  35048. */
  35049. onProjectionMatrixChangedObservable: Observable<Camera>;
  35050. /**
  35051. * Observable triggered when the inputs have been processed.
  35052. */
  35053. onAfterCheckInputsObservable: Observable<Camera>;
  35054. /**
  35055. * Observable triggered when reset has been called and applied to the camera.
  35056. */
  35057. onRestoreStateObservable: Observable<Camera>;
  35058. /**
  35059. * Is this camera a part of a rig system?
  35060. */
  35061. isRigCamera: boolean;
  35062. /**
  35063. * If isRigCamera set to true this will be set with the parent camera.
  35064. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35065. */
  35066. rigParent?: Camera;
  35067. /** @hidden */
  35068. _cameraRigParams: any;
  35069. /** @hidden */
  35070. _rigCameras: Camera[];
  35071. /** @hidden */
  35072. _rigPostProcess: Nullable<PostProcess>;
  35073. protected _webvrViewMatrix: Matrix;
  35074. /** @hidden */
  35075. _skipRendering: boolean;
  35076. /** @hidden */
  35077. _projectionMatrix: Matrix;
  35078. /** @hidden */
  35079. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35080. /** @hidden */
  35081. _activeMeshes: SmartArray<AbstractMesh>;
  35082. protected _globalPosition: Vector3;
  35083. /** @hidden */
  35084. _computedViewMatrix: Matrix;
  35085. private _doNotComputeProjectionMatrix;
  35086. private _transformMatrix;
  35087. private _frustumPlanes;
  35088. private _refreshFrustumPlanes;
  35089. private _storedFov;
  35090. private _stateStored;
  35091. /**
  35092. * Instantiates a new camera object.
  35093. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35094. * @see https://doc.babylonjs.com/features/cameras
  35095. * @param name Defines the name of the camera in the scene
  35096. * @param position Defines the position of the camera
  35097. * @param scene Defines the scene the camera belongs too
  35098. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35099. */
  35100. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35101. /**
  35102. * Store current camera state (fov, position, etc..)
  35103. * @returns the camera
  35104. */
  35105. storeState(): Camera;
  35106. /**
  35107. * Restores the camera state values if it has been stored. You must call storeState() first
  35108. */
  35109. protected _restoreStateValues(): boolean;
  35110. /**
  35111. * Restored camera state. You must call storeState() first.
  35112. * @returns true if restored and false otherwise
  35113. */
  35114. restoreState(): boolean;
  35115. /**
  35116. * Gets the class name of the camera.
  35117. * @returns the class name
  35118. */
  35119. getClassName(): string;
  35120. /** @hidden */
  35121. readonly _isCamera: boolean;
  35122. /**
  35123. * Gets a string representation of the camera useful for debug purpose.
  35124. * @param fullDetails Defines that a more verboe level of logging is required
  35125. * @returns the string representation
  35126. */
  35127. toString(fullDetails?: boolean): string;
  35128. /**
  35129. * Gets the current world space position of the camera.
  35130. */
  35131. get globalPosition(): Vector3;
  35132. /**
  35133. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35134. * @returns the active meshe list
  35135. */
  35136. getActiveMeshes(): SmartArray<AbstractMesh>;
  35137. /**
  35138. * Check whether a mesh is part of the current active mesh list of the camera
  35139. * @param mesh Defines the mesh to check
  35140. * @returns true if active, false otherwise
  35141. */
  35142. isActiveMesh(mesh: Mesh): boolean;
  35143. /**
  35144. * Is this camera ready to be used/rendered
  35145. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35146. * @return true if the camera is ready
  35147. */
  35148. isReady(completeCheck?: boolean): boolean;
  35149. /** @hidden */
  35150. _initCache(): void;
  35151. /** @hidden */
  35152. _updateCache(ignoreParentClass?: boolean): void;
  35153. /** @hidden */
  35154. _isSynchronized(): boolean;
  35155. /** @hidden */
  35156. _isSynchronizedViewMatrix(): boolean;
  35157. /** @hidden */
  35158. _isSynchronizedProjectionMatrix(): boolean;
  35159. /**
  35160. * Attach the input controls to a specific dom element to get the input from.
  35161. * @param element Defines the element the controls should be listened from
  35162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35163. */
  35164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35165. /**
  35166. * Detach the current controls from the specified dom element.
  35167. * @param element Defines the element to stop listening the inputs from
  35168. */
  35169. detachControl(element: HTMLElement): void;
  35170. /**
  35171. * Update the camera state according to the different inputs gathered during the frame.
  35172. */
  35173. update(): void;
  35174. /** @hidden */
  35175. _checkInputs(): void;
  35176. /** @hidden */
  35177. get rigCameras(): Camera[];
  35178. /**
  35179. * Gets the post process used by the rig cameras
  35180. */
  35181. get rigPostProcess(): Nullable<PostProcess>;
  35182. /**
  35183. * Internal, gets the first post proces.
  35184. * @returns the first post process to be run on this camera.
  35185. */
  35186. _getFirstPostProcess(): Nullable<PostProcess>;
  35187. private _cascadePostProcessesToRigCams;
  35188. /**
  35189. * Attach a post process to the camera.
  35190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35191. * @param postProcess The post process to attach to the camera
  35192. * @param insertAt The position of the post process in case several of them are in use in the scene
  35193. * @returns the position the post process has been inserted at
  35194. */
  35195. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35196. /**
  35197. * Detach a post process to the camera.
  35198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35199. * @param postProcess The post process to detach from the camera
  35200. */
  35201. detachPostProcess(postProcess: PostProcess): void;
  35202. /**
  35203. * Gets the current world matrix of the camera
  35204. */
  35205. getWorldMatrix(): Matrix;
  35206. /** @hidden */
  35207. _getViewMatrix(): Matrix;
  35208. /**
  35209. * Gets the current view matrix of the camera.
  35210. * @param force forces the camera to recompute the matrix without looking at the cached state
  35211. * @returns the view matrix
  35212. */
  35213. getViewMatrix(force?: boolean): Matrix;
  35214. /**
  35215. * Freeze the projection matrix.
  35216. * It will prevent the cache check of the camera projection compute and can speed up perf
  35217. * if no parameter of the camera are meant to change
  35218. * @param projection Defines manually a projection if necessary
  35219. */
  35220. freezeProjectionMatrix(projection?: Matrix): void;
  35221. /**
  35222. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35223. */
  35224. unfreezeProjectionMatrix(): void;
  35225. /**
  35226. * Gets the current projection matrix of the camera.
  35227. * @param force forces the camera to recompute the matrix without looking at the cached state
  35228. * @returns the projection matrix
  35229. */
  35230. getProjectionMatrix(force?: boolean): Matrix;
  35231. /**
  35232. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35233. * @returns a Matrix
  35234. */
  35235. getTransformationMatrix(): Matrix;
  35236. private _updateFrustumPlanes;
  35237. /**
  35238. * Checks if a cullable object (mesh...) is in the camera frustum
  35239. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35240. * @param target The object to check
  35241. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35242. * @returns true if the object is in frustum otherwise false
  35243. */
  35244. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35245. /**
  35246. * Checks if a cullable object (mesh...) is in the camera frustum
  35247. * Unlike isInFrustum this cheks the full bounding box
  35248. * @param target The object to check
  35249. * @returns true if the object is in frustum otherwise false
  35250. */
  35251. isCompletelyInFrustum(target: ICullable): boolean;
  35252. /**
  35253. * Gets a ray in the forward direction from the camera.
  35254. * @param length Defines the length of the ray to create
  35255. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35256. * @param origin Defines the start point of the ray which defaults to the camera position
  35257. * @returns the forward ray
  35258. */
  35259. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35260. /**
  35261. * Gets a ray in the forward direction from the camera.
  35262. * @param refRay the ray to (re)use when setting the values
  35263. * @param length Defines the length of the ray to create
  35264. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35265. * @param origin Defines the start point of the ray which defaults to the camera position
  35266. * @returns the forward ray
  35267. */
  35268. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35269. /**
  35270. * Releases resources associated with this node.
  35271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35273. */
  35274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35275. /** @hidden */
  35276. _isLeftCamera: boolean;
  35277. /**
  35278. * Gets the left camera of a rig setup in case of Rigged Camera
  35279. */
  35280. get isLeftCamera(): boolean;
  35281. /** @hidden */
  35282. _isRightCamera: boolean;
  35283. /**
  35284. * Gets the right camera of a rig setup in case of Rigged Camera
  35285. */
  35286. get isRightCamera(): boolean;
  35287. /**
  35288. * Gets the left camera of a rig setup in case of Rigged Camera
  35289. */
  35290. get leftCamera(): Nullable<FreeCamera>;
  35291. /**
  35292. * Gets the right camera of a rig setup in case of Rigged Camera
  35293. */
  35294. get rightCamera(): Nullable<FreeCamera>;
  35295. /**
  35296. * Gets the left camera target of a rig setup in case of Rigged Camera
  35297. * @returns the target position
  35298. */
  35299. getLeftTarget(): Nullable<Vector3>;
  35300. /**
  35301. * Gets the right camera target of a rig setup in case of Rigged Camera
  35302. * @returns the target position
  35303. */
  35304. getRightTarget(): Nullable<Vector3>;
  35305. /**
  35306. * @hidden
  35307. */
  35308. setCameraRigMode(mode: number, rigParams: any): void;
  35309. /** @hidden */
  35310. static _setStereoscopicRigMode(camera: Camera): void;
  35311. /** @hidden */
  35312. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35313. /** @hidden */
  35314. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35315. /** @hidden */
  35316. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35317. /** @hidden */
  35318. _getVRProjectionMatrix(): Matrix;
  35319. protected _updateCameraRotationMatrix(): void;
  35320. protected _updateWebVRCameraRotationMatrix(): void;
  35321. /**
  35322. * This function MUST be overwritten by the different WebVR cameras available.
  35323. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35324. * @hidden
  35325. */
  35326. _getWebVRProjectionMatrix(): Matrix;
  35327. /**
  35328. * This function MUST be overwritten by the different WebVR cameras available.
  35329. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35330. * @hidden
  35331. */
  35332. _getWebVRViewMatrix(): Matrix;
  35333. /** @hidden */
  35334. setCameraRigParameter(name: string, value: any): void;
  35335. /**
  35336. * needs to be overridden by children so sub has required properties to be copied
  35337. * @hidden
  35338. */
  35339. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35340. /**
  35341. * May need to be overridden by children
  35342. * @hidden
  35343. */
  35344. _updateRigCameras(): void;
  35345. /** @hidden */
  35346. _setupInputs(): void;
  35347. /**
  35348. * Serialiaze the camera setup to a json represention
  35349. * @returns the JSON representation
  35350. */
  35351. serialize(): any;
  35352. /**
  35353. * Clones the current camera.
  35354. * @param name The cloned camera name
  35355. * @returns the cloned camera
  35356. */
  35357. clone(name: string): Camera;
  35358. /**
  35359. * Gets the direction of the camera relative to a given local axis.
  35360. * @param localAxis Defines the reference axis to provide a relative direction.
  35361. * @return the direction
  35362. */
  35363. getDirection(localAxis: Vector3): Vector3;
  35364. /**
  35365. * Returns the current camera absolute rotation
  35366. */
  35367. get absoluteRotation(): Quaternion;
  35368. /**
  35369. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35370. * @param localAxis Defines the reference axis to provide a relative direction.
  35371. * @param result Defines the vector to store the result in
  35372. */
  35373. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35374. /**
  35375. * Gets a camera constructor for a given camera type
  35376. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35377. * @param name The name of the camera the result will be able to instantiate
  35378. * @param scene The scene the result will construct the camera in
  35379. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35380. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35381. * @returns a factory method to construc the camera
  35382. */
  35383. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35384. /**
  35385. * Compute the world matrix of the camera.
  35386. * @returns the camera world matrix
  35387. */
  35388. computeWorldMatrix(): Matrix;
  35389. /**
  35390. * Parse a JSON and creates the camera from the parsed information
  35391. * @param parsedCamera The JSON to parse
  35392. * @param scene The scene to instantiate the camera in
  35393. * @returns the newly constructed camera
  35394. */
  35395. static Parse(parsedCamera: any, scene: Scene): Camera;
  35396. }
  35397. }
  35398. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35399. import { Nullable } from "babylonjs/types";
  35400. import { Scene } from "babylonjs/scene";
  35401. import { Vector4 } from "babylonjs/Maths/math.vector";
  35402. import { Mesh } from "babylonjs/Meshes/mesh";
  35403. /**
  35404. * Class containing static functions to help procedurally build meshes
  35405. */
  35406. export class DiscBuilder {
  35407. /**
  35408. * Creates a plane polygonal mesh. By default, this is a disc
  35409. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35410. * * 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
  35411. * * 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
  35412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35415. * @param name defines the name of the mesh
  35416. * @param options defines the options used to create the mesh
  35417. * @param scene defines the hosting scene
  35418. * @returns the plane polygonal mesh
  35419. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35420. */
  35421. static CreateDisc(name: string, options: {
  35422. radius?: number;
  35423. tessellation?: number;
  35424. arc?: number;
  35425. updatable?: boolean;
  35426. sideOrientation?: number;
  35427. frontUVs?: Vector4;
  35428. backUVs?: Vector4;
  35429. }, scene?: Nullable<Scene>): Mesh;
  35430. }
  35431. }
  35432. declare module "babylonjs/Particles/solidParticleSystem" {
  35433. import { Nullable } from "babylonjs/types";
  35434. import { Mesh } from "babylonjs/Meshes/mesh";
  35435. import { Scene, IDisposable } from "babylonjs/scene";
  35436. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35437. import { Material } from "babylonjs/Materials/material";
  35438. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35439. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35440. /**
  35441. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35442. *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.
  35443. * The SPS is also a particle system. It provides some methods to manage the particles.
  35444. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35445. *
  35446. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35447. */
  35448. export class SolidParticleSystem implements IDisposable {
  35449. /**
  35450. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35451. * Example : var p = SPS.particles[i];
  35452. */
  35453. particles: SolidParticle[];
  35454. /**
  35455. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35456. */
  35457. nbParticles: number;
  35458. /**
  35459. * If the particles must ever face the camera (default false). Useful for planar particles.
  35460. */
  35461. billboard: boolean;
  35462. /**
  35463. * Recompute normals when adding a shape
  35464. */
  35465. recomputeNormals: boolean;
  35466. /**
  35467. * This a counter ofr your own usage. It's not set by any SPS functions.
  35468. */
  35469. counter: number;
  35470. /**
  35471. * The SPS name. This name is also given to the underlying mesh.
  35472. */
  35473. name: string;
  35474. /**
  35475. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35476. */
  35477. mesh: Mesh;
  35478. /**
  35479. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35480. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35481. */
  35482. vars: any;
  35483. /**
  35484. * This array is populated when the SPS is set as 'pickable'.
  35485. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35486. * Each element of this array is an object `{idx: int, faceId: int}`.
  35487. * `idx` is the picked particle index in the `SPS.particles` array
  35488. * `faceId` is the picked face index counted within this particle.
  35489. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35490. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35491. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35492. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35493. */
  35494. pickedParticles: {
  35495. idx: number;
  35496. faceId: number;
  35497. }[];
  35498. /**
  35499. * This array is populated when the SPS is set as 'pickable'
  35500. * Each key of this array is a submesh index.
  35501. * Each element of this array is a second array defined like this :
  35502. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35503. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35504. * `idx` is the picked particle index in the `SPS.particles` array
  35505. * `faceId` is the picked face index counted within this particle.
  35506. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35507. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35508. */
  35509. pickedBySubMesh: {
  35510. idx: number;
  35511. faceId: number;
  35512. }[][];
  35513. /**
  35514. * This array is populated when `enableDepthSort` is set to true.
  35515. * Each element of this array is an instance of the class DepthSortedParticle.
  35516. */
  35517. depthSortedParticles: DepthSortedParticle[];
  35518. /**
  35519. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35520. * @hidden
  35521. */
  35522. _bSphereOnly: boolean;
  35523. /**
  35524. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35525. * @hidden
  35526. */
  35527. _bSphereRadiusFactor: number;
  35528. private _scene;
  35529. private _positions;
  35530. private _indices;
  35531. private _normals;
  35532. private _colors;
  35533. private _uvs;
  35534. private _indices32;
  35535. private _positions32;
  35536. private _normals32;
  35537. private _fixedNormal32;
  35538. private _colors32;
  35539. private _uvs32;
  35540. private _index;
  35541. private _updatable;
  35542. private _pickable;
  35543. private _isVisibilityBoxLocked;
  35544. private _alwaysVisible;
  35545. private _depthSort;
  35546. private _expandable;
  35547. private _shapeCounter;
  35548. private _copy;
  35549. private _color;
  35550. private _computeParticleColor;
  35551. private _computeParticleTexture;
  35552. private _computeParticleRotation;
  35553. private _computeParticleVertex;
  35554. private _computeBoundingBox;
  35555. private _depthSortParticles;
  35556. private _camera;
  35557. private _mustUnrotateFixedNormals;
  35558. private _particlesIntersect;
  35559. private _needs32Bits;
  35560. private _isNotBuilt;
  35561. private _lastParticleId;
  35562. private _idxOfId;
  35563. private _multimaterialEnabled;
  35564. private _useModelMaterial;
  35565. private _indicesByMaterial;
  35566. private _materialIndexes;
  35567. private _depthSortFunction;
  35568. private _materialSortFunction;
  35569. private _materials;
  35570. private _multimaterial;
  35571. private _materialIndexesById;
  35572. private _defaultMaterial;
  35573. private _autoUpdateSubMeshes;
  35574. private _tmpVertex;
  35575. /**
  35576. * Creates a SPS (Solid Particle System) object.
  35577. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35578. * @param scene (Scene) is the scene in which the SPS is added.
  35579. * @param options defines the options of the sps e.g.
  35580. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35581. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35582. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35583. * * 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.
  35584. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35585. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35586. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35587. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35588. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35589. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35590. */
  35591. constructor(name: string, scene: Scene, options?: {
  35592. updatable?: boolean;
  35593. isPickable?: boolean;
  35594. enableDepthSort?: boolean;
  35595. particleIntersection?: boolean;
  35596. boundingSphereOnly?: boolean;
  35597. bSphereRadiusFactor?: number;
  35598. expandable?: boolean;
  35599. useModelMaterial?: boolean;
  35600. enableMultiMaterial?: boolean;
  35601. });
  35602. /**
  35603. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35604. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35605. * @returns the created mesh
  35606. */
  35607. buildMesh(): Mesh;
  35608. /**
  35609. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35610. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35611. * Thus the particles generated from `digest()` have their property `position` set yet.
  35612. * @param mesh ( Mesh ) is the mesh to be digested
  35613. * @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
  35614. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35615. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35616. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35617. * @returns the current SPS
  35618. */
  35619. digest(mesh: Mesh, options?: {
  35620. facetNb?: number;
  35621. number?: number;
  35622. delta?: number;
  35623. storage?: [];
  35624. }): SolidParticleSystem;
  35625. /**
  35626. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35627. * @hidden
  35628. */
  35629. private _unrotateFixedNormals;
  35630. /**
  35631. * Resets the temporary working copy particle
  35632. * @hidden
  35633. */
  35634. private _resetCopy;
  35635. /**
  35636. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35637. * @param p the current index in the positions array to be updated
  35638. * @param ind the current index in the indices array
  35639. * @param shape a Vector3 array, the shape geometry
  35640. * @param positions the positions array to be updated
  35641. * @param meshInd the shape indices array
  35642. * @param indices the indices array to be updated
  35643. * @param meshUV the shape uv array
  35644. * @param uvs the uv array to be updated
  35645. * @param meshCol the shape color array
  35646. * @param colors the color array to be updated
  35647. * @param meshNor the shape normals array
  35648. * @param normals the normals array to be updated
  35649. * @param idx the particle index
  35650. * @param idxInShape the particle index in its shape
  35651. * @param options the addShape() method passed options
  35652. * @model the particle model
  35653. * @hidden
  35654. */
  35655. private _meshBuilder;
  35656. /**
  35657. * Returns a shape Vector3 array from positions float array
  35658. * @param positions float array
  35659. * @returns a vector3 array
  35660. * @hidden
  35661. */
  35662. private _posToShape;
  35663. /**
  35664. * Returns a shapeUV array from a float uvs (array deep copy)
  35665. * @param uvs as a float array
  35666. * @returns a shapeUV array
  35667. * @hidden
  35668. */
  35669. private _uvsToShapeUV;
  35670. /**
  35671. * Adds a new particle object in the particles array
  35672. * @param idx particle index in particles array
  35673. * @param id particle id
  35674. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35675. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35676. * @param model particle ModelShape object
  35677. * @param shapeId model shape identifier
  35678. * @param idxInShape index of the particle in the current model
  35679. * @param bInfo model bounding info object
  35680. * @param storage target storage array, if any
  35681. * @hidden
  35682. */
  35683. private _addParticle;
  35684. /**
  35685. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35686. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35687. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35688. * @param nb (positive integer) the number of particles to be created from this model
  35689. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35690. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35691. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35692. * @returns the number of shapes in the system
  35693. */
  35694. addShape(mesh: Mesh, nb: number, options?: {
  35695. positionFunction?: any;
  35696. vertexFunction?: any;
  35697. storage?: [];
  35698. }): number;
  35699. /**
  35700. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35701. * @hidden
  35702. */
  35703. private _rebuildParticle;
  35704. /**
  35705. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35706. * @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.
  35707. * @returns the SPS.
  35708. */
  35709. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35710. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35711. * Returns an array with the removed particles.
  35712. * 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.
  35713. * The SPS can't be empty so at least one particle needs to remain in place.
  35714. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35715. * @param start index of the first particle to remove
  35716. * @param end index of the last particle to remove (included)
  35717. * @returns an array populated with the removed particles
  35718. */
  35719. removeParticles(start: number, end: number): SolidParticle[];
  35720. /**
  35721. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35722. * @param solidParticleArray an array populated with Solid Particles objects
  35723. * @returns the SPS
  35724. */
  35725. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35726. /**
  35727. * Creates a new particle and modifies the SPS mesh geometry :
  35728. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35729. * - calls _addParticle() to populate the particle array
  35730. * factorized code from addShape() and insertParticlesFromArray()
  35731. * @param idx particle index in the particles array
  35732. * @param i particle index in its shape
  35733. * @param modelShape particle ModelShape object
  35734. * @param shape shape vertex array
  35735. * @param meshInd shape indices array
  35736. * @param meshUV shape uv array
  35737. * @param meshCol shape color array
  35738. * @param meshNor shape normals array
  35739. * @param bbInfo shape bounding info
  35740. * @param storage target particle storage
  35741. * @options addShape() passed options
  35742. * @hidden
  35743. */
  35744. private _insertNewParticle;
  35745. /**
  35746. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35747. * This method calls `updateParticle()` for each particle of the SPS.
  35748. * For an animated SPS, it is usually called within the render loop.
  35749. * 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.
  35750. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35751. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35752. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35753. * @returns the SPS.
  35754. */
  35755. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35756. /**
  35757. * Disposes the SPS.
  35758. */
  35759. dispose(): void;
  35760. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35761. * idx is the particle index in the SPS
  35762. * faceId is the picked face index counted within this particle.
  35763. * Returns null if the pickInfo can't identify a picked particle.
  35764. * @param pickingInfo (PickingInfo object)
  35765. * @returns {idx: number, faceId: number} or null
  35766. */
  35767. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35768. idx: number;
  35769. faceId: number;
  35770. }>;
  35771. /**
  35772. * Returns a SolidParticle object from its identifier : particle.id
  35773. * @param id (integer) the particle Id
  35774. * @returns the searched particle or null if not found in the SPS.
  35775. */
  35776. getParticleById(id: number): Nullable<SolidParticle>;
  35777. /**
  35778. * Returns a new array populated with the particles having the passed shapeId.
  35779. * @param shapeId (integer) the shape identifier
  35780. * @returns a new solid particle array
  35781. */
  35782. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35783. /**
  35784. * Populates the passed array "ref" with the particles having the passed shapeId.
  35785. * @param shapeId the shape identifier
  35786. * @returns the SPS
  35787. * @param ref
  35788. */
  35789. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35790. /**
  35791. * Computes the required SubMeshes according the materials assigned to the particles.
  35792. * @returns the solid particle system.
  35793. * Does nothing if called before the SPS mesh is built.
  35794. */
  35795. computeSubMeshes(): SolidParticleSystem;
  35796. /**
  35797. * Sorts the solid particles by material when MultiMaterial is enabled.
  35798. * Updates the indices32 array.
  35799. * Updates the indicesByMaterial array.
  35800. * Updates the mesh indices array.
  35801. * @returns the SPS
  35802. * @hidden
  35803. */
  35804. private _sortParticlesByMaterial;
  35805. /**
  35806. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35807. * @hidden
  35808. */
  35809. private _setMaterialIndexesById;
  35810. /**
  35811. * Returns an array with unique values of Materials from the passed array
  35812. * @param array the material array to be checked and filtered
  35813. * @hidden
  35814. */
  35815. private _filterUniqueMaterialId;
  35816. /**
  35817. * Sets a new Standard Material as _defaultMaterial if not already set.
  35818. * @hidden
  35819. */
  35820. private _setDefaultMaterial;
  35821. /**
  35822. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35823. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35824. * @returns the SPS.
  35825. */
  35826. refreshVisibleSize(): SolidParticleSystem;
  35827. /**
  35828. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35829. * @param size the size (float) of the visibility box
  35830. * note : this doesn't lock the SPS mesh bounding box.
  35831. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35832. */
  35833. setVisibilityBox(size: number): void;
  35834. /**
  35835. * Gets whether the SPS as always visible or not
  35836. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35837. */
  35838. get isAlwaysVisible(): boolean;
  35839. /**
  35840. * Sets the SPS as always visible or not
  35841. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35842. */
  35843. set isAlwaysVisible(val: boolean);
  35844. /**
  35845. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35846. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35847. */
  35848. set isVisibilityBoxLocked(val: boolean);
  35849. /**
  35850. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35851. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35852. */
  35853. get isVisibilityBoxLocked(): boolean;
  35854. /**
  35855. * Tells to `setParticles()` to compute the particle rotations or not.
  35856. * Default value : true. The SPS is faster when it's set to false.
  35857. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35858. */
  35859. set computeParticleRotation(val: boolean);
  35860. /**
  35861. * Tells to `setParticles()` to compute the particle colors or not.
  35862. * Default value : true. The SPS is faster when it's set to false.
  35863. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35864. */
  35865. set computeParticleColor(val: boolean);
  35866. set computeParticleTexture(val: boolean);
  35867. /**
  35868. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35869. * Default value : false. The SPS is faster when it's set to false.
  35870. * Note : the particle custom vertex positions aren't stored values.
  35871. */
  35872. set computeParticleVertex(val: boolean);
  35873. /**
  35874. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35875. */
  35876. set computeBoundingBox(val: boolean);
  35877. /**
  35878. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35879. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35880. * Default : `true`
  35881. */
  35882. set depthSortParticles(val: boolean);
  35883. /**
  35884. * Gets if `setParticles()` computes the particle rotations or not.
  35885. * Default value : true. The SPS is faster when it's set to false.
  35886. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35887. */
  35888. get computeParticleRotation(): boolean;
  35889. /**
  35890. * Gets if `setParticles()` computes the particle colors or not.
  35891. * Default value : true. The SPS is faster when it's set to false.
  35892. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35893. */
  35894. get computeParticleColor(): boolean;
  35895. /**
  35896. * Gets if `setParticles()` computes the particle textures or not.
  35897. * Default value : true. The SPS is faster when it's set to false.
  35898. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35899. */
  35900. get computeParticleTexture(): boolean;
  35901. /**
  35902. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35903. * Default value : false. The SPS is faster when it's set to false.
  35904. * Note : the particle custom vertex positions aren't stored values.
  35905. */
  35906. get computeParticleVertex(): boolean;
  35907. /**
  35908. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35909. */
  35910. get computeBoundingBox(): boolean;
  35911. /**
  35912. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35913. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35914. * Default : `true`
  35915. */
  35916. get depthSortParticles(): boolean;
  35917. /**
  35918. * Gets if the SPS is created as expandable at construction time.
  35919. * Default : `false`
  35920. */
  35921. get expandable(): boolean;
  35922. /**
  35923. * Gets if the SPS supports the Multi Materials
  35924. */
  35925. get multimaterialEnabled(): boolean;
  35926. /**
  35927. * Gets if the SPS uses the model materials for its own multimaterial.
  35928. */
  35929. get useModelMaterial(): boolean;
  35930. /**
  35931. * The SPS used material array.
  35932. */
  35933. get materials(): Material[];
  35934. /**
  35935. * Sets the SPS MultiMaterial from the passed materials.
  35936. * Note : the passed array is internally copied and not used then by reference.
  35937. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35938. */
  35939. setMultiMaterial(materials: Material[]): void;
  35940. /**
  35941. * The SPS computed multimaterial object
  35942. */
  35943. get multimaterial(): MultiMaterial;
  35944. set multimaterial(mm: MultiMaterial);
  35945. /**
  35946. * If the subMeshes must be updated on the next call to setParticles()
  35947. */
  35948. get autoUpdateSubMeshes(): boolean;
  35949. set autoUpdateSubMeshes(val: boolean);
  35950. /**
  35951. * This function does nothing. It may be overwritten to set all the particle first values.
  35952. * The SPS doesn't call this function, you may have to call it by your own.
  35953. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35954. */
  35955. initParticles(): void;
  35956. /**
  35957. * This function does nothing. It may be overwritten to recycle a particle.
  35958. * The SPS doesn't call this function, you may have to call it by your own.
  35959. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35960. * @param particle The particle to recycle
  35961. * @returns the recycled particle
  35962. */
  35963. recycleParticle(particle: SolidParticle): SolidParticle;
  35964. /**
  35965. * Updates a particle : this function should be overwritten by the user.
  35966. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35967. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35968. * @example : just set a particle position or velocity and recycle conditions
  35969. * @param particle The particle to update
  35970. * @returns the updated particle
  35971. */
  35972. updateParticle(particle: SolidParticle): SolidParticle;
  35973. /**
  35974. * Updates a vertex of a particle : it can be overwritten by the user.
  35975. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35976. * @param particle the current particle
  35977. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35978. * @param pt the index of the current vertex in the particle shape
  35979. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35980. * @example : just set a vertex particle position or color
  35981. * @returns the sps
  35982. */
  35983. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35984. /**
  35985. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35986. * This does nothing and may be overwritten by the user.
  35987. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35988. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35989. * @param update the boolean update value actually passed to setParticles()
  35990. */
  35991. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35992. /**
  35993. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35994. * This will be passed three parameters.
  35995. * This does nothing and may be overwritten by the user.
  35996. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35997. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35998. * @param update the boolean update value actually passed to setParticles()
  35999. */
  36000. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36001. }
  36002. }
  36003. declare module "babylonjs/Particles/solidParticle" {
  36004. import { Nullable } from "babylonjs/types";
  36005. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36006. import { Color4 } from "babylonjs/Maths/math.color";
  36007. import { Mesh } from "babylonjs/Meshes/mesh";
  36008. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36009. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36010. import { Plane } from "babylonjs/Maths/math.plane";
  36011. import { Material } from "babylonjs/Materials/material";
  36012. /**
  36013. * Represents one particle of a solid particle system.
  36014. */
  36015. export class SolidParticle {
  36016. /**
  36017. * particle global index
  36018. */
  36019. idx: number;
  36020. /**
  36021. * particle identifier
  36022. */
  36023. id: number;
  36024. /**
  36025. * The color of the particle
  36026. */
  36027. color: Nullable<Color4>;
  36028. /**
  36029. * The world space position of the particle.
  36030. */
  36031. position: Vector3;
  36032. /**
  36033. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36034. */
  36035. rotation: Vector3;
  36036. /**
  36037. * The world space rotation quaternion of the particle.
  36038. */
  36039. rotationQuaternion: Nullable<Quaternion>;
  36040. /**
  36041. * The scaling of the particle.
  36042. */
  36043. scaling: Vector3;
  36044. /**
  36045. * The uvs of the particle.
  36046. */
  36047. uvs: Vector4;
  36048. /**
  36049. * The current speed of the particle.
  36050. */
  36051. velocity: Vector3;
  36052. /**
  36053. * The pivot point in the particle local space.
  36054. */
  36055. pivot: Vector3;
  36056. /**
  36057. * Must the particle be translated from its pivot point in its local space ?
  36058. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36059. * Default : false
  36060. */
  36061. translateFromPivot: boolean;
  36062. /**
  36063. * Is the particle active or not ?
  36064. */
  36065. alive: boolean;
  36066. /**
  36067. * Is the particle visible or not ?
  36068. */
  36069. isVisible: boolean;
  36070. /**
  36071. * Index of this particle in the global "positions" array (Internal use)
  36072. * @hidden
  36073. */
  36074. _pos: number;
  36075. /**
  36076. * @hidden Index of this particle in the global "indices" array (Internal use)
  36077. */
  36078. _ind: number;
  36079. /**
  36080. * @hidden ModelShape of this particle (Internal use)
  36081. */
  36082. _model: ModelShape;
  36083. /**
  36084. * ModelShape id of this particle
  36085. */
  36086. shapeId: number;
  36087. /**
  36088. * Index of the particle in its shape id
  36089. */
  36090. idxInShape: number;
  36091. /**
  36092. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36093. */
  36094. _modelBoundingInfo: BoundingInfo;
  36095. /**
  36096. * @hidden Particle BoundingInfo object (Internal use)
  36097. */
  36098. _boundingInfo: BoundingInfo;
  36099. /**
  36100. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36101. */
  36102. _sps: SolidParticleSystem;
  36103. /**
  36104. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36105. */
  36106. _stillInvisible: boolean;
  36107. /**
  36108. * @hidden Last computed particle rotation matrix
  36109. */
  36110. _rotationMatrix: number[];
  36111. /**
  36112. * Parent particle Id, if any.
  36113. * Default null.
  36114. */
  36115. parentId: Nullable<number>;
  36116. /**
  36117. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36118. */
  36119. materialIndex: Nullable<number>;
  36120. /**
  36121. * Custom object or properties.
  36122. */
  36123. props: Nullable<any>;
  36124. /**
  36125. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36126. * The possible values are :
  36127. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36128. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36129. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36130. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36131. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36132. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36133. * */
  36134. cullingStrategy: number;
  36135. /**
  36136. * @hidden Internal global position in the SPS.
  36137. */
  36138. _globalPosition: Vector3;
  36139. /**
  36140. * Creates a Solid Particle object.
  36141. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36142. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36143. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36144. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36145. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36146. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36147. * @param shapeId (integer) is the model shape identifier in the SPS.
  36148. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36149. * @param sps defines the sps it is associated to
  36150. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36151. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36152. */
  36153. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36154. /**
  36155. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36156. * @param target the particle target
  36157. * @returns the current particle
  36158. */
  36159. copyToRef(target: SolidParticle): SolidParticle;
  36160. /**
  36161. * Legacy support, changed scale to scaling
  36162. */
  36163. get scale(): Vector3;
  36164. /**
  36165. * Legacy support, changed scale to scaling
  36166. */
  36167. set scale(scale: Vector3);
  36168. /**
  36169. * Legacy support, changed quaternion to rotationQuaternion
  36170. */
  36171. get quaternion(): Nullable<Quaternion>;
  36172. /**
  36173. * Legacy support, changed quaternion to rotationQuaternion
  36174. */
  36175. set quaternion(q: Nullable<Quaternion>);
  36176. /**
  36177. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36178. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36179. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36180. * @returns true if it intersects
  36181. */
  36182. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36183. /**
  36184. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36185. * A particle is in the frustum if its bounding box intersects the frustum
  36186. * @param frustumPlanes defines the frustum to test
  36187. * @returns true if the particle is in the frustum planes
  36188. */
  36189. isInFrustum(frustumPlanes: Plane[]): boolean;
  36190. /**
  36191. * get the rotation matrix of the particle
  36192. * @hidden
  36193. */
  36194. getRotationMatrix(m: Matrix): void;
  36195. }
  36196. /**
  36197. * Represents the shape of the model used by one particle of a solid particle system.
  36198. * SPS internal tool, don't use it manually.
  36199. */
  36200. export class ModelShape {
  36201. /**
  36202. * The shape id
  36203. * @hidden
  36204. */
  36205. shapeID: number;
  36206. /**
  36207. * flat array of model positions (internal use)
  36208. * @hidden
  36209. */
  36210. _shape: Vector3[];
  36211. /**
  36212. * flat array of model UVs (internal use)
  36213. * @hidden
  36214. */
  36215. _shapeUV: number[];
  36216. /**
  36217. * color array of the model
  36218. * @hidden
  36219. */
  36220. _shapeColors: number[];
  36221. /**
  36222. * indices array of the model
  36223. * @hidden
  36224. */
  36225. _indices: number[];
  36226. /**
  36227. * normals array of the model
  36228. * @hidden
  36229. */
  36230. _normals: number[];
  36231. /**
  36232. * length of the shape in the model indices array (internal use)
  36233. * @hidden
  36234. */
  36235. _indicesLength: number;
  36236. /**
  36237. * Custom position function (internal use)
  36238. * @hidden
  36239. */
  36240. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36241. /**
  36242. * Custom vertex function (internal use)
  36243. * @hidden
  36244. */
  36245. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36246. /**
  36247. * Model material (internal use)
  36248. * @hidden
  36249. */
  36250. _material: Nullable<Material>;
  36251. /**
  36252. * 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.
  36253. * SPS internal tool, don't use it manually.
  36254. * @hidden
  36255. */
  36256. 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>);
  36257. }
  36258. /**
  36259. * Represents a Depth Sorted Particle in the solid particle system.
  36260. * @hidden
  36261. */
  36262. export class DepthSortedParticle {
  36263. /**
  36264. * Particle index
  36265. */
  36266. idx: number;
  36267. /**
  36268. * Index of the particle in the "indices" array
  36269. */
  36270. ind: number;
  36271. /**
  36272. * Length of the particle shape in the "indices" array
  36273. */
  36274. indicesLength: number;
  36275. /**
  36276. * Squared distance from the particle to the camera
  36277. */
  36278. sqDistance: number;
  36279. /**
  36280. * Material index when used with MultiMaterials
  36281. */
  36282. materialIndex: number;
  36283. /**
  36284. * Creates a new sorted particle
  36285. * @param materialIndex
  36286. */
  36287. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36288. }
  36289. /**
  36290. * Represents a solid particle vertex
  36291. */
  36292. export class SolidParticleVertex {
  36293. /**
  36294. * Vertex position
  36295. */
  36296. position: Vector3;
  36297. /**
  36298. * Vertex color
  36299. */
  36300. color: Color4;
  36301. /**
  36302. * Vertex UV
  36303. */
  36304. uv: Vector2;
  36305. /**
  36306. * Creates a new solid particle vertex
  36307. */
  36308. constructor();
  36309. /** Vertex x coordinate */
  36310. get x(): number;
  36311. set x(val: number);
  36312. /** Vertex y coordinate */
  36313. get y(): number;
  36314. set y(val: number);
  36315. /** Vertex z coordinate */
  36316. get z(): number;
  36317. set z(val: number);
  36318. }
  36319. }
  36320. declare module "babylonjs/Collisions/meshCollisionData" {
  36321. import { Collider } from "babylonjs/Collisions/collider";
  36322. import { Vector3 } from "babylonjs/Maths/math.vector";
  36323. import { Nullable } from "babylonjs/types";
  36324. import { Observer } from "babylonjs/Misc/observable";
  36325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36326. /**
  36327. * @hidden
  36328. */
  36329. export class _MeshCollisionData {
  36330. _checkCollisions: boolean;
  36331. _collisionMask: number;
  36332. _collisionGroup: number;
  36333. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36334. _collider: Nullable<Collider>;
  36335. _oldPositionForCollisions: Vector3;
  36336. _diffPositionForCollisions: Vector3;
  36337. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36338. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36339. _collisionResponse: boolean;
  36340. }
  36341. }
  36342. declare module "babylonjs/Meshes/abstractMesh" {
  36343. import { Observable } from "babylonjs/Misc/observable";
  36344. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36345. import { Camera } from "babylonjs/Cameras/camera";
  36346. import { Scene, IDisposable } from "babylonjs/scene";
  36347. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36348. import { Node } from "babylonjs/node";
  36349. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36352. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36353. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36354. import { Material } from "babylonjs/Materials/material";
  36355. import { Light } from "babylonjs/Lights/light";
  36356. import { Skeleton } from "babylonjs/Bones/skeleton";
  36357. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36358. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36359. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36360. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36362. import { Plane } from "babylonjs/Maths/math.plane";
  36363. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36364. import { Ray } from "babylonjs/Culling/ray";
  36365. import { Collider } from "babylonjs/Collisions/collider";
  36366. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36367. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36368. /** @hidden */
  36369. class _FacetDataStorage {
  36370. facetPositions: Vector3[];
  36371. facetNormals: Vector3[];
  36372. facetPartitioning: number[][];
  36373. facetNb: number;
  36374. partitioningSubdivisions: number;
  36375. partitioningBBoxRatio: number;
  36376. facetDataEnabled: boolean;
  36377. facetParameters: any;
  36378. bbSize: Vector3;
  36379. subDiv: {
  36380. max: number;
  36381. X: number;
  36382. Y: number;
  36383. Z: number;
  36384. };
  36385. facetDepthSort: boolean;
  36386. facetDepthSortEnabled: boolean;
  36387. depthSortedIndices: IndicesArray;
  36388. depthSortedFacets: {
  36389. ind: number;
  36390. sqDistance: number;
  36391. }[];
  36392. facetDepthSortFunction: (f1: {
  36393. ind: number;
  36394. sqDistance: number;
  36395. }, f2: {
  36396. ind: number;
  36397. sqDistance: number;
  36398. }) => number;
  36399. facetDepthSortFrom: Vector3;
  36400. facetDepthSortOrigin: Vector3;
  36401. invertedMatrix: Matrix;
  36402. }
  36403. /**
  36404. * @hidden
  36405. **/
  36406. class _InternalAbstractMeshDataInfo {
  36407. _hasVertexAlpha: boolean;
  36408. _useVertexColors: boolean;
  36409. _numBoneInfluencers: number;
  36410. _applyFog: boolean;
  36411. _receiveShadows: boolean;
  36412. _facetData: _FacetDataStorage;
  36413. _visibility: number;
  36414. _skeleton: Nullable<Skeleton>;
  36415. _layerMask: number;
  36416. _computeBonesUsingShaders: boolean;
  36417. _isActive: boolean;
  36418. _onlyForInstances: boolean;
  36419. _isActiveIntermediate: boolean;
  36420. _onlyForInstancesIntermediate: boolean;
  36421. _actAsRegularMesh: boolean;
  36422. }
  36423. /**
  36424. * Class used to store all common mesh properties
  36425. */
  36426. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36427. /** No occlusion */
  36428. static OCCLUSION_TYPE_NONE: number;
  36429. /** Occlusion set to optimisitic */
  36430. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36431. /** Occlusion set to strict */
  36432. static OCCLUSION_TYPE_STRICT: number;
  36433. /** Use an accurante occlusion algorithm */
  36434. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36435. /** Use a conservative occlusion algorithm */
  36436. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36437. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36438. * Test order :
  36439. * Is the bounding sphere outside the frustum ?
  36440. * If not, are the bounding box vertices outside the frustum ?
  36441. * It not, then the cullable object is in the frustum.
  36442. */
  36443. static readonly CULLINGSTRATEGY_STANDARD: number;
  36444. /** Culling strategy : Bounding Sphere Only.
  36445. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36446. * It's also less accurate than the standard because some not visible objects can still be selected.
  36447. * Test : is the bounding sphere outside the frustum ?
  36448. * If not, then the cullable object is in the frustum.
  36449. */
  36450. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36451. /** Culling strategy : Optimistic Inclusion.
  36452. * This in an inclusion test first, then the standard exclusion test.
  36453. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36454. * 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.
  36455. * Anyway, it's as accurate as the standard strategy.
  36456. * Test :
  36457. * Is the cullable object bounding sphere center in the frustum ?
  36458. * If not, apply the default culling strategy.
  36459. */
  36460. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36461. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36462. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36463. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36464. * 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.
  36465. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36466. * Test :
  36467. * Is the cullable object bounding sphere center in the frustum ?
  36468. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36469. */
  36470. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36471. /**
  36472. * No billboard
  36473. */
  36474. static get BILLBOARDMODE_NONE(): number;
  36475. /** Billboard on X axis */
  36476. static get BILLBOARDMODE_X(): number;
  36477. /** Billboard on Y axis */
  36478. static get BILLBOARDMODE_Y(): number;
  36479. /** Billboard on Z axis */
  36480. static get BILLBOARDMODE_Z(): number;
  36481. /** Billboard on all axes */
  36482. static get BILLBOARDMODE_ALL(): number;
  36483. /** Billboard on using position instead of orientation */
  36484. static get BILLBOARDMODE_USE_POSITION(): number;
  36485. /** @hidden */
  36486. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36487. /**
  36488. * The culling strategy to use to check whether the mesh must be rendered or not.
  36489. * This value can be changed at any time and will be used on the next render mesh selection.
  36490. * The possible values are :
  36491. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36492. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36493. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36494. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36495. * Please read each static variable documentation to get details about the culling process.
  36496. * */
  36497. cullingStrategy: number;
  36498. /**
  36499. * Gets the number of facets in the mesh
  36500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36501. */
  36502. get facetNb(): number;
  36503. /**
  36504. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36505. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36506. */
  36507. get partitioningSubdivisions(): number;
  36508. set partitioningSubdivisions(nb: number);
  36509. /**
  36510. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36511. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36512. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36513. */
  36514. get partitioningBBoxRatio(): number;
  36515. set partitioningBBoxRatio(ratio: number);
  36516. /**
  36517. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36518. * Works only for updatable meshes.
  36519. * Doesn't work with multi-materials
  36520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36521. */
  36522. get mustDepthSortFacets(): boolean;
  36523. set mustDepthSortFacets(sort: boolean);
  36524. /**
  36525. * The location (Vector3) where the facet depth sort must be computed from.
  36526. * By default, the active camera position.
  36527. * Used only when facet depth sort is enabled
  36528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36529. */
  36530. get facetDepthSortFrom(): Vector3;
  36531. set facetDepthSortFrom(location: Vector3);
  36532. /**
  36533. * gets a boolean indicating if facetData is enabled
  36534. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36535. */
  36536. get isFacetDataEnabled(): boolean;
  36537. /** @hidden */
  36538. _updateNonUniformScalingState(value: boolean): boolean;
  36539. /**
  36540. * An event triggered when this mesh collides with another one
  36541. */
  36542. onCollideObservable: Observable<AbstractMesh>;
  36543. /** Set a function to call when this mesh collides with another one */
  36544. set onCollide(callback: () => void);
  36545. /**
  36546. * An event triggered when the collision's position changes
  36547. */
  36548. onCollisionPositionChangeObservable: Observable<Vector3>;
  36549. /** Set a function to call when the collision's position changes */
  36550. set onCollisionPositionChange(callback: () => void);
  36551. /**
  36552. * An event triggered when material is changed
  36553. */
  36554. onMaterialChangedObservable: Observable<AbstractMesh>;
  36555. /**
  36556. * Gets or sets the orientation for POV movement & rotation
  36557. */
  36558. definedFacingForward: boolean;
  36559. /** @hidden */
  36560. _occlusionQuery: Nullable<WebGLQuery>;
  36561. /** @hidden */
  36562. _renderingGroup: Nullable<RenderingGroup>;
  36563. /**
  36564. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36565. */
  36566. get visibility(): number;
  36567. /**
  36568. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36569. */
  36570. set visibility(value: number);
  36571. /** Gets or sets the alpha index used to sort transparent meshes
  36572. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36573. */
  36574. alphaIndex: number;
  36575. /**
  36576. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36577. */
  36578. isVisible: boolean;
  36579. /**
  36580. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36581. */
  36582. isPickable: boolean;
  36583. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36584. showSubMeshesBoundingBox: boolean;
  36585. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36586. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36587. */
  36588. isBlocker: boolean;
  36589. /**
  36590. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36591. */
  36592. enablePointerMoveEvents: boolean;
  36593. private _renderingGroupId;
  36594. /**
  36595. * Specifies the rendering group id for this mesh (0 by default)
  36596. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36597. */
  36598. get renderingGroupId(): number;
  36599. set renderingGroupId(value: number);
  36600. private _material;
  36601. /** Gets or sets current material */
  36602. get material(): Nullable<Material>;
  36603. set material(value: Nullable<Material>);
  36604. /**
  36605. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36606. * @see https://doc.babylonjs.com/babylon101/shadows
  36607. */
  36608. get receiveShadows(): boolean;
  36609. set receiveShadows(value: boolean);
  36610. /** Defines color to use when rendering outline */
  36611. outlineColor: Color3;
  36612. /** Define width to use when rendering outline */
  36613. outlineWidth: number;
  36614. /** Defines color to use when rendering overlay */
  36615. overlayColor: Color3;
  36616. /** Defines alpha to use when rendering overlay */
  36617. overlayAlpha: number;
  36618. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36619. get hasVertexAlpha(): boolean;
  36620. set hasVertexAlpha(value: boolean);
  36621. /** 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) */
  36622. get useVertexColors(): boolean;
  36623. set useVertexColors(value: boolean);
  36624. /**
  36625. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36626. */
  36627. get computeBonesUsingShaders(): boolean;
  36628. set computeBonesUsingShaders(value: boolean);
  36629. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36630. get numBoneInfluencers(): number;
  36631. set numBoneInfluencers(value: number);
  36632. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36633. get applyFog(): boolean;
  36634. set applyFog(value: boolean);
  36635. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36636. useOctreeForRenderingSelection: boolean;
  36637. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36638. useOctreeForPicking: boolean;
  36639. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36640. useOctreeForCollisions: boolean;
  36641. /**
  36642. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36643. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36644. */
  36645. get layerMask(): number;
  36646. set layerMask(value: number);
  36647. /**
  36648. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36649. */
  36650. alwaysSelectAsActiveMesh: boolean;
  36651. /**
  36652. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36653. */
  36654. doNotSyncBoundingInfo: boolean;
  36655. /**
  36656. * Gets or sets the current action manager
  36657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36658. */
  36659. actionManager: Nullable<AbstractActionManager>;
  36660. private _meshCollisionData;
  36661. /**
  36662. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36663. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36664. */
  36665. ellipsoid: Vector3;
  36666. /**
  36667. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36668. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36669. */
  36670. ellipsoidOffset: Vector3;
  36671. /**
  36672. * Gets or sets a collision mask used to mask collisions (default is -1).
  36673. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36674. */
  36675. get collisionMask(): number;
  36676. set collisionMask(mask: number);
  36677. /**
  36678. * Gets or sets a collision response flag (default is true).
  36679. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36680. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36681. * to respond to the collision.
  36682. */
  36683. get collisionResponse(): boolean;
  36684. set collisionResponse(response: boolean);
  36685. /**
  36686. * Gets or sets the current collision group mask (-1 by default).
  36687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36688. */
  36689. get collisionGroup(): number;
  36690. set collisionGroup(mask: number);
  36691. /**
  36692. * Gets or sets current surrounding meshes (null by default).
  36693. *
  36694. * By default collision detection is tested against every mesh in the scene.
  36695. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36696. * meshes will be tested for the collision.
  36697. *
  36698. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36699. */
  36700. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36701. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36702. /**
  36703. * Defines edge width used when edgesRenderer is enabled
  36704. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36705. */
  36706. edgesWidth: number;
  36707. /**
  36708. * Defines edge color used when edgesRenderer is enabled
  36709. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36710. */
  36711. edgesColor: Color4;
  36712. /** @hidden */
  36713. _edgesRenderer: Nullable<IEdgesRenderer>;
  36714. /** @hidden */
  36715. _masterMesh: Nullable<AbstractMesh>;
  36716. /** @hidden */
  36717. _boundingInfo: Nullable<BoundingInfo>;
  36718. /** @hidden */
  36719. _renderId: number;
  36720. /**
  36721. * Gets or sets the list of subMeshes
  36722. * @see https://doc.babylonjs.com/how_to/multi_materials
  36723. */
  36724. subMeshes: SubMesh[];
  36725. /** @hidden */
  36726. _intersectionsInProgress: AbstractMesh[];
  36727. /** @hidden */
  36728. _unIndexed: boolean;
  36729. /** @hidden */
  36730. _lightSources: Light[];
  36731. /** Gets the list of lights affecting that mesh */
  36732. get lightSources(): Light[];
  36733. /** @hidden */
  36734. get _positions(): Nullable<Vector3[]>;
  36735. /** @hidden */
  36736. _waitingData: {
  36737. lods: Nullable<any>;
  36738. actions: Nullable<any>;
  36739. freezeWorldMatrix: Nullable<boolean>;
  36740. };
  36741. /** @hidden */
  36742. _bonesTransformMatrices: Nullable<Float32Array>;
  36743. /** @hidden */
  36744. _transformMatrixTexture: Nullable<RawTexture>;
  36745. /**
  36746. * Gets or sets a skeleton to apply skining transformations
  36747. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36748. */
  36749. set skeleton(value: Nullable<Skeleton>);
  36750. get skeleton(): Nullable<Skeleton>;
  36751. /**
  36752. * An event triggered when the mesh is rebuilt.
  36753. */
  36754. onRebuildObservable: Observable<AbstractMesh>;
  36755. /**
  36756. * Creates a new AbstractMesh
  36757. * @param name defines the name of the mesh
  36758. * @param scene defines the hosting scene
  36759. */
  36760. constructor(name: string, scene?: Nullable<Scene>);
  36761. /**
  36762. * Returns the string "AbstractMesh"
  36763. * @returns "AbstractMesh"
  36764. */
  36765. getClassName(): string;
  36766. /**
  36767. * Gets a string representation of the current mesh
  36768. * @param fullDetails defines a boolean indicating if full details must be included
  36769. * @returns a string representation of the current mesh
  36770. */
  36771. toString(fullDetails?: boolean): string;
  36772. /**
  36773. * @hidden
  36774. */
  36775. protected _getEffectiveParent(): Nullable<Node>;
  36776. /** @hidden */
  36777. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36778. /** @hidden */
  36779. _rebuild(): void;
  36780. /** @hidden */
  36781. _resyncLightSources(): void;
  36782. /** @hidden */
  36783. _resyncLightSource(light: Light): void;
  36784. /** @hidden */
  36785. _unBindEffect(): void;
  36786. /** @hidden */
  36787. _removeLightSource(light: Light, dispose: boolean): void;
  36788. private _markSubMeshesAsDirty;
  36789. /** @hidden */
  36790. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36791. /** @hidden */
  36792. _markSubMeshesAsAttributesDirty(): void;
  36793. /** @hidden */
  36794. _markSubMeshesAsMiscDirty(): void;
  36795. /**
  36796. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36797. */
  36798. get scaling(): Vector3;
  36799. set scaling(newScaling: Vector3);
  36800. /**
  36801. * Returns true if the mesh is blocked. Implemented by child classes
  36802. */
  36803. get isBlocked(): boolean;
  36804. /**
  36805. * Returns the mesh itself by default. Implemented by child classes
  36806. * @param camera defines the camera to use to pick the right LOD level
  36807. * @returns the currentAbstractMesh
  36808. */
  36809. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36810. /**
  36811. * Returns 0 by default. Implemented by child classes
  36812. * @returns an integer
  36813. */
  36814. getTotalVertices(): number;
  36815. /**
  36816. * Returns a positive integer : the total number of indices in this mesh geometry.
  36817. * @returns the numner of indices or zero if the mesh has no geometry.
  36818. */
  36819. getTotalIndices(): number;
  36820. /**
  36821. * Returns null by default. Implemented by child classes
  36822. * @returns null
  36823. */
  36824. getIndices(): Nullable<IndicesArray>;
  36825. /**
  36826. * Returns the array of the requested vertex data kind. Implemented by child classes
  36827. * @param kind defines the vertex data kind to use
  36828. * @returns null
  36829. */
  36830. getVerticesData(kind: string): Nullable<FloatArray>;
  36831. /**
  36832. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36833. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36834. * Note that a new underlying VertexBuffer object is created each call.
  36835. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36836. * @param kind defines vertex data kind:
  36837. * * VertexBuffer.PositionKind
  36838. * * VertexBuffer.UVKind
  36839. * * VertexBuffer.UV2Kind
  36840. * * VertexBuffer.UV3Kind
  36841. * * VertexBuffer.UV4Kind
  36842. * * VertexBuffer.UV5Kind
  36843. * * VertexBuffer.UV6Kind
  36844. * * VertexBuffer.ColorKind
  36845. * * VertexBuffer.MatricesIndicesKind
  36846. * * VertexBuffer.MatricesIndicesExtraKind
  36847. * * VertexBuffer.MatricesWeightsKind
  36848. * * VertexBuffer.MatricesWeightsExtraKind
  36849. * @param data defines the data source
  36850. * @param updatable defines if the data must be flagged as updatable (or static)
  36851. * @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
  36852. * @returns the current mesh
  36853. */
  36854. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36855. /**
  36856. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36857. * If the mesh has no geometry, it is simply returned as it is.
  36858. * @param kind defines vertex data kind:
  36859. * * VertexBuffer.PositionKind
  36860. * * VertexBuffer.UVKind
  36861. * * VertexBuffer.UV2Kind
  36862. * * VertexBuffer.UV3Kind
  36863. * * VertexBuffer.UV4Kind
  36864. * * VertexBuffer.UV5Kind
  36865. * * VertexBuffer.UV6Kind
  36866. * * VertexBuffer.ColorKind
  36867. * * VertexBuffer.MatricesIndicesKind
  36868. * * VertexBuffer.MatricesIndicesExtraKind
  36869. * * VertexBuffer.MatricesWeightsKind
  36870. * * VertexBuffer.MatricesWeightsExtraKind
  36871. * @param data defines the data source
  36872. * @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
  36873. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36874. * @returns the current mesh
  36875. */
  36876. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36877. /**
  36878. * Sets the mesh indices,
  36879. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36880. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36881. * @param totalVertices Defines the total number of vertices
  36882. * @returns the current mesh
  36883. */
  36884. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36885. /**
  36886. * Gets a boolean indicating if specific vertex data is present
  36887. * @param kind defines the vertex data kind to use
  36888. * @returns true is data kind is present
  36889. */
  36890. isVerticesDataPresent(kind: string): boolean;
  36891. /**
  36892. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36893. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36894. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36895. * @returns a BoundingInfo
  36896. */
  36897. getBoundingInfo(): BoundingInfo;
  36898. /**
  36899. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36900. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36901. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36902. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36903. * @returns the current mesh
  36904. */
  36905. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36906. /**
  36907. * Overwrite the current bounding info
  36908. * @param boundingInfo defines the new bounding info
  36909. * @returns the current mesh
  36910. */
  36911. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36912. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36913. get useBones(): boolean;
  36914. /** @hidden */
  36915. _preActivate(): void;
  36916. /** @hidden */
  36917. _preActivateForIntermediateRendering(renderId: number): void;
  36918. /** @hidden */
  36919. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36920. /** @hidden */
  36921. _postActivate(): void;
  36922. /** @hidden */
  36923. _freeze(): void;
  36924. /** @hidden */
  36925. _unFreeze(): void;
  36926. /**
  36927. * Gets the current world matrix
  36928. * @returns a Matrix
  36929. */
  36930. getWorldMatrix(): Matrix;
  36931. /** @hidden */
  36932. _getWorldMatrixDeterminant(): number;
  36933. /**
  36934. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36935. */
  36936. get isAnInstance(): boolean;
  36937. /**
  36938. * Gets a boolean indicating if this mesh has instances
  36939. */
  36940. get hasInstances(): boolean;
  36941. /**
  36942. * Gets a boolean indicating if this mesh has thin instances
  36943. */
  36944. get hasThinInstances(): boolean;
  36945. /**
  36946. * Perform relative position change from the point of view of behind the front of the mesh.
  36947. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36948. * Supports definition of mesh facing forward or backward
  36949. * @param amountRight defines the distance on the right axis
  36950. * @param amountUp defines the distance on the up axis
  36951. * @param amountForward defines the distance on the forward axis
  36952. * @returns the current mesh
  36953. */
  36954. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36955. /**
  36956. * Calculate relative position change from the point of view of behind the front of the mesh.
  36957. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36958. * Supports definition of mesh facing forward or backward
  36959. * @param amountRight defines the distance on the right axis
  36960. * @param amountUp defines the distance on the up axis
  36961. * @param amountForward defines the distance on the forward axis
  36962. * @returns the new displacement vector
  36963. */
  36964. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36965. /**
  36966. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36967. * Supports definition of mesh facing forward or backward
  36968. * @param flipBack defines the flip
  36969. * @param twirlClockwise defines the twirl
  36970. * @param tiltRight defines the tilt
  36971. * @returns the current mesh
  36972. */
  36973. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36974. /**
  36975. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36976. * Supports definition of mesh facing forward or backward.
  36977. * @param flipBack defines the flip
  36978. * @param twirlClockwise defines the twirl
  36979. * @param tiltRight defines the tilt
  36980. * @returns the new rotation vector
  36981. */
  36982. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36983. /**
  36984. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36985. * This means the mesh underlying bounding box and sphere are recomputed.
  36986. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36987. * @returns the current mesh
  36988. */
  36989. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36990. /** @hidden */
  36991. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36992. /** @hidden */
  36993. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36994. /** @hidden */
  36995. _updateBoundingInfo(): AbstractMesh;
  36996. /** @hidden */
  36997. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36998. /** @hidden */
  36999. protected _afterComputeWorldMatrix(): void;
  37000. /** @hidden */
  37001. get _effectiveMesh(): AbstractMesh;
  37002. /**
  37003. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37004. * A mesh is in the frustum if its bounding box intersects the frustum
  37005. * @param frustumPlanes defines the frustum to test
  37006. * @returns true if the mesh is in the frustum planes
  37007. */
  37008. isInFrustum(frustumPlanes: Plane[]): boolean;
  37009. /**
  37010. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37011. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37012. * @param frustumPlanes defines the frustum to test
  37013. * @returns true if the mesh is completely in the frustum planes
  37014. */
  37015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37016. /**
  37017. * True if the mesh intersects another mesh or a SolidParticle object
  37018. * @param mesh defines a target mesh or SolidParticle to test
  37019. * @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)
  37020. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37021. * @returns true if there is an intersection
  37022. */
  37023. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37024. /**
  37025. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37026. * @param point defines the point to test
  37027. * @returns true if there is an intersection
  37028. */
  37029. intersectsPoint(point: Vector3): boolean;
  37030. /**
  37031. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37032. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37033. */
  37034. get checkCollisions(): boolean;
  37035. set checkCollisions(collisionEnabled: boolean);
  37036. /**
  37037. * Gets Collider object used to compute collisions (not physics)
  37038. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37039. */
  37040. get collider(): Nullable<Collider>;
  37041. /**
  37042. * Move the mesh using collision engine
  37043. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37044. * @param displacement defines the requested displacement vector
  37045. * @returns the current mesh
  37046. */
  37047. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37048. private _onCollisionPositionChange;
  37049. /** @hidden */
  37050. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37051. /** @hidden */
  37052. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37053. /** @hidden */
  37054. _checkCollision(collider: Collider): AbstractMesh;
  37055. /** @hidden */
  37056. _generatePointsArray(): boolean;
  37057. /**
  37058. * Checks if the passed Ray intersects with the mesh
  37059. * @param ray defines the ray to use
  37060. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37061. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37062. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37063. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37064. * @returns the picking info
  37065. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37066. */
  37067. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37068. /**
  37069. * Clones the current mesh
  37070. * @param name defines the mesh name
  37071. * @param newParent defines the new mesh parent
  37072. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37073. * @returns the new mesh
  37074. */
  37075. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37076. /**
  37077. * Disposes all the submeshes of the current meshnp
  37078. * @returns the current mesh
  37079. */
  37080. releaseSubMeshes(): AbstractMesh;
  37081. /**
  37082. * Releases resources associated with this abstract mesh.
  37083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37085. */
  37086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37087. /**
  37088. * Adds the passed mesh as a child to the current mesh
  37089. * @param mesh defines the child mesh
  37090. * @returns the current mesh
  37091. */
  37092. addChild(mesh: AbstractMesh): AbstractMesh;
  37093. /**
  37094. * Removes the passed mesh from the current mesh children list
  37095. * @param mesh defines the child mesh
  37096. * @returns the current mesh
  37097. */
  37098. removeChild(mesh: AbstractMesh): AbstractMesh;
  37099. /** @hidden */
  37100. private _initFacetData;
  37101. /**
  37102. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37103. * This method can be called within the render loop.
  37104. * 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
  37105. * @returns the current mesh
  37106. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37107. */
  37108. updateFacetData(): AbstractMesh;
  37109. /**
  37110. * Returns the facetLocalNormals array.
  37111. * The normals are expressed in the mesh local spac
  37112. * @returns an array of Vector3
  37113. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37114. */
  37115. getFacetLocalNormals(): Vector3[];
  37116. /**
  37117. * Returns the facetLocalPositions array.
  37118. * The facet positions are expressed in the mesh local space
  37119. * @returns an array of Vector3
  37120. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37121. */
  37122. getFacetLocalPositions(): Vector3[];
  37123. /**
  37124. * Returns the facetLocalPartioning array
  37125. * @returns an array of array of numbers
  37126. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37127. */
  37128. getFacetLocalPartitioning(): number[][];
  37129. /**
  37130. * Returns the i-th facet position in the world system.
  37131. * This method allocates a new Vector3 per call
  37132. * @param i defines the facet index
  37133. * @returns a new Vector3
  37134. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37135. */
  37136. getFacetPosition(i: number): Vector3;
  37137. /**
  37138. * Sets the reference Vector3 with the i-th facet position in the world system
  37139. * @param i defines the facet index
  37140. * @param ref defines the target vector
  37141. * @returns the current mesh
  37142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37143. */
  37144. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37145. /**
  37146. * Returns the i-th facet normal in the world system.
  37147. * This method allocates a new Vector3 per call
  37148. * @param i defines the facet index
  37149. * @returns a new Vector3
  37150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37151. */
  37152. getFacetNormal(i: number): Vector3;
  37153. /**
  37154. * Sets the reference Vector3 with the i-th facet normal in the world system
  37155. * @param i defines the facet index
  37156. * @param ref defines the target vector
  37157. * @returns the current mesh
  37158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37159. */
  37160. getFacetNormalToRef(i: number, ref: Vector3): this;
  37161. /**
  37162. * 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)
  37163. * @param x defines x coordinate
  37164. * @param y defines y coordinate
  37165. * @param z defines z coordinate
  37166. * @returns the array of facet indexes
  37167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37168. */
  37169. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37170. /**
  37171. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37172. * @param projected sets as the (x,y,z) world projection on the facet
  37173. * @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
  37174. * @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
  37175. * @param x defines x coordinate
  37176. * @param y defines y coordinate
  37177. * @param z defines z coordinate
  37178. * @returns the face index if found (or null instead)
  37179. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37180. */
  37181. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37182. /**
  37183. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37184. * @param projected sets as the (x,y,z) local projection on the facet
  37185. * @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
  37186. * @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
  37187. * @param x defines x coordinate
  37188. * @param y defines y coordinate
  37189. * @param z defines z coordinate
  37190. * @returns the face index if found (or null instead)
  37191. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37192. */
  37193. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37194. /**
  37195. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37196. * @returns the parameters
  37197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37198. */
  37199. getFacetDataParameters(): any;
  37200. /**
  37201. * Disables the feature FacetData and frees the related memory
  37202. * @returns the current mesh
  37203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37204. */
  37205. disableFacetData(): AbstractMesh;
  37206. /**
  37207. * Updates the AbstractMesh indices array
  37208. * @param indices defines the data source
  37209. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37210. * @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)
  37211. * @returns the current mesh
  37212. */
  37213. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37214. /**
  37215. * Creates new normals data for the mesh
  37216. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37217. * @returns the current mesh
  37218. */
  37219. createNormals(updatable: boolean): AbstractMesh;
  37220. /**
  37221. * Align the mesh with a normal
  37222. * @param normal defines the normal to use
  37223. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37224. * @returns the current mesh
  37225. */
  37226. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37227. /** @hidden */
  37228. _checkOcclusionQuery(): boolean;
  37229. /**
  37230. * Disables the mesh edge rendering mode
  37231. * @returns the currentAbstractMesh
  37232. */
  37233. disableEdgesRendering(): AbstractMesh;
  37234. /**
  37235. * Enables the edge rendering mode on the mesh.
  37236. * This mode makes the mesh edges visible
  37237. * @param epsilon defines the maximal distance between two angles to detect a face
  37238. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37239. * @returns the currentAbstractMesh
  37240. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37241. */
  37242. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37243. /**
  37244. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37245. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37246. */
  37247. getConnectedParticleSystems(): IParticleSystem[];
  37248. }
  37249. }
  37250. declare module "babylonjs/Actions/actionEvent" {
  37251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37252. import { Nullable } from "babylonjs/types";
  37253. import { Sprite } from "babylonjs/Sprites/sprite";
  37254. import { Scene } from "babylonjs/scene";
  37255. import { Vector2 } from "babylonjs/Maths/math.vector";
  37256. /**
  37257. * Interface used to define ActionEvent
  37258. */
  37259. export interface IActionEvent {
  37260. /** The mesh or sprite that triggered the action */
  37261. source: any;
  37262. /** The X mouse cursor position at the time of the event */
  37263. pointerX: number;
  37264. /** The Y mouse cursor position at the time of the event */
  37265. pointerY: number;
  37266. /** The mesh that is currently pointed at (can be null) */
  37267. meshUnderPointer: Nullable<AbstractMesh>;
  37268. /** the original (browser) event that triggered the ActionEvent */
  37269. sourceEvent?: any;
  37270. /** additional data for the event */
  37271. additionalData?: any;
  37272. }
  37273. /**
  37274. * ActionEvent is the event being sent when an action is triggered.
  37275. */
  37276. export class ActionEvent implements IActionEvent {
  37277. /** The mesh or sprite that triggered the action */
  37278. source: any;
  37279. /** The X mouse cursor position at the time of the event */
  37280. pointerX: number;
  37281. /** The Y mouse cursor position at the time of the event */
  37282. pointerY: number;
  37283. /** The mesh that is currently pointed at (can be null) */
  37284. meshUnderPointer: Nullable<AbstractMesh>;
  37285. /** the original (browser) event that triggered the ActionEvent */
  37286. sourceEvent?: any;
  37287. /** additional data for the event */
  37288. additionalData?: any;
  37289. /**
  37290. * Creates a new ActionEvent
  37291. * @param source The mesh or sprite that triggered the action
  37292. * @param pointerX The X mouse cursor position at the time of the event
  37293. * @param pointerY The Y mouse cursor position at the time of the event
  37294. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37295. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37296. * @param additionalData additional data for the event
  37297. */
  37298. constructor(
  37299. /** The mesh or sprite that triggered the action */
  37300. source: any,
  37301. /** The X mouse cursor position at the time of the event */
  37302. pointerX: number,
  37303. /** The Y mouse cursor position at the time of the event */
  37304. pointerY: number,
  37305. /** The mesh that is currently pointed at (can be null) */
  37306. meshUnderPointer: Nullable<AbstractMesh>,
  37307. /** the original (browser) event that triggered the ActionEvent */
  37308. sourceEvent?: any,
  37309. /** additional data for the event */
  37310. additionalData?: any);
  37311. /**
  37312. * Helper function to auto-create an ActionEvent from a source mesh.
  37313. * @param source The source mesh that triggered the event
  37314. * @param evt The original (browser) event
  37315. * @param additionalData additional data for the event
  37316. * @returns the new ActionEvent
  37317. */
  37318. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37319. /**
  37320. * Helper function to auto-create an ActionEvent from a source sprite
  37321. * @param source The source sprite that triggered the event
  37322. * @param scene Scene associated with the sprite
  37323. * @param evt The original (browser) event
  37324. * @param additionalData additional data for the event
  37325. * @returns the new ActionEvent
  37326. */
  37327. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37328. /**
  37329. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37330. * @param scene the scene where the event occurred
  37331. * @param evt The original (browser) event
  37332. * @returns the new ActionEvent
  37333. */
  37334. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37335. /**
  37336. * Helper function to auto-create an ActionEvent from a primitive
  37337. * @param prim defines the target primitive
  37338. * @param pointerPos defines the pointer position
  37339. * @param evt The original (browser) event
  37340. * @param additionalData additional data for the event
  37341. * @returns the new ActionEvent
  37342. */
  37343. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37344. }
  37345. }
  37346. declare module "babylonjs/Actions/abstractActionManager" {
  37347. import { IDisposable } from "babylonjs/scene";
  37348. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37349. import { IAction } from "babylonjs/Actions/action";
  37350. import { Nullable } from "babylonjs/types";
  37351. /**
  37352. * Abstract class used to decouple action Manager from scene and meshes.
  37353. * Do not instantiate.
  37354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37355. */
  37356. export abstract class AbstractActionManager implements IDisposable {
  37357. /** Gets the list of active triggers */
  37358. static Triggers: {
  37359. [key: string]: number;
  37360. };
  37361. /** Gets the cursor to use when hovering items */
  37362. hoverCursor: string;
  37363. /** Gets the list of actions */
  37364. actions: IAction[];
  37365. /**
  37366. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37367. */
  37368. isRecursive: boolean;
  37369. /**
  37370. * Releases all associated resources
  37371. */
  37372. abstract dispose(): void;
  37373. /**
  37374. * Does this action manager has pointer triggers
  37375. */
  37376. abstract get hasPointerTriggers(): boolean;
  37377. /**
  37378. * Does this action manager has pick triggers
  37379. */
  37380. abstract get hasPickTriggers(): boolean;
  37381. /**
  37382. * Process a specific trigger
  37383. * @param trigger defines the trigger to process
  37384. * @param evt defines the event details to be processed
  37385. */
  37386. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37387. /**
  37388. * Does this action manager handles actions of any of the given triggers
  37389. * @param triggers defines the triggers to be tested
  37390. * @return a boolean indicating whether one (or more) of the triggers is handled
  37391. */
  37392. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37393. /**
  37394. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37395. * speed.
  37396. * @param triggerA defines the trigger to be tested
  37397. * @param triggerB defines the trigger to be tested
  37398. * @return a boolean indicating whether one (or more) of the triggers is handled
  37399. */
  37400. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37401. /**
  37402. * Does this action manager handles actions of a given trigger
  37403. * @param trigger defines the trigger to be tested
  37404. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37405. * @return whether the trigger is handled
  37406. */
  37407. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37408. /**
  37409. * Serialize this manager to a JSON object
  37410. * @param name defines the property name to store this manager
  37411. * @returns a JSON representation of this manager
  37412. */
  37413. abstract serialize(name: string): any;
  37414. /**
  37415. * Registers an action to this action manager
  37416. * @param action defines the action to be registered
  37417. * @return the action amended (prepared) after registration
  37418. */
  37419. abstract registerAction(action: IAction): Nullable<IAction>;
  37420. /**
  37421. * Unregisters an action to this action manager
  37422. * @param action defines the action to be unregistered
  37423. * @return a boolean indicating whether the action has been unregistered
  37424. */
  37425. abstract unregisterAction(action: IAction): Boolean;
  37426. /**
  37427. * Does exist one action manager with at least one trigger
  37428. **/
  37429. static get HasTriggers(): boolean;
  37430. /**
  37431. * Does exist one action manager with at least one pick trigger
  37432. **/
  37433. static get HasPickTriggers(): boolean;
  37434. /**
  37435. * Does exist one action manager that handles actions of a given trigger
  37436. * @param trigger defines the trigger to be tested
  37437. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37438. **/
  37439. static HasSpecificTrigger(trigger: number): boolean;
  37440. }
  37441. }
  37442. declare module "babylonjs/node" {
  37443. import { Scene } from "babylonjs/scene";
  37444. import { Nullable } from "babylonjs/types";
  37445. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37446. import { Engine } from "babylonjs/Engines/engine";
  37447. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37448. import { Observable } from "babylonjs/Misc/observable";
  37449. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37450. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37451. import { Animatable } from "babylonjs/Animations/animatable";
  37452. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37453. import { Animation } from "babylonjs/Animations/animation";
  37454. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37456. /**
  37457. * Defines how a node can be built from a string name.
  37458. */
  37459. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37460. /**
  37461. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37462. */
  37463. export class Node implements IBehaviorAware<Node> {
  37464. /** @hidden */
  37465. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37466. private static _NodeConstructors;
  37467. /**
  37468. * Add a new node constructor
  37469. * @param type defines the type name of the node to construct
  37470. * @param constructorFunc defines the constructor function
  37471. */
  37472. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37473. /**
  37474. * Returns a node constructor based on type name
  37475. * @param type defines the type name
  37476. * @param name defines the new node name
  37477. * @param scene defines the hosting scene
  37478. * @param options defines optional options to transmit to constructors
  37479. * @returns the new constructor or null
  37480. */
  37481. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37482. /**
  37483. * Gets or sets the name of the node
  37484. */
  37485. name: string;
  37486. /**
  37487. * Gets or sets the id of the node
  37488. */
  37489. id: string;
  37490. /**
  37491. * Gets or sets the unique id of the node
  37492. */
  37493. uniqueId: number;
  37494. /**
  37495. * Gets or sets a string used to store user defined state for the node
  37496. */
  37497. state: string;
  37498. /**
  37499. * Gets or sets an object used to store user defined information for the node
  37500. */
  37501. metadata: any;
  37502. /**
  37503. * For internal use only. Please do not use.
  37504. */
  37505. reservedDataStore: any;
  37506. /**
  37507. * List of inspectable custom properties (used by the Inspector)
  37508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37509. */
  37510. inspectableCustomProperties: IInspectable[];
  37511. private _doNotSerialize;
  37512. /**
  37513. * Gets or sets a boolean used to define if the node must be serialized
  37514. */
  37515. get doNotSerialize(): boolean;
  37516. set doNotSerialize(value: boolean);
  37517. /** @hidden */
  37518. _isDisposed: boolean;
  37519. /**
  37520. * Gets a list of Animations associated with the node
  37521. */
  37522. animations: import("babylonjs/Animations/animation").Animation[];
  37523. protected _ranges: {
  37524. [name: string]: Nullable<AnimationRange>;
  37525. };
  37526. /**
  37527. * Callback raised when the node is ready to be used
  37528. */
  37529. onReady: Nullable<(node: Node) => void>;
  37530. private _isEnabled;
  37531. private _isParentEnabled;
  37532. private _isReady;
  37533. /** @hidden */
  37534. _currentRenderId: number;
  37535. private _parentUpdateId;
  37536. /** @hidden */
  37537. _childUpdateId: number;
  37538. /** @hidden */
  37539. _waitingParentId: Nullable<string>;
  37540. /** @hidden */
  37541. _scene: Scene;
  37542. /** @hidden */
  37543. _cache: any;
  37544. private _parentNode;
  37545. private _children;
  37546. /** @hidden */
  37547. _worldMatrix: Matrix;
  37548. /** @hidden */
  37549. _worldMatrixDeterminant: number;
  37550. /** @hidden */
  37551. _worldMatrixDeterminantIsDirty: boolean;
  37552. /** @hidden */
  37553. private _sceneRootNodesIndex;
  37554. /**
  37555. * Gets a boolean indicating if the node has been disposed
  37556. * @returns true if the node was disposed
  37557. */
  37558. isDisposed(): boolean;
  37559. /**
  37560. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37561. * @see https://doc.babylonjs.com/how_to/parenting
  37562. */
  37563. set parent(parent: Nullable<Node>);
  37564. get parent(): Nullable<Node>;
  37565. /** @hidden */
  37566. _addToSceneRootNodes(): void;
  37567. /** @hidden */
  37568. _removeFromSceneRootNodes(): void;
  37569. private _animationPropertiesOverride;
  37570. /**
  37571. * Gets or sets the animation properties override
  37572. */
  37573. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37574. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37575. /**
  37576. * Gets a string identifying the name of the class
  37577. * @returns "Node" string
  37578. */
  37579. getClassName(): string;
  37580. /** @hidden */
  37581. readonly _isNode: boolean;
  37582. /**
  37583. * An event triggered when the mesh is disposed
  37584. */
  37585. onDisposeObservable: Observable<Node>;
  37586. private _onDisposeObserver;
  37587. /**
  37588. * Sets a callback that will be raised when the node will be disposed
  37589. */
  37590. set onDispose(callback: () => void);
  37591. /**
  37592. * Creates a new Node
  37593. * @param name the name and id to be given to this node
  37594. * @param scene the scene this node will be added to
  37595. */
  37596. constructor(name: string, scene?: Nullable<Scene>);
  37597. /**
  37598. * Gets the scene of the node
  37599. * @returns a scene
  37600. */
  37601. getScene(): Scene;
  37602. /**
  37603. * Gets the engine of the node
  37604. * @returns a Engine
  37605. */
  37606. getEngine(): Engine;
  37607. private _behaviors;
  37608. /**
  37609. * Attach a behavior to the node
  37610. * @see https://doc.babylonjs.com/features/behaviour
  37611. * @param behavior defines the behavior to attach
  37612. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37613. * @returns the current Node
  37614. */
  37615. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37616. /**
  37617. * Remove an attached behavior
  37618. * @see https://doc.babylonjs.com/features/behaviour
  37619. * @param behavior defines the behavior to attach
  37620. * @returns the current Node
  37621. */
  37622. removeBehavior(behavior: Behavior<Node>): Node;
  37623. /**
  37624. * Gets the list of attached behaviors
  37625. * @see https://doc.babylonjs.com/features/behaviour
  37626. */
  37627. get behaviors(): Behavior<Node>[];
  37628. /**
  37629. * Gets an attached behavior by name
  37630. * @param name defines the name of the behavior to look for
  37631. * @see https://doc.babylonjs.com/features/behaviour
  37632. * @returns null if behavior was not found else the requested behavior
  37633. */
  37634. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37635. /**
  37636. * Returns the latest update of the World matrix
  37637. * @returns a Matrix
  37638. */
  37639. getWorldMatrix(): Matrix;
  37640. /** @hidden */
  37641. _getWorldMatrixDeterminant(): number;
  37642. /**
  37643. * Returns directly the latest state of the mesh World matrix.
  37644. * A Matrix is returned.
  37645. */
  37646. get worldMatrixFromCache(): Matrix;
  37647. /** @hidden */
  37648. _initCache(): void;
  37649. /** @hidden */
  37650. updateCache(force?: boolean): void;
  37651. /** @hidden */
  37652. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37653. /** @hidden */
  37654. _updateCache(ignoreParentClass?: boolean): void;
  37655. /** @hidden */
  37656. _isSynchronized(): boolean;
  37657. /** @hidden */
  37658. _markSyncedWithParent(): void;
  37659. /** @hidden */
  37660. isSynchronizedWithParent(): boolean;
  37661. /** @hidden */
  37662. isSynchronized(): boolean;
  37663. /**
  37664. * Is this node ready to be used/rendered
  37665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37666. * @return true if the node is ready
  37667. */
  37668. isReady(completeCheck?: boolean): boolean;
  37669. /**
  37670. * Is this node enabled?
  37671. * 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
  37672. * @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
  37673. * @return whether this node (and its parent) is enabled
  37674. */
  37675. isEnabled(checkAncestors?: boolean): boolean;
  37676. /** @hidden */
  37677. protected _syncParentEnabledState(): void;
  37678. /**
  37679. * Set the enabled state of this node
  37680. * @param value defines the new enabled state
  37681. */
  37682. setEnabled(value: boolean): void;
  37683. /**
  37684. * Is this node a descendant of the given node?
  37685. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37686. * @param ancestor defines the parent node to inspect
  37687. * @returns a boolean indicating if this node is a descendant of the given node
  37688. */
  37689. isDescendantOf(ancestor: Node): boolean;
  37690. /** @hidden */
  37691. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37692. /**
  37693. * Will return all nodes that have this node as ascendant
  37694. * @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
  37695. * @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
  37696. * @return all children nodes of all types
  37697. */
  37698. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37699. /**
  37700. * Get all child-meshes of this node
  37701. * @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)
  37702. * @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
  37703. * @returns an array of AbstractMesh
  37704. */
  37705. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37706. /**
  37707. * Get all direct children of this node
  37708. * @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
  37709. * @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)
  37710. * @returns an array of Node
  37711. */
  37712. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37713. /** @hidden */
  37714. _setReady(state: boolean): void;
  37715. /**
  37716. * Get an animation by name
  37717. * @param name defines the name of the animation to look for
  37718. * @returns null if not found else the requested animation
  37719. */
  37720. getAnimationByName(name: string): Nullable<Animation>;
  37721. /**
  37722. * Creates an animation range for this node
  37723. * @param name defines the name of the range
  37724. * @param from defines the starting key
  37725. * @param to defines the end key
  37726. */
  37727. createAnimationRange(name: string, from: number, to: number): void;
  37728. /**
  37729. * Delete a specific animation range
  37730. * @param name defines the name of the range to delete
  37731. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37732. */
  37733. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37734. /**
  37735. * Get an animation range by name
  37736. * @param name defines the name of the animation range to look for
  37737. * @returns null if not found else the requested animation range
  37738. */
  37739. getAnimationRange(name: string): Nullable<AnimationRange>;
  37740. /**
  37741. * Gets the list of all animation ranges defined on this node
  37742. * @returns an array
  37743. */
  37744. getAnimationRanges(): Nullable<AnimationRange>[];
  37745. /**
  37746. * Will start the animation sequence
  37747. * @param name defines the range frames for animation sequence
  37748. * @param loop defines if the animation should loop (false by default)
  37749. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37750. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37751. * @returns the object created for this animation. If range does not exist, it will return null
  37752. */
  37753. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37754. /**
  37755. * Serialize animation ranges into a JSON compatible object
  37756. * @returns serialization object
  37757. */
  37758. serializeAnimationRanges(): any;
  37759. /**
  37760. * Computes the world matrix of the node
  37761. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37762. * @returns the world matrix
  37763. */
  37764. computeWorldMatrix(force?: boolean): Matrix;
  37765. /**
  37766. * Releases resources associated with this node.
  37767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37769. */
  37770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37771. /**
  37772. * Parse animation range data from a serialization object and store them into a given node
  37773. * @param node defines where to store the animation ranges
  37774. * @param parsedNode defines the serialization object to read data from
  37775. * @param scene defines the hosting scene
  37776. */
  37777. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37778. /**
  37779. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37780. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37781. * @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
  37782. * @returns the new bounding vectors
  37783. */
  37784. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37785. min: Vector3;
  37786. max: Vector3;
  37787. };
  37788. }
  37789. }
  37790. declare module "babylonjs/Animations/animation" {
  37791. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37792. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37793. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37794. import { Nullable } from "babylonjs/types";
  37795. import { Scene } from "babylonjs/scene";
  37796. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37797. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37798. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37799. import { Node } from "babylonjs/node";
  37800. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37801. import { Size } from "babylonjs/Maths/math.size";
  37802. import { Animatable } from "babylonjs/Animations/animatable";
  37803. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37804. /**
  37805. * @hidden
  37806. */
  37807. export class _IAnimationState {
  37808. key: number;
  37809. repeatCount: number;
  37810. workValue?: any;
  37811. loopMode?: number;
  37812. offsetValue?: any;
  37813. highLimitValue?: any;
  37814. }
  37815. /**
  37816. * Class used to store any kind of animation
  37817. */
  37818. export class Animation {
  37819. /**Name of the animation */
  37820. name: string;
  37821. /**Property to animate */
  37822. targetProperty: string;
  37823. /**The frames per second of the animation */
  37824. framePerSecond: number;
  37825. /**The data type of the animation */
  37826. dataType: number;
  37827. /**The loop mode of the animation */
  37828. loopMode?: number | undefined;
  37829. /**Specifies if blending should be enabled */
  37830. enableBlending?: boolean | undefined;
  37831. /**
  37832. * Use matrix interpolation instead of using direct key value when animating matrices
  37833. */
  37834. static AllowMatricesInterpolation: boolean;
  37835. /**
  37836. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37837. */
  37838. static AllowMatrixDecomposeForInterpolation: boolean;
  37839. /** Define the Url to load snippets */
  37840. static SnippetUrl: string;
  37841. /** Snippet ID if the animation was created from the snippet server */
  37842. snippetId: string;
  37843. /**
  37844. * Stores the key frames of the animation
  37845. */
  37846. private _keys;
  37847. /**
  37848. * Stores the easing function of the animation
  37849. */
  37850. private _easingFunction;
  37851. /**
  37852. * @hidden Internal use only
  37853. */
  37854. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37855. /**
  37856. * The set of event that will be linked to this animation
  37857. */
  37858. private _events;
  37859. /**
  37860. * Stores an array of target property paths
  37861. */
  37862. targetPropertyPath: string[];
  37863. /**
  37864. * Stores the blending speed of the animation
  37865. */
  37866. blendingSpeed: number;
  37867. /**
  37868. * Stores the animation ranges for the animation
  37869. */
  37870. private _ranges;
  37871. /**
  37872. * @hidden Internal use
  37873. */
  37874. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37875. /**
  37876. * Sets up an animation
  37877. * @param property The property to animate
  37878. * @param animationType The animation type to apply
  37879. * @param framePerSecond The frames per second of the animation
  37880. * @param easingFunction The easing function used in the animation
  37881. * @returns The created animation
  37882. */
  37883. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37884. /**
  37885. * Create and start an animation on a node
  37886. * @param name defines the name of the global animation that will be run on all nodes
  37887. * @param node defines the root node where the animation will take place
  37888. * @param targetProperty defines property to animate
  37889. * @param framePerSecond defines the number of frame per second yo use
  37890. * @param totalFrame defines the number of frames in total
  37891. * @param from defines the initial value
  37892. * @param to defines the final value
  37893. * @param loopMode defines which loop mode you want to use (off by default)
  37894. * @param easingFunction defines the easing function to use (linear by default)
  37895. * @param onAnimationEnd defines the callback to call when animation end
  37896. * @returns the animatable created for this animation
  37897. */
  37898. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37899. /**
  37900. * Create and start an animation on a node and its descendants
  37901. * @param name defines the name of the global animation that will be run on all nodes
  37902. * @param node defines the root node where the animation will take place
  37903. * @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
  37904. * @param targetProperty defines property to animate
  37905. * @param framePerSecond defines the number of frame per second to use
  37906. * @param totalFrame defines the number of frames in total
  37907. * @param from defines the initial value
  37908. * @param to defines the final value
  37909. * @param loopMode defines which loop mode you want to use (off by default)
  37910. * @param easingFunction defines the easing function to use (linear by default)
  37911. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37912. * @returns the list of animatables created for all nodes
  37913. * @example https://www.babylonjs-playground.com/#MH0VLI
  37914. */
  37915. 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[]>;
  37916. /**
  37917. * Creates a new animation, merges it with the existing animations and starts it
  37918. * @param name Name of the animation
  37919. * @param node Node which contains the scene that begins the animations
  37920. * @param targetProperty Specifies which property to animate
  37921. * @param framePerSecond The frames per second of the animation
  37922. * @param totalFrame The total number of frames
  37923. * @param from The frame at the beginning of the animation
  37924. * @param to The frame at the end of the animation
  37925. * @param loopMode Specifies the loop mode of the animation
  37926. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37927. * @param onAnimationEnd Callback to run once the animation is complete
  37928. * @returns Nullable animation
  37929. */
  37930. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37931. /**
  37932. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37933. * @param sourceAnimation defines the Animation containing keyframes to convert
  37934. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37935. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37936. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37937. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37938. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37939. */
  37940. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37941. /**
  37942. * Transition property of an host to the target Value
  37943. * @param property The property to transition
  37944. * @param targetValue The target Value of the property
  37945. * @param host The object where the property to animate belongs
  37946. * @param scene Scene used to run the animation
  37947. * @param frameRate Framerate (in frame/s) to use
  37948. * @param transition The transition type we want to use
  37949. * @param duration The duration of the animation, in milliseconds
  37950. * @param onAnimationEnd Callback trigger at the end of the animation
  37951. * @returns Nullable animation
  37952. */
  37953. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37954. /**
  37955. * Return the array of runtime animations currently using this animation
  37956. */
  37957. get runtimeAnimations(): RuntimeAnimation[];
  37958. /**
  37959. * Specifies if any of the runtime animations are currently running
  37960. */
  37961. get hasRunningRuntimeAnimations(): boolean;
  37962. /**
  37963. * Initializes the animation
  37964. * @param name Name of the animation
  37965. * @param targetProperty Property to animate
  37966. * @param framePerSecond The frames per second of the animation
  37967. * @param dataType The data type of the animation
  37968. * @param loopMode The loop mode of the animation
  37969. * @param enableBlending Specifies if blending should be enabled
  37970. */
  37971. constructor(
  37972. /**Name of the animation */
  37973. name: string,
  37974. /**Property to animate */
  37975. targetProperty: string,
  37976. /**The frames per second of the animation */
  37977. framePerSecond: number,
  37978. /**The data type of the animation */
  37979. dataType: number,
  37980. /**The loop mode of the animation */
  37981. loopMode?: number | undefined,
  37982. /**Specifies if blending should be enabled */
  37983. enableBlending?: boolean | undefined);
  37984. /**
  37985. * Converts the animation to a string
  37986. * @param fullDetails support for multiple levels of logging within scene loading
  37987. * @returns String form of the animation
  37988. */
  37989. toString(fullDetails?: boolean): string;
  37990. /**
  37991. * Add an event to this animation
  37992. * @param event Event to add
  37993. */
  37994. addEvent(event: AnimationEvent): void;
  37995. /**
  37996. * Remove all events found at the given frame
  37997. * @param frame The frame to remove events from
  37998. */
  37999. removeEvents(frame: number): void;
  38000. /**
  38001. * Retrieves all the events from the animation
  38002. * @returns Events from the animation
  38003. */
  38004. getEvents(): AnimationEvent[];
  38005. /**
  38006. * Creates an animation range
  38007. * @param name Name of the animation range
  38008. * @param from Starting frame of the animation range
  38009. * @param to Ending frame of the animation
  38010. */
  38011. createRange(name: string, from: number, to: number): void;
  38012. /**
  38013. * Deletes an animation range by name
  38014. * @param name Name of the animation range to delete
  38015. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38016. */
  38017. deleteRange(name: string, deleteFrames?: boolean): void;
  38018. /**
  38019. * Gets the animation range by name, or null if not defined
  38020. * @param name Name of the animation range
  38021. * @returns Nullable animation range
  38022. */
  38023. getRange(name: string): Nullable<AnimationRange>;
  38024. /**
  38025. * Gets the key frames from the animation
  38026. * @returns The key frames of the animation
  38027. */
  38028. getKeys(): Array<IAnimationKey>;
  38029. /**
  38030. * Gets the highest frame rate of the animation
  38031. * @returns Highest frame rate of the animation
  38032. */
  38033. getHighestFrame(): number;
  38034. /**
  38035. * Gets the easing function of the animation
  38036. * @returns Easing function of the animation
  38037. */
  38038. getEasingFunction(): IEasingFunction;
  38039. /**
  38040. * Sets the easing function of the animation
  38041. * @param easingFunction A custom mathematical formula for animation
  38042. */
  38043. setEasingFunction(easingFunction: EasingFunction): void;
  38044. /**
  38045. * Interpolates a scalar linearly
  38046. * @param startValue Start value of the animation curve
  38047. * @param endValue End value of the animation curve
  38048. * @param gradient Scalar amount to interpolate
  38049. * @returns Interpolated scalar value
  38050. */
  38051. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38052. /**
  38053. * Interpolates a scalar cubically
  38054. * @param startValue Start value of the animation curve
  38055. * @param outTangent End tangent of the animation
  38056. * @param endValue End value of the animation curve
  38057. * @param inTangent Start tangent of the animation curve
  38058. * @param gradient Scalar amount to interpolate
  38059. * @returns Interpolated scalar value
  38060. */
  38061. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38062. /**
  38063. * Interpolates a quaternion using a spherical linear interpolation
  38064. * @param startValue Start value of the animation curve
  38065. * @param endValue End value of the animation curve
  38066. * @param gradient Scalar amount to interpolate
  38067. * @returns Interpolated quaternion value
  38068. */
  38069. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38070. /**
  38071. * Interpolates a quaternion cubically
  38072. * @param startValue Start value of the animation curve
  38073. * @param outTangent End tangent of the animation curve
  38074. * @param endValue End value of the animation curve
  38075. * @param inTangent Start tangent of the animation curve
  38076. * @param gradient Scalar amount to interpolate
  38077. * @returns Interpolated quaternion value
  38078. */
  38079. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38080. /**
  38081. * Interpolates a Vector3 linearl
  38082. * @param startValue Start value of the animation curve
  38083. * @param endValue End value of the animation curve
  38084. * @param gradient Scalar amount to interpolate
  38085. * @returns Interpolated scalar value
  38086. */
  38087. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38088. /**
  38089. * Interpolates a Vector3 cubically
  38090. * @param startValue Start value of the animation curve
  38091. * @param outTangent End tangent of the animation
  38092. * @param endValue End value of the animation curve
  38093. * @param inTangent Start tangent of the animation curve
  38094. * @param gradient Scalar amount to interpolate
  38095. * @returns InterpolatedVector3 value
  38096. */
  38097. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38098. /**
  38099. * Interpolates a Vector2 linearly
  38100. * @param startValue Start value of the animation curve
  38101. * @param endValue End value of the animation curve
  38102. * @param gradient Scalar amount to interpolate
  38103. * @returns Interpolated Vector2 value
  38104. */
  38105. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38106. /**
  38107. * Interpolates a Vector2 cubically
  38108. * @param startValue Start value of the animation curve
  38109. * @param outTangent End tangent of the animation
  38110. * @param endValue End value of the animation curve
  38111. * @param inTangent Start tangent of the animation curve
  38112. * @param gradient Scalar amount to interpolate
  38113. * @returns Interpolated Vector2 value
  38114. */
  38115. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38116. /**
  38117. * Interpolates a size linearly
  38118. * @param startValue Start value of the animation curve
  38119. * @param endValue End value of the animation curve
  38120. * @param gradient Scalar amount to interpolate
  38121. * @returns Interpolated Size value
  38122. */
  38123. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38124. /**
  38125. * Interpolates a Color3 linearly
  38126. * @param startValue Start value of the animation curve
  38127. * @param endValue End value of the animation curve
  38128. * @param gradient Scalar amount to interpolate
  38129. * @returns Interpolated Color3 value
  38130. */
  38131. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38132. /**
  38133. * Interpolates a Color4 linearly
  38134. * @param startValue Start value of the animation curve
  38135. * @param endValue End value of the animation curve
  38136. * @param gradient Scalar amount to interpolate
  38137. * @returns Interpolated Color3 value
  38138. */
  38139. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38140. /**
  38141. * @hidden Internal use only
  38142. */
  38143. _getKeyValue(value: any): any;
  38144. /**
  38145. * @hidden Internal use only
  38146. */
  38147. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38148. /**
  38149. * Defines the function to use to interpolate matrices
  38150. * @param startValue defines the start matrix
  38151. * @param endValue defines the end matrix
  38152. * @param gradient defines the gradient between both matrices
  38153. * @param result defines an optional target matrix where to store the interpolation
  38154. * @returns the interpolated matrix
  38155. */
  38156. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38157. /**
  38158. * Makes a copy of the animation
  38159. * @returns Cloned animation
  38160. */
  38161. clone(): Animation;
  38162. /**
  38163. * Sets the key frames of the animation
  38164. * @param values The animation key frames to set
  38165. */
  38166. setKeys(values: Array<IAnimationKey>): void;
  38167. /**
  38168. * Serializes the animation to an object
  38169. * @returns Serialized object
  38170. */
  38171. serialize(): any;
  38172. /**
  38173. * Float animation type
  38174. */
  38175. static readonly ANIMATIONTYPE_FLOAT: number;
  38176. /**
  38177. * Vector3 animation type
  38178. */
  38179. static readonly ANIMATIONTYPE_VECTOR3: number;
  38180. /**
  38181. * Quaternion animation type
  38182. */
  38183. static readonly ANIMATIONTYPE_QUATERNION: number;
  38184. /**
  38185. * Matrix animation type
  38186. */
  38187. static readonly ANIMATIONTYPE_MATRIX: number;
  38188. /**
  38189. * Color3 animation type
  38190. */
  38191. static readonly ANIMATIONTYPE_COLOR3: number;
  38192. /**
  38193. * Color3 animation type
  38194. */
  38195. static readonly ANIMATIONTYPE_COLOR4: number;
  38196. /**
  38197. * Vector2 animation type
  38198. */
  38199. static readonly ANIMATIONTYPE_VECTOR2: number;
  38200. /**
  38201. * Size animation type
  38202. */
  38203. static readonly ANIMATIONTYPE_SIZE: number;
  38204. /**
  38205. * Relative Loop Mode
  38206. */
  38207. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38208. /**
  38209. * Cycle Loop Mode
  38210. */
  38211. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38212. /**
  38213. * Constant Loop Mode
  38214. */
  38215. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38216. /** @hidden */
  38217. static _UniversalLerp(left: any, right: any, amount: number): any;
  38218. /**
  38219. * Parses an animation object and creates an animation
  38220. * @param parsedAnimation Parsed animation object
  38221. * @returns Animation object
  38222. */
  38223. static Parse(parsedAnimation: any): Animation;
  38224. /**
  38225. * Appends the serialized animations from the source animations
  38226. * @param source Source containing the animations
  38227. * @param destination Target to store the animations
  38228. */
  38229. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38230. /**
  38231. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38232. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38233. * @param url defines the url to load from
  38234. * @returns a promise that will resolve to the new animation or an array of animations
  38235. */
  38236. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38237. /**
  38238. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38239. * @param snippetId defines the snippet to load
  38240. * @returns a promise that will resolve to the new animation or a new array of animations
  38241. */
  38242. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38243. }
  38244. }
  38245. declare module "babylonjs/Animations/animatable.interface" {
  38246. import { Nullable } from "babylonjs/types";
  38247. import { Animation } from "babylonjs/Animations/animation";
  38248. /**
  38249. * Interface containing an array of animations
  38250. */
  38251. export interface IAnimatable {
  38252. /**
  38253. * Array of animations
  38254. */
  38255. animations: Nullable<Array<Animation>>;
  38256. }
  38257. }
  38258. declare module "babylonjs/Misc/decorators" {
  38259. import { Nullable } from "babylonjs/types";
  38260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38261. import { Scene } from "babylonjs/scene";
  38262. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38263. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38264. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38266. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38267. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38268. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38269. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38270. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38271. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38272. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38273. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38274. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38275. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38276. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38277. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38278. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38279. /**
  38280. * Decorator used to define property that can be serialized as reference to a camera
  38281. * @param sourceName defines the name of the property to decorate
  38282. */
  38283. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38284. /**
  38285. * Class used to help serialization objects
  38286. */
  38287. export class SerializationHelper {
  38288. /** @hidden */
  38289. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38290. /** @hidden */
  38291. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38292. /** @hidden */
  38293. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38294. /** @hidden */
  38295. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38296. /**
  38297. * Appends the serialized animations from the source animations
  38298. * @param source Source containing the animations
  38299. * @param destination Target to store the animations
  38300. */
  38301. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38302. /**
  38303. * Static function used to serialized a specific entity
  38304. * @param entity defines the entity to serialize
  38305. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38306. * @returns a JSON compatible object representing the serialization of the entity
  38307. */
  38308. static Serialize<T>(entity: T, serializationObject?: any): any;
  38309. /**
  38310. * Creates a new entity from a serialization data object
  38311. * @param creationFunction defines a function used to instanciated the new entity
  38312. * @param source defines the source serialization data
  38313. * @param scene defines the hosting scene
  38314. * @param rootUrl defines the root url for resources
  38315. * @returns a new entity
  38316. */
  38317. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38318. /**
  38319. * Clones an object
  38320. * @param creationFunction defines the function used to instanciate the new object
  38321. * @param source defines the source object
  38322. * @returns the cloned object
  38323. */
  38324. static Clone<T>(creationFunction: () => T, source: T): T;
  38325. /**
  38326. * Instanciates a new object based on a source one (some data will be shared between both object)
  38327. * @param creationFunction defines the function used to instanciate the new object
  38328. * @param source defines the source object
  38329. * @returns the new object
  38330. */
  38331. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38332. }
  38333. }
  38334. declare module "babylonjs/Materials/Textures/baseTexture" {
  38335. import { Observable } from "babylonjs/Misc/observable";
  38336. import { Nullable } from "babylonjs/types";
  38337. import { Scene } from "babylonjs/scene";
  38338. import { Matrix } from "babylonjs/Maths/math.vector";
  38339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38341. import { ISize } from "babylonjs/Maths/math.size";
  38342. import "babylonjs/Misc/fileTools";
  38343. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38344. /**
  38345. * Base class of all the textures in babylon.
  38346. * It groups all the common properties the materials, post process, lights... might need
  38347. * in order to make a correct use of the texture.
  38348. */
  38349. export class BaseTexture implements IAnimatable {
  38350. /**
  38351. * Default anisotropic filtering level for the application.
  38352. * It is set to 4 as a good tradeoff between perf and quality.
  38353. */
  38354. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38355. /**
  38356. * Gets or sets the unique id of the texture
  38357. */
  38358. uniqueId: number;
  38359. /**
  38360. * Define the name of the texture.
  38361. */
  38362. name: string;
  38363. /**
  38364. * Gets or sets an object used to store user defined information.
  38365. */
  38366. metadata: any;
  38367. /**
  38368. * For internal use only. Please do not use.
  38369. */
  38370. reservedDataStore: any;
  38371. private _hasAlpha;
  38372. /**
  38373. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38374. */
  38375. set hasAlpha(value: boolean);
  38376. get hasAlpha(): boolean;
  38377. /**
  38378. * Defines if the alpha value should be determined via the rgb values.
  38379. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38380. */
  38381. getAlphaFromRGB: boolean;
  38382. /**
  38383. * Intensity or strength of the texture.
  38384. * It is commonly used by materials to fine tune the intensity of the texture
  38385. */
  38386. level: number;
  38387. /**
  38388. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38389. * This is part of the texture as textures usually maps to one uv set.
  38390. */
  38391. coordinatesIndex: number;
  38392. protected _coordinatesMode: number;
  38393. /**
  38394. * How a texture is mapped.
  38395. *
  38396. * | Value | Type | Description |
  38397. * | ----- | ----------------------------------- | ----------- |
  38398. * | 0 | EXPLICIT_MODE | |
  38399. * | 1 | SPHERICAL_MODE | |
  38400. * | 2 | PLANAR_MODE | |
  38401. * | 3 | CUBIC_MODE | |
  38402. * | 4 | PROJECTION_MODE | |
  38403. * | 5 | SKYBOX_MODE | |
  38404. * | 6 | INVCUBIC_MODE | |
  38405. * | 7 | EQUIRECTANGULAR_MODE | |
  38406. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38407. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38408. */
  38409. set coordinatesMode(value: number);
  38410. get coordinatesMode(): number;
  38411. private _wrapU;
  38412. /**
  38413. * | Value | Type | Description |
  38414. * | ----- | ------------------ | ----------- |
  38415. * | 0 | CLAMP_ADDRESSMODE | |
  38416. * | 1 | WRAP_ADDRESSMODE | |
  38417. * | 2 | MIRROR_ADDRESSMODE | |
  38418. */
  38419. get wrapU(): number;
  38420. set wrapU(value: number);
  38421. private _wrapV;
  38422. /**
  38423. * | Value | Type | Description |
  38424. * | ----- | ------------------ | ----------- |
  38425. * | 0 | CLAMP_ADDRESSMODE | |
  38426. * | 1 | WRAP_ADDRESSMODE | |
  38427. * | 2 | MIRROR_ADDRESSMODE | |
  38428. */
  38429. get wrapV(): number;
  38430. set wrapV(value: number);
  38431. /**
  38432. * | Value | Type | Description |
  38433. * | ----- | ------------------ | ----------- |
  38434. * | 0 | CLAMP_ADDRESSMODE | |
  38435. * | 1 | WRAP_ADDRESSMODE | |
  38436. * | 2 | MIRROR_ADDRESSMODE | |
  38437. */
  38438. wrapR: number;
  38439. /**
  38440. * With compliant hardware and browser (supporting anisotropic filtering)
  38441. * this defines the level of anisotropic filtering in the texture.
  38442. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38443. */
  38444. anisotropicFilteringLevel: number;
  38445. /**
  38446. * Define if the texture is a cube texture or if false a 2d texture.
  38447. */
  38448. get isCube(): boolean;
  38449. set isCube(value: boolean);
  38450. /**
  38451. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38452. */
  38453. get is3D(): boolean;
  38454. set is3D(value: boolean);
  38455. /**
  38456. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38457. */
  38458. get is2DArray(): boolean;
  38459. set is2DArray(value: boolean);
  38460. private _gammaSpace;
  38461. /**
  38462. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38463. * HDR texture are usually stored in linear space.
  38464. * This only impacts the PBR and Background materials
  38465. */
  38466. get gammaSpace(): boolean;
  38467. set gammaSpace(gamma: boolean);
  38468. /**
  38469. * Gets or sets whether or not the texture contains RGBD data.
  38470. */
  38471. get isRGBD(): boolean;
  38472. set isRGBD(value: boolean);
  38473. /**
  38474. * Is Z inverted in the texture (useful in a cube texture).
  38475. */
  38476. invertZ: boolean;
  38477. /**
  38478. * Are mip maps generated for this texture or not.
  38479. */
  38480. get noMipmap(): boolean;
  38481. /**
  38482. * @hidden
  38483. */
  38484. lodLevelInAlpha: boolean;
  38485. /**
  38486. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38487. */
  38488. get lodGenerationOffset(): number;
  38489. set lodGenerationOffset(value: number);
  38490. /**
  38491. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38492. */
  38493. get lodGenerationScale(): number;
  38494. set lodGenerationScale(value: number);
  38495. /**
  38496. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38497. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38498. * average roughness values.
  38499. */
  38500. get linearSpecularLOD(): boolean;
  38501. set linearSpecularLOD(value: boolean);
  38502. /**
  38503. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38504. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38505. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38506. */
  38507. get irradianceTexture(): Nullable<BaseTexture>;
  38508. set irradianceTexture(value: Nullable<BaseTexture>);
  38509. /**
  38510. * Define if the texture is a render target.
  38511. */
  38512. isRenderTarget: boolean;
  38513. /**
  38514. * Define the unique id of the texture in the scene.
  38515. */
  38516. get uid(): string;
  38517. /** @hidden */
  38518. _prefiltered: boolean;
  38519. /**
  38520. * Return a string representation of the texture.
  38521. * @returns the texture as a string
  38522. */
  38523. toString(): string;
  38524. /**
  38525. * Get the class name of the texture.
  38526. * @returns "BaseTexture"
  38527. */
  38528. getClassName(): string;
  38529. /**
  38530. * Define the list of animation attached to the texture.
  38531. */
  38532. animations: import("babylonjs/Animations/animation").Animation[];
  38533. /**
  38534. * An event triggered when the texture is disposed.
  38535. */
  38536. onDisposeObservable: Observable<BaseTexture>;
  38537. private _onDisposeObserver;
  38538. /**
  38539. * Callback triggered when the texture has been disposed.
  38540. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38541. */
  38542. set onDispose(callback: () => void);
  38543. /**
  38544. * Define the current state of the loading sequence when in delayed load mode.
  38545. */
  38546. delayLoadState: number;
  38547. protected _scene: Nullable<Scene>;
  38548. protected _engine: Nullable<ThinEngine>;
  38549. /** @hidden */
  38550. _texture: Nullable<InternalTexture>;
  38551. private _uid;
  38552. /**
  38553. * Define if the texture is preventinga material to render or not.
  38554. * If not and the texture is not ready, the engine will use a default black texture instead.
  38555. */
  38556. get isBlocking(): boolean;
  38557. /**
  38558. * Instantiates a new BaseTexture.
  38559. * Base class of all the textures in babylon.
  38560. * It groups all the common properties the materials, post process, lights... might need
  38561. * in order to make a correct use of the texture.
  38562. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38563. */
  38564. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38565. /**
  38566. * Get the scene the texture belongs to.
  38567. * @returns the scene or null if undefined
  38568. */
  38569. getScene(): Nullable<Scene>;
  38570. /** @hidden */
  38571. protected _getEngine(): Nullable<ThinEngine>;
  38572. /**
  38573. * Get the texture transform matrix used to offset tile the texture for istance.
  38574. * @returns the transformation matrix
  38575. */
  38576. getTextureMatrix(): Matrix;
  38577. /**
  38578. * Get the texture reflection matrix used to rotate/transform the reflection.
  38579. * @returns the reflection matrix
  38580. */
  38581. getReflectionTextureMatrix(): Matrix;
  38582. /**
  38583. * Get the underlying lower level texture from Babylon.
  38584. * @returns the insternal texture
  38585. */
  38586. getInternalTexture(): Nullable<InternalTexture>;
  38587. /**
  38588. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38589. * @returns true if ready or not blocking
  38590. */
  38591. isReadyOrNotBlocking(): boolean;
  38592. /**
  38593. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38594. * @returns true if fully ready
  38595. */
  38596. isReady(): boolean;
  38597. private _cachedSize;
  38598. /**
  38599. * Get the size of the texture.
  38600. * @returns the texture size.
  38601. */
  38602. getSize(): ISize;
  38603. /**
  38604. * Get the base size of the texture.
  38605. * It can be different from the size if the texture has been resized for POT for instance
  38606. * @returns the base size
  38607. */
  38608. getBaseSize(): ISize;
  38609. /**
  38610. * Update the sampling mode of the texture.
  38611. * Default is Trilinear mode.
  38612. *
  38613. * | Value | Type | Description |
  38614. * | ----- | ------------------ | ----------- |
  38615. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38616. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38617. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38618. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38619. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38620. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38621. * | 7 | NEAREST_LINEAR | |
  38622. * | 8 | NEAREST_NEAREST | |
  38623. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38624. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38625. * | 11 | LINEAR_LINEAR | |
  38626. * | 12 | LINEAR_NEAREST | |
  38627. *
  38628. * > _mag_: magnification filter (close to the viewer)
  38629. * > _min_: minification filter (far from the viewer)
  38630. * > _mip_: filter used between mip map levels
  38631. *@param samplingMode Define the new sampling mode of the texture
  38632. */
  38633. updateSamplingMode(samplingMode: number): void;
  38634. /**
  38635. * Scales the texture if is `canRescale()`
  38636. * @param ratio the resize factor we want to use to rescale
  38637. */
  38638. scale(ratio: number): void;
  38639. /**
  38640. * Get if the texture can rescale.
  38641. */
  38642. get canRescale(): boolean;
  38643. /** @hidden */
  38644. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38645. /** @hidden */
  38646. _rebuild(): void;
  38647. /**
  38648. * Triggers the load sequence in delayed load mode.
  38649. */
  38650. delayLoad(): void;
  38651. /**
  38652. * Clones the texture.
  38653. * @returns the cloned texture
  38654. */
  38655. clone(): Nullable<BaseTexture>;
  38656. /**
  38657. * Get the texture underlying type (INT, FLOAT...)
  38658. */
  38659. get textureType(): number;
  38660. /**
  38661. * Get the texture underlying format (RGB, RGBA...)
  38662. */
  38663. get textureFormat(): number;
  38664. /**
  38665. * Indicates that textures need to be re-calculated for all materials
  38666. */
  38667. protected _markAllSubMeshesAsTexturesDirty(): void;
  38668. /**
  38669. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38670. * This will returns an RGBA array buffer containing either in values (0-255) or
  38671. * float values (0-1) depending of the underlying buffer type.
  38672. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38673. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38674. * @param buffer defines a user defined buffer to fill with data (can be null)
  38675. * @returns The Array buffer containing the pixels data.
  38676. */
  38677. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38678. /**
  38679. * Release and destroy the underlying lower level texture aka internalTexture.
  38680. */
  38681. releaseInternalTexture(): void;
  38682. /** @hidden */
  38683. get _lodTextureHigh(): Nullable<BaseTexture>;
  38684. /** @hidden */
  38685. get _lodTextureMid(): Nullable<BaseTexture>;
  38686. /** @hidden */
  38687. get _lodTextureLow(): Nullable<BaseTexture>;
  38688. /**
  38689. * Dispose the texture and release its associated resources.
  38690. */
  38691. dispose(): void;
  38692. /**
  38693. * Serialize the texture into a JSON representation that can be parsed later on.
  38694. * @returns the JSON representation of the texture
  38695. */
  38696. serialize(): any;
  38697. /**
  38698. * Helper function to be called back once a list of texture contains only ready textures.
  38699. * @param textures Define the list of textures to wait for
  38700. * @param callback Define the callback triggered once the entire list will be ready
  38701. */
  38702. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38703. private static _isScene;
  38704. }
  38705. }
  38706. declare module "babylonjs/Materials/effect" {
  38707. import { Observable } from "babylonjs/Misc/observable";
  38708. import { Nullable } from "babylonjs/types";
  38709. import { IDisposable } from "babylonjs/scene";
  38710. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38711. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38712. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38713. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38714. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38715. import { Engine } from "babylonjs/Engines/engine";
  38716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38718. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38719. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38720. /**
  38721. * Options to be used when creating an effect.
  38722. */
  38723. export interface IEffectCreationOptions {
  38724. /**
  38725. * Atrributes that will be used in the shader.
  38726. */
  38727. attributes: string[];
  38728. /**
  38729. * Uniform varible names that will be set in the shader.
  38730. */
  38731. uniformsNames: string[];
  38732. /**
  38733. * Uniform buffer variable names that will be set in the shader.
  38734. */
  38735. uniformBuffersNames: string[];
  38736. /**
  38737. * Sampler texture variable names that will be set in the shader.
  38738. */
  38739. samplers: string[];
  38740. /**
  38741. * Define statements that will be set in the shader.
  38742. */
  38743. defines: any;
  38744. /**
  38745. * Possible fallbacks for this effect to improve performance when needed.
  38746. */
  38747. fallbacks: Nullable<IEffectFallbacks>;
  38748. /**
  38749. * Callback that will be called when the shader is compiled.
  38750. */
  38751. onCompiled: Nullable<(effect: Effect) => void>;
  38752. /**
  38753. * Callback that will be called if an error occurs during shader compilation.
  38754. */
  38755. onError: Nullable<(effect: Effect, errors: string) => void>;
  38756. /**
  38757. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38758. */
  38759. indexParameters?: any;
  38760. /**
  38761. * Max number of lights that can be used in the shader.
  38762. */
  38763. maxSimultaneousLights?: number;
  38764. /**
  38765. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38766. */
  38767. transformFeedbackVaryings?: Nullable<string[]>;
  38768. /**
  38769. * 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
  38770. */
  38771. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38772. /**
  38773. * Is this effect rendering to several color attachments ?
  38774. */
  38775. multiTarget?: boolean;
  38776. }
  38777. /**
  38778. * Effect containing vertex and fragment shader that can be executed on an object.
  38779. */
  38780. export class Effect implements IDisposable {
  38781. /**
  38782. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38783. */
  38784. static ShadersRepository: string;
  38785. /**
  38786. * Enable logging of the shader code when a compilation error occurs
  38787. */
  38788. static LogShaderCodeOnCompilationError: boolean;
  38789. /**
  38790. * Name of the effect.
  38791. */
  38792. name: any;
  38793. /**
  38794. * String container all the define statements that should be set on the shader.
  38795. */
  38796. defines: string;
  38797. /**
  38798. * Callback that will be called when the shader is compiled.
  38799. */
  38800. onCompiled: Nullable<(effect: Effect) => void>;
  38801. /**
  38802. * Callback that will be called if an error occurs during shader compilation.
  38803. */
  38804. onError: Nullable<(effect: Effect, errors: string) => void>;
  38805. /**
  38806. * Callback that will be called when effect is bound.
  38807. */
  38808. onBind: Nullable<(effect: Effect) => void>;
  38809. /**
  38810. * Unique ID of the effect.
  38811. */
  38812. uniqueId: number;
  38813. /**
  38814. * Observable that will be called when the shader is compiled.
  38815. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38816. */
  38817. onCompileObservable: Observable<Effect>;
  38818. /**
  38819. * Observable that will be called if an error occurs during shader compilation.
  38820. */
  38821. onErrorObservable: Observable<Effect>;
  38822. /** @hidden */
  38823. _onBindObservable: Nullable<Observable<Effect>>;
  38824. /**
  38825. * @hidden
  38826. * Specifies if the effect was previously ready
  38827. */
  38828. _wasPreviouslyReady: boolean;
  38829. /**
  38830. * Observable that will be called when effect is bound.
  38831. */
  38832. get onBindObservable(): Observable<Effect>;
  38833. /** @hidden */
  38834. _bonesComputationForcedToCPU: boolean;
  38835. /** @hidden */
  38836. _multiTarget: boolean;
  38837. private static _uniqueIdSeed;
  38838. private _engine;
  38839. private _uniformBuffersNames;
  38840. private _uniformBuffersNamesList;
  38841. private _uniformsNames;
  38842. private _samplerList;
  38843. private _samplers;
  38844. private _isReady;
  38845. private _compilationError;
  38846. private _allFallbacksProcessed;
  38847. private _attributesNames;
  38848. private _attributes;
  38849. private _attributeLocationByName;
  38850. private _uniforms;
  38851. /**
  38852. * Key for the effect.
  38853. * @hidden
  38854. */
  38855. _key: string;
  38856. private _indexParameters;
  38857. private _fallbacks;
  38858. private _vertexSourceCode;
  38859. private _fragmentSourceCode;
  38860. private _vertexSourceCodeOverride;
  38861. private _fragmentSourceCodeOverride;
  38862. private _transformFeedbackVaryings;
  38863. /**
  38864. * Compiled shader to webGL program.
  38865. * @hidden
  38866. */
  38867. _pipelineContext: Nullable<IPipelineContext>;
  38868. private _valueCache;
  38869. private static _baseCache;
  38870. /**
  38871. * Instantiates an effect.
  38872. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38873. * @param baseName Name of the effect.
  38874. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38875. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38876. * @param samplers List of sampler variables that will be passed to the shader.
  38877. * @param engine Engine to be used to render the effect
  38878. * @param defines Define statements to be added to the shader.
  38879. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38880. * @param onCompiled Callback that will be called when the shader is compiled.
  38881. * @param onError Callback that will be called if an error occurs during shader compilation.
  38882. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38883. */
  38884. 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);
  38885. private _useFinalCode;
  38886. /**
  38887. * Unique key for this effect
  38888. */
  38889. get key(): string;
  38890. /**
  38891. * If the effect has been compiled and prepared.
  38892. * @returns if the effect is compiled and prepared.
  38893. */
  38894. isReady(): boolean;
  38895. private _isReadyInternal;
  38896. /**
  38897. * The engine the effect was initialized with.
  38898. * @returns the engine.
  38899. */
  38900. getEngine(): Engine;
  38901. /**
  38902. * The pipeline context for this effect
  38903. * @returns the associated pipeline context
  38904. */
  38905. getPipelineContext(): Nullable<IPipelineContext>;
  38906. /**
  38907. * The set of names of attribute variables for the shader.
  38908. * @returns An array of attribute names.
  38909. */
  38910. getAttributesNames(): string[];
  38911. /**
  38912. * Returns the attribute at the given index.
  38913. * @param index The index of the attribute.
  38914. * @returns The location of the attribute.
  38915. */
  38916. getAttributeLocation(index: number): number;
  38917. /**
  38918. * Returns the attribute based on the name of the variable.
  38919. * @param name of the attribute to look up.
  38920. * @returns the attribute location.
  38921. */
  38922. getAttributeLocationByName(name: string): number;
  38923. /**
  38924. * The number of attributes.
  38925. * @returns the numnber of attributes.
  38926. */
  38927. getAttributesCount(): number;
  38928. /**
  38929. * Gets the index of a uniform variable.
  38930. * @param uniformName of the uniform to look up.
  38931. * @returns the index.
  38932. */
  38933. getUniformIndex(uniformName: string): number;
  38934. /**
  38935. * Returns the attribute based on the name of the variable.
  38936. * @param uniformName of the uniform to look up.
  38937. * @returns the location of the uniform.
  38938. */
  38939. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38940. /**
  38941. * Returns an array of sampler variable names
  38942. * @returns The array of sampler variable names.
  38943. */
  38944. getSamplers(): string[];
  38945. /**
  38946. * Returns an array of uniform variable names
  38947. * @returns The array of uniform variable names.
  38948. */
  38949. getUniformNames(): string[];
  38950. /**
  38951. * Returns an array of uniform buffer variable names
  38952. * @returns The array of uniform buffer variable names.
  38953. */
  38954. getUniformBuffersNames(): string[];
  38955. /**
  38956. * Returns the index parameters used to create the effect
  38957. * @returns The index parameters object
  38958. */
  38959. getIndexParameters(): any;
  38960. /**
  38961. * The error from the last compilation.
  38962. * @returns the error string.
  38963. */
  38964. getCompilationError(): string;
  38965. /**
  38966. * Gets a boolean indicating that all fallbacks were used during compilation
  38967. * @returns true if all fallbacks were used
  38968. */
  38969. allFallbacksProcessed(): boolean;
  38970. /**
  38971. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38972. * @param func The callback to be used.
  38973. */
  38974. executeWhenCompiled(func: (effect: Effect) => void): void;
  38975. private _checkIsReady;
  38976. private _loadShader;
  38977. /**
  38978. * Gets the vertex shader source code of this effect
  38979. */
  38980. get vertexSourceCode(): string;
  38981. /**
  38982. * Gets the fragment shader source code of this effect
  38983. */
  38984. get fragmentSourceCode(): string;
  38985. /**
  38986. * Recompiles the webGL program
  38987. * @param vertexSourceCode The source code for the vertex shader.
  38988. * @param fragmentSourceCode The source code for the fragment shader.
  38989. * @param onCompiled Callback called when completed.
  38990. * @param onError Callback called on error.
  38991. * @hidden
  38992. */
  38993. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38994. /**
  38995. * Prepares the effect
  38996. * @hidden
  38997. */
  38998. _prepareEffect(): void;
  38999. private _getShaderCodeAndErrorLine;
  39000. private _processCompilationErrors;
  39001. /**
  39002. * Checks if the effect is supported. (Must be called after compilation)
  39003. */
  39004. get isSupported(): boolean;
  39005. /**
  39006. * Binds a texture to the engine to be used as output of the shader.
  39007. * @param channel Name of the output variable.
  39008. * @param texture Texture to bind.
  39009. * @hidden
  39010. */
  39011. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39012. /**
  39013. * Sets a texture on the engine to be used in the shader.
  39014. * @param channel Name of the sampler variable.
  39015. * @param texture Texture to set.
  39016. */
  39017. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39018. /**
  39019. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39020. * @param channel Name of the sampler variable.
  39021. * @param texture Texture to set.
  39022. */
  39023. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39024. /**
  39025. * Sets an array of textures on the engine to be used in the shader.
  39026. * @param channel Name of the variable.
  39027. * @param textures Textures to set.
  39028. */
  39029. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39030. /**
  39031. * 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)
  39032. * @param channel Name of the sampler variable.
  39033. * @param postProcess Post process to get the input texture from.
  39034. */
  39035. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39036. /**
  39037. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39038. * 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)
  39039. * @param channel Name of the sampler variable.
  39040. * @param postProcess Post process to get the output texture from.
  39041. */
  39042. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39043. /** @hidden */
  39044. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39045. /** @hidden */
  39046. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39047. /** @hidden */
  39048. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39049. /** @hidden */
  39050. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39051. /**
  39052. * Binds a buffer to a uniform.
  39053. * @param buffer Buffer to bind.
  39054. * @param name Name of the uniform variable to bind to.
  39055. */
  39056. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39057. /**
  39058. * Binds block to a uniform.
  39059. * @param blockName Name of the block to bind.
  39060. * @param index Index to bind.
  39061. */
  39062. bindUniformBlock(blockName: string, index: number): void;
  39063. /**
  39064. * Sets an interger value on a uniform variable.
  39065. * @param uniformName Name of the variable.
  39066. * @param value Value to be set.
  39067. * @returns this effect.
  39068. */
  39069. setInt(uniformName: string, value: number): Effect;
  39070. /**
  39071. * Sets an int array on a uniform variable.
  39072. * @param uniformName Name of the variable.
  39073. * @param array array to be set.
  39074. * @returns this effect.
  39075. */
  39076. setIntArray(uniformName: string, array: Int32Array): Effect;
  39077. /**
  39078. * 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)
  39079. * @param uniformName Name of the variable.
  39080. * @param array array to be set.
  39081. * @returns this effect.
  39082. */
  39083. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39084. /**
  39085. * 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)
  39086. * @param uniformName Name of the variable.
  39087. * @param array array to be set.
  39088. * @returns this effect.
  39089. */
  39090. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39091. /**
  39092. * 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)
  39093. * @param uniformName Name of the variable.
  39094. * @param array array to be set.
  39095. * @returns this effect.
  39096. */
  39097. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39098. /**
  39099. * Sets an float array on a uniform variable.
  39100. * @param uniformName Name of the variable.
  39101. * @param array array to be set.
  39102. * @returns this effect.
  39103. */
  39104. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39105. /**
  39106. * 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)
  39107. * @param uniformName Name of the variable.
  39108. * @param array array to be set.
  39109. * @returns this effect.
  39110. */
  39111. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39112. /**
  39113. * 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)
  39114. * @param uniformName Name of the variable.
  39115. * @param array array to be set.
  39116. * @returns this effect.
  39117. */
  39118. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39119. /**
  39120. * 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)
  39121. * @param uniformName Name of the variable.
  39122. * @param array array to be set.
  39123. * @returns this effect.
  39124. */
  39125. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39126. /**
  39127. * Sets an array on a uniform variable.
  39128. * @param uniformName Name of the variable.
  39129. * @param array array to be set.
  39130. * @returns this effect.
  39131. */
  39132. setArray(uniformName: string, array: number[]): Effect;
  39133. /**
  39134. * 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)
  39135. * @param uniformName Name of the variable.
  39136. * @param array array to be set.
  39137. * @returns this effect.
  39138. */
  39139. setArray2(uniformName: string, array: number[]): Effect;
  39140. /**
  39141. * 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)
  39142. * @param uniformName Name of the variable.
  39143. * @param array array to be set.
  39144. * @returns this effect.
  39145. */
  39146. setArray3(uniformName: string, array: number[]): Effect;
  39147. /**
  39148. * 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)
  39149. * @param uniformName Name of the variable.
  39150. * @param array array to be set.
  39151. * @returns this effect.
  39152. */
  39153. setArray4(uniformName: string, array: number[]): Effect;
  39154. /**
  39155. * Sets matrices on a uniform variable.
  39156. * @param uniformName Name of the variable.
  39157. * @param matrices matrices to be set.
  39158. * @returns this effect.
  39159. */
  39160. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39161. /**
  39162. * Sets matrix on a uniform variable.
  39163. * @param uniformName Name of the variable.
  39164. * @param matrix matrix to be set.
  39165. * @returns this effect.
  39166. */
  39167. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39168. /**
  39169. * 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)
  39170. * @param uniformName Name of the variable.
  39171. * @param matrix matrix to be set.
  39172. * @returns this effect.
  39173. */
  39174. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39175. /**
  39176. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39177. * @param uniformName Name of the variable.
  39178. * @param matrix matrix to be set.
  39179. * @returns this effect.
  39180. */
  39181. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39182. /**
  39183. * Sets a float on a uniform variable.
  39184. * @param uniformName Name of the variable.
  39185. * @param value value to be set.
  39186. * @returns this effect.
  39187. */
  39188. setFloat(uniformName: string, value: number): Effect;
  39189. /**
  39190. * Sets a boolean on a uniform variable.
  39191. * @param uniformName Name of the variable.
  39192. * @param bool value to be set.
  39193. * @returns this effect.
  39194. */
  39195. setBool(uniformName: string, bool: boolean): Effect;
  39196. /**
  39197. * Sets a Vector2 on a uniform variable.
  39198. * @param uniformName Name of the variable.
  39199. * @param vector2 vector2 to be set.
  39200. * @returns this effect.
  39201. */
  39202. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39203. /**
  39204. * Sets a float2 on a uniform variable.
  39205. * @param uniformName Name of the variable.
  39206. * @param x First float in float2.
  39207. * @param y Second float in float2.
  39208. * @returns this effect.
  39209. */
  39210. setFloat2(uniformName: string, x: number, y: number): Effect;
  39211. /**
  39212. * Sets a Vector3 on a uniform variable.
  39213. * @param uniformName Name of the variable.
  39214. * @param vector3 Value to be set.
  39215. * @returns this effect.
  39216. */
  39217. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39218. /**
  39219. * Sets a float3 on a uniform variable.
  39220. * @param uniformName Name of the variable.
  39221. * @param x First float in float3.
  39222. * @param y Second float in float3.
  39223. * @param z Third float in float3.
  39224. * @returns this effect.
  39225. */
  39226. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39227. /**
  39228. * Sets a Vector4 on a uniform variable.
  39229. * @param uniformName Name of the variable.
  39230. * @param vector4 Value to be set.
  39231. * @returns this effect.
  39232. */
  39233. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39234. /**
  39235. * Sets a float4 on a uniform variable.
  39236. * @param uniformName Name of the variable.
  39237. * @param x First float in float4.
  39238. * @param y Second float in float4.
  39239. * @param z Third float in float4.
  39240. * @param w Fourth float in float4.
  39241. * @returns this effect.
  39242. */
  39243. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39244. /**
  39245. * Sets a Color3 on a uniform variable.
  39246. * @param uniformName Name of the variable.
  39247. * @param color3 Value to be set.
  39248. * @returns this effect.
  39249. */
  39250. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39251. /**
  39252. * Sets a Color4 on a uniform variable.
  39253. * @param uniformName Name of the variable.
  39254. * @param color3 Value to be set.
  39255. * @param alpha Alpha value to be set.
  39256. * @returns this effect.
  39257. */
  39258. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39259. /**
  39260. * Sets a Color4 on a uniform variable
  39261. * @param uniformName defines the name of the variable
  39262. * @param color4 defines the value to be set
  39263. * @returns this effect.
  39264. */
  39265. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39266. /** Release all associated resources */
  39267. dispose(): void;
  39268. /**
  39269. * This function will add a new shader to the shader store
  39270. * @param name the name of the shader
  39271. * @param pixelShader optional pixel shader content
  39272. * @param vertexShader optional vertex shader content
  39273. */
  39274. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39275. /**
  39276. * Store of each shader (The can be looked up using effect.key)
  39277. */
  39278. static ShadersStore: {
  39279. [key: string]: string;
  39280. };
  39281. /**
  39282. * Store of each included file for a shader (The can be looked up using effect.key)
  39283. */
  39284. static IncludesShadersStore: {
  39285. [key: string]: string;
  39286. };
  39287. /**
  39288. * Resets the cache of effects.
  39289. */
  39290. static ResetCache(): void;
  39291. }
  39292. }
  39293. declare module "babylonjs/Engines/engineCapabilities" {
  39294. /**
  39295. * Interface used to describe the capabilities of the engine relatively to the current browser
  39296. */
  39297. export interface EngineCapabilities {
  39298. /** Maximum textures units per fragment shader */
  39299. maxTexturesImageUnits: number;
  39300. /** Maximum texture units per vertex shader */
  39301. maxVertexTextureImageUnits: number;
  39302. /** Maximum textures units in the entire pipeline */
  39303. maxCombinedTexturesImageUnits: number;
  39304. /** Maximum texture size */
  39305. maxTextureSize: number;
  39306. /** Maximum texture samples */
  39307. maxSamples?: number;
  39308. /** Maximum cube texture size */
  39309. maxCubemapTextureSize: number;
  39310. /** Maximum render texture size */
  39311. maxRenderTextureSize: number;
  39312. /** Maximum number of vertex attributes */
  39313. maxVertexAttribs: number;
  39314. /** Maximum number of varyings */
  39315. maxVaryingVectors: number;
  39316. /** Maximum number of uniforms per vertex shader */
  39317. maxVertexUniformVectors: number;
  39318. /** Maximum number of uniforms per fragment shader */
  39319. maxFragmentUniformVectors: number;
  39320. /** Defines if standard derivates (dx/dy) are supported */
  39321. standardDerivatives: boolean;
  39322. /** Defines if s3tc texture compression is supported */
  39323. s3tc?: WEBGL_compressed_texture_s3tc;
  39324. /** Defines if pvrtc texture compression is supported */
  39325. pvrtc: any;
  39326. /** Defines if etc1 texture compression is supported */
  39327. etc1: any;
  39328. /** Defines if etc2 texture compression is supported */
  39329. etc2: any;
  39330. /** Defines if astc texture compression is supported */
  39331. astc: any;
  39332. /** Defines if bptc texture compression is supported */
  39333. bptc: any;
  39334. /** Defines if float textures are supported */
  39335. textureFloat: boolean;
  39336. /** Defines if vertex array objects are supported */
  39337. vertexArrayObject: boolean;
  39338. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39339. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39340. /** Gets the maximum level of anisotropy supported */
  39341. maxAnisotropy: number;
  39342. /** Defines if instancing is supported */
  39343. instancedArrays: boolean;
  39344. /** Defines if 32 bits indices are supported */
  39345. uintIndices: boolean;
  39346. /** Defines if high precision shaders are supported */
  39347. highPrecisionShaderSupported: boolean;
  39348. /** Defines if depth reading in the fragment shader is supported */
  39349. fragmentDepthSupported: boolean;
  39350. /** Defines if float texture linear filtering is supported*/
  39351. textureFloatLinearFiltering: boolean;
  39352. /** Defines if rendering to float textures is supported */
  39353. textureFloatRender: boolean;
  39354. /** Defines if half float textures are supported*/
  39355. textureHalfFloat: boolean;
  39356. /** Defines if half float texture linear filtering is supported*/
  39357. textureHalfFloatLinearFiltering: boolean;
  39358. /** Defines if rendering to half float textures is supported */
  39359. textureHalfFloatRender: boolean;
  39360. /** Defines if textureLOD shader command is supported */
  39361. textureLOD: boolean;
  39362. /** Defines if draw buffers extension is supported */
  39363. drawBuffersExtension: boolean;
  39364. /** Defines if depth textures are supported */
  39365. depthTextureExtension: boolean;
  39366. /** Defines if float color buffer are supported */
  39367. colorBufferFloat: boolean;
  39368. /** Gets disjoint timer query extension (null if not supported) */
  39369. timerQuery?: EXT_disjoint_timer_query;
  39370. /** Defines if timestamp can be used with timer query */
  39371. canUseTimestampForTimerQuery: boolean;
  39372. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39373. multiview?: any;
  39374. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39375. oculusMultiview?: any;
  39376. /** Function used to let the system compiles shaders in background */
  39377. parallelShaderCompile?: {
  39378. COMPLETION_STATUS_KHR: number;
  39379. };
  39380. /** Max number of texture samples for MSAA */
  39381. maxMSAASamples: number;
  39382. /** Defines if the blend min max extension is supported */
  39383. blendMinMax: boolean;
  39384. }
  39385. }
  39386. declare module "babylonjs/States/depthCullingState" {
  39387. import { Nullable } from "babylonjs/types";
  39388. /**
  39389. * @hidden
  39390. **/
  39391. export class DepthCullingState {
  39392. private _isDepthTestDirty;
  39393. private _isDepthMaskDirty;
  39394. private _isDepthFuncDirty;
  39395. private _isCullFaceDirty;
  39396. private _isCullDirty;
  39397. private _isZOffsetDirty;
  39398. private _isFrontFaceDirty;
  39399. private _depthTest;
  39400. private _depthMask;
  39401. private _depthFunc;
  39402. private _cull;
  39403. private _cullFace;
  39404. private _zOffset;
  39405. private _frontFace;
  39406. /**
  39407. * Initializes the state.
  39408. */
  39409. constructor();
  39410. get isDirty(): boolean;
  39411. get zOffset(): number;
  39412. set zOffset(value: number);
  39413. get cullFace(): Nullable<number>;
  39414. set cullFace(value: Nullable<number>);
  39415. get cull(): Nullable<boolean>;
  39416. set cull(value: Nullable<boolean>);
  39417. get depthFunc(): Nullable<number>;
  39418. set depthFunc(value: Nullable<number>);
  39419. get depthMask(): boolean;
  39420. set depthMask(value: boolean);
  39421. get depthTest(): boolean;
  39422. set depthTest(value: boolean);
  39423. get frontFace(): Nullable<number>;
  39424. set frontFace(value: Nullable<number>);
  39425. reset(): void;
  39426. apply(gl: WebGLRenderingContext): void;
  39427. }
  39428. }
  39429. declare module "babylonjs/States/stencilState" {
  39430. /**
  39431. * @hidden
  39432. **/
  39433. export class StencilState {
  39434. /** 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 */
  39435. static readonly ALWAYS: number;
  39436. /** Passed to stencilOperation to specify that stencil value must be kept */
  39437. static readonly KEEP: number;
  39438. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39439. static readonly REPLACE: number;
  39440. private _isStencilTestDirty;
  39441. private _isStencilMaskDirty;
  39442. private _isStencilFuncDirty;
  39443. private _isStencilOpDirty;
  39444. private _stencilTest;
  39445. private _stencilMask;
  39446. private _stencilFunc;
  39447. private _stencilFuncRef;
  39448. private _stencilFuncMask;
  39449. private _stencilOpStencilFail;
  39450. private _stencilOpDepthFail;
  39451. private _stencilOpStencilDepthPass;
  39452. get isDirty(): boolean;
  39453. get stencilFunc(): number;
  39454. set stencilFunc(value: number);
  39455. get stencilFuncRef(): number;
  39456. set stencilFuncRef(value: number);
  39457. get stencilFuncMask(): number;
  39458. set stencilFuncMask(value: number);
  39459. get stencilOpStencilFail(): number;
  39460. set stencilOpStencilFail(value: number);
  39461. get stencilOpDepthFail(): number;
  39462. set stencilOpDepthFail(value: number);
  39463. get stencilOpStencilDepthPass(): number;
  39464. set stencilOpStencilDepthPass(value: number);
  39465. get stencilMask(): number;
  39466. set stencilMask(value: number);
  39467. get stencilTest(): boolean;
  39468. set stencilTest(value: boolean);
  39469. constructor();
  39470. reset(): void;
  39471. apply(gl: WebGLRenderingContext): void;
  39472. }
  39473. }
  39474. declare module "babylonjs/States/alphaCullingState" {
  39475. /**
  39476. * @hidden
  39477. **/
  39478. export class AlphaState {
  39479. private _isAlphaBlendDirty;
  39480. private _isBlendFunctionParametersDirty;
  39481. private _isBlendEquationParametersDirty;
  39482. private _isBlendConstantsDirty;
  39483. private _alphaBlend;
  39484. private _blendFunctionParameters;
  39485. private _blendEquationParameters;
  39486. private _blendConstants;
  39487. /**
  39488. * Initializes the state.
  39489. */
  39490. constructor();
  39491. get isDirty(): boolean;
  39492. get alphaBlend(): boolean;
  39493. set alphaBlend(value: boolean);
  39494. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39495. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39496. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39497. reset(): void;
  39498. apply(gl: WebGLRenderingContext): void;
  39499. }
  39500. }
  39501. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39502. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39503. /** @hidden */
  39504. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39505. attributeProcessor(attribute: string): string;
  39506. varyingProcessor(varying: string, isFragment: boolean): string;
  39507. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39508. }
  39509. }
  39510. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39511. /**
  39512. * Interface for attribute information associated with buffer instanciation
  39513. */
  39514. export interface InstancingAttributeInfo {
  39515. /**
  39516. * Name of the GLSL attribute
  39517. * if attribute index is not specified, this is used to retrieve the index from the effect
  39518. */
  39519. attributeName: string;
  39520. /**
  39521. * Index/offset of the attribute in the vertex shader
  39522. * if not specified, this will be computes from the name.
  39523. */
  39524. index?: number;
  39525. /**
  39526. * size of the attribute, 1, 2, 3 or 4
  39527. */
  39528. attributeSize: number;
  39529. /**
  39530. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39531. */
  39532. offset: number;
  39533. /**
  39534. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39535. * default to 1
  39536. */
  39537. divisor?: number;
  39538. /**
  39539. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39540. * default is FLOAT
  39541. */
  39542. attributeType?: number;
  39543. /**
  39544. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39545. */
  39546. normalized?: boolean;
  39547. }
  39548. }
  39549. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39550. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39551. import { Nullable } from "babylonjs/types";
  39552. module "babylonjs/Engines/thinEngine" {
  39553. interface ThinEngine {
  39554. /**
  39555. * Update a video texture
  39556. * @param texture defines the texture to update
  39557. * @param video defines the video element to use
  39558. * @param invertY defines if data must be stored with Y axis inverted
  39559. */
  39560. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39561. }
  39562. }
  39563. }
  39564. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39566. import { Nullable } from "babylonjs/types";
  39567. module "babylonjs/Engines/thinEngine" {
  39568. interface ThinEngine {
  39569. /**
  39570. * Creates a dynamic texture
  39571. * @param width defines the width of the texture
  39572. * @param height defines the height of the texture
  39573. * @param generateMipMaps defines if the engine should generate the mip levels
  39574. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39575. * @returns the dynamic texture inside an InternalTexture
  39576. */
  39577. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39578. /**
  39579. * Update the content of a dynamic texture
  39580. * @param texture defines the texture to update
  39581. * @param canvas defines the canvas containing the source
  39582. * @param invertY defines if data must be stored with Y axis inverted
  39583. * @param premulAlpha defines if alpha is stored as premultiplied
  39584. * @param format defines the format of the data
  39585. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39586. */
  39587. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39588. }
  39589. }
  39590. }
  39591. declare module "babylonjs/Materials/Textures/videoTexture" {
  39592. import { Observable } from "babylonjs/Misc/observable";
  39593. import { Nullable } from "babylonjs/types";
  39594. import { Scene } from "babylonjs/scene";
  39595. import { Texture } from "babylonjs/Materials/Textures/texture";
  39596. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39597. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39598. /**
  39599. * Settings for finer control over video usage
  39600. */
  39601. export interface VideoTextureSettings {
  39602. /**
  39603. * Applies `autoplay` to video, if specified
  39604. */
  39605. autoPlay?: boolean;
  39606. /**
  39607. * Applies `muted` to video, if specified
  39608. */
  39609. muted?: boolean;
  39610. /**
  39611. * Applies `loop` to video, if specified
  39612. */
  39613. loop?: boolean;
  39614. /**
  39615. * Automatically updates internal texture from video at every frame in the render loop
  39616. */
  39617. autoUpdateTexture: boolean;
  39618. /**
  39619. * Image src displayed during the video loading or until the user interacts with the video.
  39620. */
  39621. poster?: string;
  39622. }
  39623. /**
  39624. * If you want to display a video in your scene, this is the special texture for that.
  39625. * This special texture works similar to other textures, with the exception of a few parameters.
  39626. * @see https://doc.babylonjs.com/how_to/video_texture
  39627. */
  39628. export class VideoTexture extends Texture {
  39629. /**
  39630. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39631. */
  39632. readonly autoUpdateTexture: boolean;
  39633. /**
  39634. * The video instance used by the texture internally
  39635. */
  39636. readonly video: HTMLVideoElement;
  39637. private _onUserActionRequestedObservable;
  39638. /**
  39639. * Event triggerd when a dom action is required by the user to play the video.
  39640. * This happens due to recent changes in browser policies preventing video to auto start.
  39641. */
  39642. get onUserActionRequestedObservable(): Observable<Texture>;
  39643. private _generateMipMaps;
  39644. private _stillImageCaptured;
  39645. private _displayingPosterTexture;
  39646. private _settings;
  39647. private _createInternalTextureOnEvent;
  39648. private _frameId;
  39649. private _currentSrc;
  39650. /**
  39651. * Creates a video texture.
  39652. * If you want to display a video in your scene, this is the special texture for that.
  39653. * This special texture works similar to other textures, with the exception of a few parameters.
  39654. * @see https://doc.babylonjs.com/how_to/video_texture
  39655. * @param name optional name, will detect from video source, if not defined
  39656. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39657. * @param scene is obviously the current scene.
  39658. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39659. * @param invertY is false by default but can be used to invert video on Y axis
  39660. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39661. * @param settings allows finer control over video usage
  39662. */
  39663. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39664. private _getName;
  39665. private _getVideo;
  39666. private _createInternalTexture;
  39667. private reset;
  39668. /**
  39669. * @hidden Internal method to initiate `update`.
  39670. */
  39671. _rebuild(): void;
  39672. /**
  39673. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39674. */
  39675. update(): void;
  39676. /**
  39677. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39678. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39679. */
  39680. updateTexture(isVisible: boolean): void;
  39681. protected _updateInternalTexture: () => void;
  39682. /**
  39683. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39684. * @param url New url.
  39685. */
  39686. updateURL(url: string): void;
  39687. /**
  39688. * Clones the texture.
  39689. * @returns the cloned texture
  39690. */
  39691. clone(): VideoTexture;
  39692. /**
  39693. * Dispose the texture and release its associated resources.
  39694. */
  39695. dispose(): void;
  39696. /**
  39697. * Creates a video texture straight from a stream.
  39698. * @param scene Define the scene the texture should be created in
  39699. * @param stream Define the stream the texture should be created from
  39700. * @returns The created video texture as a promise
  39701. */
  39702. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39703. /**
  39704. * Creates a video texture straight from your WebCam video feed.
  39705. * @param scene Define the scene the texture should be created in
  39706. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39707. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39708. * @returns The created video texture as a promise
  39709. */
  39710. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39711. minWidth: number;
  39712. maxWidth: number;
  39713. minHeight: number;
  39714. maxHeight: number;
  39715. deviceId: string;
  39716. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39717. /**
  39718. * Creates a video texture straight from your WebCam video feed.
  39719. * @param scene Define the scene the texture should be created in
  39720. * @param onReady Define a callback to triggered once the texture will be ready
  39721. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39722. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39723. */
  39724. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39725. minWidth: number;
  39726. maxWidth: number;
  39727. minHeight: number;
  39728. maxHeight: number;
  39729. deviceId: string;
  39730. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39731. }
  39732. }
  39733. declare module "babylonjs/Engines/thinEngine" {
  39734. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39735. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39736. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39737. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39738. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39739. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39740. import { Observable } from "babylonjs/Misc/observable";
  39741. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39742. import { StencilState } from "babylonjs/States/stencilState";
  39743. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39745. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39746. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39747. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39748. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39749. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39750. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39751. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39753. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39754. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39755. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39756. import { WebRequest } from "babylonjs/Misc/webRequest";
  39757. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39758. /**
  39759. * Defines the interface used by objects working like Scene
  39760. * @hidden
  39761. */
  39762. export interface ISceneLike {
  39763. _addPendingData(data: any): void;
  39764. _removePendingData(data: any): void;
  39765. offlineProvider: IOfflineProvider;
  39766. }
  39767. /**
  39768. * Information about the current host
  39769. */
  39770. export interface HostInformation {
  39771. /**
  39772. * Defines if the current host is a mobile
  39773. */
  39774. isMobile: boolean;
  39775. }
  39776. /** Interface defining initialization parameters for Engine class */
  39777. export interface EngineOptions extends WebGLContextAttributes {
  39778. /**
  39779. * Defines if the engine should no exceed a specified device ratio
  39780. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39781. */
  39782. limitDeviceRatio?: number;
  39783. /**
  39784. * Defines if webvr should be enabled automatically
  39785. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39786. */
  39787. autoEnableWebVR?: boolean;
  39788. /**
  39789. * Defines if webgl2 should be turned off even if supported
  39790. * @see https://doc.babylonjs.com/features/webgl2
  39791. */
  39792. disableWebGL2Support?: boolean;
  39793. /**
  39794. * Defines if webaudio should be initialized as well
  39795. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39796. */
  39797. audioEngine?: boolean;
  39798. /**
  39799. * Defines if animations should run using a deterministic lock step
  39800. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39801. */
  39802. deterministicLockstep?: boolean;
  39803. /** Defines the maximum steps to use with deterministic lock step mode */
  39804. lockstepMaxSteps?: number;
  39805. /** Defines the seconds between each deterministic lock step */
  39806. timeStep?: number;
  39807. /**
  39808. * Defines that engine should ignore context lost events
  39809. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39810. */
  39811. doNotHandleContextLost?: boolean;
  39812. /**
  39813. * Defines that engine should ignore modifying touch action attribute and style
  39814. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39815. */
  39816. doNotHandleTouchAction?: boolean;
  39817. /**
  39818. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39819. */
  39820. useHighPrecisionFloats?: boolean;
  39821. /**
  39822. * Make the canvas XR Compatible for XR sessions
  39823. */
  39824. xrCompatible?: boolean;
  39825. /**
  39826. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39827. */
  39828. useHighPrecisionMatrix?: boolean;
  39829. /**
  39830. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39831. */
  39832. failIfMajorPerformanceCaveat?: boolean;
  39833. }
  39834. /**
  39835. * The base engine class (root of all engines)
  39836. */
  39837. export class ThinEngine {
  39838. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39839. static ExceptionList: ({
  39840. key: string;
  39841. capture: string;
  39842. captureConstraint: number;
  39843. targets: string[];
  39844. } | {
  39845. key: string;
  39846. capture: null;
  39847. captureConstraint: null;
  39848. targets: string[];
  39849. })[];
  39850. /** @hidden */
  39851. static _TextureLoaders: IInternalTextureLoader[];
  39852. /**
  39853. * Returns the current npm package of the sdk
  39854. */
  39855. static get NpmPackage(): string;
  39856. /**
  39857. * Returns the current version of the framework
  39858. */
  39859. static get Version(): string;
  39860. /**
  39861. * Returns a string describing the current engine
  39862. */
  39863. get description(): string;
  39864. /**
  39865. * Gets or sets the epsilon value used by collision engine
  39866. */
  39867. static CollisionsEpsilon: number;
  39868. /**
  39869. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39870. */
  39871. static get ShadersRepository(): string;
  39872. static set ShadersRepository(value: string);
  39873. /** @hidden */
  39874. _shaderProcessor: IShaderProcessor;
  39875. /**
  39876. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39877. */
  39878. forcePOTTextures: boolean;
  39879. /**
  39880. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39881. */
  39882. isFullscreen: boolean;
  39883. /**
  39884. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39885. */
  39886. cullBackFaces: boolean;
  39887. /**
  39888. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39889. */
  39890. renderEvenInBackground: boolean;
  39891. /**
  39892. * Gets or sets a boolean indicating that cache can be kept between frames
  39893. */
  39894. preventCacheWipeBetweenFrames: boolean;
  39895. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39896. validateShaderPrograms: boolean;
  39897. /**
  39898. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39899. * This can provide greater z depth for distant objects.
  39900. */
  39901. useReverseDepthBuffer: boolean;
  39902. /**
  39903. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39904. */
  39905. disableUniformBuffers: boolean;
  39906. /** @hidden */
  39907. _uniformBuffers: UniformBuffer[];
  39908. /**
  39909. * Gets a boolean indicating that the engine supports uniform buffers
  39910. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39911. */
  39912. get supportsUniformBuffers(): boolean;
  39913. /** @hidden */
  39914. _gl: WebGLRenderingContext;
  39915. /** @hidden */
  39916. _webGLVersion: number;
  39917. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39918. protected _windowIsBackground: boolean;
  39919. protected _creationOptions: EngineOptions;
  39920. protected _highPrecisionShadersAllowed: boolean;
  39921. /** @hidden */
  39922. get _shouldUseHighPrecisionShader(): boolean;
  39923. /**
  39924. * Gets a boolean indicating that only power of 2 textures are supported
  39925. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39926. */
  39927. get needPOTTextures(): boolean;
  39928. /** @hidden */
  39929. _badOS: boolean;
  39930. /** @hidden */
  39931. _badDesktopOS: boolean;
  39932. private _hardwareScalingLevel;
  39933. /** @hidden */
  39934. _caps: EngineCapabilities;
  39935. private _isStencilEnable;
  39936. private _glVersion;
  39937. private _glRenderer;
  39938. private _glVendor;
  39939. /** @hidden */
  39940. _videoTextureSupported: boolean;
  39941. protected _renderingQueueLaunched: boolean;
  39942. protected _activeRenderLoops: (() => void)[];
  39943. /**
  39944. * Observable signaled when a context lost event is raised
  39945. */
  39946. onContextLostObservable: Observable<ThinEngine>;
  39947. /**
  39948. * Observable signaled when a context restored event is raised
  39949. */
  39950. onContextRestoredObservable: Observable<ThinEngine>;
  39951. private _onContextLost;
  39952. private _onContextRestored;
  39953. protected _contextWasLost: boolean;
  39954. /** @hidden */
  39955. _doNotHandleContextLost: boolean;
  39956. /**
  39957. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39958. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39959. */
  39960. get doNotHandleContextLost(): boolean;
  39961. set doNotHandleContextLost(value: boolean);
  39962. /**
  39963. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39964. */
  39965. disableVertexArrayObjects: boolean;
  39966. /** @hidden */
  39967. protected _colorWrite: boolean;
  39968. /** @hidden */
  39969. protected _colorWriteChanged: boolean;
  39970. /** @hidden */
  39971. protected _depthCullingState: DepthCullingState;
  39972. /** @hidden */
  39973. protected _stencilState: StencilState;
  39974. /** @hidden */
  39975. _alphaState: AlphaState;
  39976. /** @hidden */
  39977. _alphaMode: number;
  39978. /** @hidden */
  39979. _alphaEquation: number;
  39980. /** @hidden */
  39981. _internalTexturesCache: InternalTexture[];
  39982. /** @hidden */
  39983. protected _activeChannel: number;
  39984. private _currentTextureChannel;
  39985. /** @hidden */
  39986. protected _boundTexturesCache: {
  39987. [key: string]: Nullable<InternalTexture>;
  39988. };
  39989. /** @hidden */
  39990. protected _currentEffect: Nullable<Effect>;
  39991. /** @hidden */
  39992. protected _currentProgram: Nullable<WebGLProgram>;
  39993. private _compiledEffects;
  39994. private _vertexAttribArraysEnabled;
  39995. /** @hidden */
  39996. protected _cachedViewport: Nullable<IViewportLike>;
  39997. private _cachedVertexArrayObject;
  39998. /** @hidden */
  39999. protected _cachedVertexBuffers: any;
  40000. /** @hidden */
  40001. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40002. /** @hidden */
  40003. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40004. /** @hidden */
  40005. _currentRenderTarget: Nullable<InternalTexture>;
  40006. private _uintIndicesCurrentlySet;
  40007. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40008. /** @hidden */
  40009. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40010. /** @hidden */
  40011. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40012. private _currentBufferPointers;
  40013. private _currentInstanceLocations;
  40014. private _currentInstanceBuffers;
  40015. private _textureUnits;
  40016. /** @hidden */
  40017. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40018. /** @hidden */
  40019. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40020. /** @hidden */
  40021. _boundRenderFunction: any;
  40022. private _vaoRecordInProgress;
  40023. private _mustWipeVertexAttributes;
  40024. private _emptyTexture;
  40025. private _emptyCubeTexture;
  40026. private _emptyTexture3D;
  40027. private _emptyTexture2DArray;
  40028. /** @hidden */
  40029. _frameHandler: number;
  40030. private _nextFreeTextureSlots;
  40031. private _maxSimultaneousTextures;
  40032. private _activeRequests;
  40033. /** @hidden */
  40034. _transformTextureUrl: Nullable<(url: string) => string>;
  40035. /**
  40036. * Gets information about the current host
  40037. */
  40038. hostInformation: HostInformation;
  40039. protected get _supportsHardwareTextureRescaling(): boolean;
  40040. private _framebufferDimensionsObject;
  40041. /**
  40042. * sets the object from which width and height will be taken from when getting render width and height
  40043. * Will fallback to the gl object
  40044. * @param dimensions the framebuffer width and height that will be used.
  40045. */
  40046. set framebufferDimensionsObject(dimensions: Nullable<{
  40047. framebufferWidth: number;
  40048. framebufferHeight: number;
  40049. }>);
  40050. /**
  40051. * Gets the current viewport
  40052. */
  40053. get currentViewport(): Nullable<IViewportLike>;
  40054. /**
  40055. * Gets the default empty texture
  40056. */
  40057. get emptyTexture(): InternalTexture;
  40058. /**
  40059. * Gets the default empty 3D texture
  40060. */
  40061. get emptyTexture3D(): InternalTexture;
  40062. /**
  40063. * Gets the default empty 2D array texture
  40064. */
  40065. get emptyTexture2DArray(): InternalTexture;
  40066. /**
  40067. * Gets the default empty cube texture
  40068. */
  40069. get emptyCubeTexture(): InternalTexture;
  40070. /**
  40071. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40072. */
  40073. readonly premultipliedAlpha: boolean;
  40074. /**
  40075. * Observable event triggered before each texture is initialized
  40076. */
  40077. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40078. /**
  40079. * Creates a new engine
  40080. * @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
  40081. * @param antialias defines enable antialiasing (default: false)
  40082. * @param options defines further options to be sent to the getContext() function
  40083. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40084. */
  40085. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40086. private _rebuildInternalTextures;
  40087. private _rebuildEffects;
  40088. /**
  40089. * Gets a boolean indicating if all created effects are ready
  40090. * @returns true if all effects are ready
  40091. */
  40092. areAllEffectsReady(): boolean;
  40093. protected _rebuildBuffers(): void;
  40094. protected _initGLContext(): void;
  40095. /**
  40096. * Gets version of the current webGL context
  40097. */
  40098. get webGLVersion(): number;
  40099. /**
  40100. * Gets a string identifying the name of the class
  40101. * @returns "Engine" string
  40102. */
  40103. getClassName(): string;
  40104. /**
  40105. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40106. */
  40107. get isStencilEnable(): boolean;
  40108. /** @hidden */
  40109. _prepareWorkingCanvas(): void;
  40110. /**
  40111. * Reset the texture cache to empty state
  40112. */
  40113. resetTextureCache(): void;
  40114. /**
  40115. * Gets an object containing information about the current webGL context
  40116. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40117. */
  40118. getGlInfo(): {
  40119. vendor: string;
  40120. renderer: string;
  40121. version: string;
  40122. };
  40123. /**
  40124. * Defines the hardware scaling level.
  40125. * By default the hardware scaling level is computed from the window device ratio.
  40126. * 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.
  40127. * @param level defines the level to use
  40128. */
  40129. setHardwareScalingLevel(level: number): void;
  40130. /**
  40131. * Gets the current hardware scaling level.
  40132. * By default the hardware scaling level is computed from the window device ratio.
  40133. * 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.
  40134. * @returns a number indicating the current hardware scaling level
  40135. */
  40136. getHardwareScalingLevel(): number;
  40137. /**
  40138. * Gets the list of loaded textures
  40139. * @returns an array containing all loaded textures
  40140. */
  40141. getLoadedTexturesCache(): InternalTexture[];
  40142. /**
  40143. * Gets the object containing all engine capabilities
  40144. * @returns the EngineCapabilities object
  40145. */
  40146. getCaps(): EngineCapabilities;
  40147. /**
  40148. * stop executing a render loop function and remove it from the execution array
  40149. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40150. */
  40151. stopRenderLoop(renderFunction?: () => void): void;
  40152. /** @hidden */
  40153. _renderLoop(): void;
  40154. /**
  40155. * Gets the HTML canvas attached with the current webGL context
  40156. * @returns a HTML canvas
  40157. */
  40158. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40159. /**
  40160. * Gets host window
  40161. * @returns the host window object
  40162. */
  40163. getHostWindow(): Nullable<Window>;
  40164. /**
  40165. * Gets the current render width
  40166. * @param useScreen defines if screen size must be used (or the current render target if any)
  40167. * @returns a number defining the current render width
  40168. */
  40169. getRenderWidth(useScreen?: boolean): number;
  40170. /**
  40171. * Gets the current render height
  40172. * @param useScreen defines if screen size must be used (or the current render target if any)
  40173. * @returns a number defining the current render height
  40174. */
  40175. getRenderHeight(useScreen?: boolean): number;
  40176. /**
  40177. * Can be used to override the current requestAnimationFrame requester.
  40178. * @hidden
  40179. */
  40180. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40181. /**
  40182. * Register and execute a render loop. The engine can have more than one render function
  40183. * @param renderFunction defines the function to continuously execute
  40184. */
  40185. runRenderLoop(renderFunction: () => void): void;
  40186. /**
  40187. * Clear the current render buffer or the current render target (if any is set up)
  40188. * @param color defines the color to use
  40189. * @param backBuffer defines if the back buffer must be cleared
  40190. * @param depth defines if the depth buffer must be cleared
  40191. * @param stencil defines if the stencil buffer must be cleared
  40192. */
  40193. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40194. private _viewportCached;
  40195. /** @hidden */
  40196. _viewport(x: number, y: number, width: number, height: number): void;
  40197. /**
  40198. * Set the WebGL's viewport
  40199. * @param viewport defines the viewport element to be used
  40200. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40201. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40202. */
  40203. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40204. /**
  40205. * Begin a new frame
  40206. */
  40207. beginFrame(): void;
  40208. /**
  40209. * Enf the current frame
  40210. */
  40211. endFrame(): void;
  40212. /**
  40213. * Resize the view according to the canvas' size
  40214. */
  40215. resize(): void;
  40216. /**
  40217. * Force a specific size of the canvas
  40218. * @param width defines the new canvas' width
  40219. * @param height defines the new canvas' height
  40220. * @returns true if the size was changed
  40221. */
  40222. setSize(width: number, height: number): boolean;
  40223. /**
  40224. * Binds the frame buffer to the specified texture.
  40225. * @param texture The texture to render to or null for the default canvas
  40226. * @param faceIndex The face of the texture to render to in case of cube texture
  40227. * @param requiredWidth The width of the target to render to
  40228. * @param requiredHeight The height of the target to render to
  40229. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40230. * @param lodLevel defines the lod level to bind to the frame buffer
  40231. * @param layer defines the 2d array index to bind to frame buffer to
  40232. */
  40233. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40234. /** @hidden */
  40235. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40236. /**
  40237. * Unbind the current render target texture from the webGL context
  40238. * @param texture defines the render target texture to unbind
  40239. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40240. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40241. */
  40242. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40243. /**
  40244. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40245. */
  40246. flushFramebuffer(): void;
  40247. /**
  40248. * Unbind the current render target and bind the default framebuffer
  40249. */
  40250. restoreDefaultFramebuffer(): void;
  40251. /** @hidden */
  40252. protected _resetVertexBufferBinding(): void;
  40253. /**
  40254. * Creates a vertex buffer
  40255. * @param data the data for the vertex buffer
  40256. * @returns the new WebGL static buffer
  40257. */
  40258. createVertexBuffer(data: DataArray): DataBuffer;
  40259. private _createVertexBuffer;
  40260. /**
  40261. * Creates a dynamic vertex buffer
  40262. * @param data the data for the dynamic vertex buffer
  40263. * @returns the new WebGL dynamic buffer
  40264. */
  40265. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40266. protected _resetIndexBufferBinding(): void;
  40267. /**
  40268. * Creates a new index buffer
  40269. * @param indices defines the content of the index buffer
  40270. * @param updatable defines if the index buffer must be updatable
  40271. * @returns a new webGL buffer
  40272. */
  40273. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40274. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40275. /**
  40276. * Bind a webGL buffer to the webGL context
  40277. * @param buffer defines the buffer to bind
  40278. */
  40279. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40280. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40281. private bindBuffer;
  40282. /**
  40283. * update the bound buffer with the given data
  40284. * @param data defines the data to update
  40285. */
  40286. updateArrayBuffer(data: Float32Array): void;
  40287. private _vertexAttribPointer;
  40288. /** @hidden */
  40289. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40290. private _bindVertexBuffersAttributes;
  40291. /**
  40292. * Records a vertex array object
  40293. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40294. * @param vertexBuffers defines the list of vertex buffers to store
  40295. * @param indexBuffer defines the index buffer to store
  40296. * @param effect defines the effect to store
  40297. * @returns the new vertex array object
  40298. */
  40299. recordVertexArrayObject(vertexBuffers: {
  40300. [key: string]: VertexBuffer;
  40301. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40302. /**
  40303. * Bind a specific vertex array object
  40304. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40305. * @param vertexArrayObject defines the vertex array object to bind
  40306. * @param indexBuffer defines the index buffer to bind
  40307. */
  40308. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40309. /**
  40310. * Bind webGl buffers directly to the webGL context
  40311. * @param vertexBuffer defines the vertex buffer to bind
  40312. * @param indexBuffer defines the index buffer to bind
  40313. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40314. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40315. * @param effect defines the effect associated with the vertex buffer
  40316. */
  40317. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40318. private _unbindVertexArrayObject;
  40319. /**
  40320. * Bind a list of vertex buffers to the webGL context
  40321. * @param vertexBuffers defines the list of vertex buffers to bind
  40322. * @param indexBuffer defines the index buffer to bind
  40323. * @param effect defines the effect associated with the vertex buffers
  40324. */
  40325. bindBuffers(vertexBuffers: {
  40326. [key: string]: Nullable<VertexBuffer>;
  40327. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40328. /**
  40329. * Unbind all instance attributes
  40330. */
  40331. unbindInstanceAttributes(): void;
  40332. /**
  40333. * Release and free the memory of a vertex array object
  40334. * @param vao defines the vertex array object to delete
  40335. */
  40336. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40337. /** @hidden */
  40338. _releaseBuffer(buffer: DataBuffer): boolean;
  40339. protected _deleteBuffer(buffer: DataBuffer): void;
  40340. /**
  40341. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40342. * @param instancesBuffer defines the webGL buffer to update and bind
  40343. * @param data defines the data to store in the buffer
  40344. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40345. */
  40346. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40347. /**
  40348. * Bind the content of a webGL buffer used with instantiation
  40349. * @param instancesBuffer defines the webGL buffer to bind
  40350. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40351. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40352. */
  40353. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40354. /**
  40355. * Disable the instance attribute corresponding to the name in parameter
  40356. * @param name defines the name of the attribute to disable
  40357. */
  40358. disableInstanceAttributeByName(name: string): void;
  40359. /**
  40360. * Disable the instance attribute corresponding to the location in parameter
  40361. * @param attributeLocation defines the attribute location of the attribute to disable
  40362. */
  40363. disableInstanceAttribute(attributeLocation: number): void;
  40364. /**
  40365. * Disable the attribute corresponding to the location in parameter
  40366. * @param attributeLocation defines the attribute location of the attribute to disable
  40367. */
  40368. disableAttributeByIndex(attributeLocation: number): void;
  40369. /**
  40370. * Send a draw order
  40371. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40372. * @param indexStart defines the starting index
  40373. * @param indexCount defines the number of index to draw
  40374. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40375. */
  40376. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40377. /**
  40378. * Draw a list of points
  40379. * @param verticesStart defines the index of first vertex to draw
  40380. * @param verticesCount defines the count of vertices to draw
  40381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40382. */
  40383. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40384. /**
  40385. * Draw a list of unindexed primitives
  40386. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40387. * @param verticesStart defines the index of first vertex to draw
  40388. * @param verticesCount defines the count of vertices to draw
  40389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40390. */
  40391. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40392. /**
  40393. * Draw a list of indexed primitives
  40394. * @param fillMode defines the primitive to use
  40395. * @param indexStart defines the starting index
  40396. * @param indexCount defines the number of index to draw
  40397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40398. */
  40399. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40400. /**
  40401. * Draw a list of unindexed primitives
  40402. * @param fillMode defines the primitive to use
  40403. * @param verticesStart defines the index of first vertex to draw
  40404. * @param verticesCount defines the count of vertices to draw
  40405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40406. */
  40407. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40408. private _drawMode;
  40409. /** @hidden */
  40410. protected _reportDrawCall(): void;
  40411. /** @hidden */
  40412. _releaseEffect(effect: Effect): void;
  40413. /** @hidden */
  40414. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40415. /**
  40416. * Create a new effect (used to store vertex/fragment shaders)
  40417. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40418. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40419. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40420. * @param samplers defines an array of string used to represent textures
  40421. * @param defines defines the string containing the defines to use to compile the shaders
  40422. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40423. * @param onCompiled defines a function to call when the effect creation is successful
  40424. * @param onError defines a function to call when the effect creation has failed
  40425. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40426. * @returns the new Effect
  40427. */
  40428. 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;
  40429. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40430. private _compileShader;
  40431. private _compileRawShader;
  40432. /** @hidden */
  40433. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40434. /**
  40435. * Directly creates a webGL program
  40436. * @param pipelineContext defines the pipeline context to attach to
  40437. * @param vertexCode defines the vertex shader code to use
  40438. * @param fragmentCode defines the fragment shader code to use
  40439. * @param context defines the webGL context to use (if not set, the current one will be used)
  40440. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40441. * @returns the new webGL program
  40442. */
  40443. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40444. /**
  40445. * Creates a webGL program
  40446. * @param pipelineContext defines the pipeline context to attach to
  40447. * @param vertexCode defines the vertex shader code to use
  40448. * @param fragmentCode defines the fragment shader code to use
  40449. * @param defines defines the string containing the defines to use to compile the shaders
  40450. * @param context defines the webGL context to use (if not set, the current one will be used)
  40451. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40452. * @returns the new webGL program
  40453. */
  40454. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40455. /**
  40456. * Creates a new pipeline context
  40457. * @returns the new pipeline
  40458. */
  40459. createPipelineContext(): IPipelineContext;
  40460. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40461. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40462. /** @hidden */
  40463. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40464. /** @hidden */
  40465. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40466. /** @hidden */
  40467. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40468. /**
  40469. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40470. * @param pipelineContext defines the pipeline context to use
  40471. * @param uniformsNames defines the list of uniform names
  40472. * @returns an array of webGL uniform locations
  40473. */
  40474. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40475. /**
  40476. * Gets the lsit of active attributes for a given webGL program
  40477. * @param pipelineContext defines the pipeline context to use
  40478. * @param attributesNames defines the list of attribute names to get
  40479. * @returns an array of indices indicating the offset of each attribute
  40480. */
  40481. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40482. /**
  40483. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40484. * @param effect defines the effect to activate
  40485. */
  40486. enableEffect(effect: Nullable<Effect>): void;
  40487. /**
  40488. * Set the value of an uniform to a number (int)
  40489. * @param uniform defines the webGL uniform location where to store the value
  40490. * @param value defines the int number to store
  40491. * @returns true if the value was set
  40492. */
  40493. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40494. /**
  40495. * Set the value of an uniform to an array of int32
  40496. * @param uniform defines the webGL uniform location where to store the value
  40497. * @param array defines the array of int32 to store
  40498. * @returns true if the value was set
  40499. */
  40500. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40501. /**
  40502. * Set the value of an uniform to an array of int32 (stored as vec2)
  40503. * @param uniform defines the webGL uniform location where to store the value
  40504. * @param array defines the array of int32 to store
  40505. * @returns true if the value was set
  40506. */
  40507. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40508. /**
  40509. * Set the value of an uniform to an array of int32 (stored as vec3)
  40510. * @param uniform defines the webGL uniform location where to store the value
  40511. * @param array defines the array of int32 to store
  40512. * @returns true if the value was set
  40513. */
  40514. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40515. /**
  40516. * Set the value of an uniform to an array of int32 (stored as vec4)
  40517. * @param uniform defines the webGL uniform location where to store the value
  40518. * @param array defines the array of int32 to store
  40519. * @returns true if the value was set
  40520. */
  40521. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40522. /**
  40523. * Set the value of an uniform to an array of number
  40524. * @param uniform defines the webGL uniform location where to store the value
  40525. * @param array defines the array of number to store
  40526. * @returns true if the value was set
  40527. */
  40528. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40529. /**
  40530. * Set the value of an uniform to an array of number (stored as vec2)
  40531. * @param uniform defines the webGL uniform location where to store the value
  40532. * @param array defines the array of number to store
  40533. * @returns true if the value was set
  40534. */
  40535. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40536. /**
  40537. * Set the value of an uniform to an array of number (stored as vec3)
  40538. * @param uniform defines the webGL uniform location where to store the value
  40539. * @param array defines the array of number to store
  40540. * @returns true if the value was set
  40541. */
  40542. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40543. /**
  40544. * Set the value of an uniform to an array of number (stored as vec4)
  40545. * @param uniform defines the webGL uniform location where to store the value
  40546. * @param array defines the array of number to store
  40547. * @returns true if the value was set
  40548. */
  40549. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40550. /**
  40551. * Set the value of an uniform to an array of float32 (stored as matrices)
  40552. * @param uniform defines the webGL uniform location where to store the value
  40553. * @param matrices defines the array of float32 to store
  40554. * @returns true if the value was set
  40555. */
  40556. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40557. /**
  40558. * Set the value of an uniform to a matrix (3x3)
  40559. * @param uniform defines the webGL uniform location where to store the value
  40560. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40561. * @returns true if the value was set
  40562. */
  40563. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40564. /**
  40565. * Set the value of an uniform to a matrix (2x2)
  40566. * @param uniform defines the webGL uniform location where to store the value
  40567. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40568. * @returns true if the value was set
  40569. */
  40570. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40571. /**
  40572. * Set the value of an uniform to a number (float)
  40573. * @param uniform defines the webGL uniform location where to store the value
  40574. * @param value defines the float number to store
  40575. * @returns true if the value was transfered
  40576. */
  40577. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40578. /**
  40579. * Set the value of an uniform to a vec2
  40580. * @param uniform defines the webGL uniform location where to store the value
  40581. * @param x defines the 1st component of the value
  40582. * @param y defines the 2nd component of the value
  40583. * @returns true if the value was set
  40584. */
  40585. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40586. /**
  40587. * Set the value of an uniform to a vec3
  40588. * @param uniform defines the webGL uniform location where to store the value
  40589. * @param x defines the 1st component of the value
  40590. * @param y defines the 2nd component of the value
  40591. * @param z defines the 3rd component of the value
  40592. * @returns true if the value was set
  40593. */
  40594. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40595. /**
  40596. * Set the value of an uniform to a vec4
  40597. * @param uniform defines the webGL uniform location where to store the value
  40598. * @param x defines the 1st component of the value
  40599. * @param y defines the 2nd component of the value
  40600. * @param z defines the 3rd component of the value
  40601. * @param w defines the 4th component of the value
  40602. * @returns true if the value was set
  40603. */
  40604. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40605. /**
  40606. * Apply all cached states (depth, culling, stencil and alpha)
  40607. */
  40608. applyStates(): void;
  40609. /**
  40610. * Enable or disable color writing
  40611. * @param enable defines the state to set
  40612. */
  40613. setColorWrite(enable: boolean): void;
  40614. /**
  40615. * Gets a boolean indicating if color writing is enabled
  40616. * @returns the current color writing state
  40617. */
  40618. getColorWrite(): boolean;
  40619. /**
  40620. * Gets the depth culling state manager
  40621. */
  40622. get depthCullingState(): DepthCullingState;
  40623. /**
  40624. * Gets the alpha state manager
  40625. */
  40626. get alphaState(): AlphaState;
  40627. /**
  40628. * Gets the stencil state manager
  40629. */
  40630. get stencilState(): StencilState;
  40631. /**
  40632. * Clears the list of texture accessible through engine.
  40633. * This can help preventing texture load conflict due to name collision.
  40634. */
  40635. clearInternalTexturesCache(): void;
  40636. /**
  40637. * Force the entire cache to be cleared
  40638. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40639. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40640. */
  40641. wipeCaches(bruteForce?: boolean): void;
  40642. /** @hidden */
  40643. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40644. min: number;
  40645. mag: number;
  40646. };
  40647. /** @hidden */
  40648. _createTexture(): WebGLTexture;
  40649. /**
  40650. * Usually called from Texture.ts.
  40651. * Passed information to create a WebGLTexture
  40652. * @param url defines a value which contains one of the following:
  40653. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40654. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40655. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40657. * @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)
  40658. * @param scene needed for loading to the correct scene
  40659. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40660. * @param onLoad optional callback to be called upon successful completion
  40661. * @param onError optional callback to be called upon failure
  40662. * @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
  40663. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40664. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40665. * @param forcedExtension defines the extension to use to pick the right loader
  40666. * @param mimeType defines an optional mime type
  40667. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40668. */
  40669. 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;
  40670. /**
  40671. * Loads an image as an HTMLImageElement.
  40672. * @param input url string, ArrayBuffer, or Blob to load
  40673. * @param onLoad callback called when the image successfully loads
  40674. * @param onError callback called when the image fails to load
  40675. * @param offlineProvider offline provider for caching
  40676. * @param mimeType optional mime type
  40677. * @returns the HTMLImageElement of the loaded image
  40678. * @hidden
  40679. */
  40680. 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>;
  40681. /**
  40682. * @hidden
  40683. */
  40684. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40685. private _unpackFlipYCached;
  40686. /**
  40687. * In case you are sharing the context with other applications, it might
  40688. * be interested to not cache the unpack flip y state to ensure a consistent
  40689. * value would be set.
  40690. */
  40691. enableUnpackFlipYCached: boolean;
  40692. /** @hidden */
  40693. _unpackFlipY(value: boolean): void;
  40694. /** @hidden */
  40695. _getUnpackAlignement(): number;
  40696. private _getTextureTarget;
  40697. /**
  40698. * Update the sampling mode of a given texture
  40699. * @param samplingMode defines the required sampling mode
  40700. * @param texture defines the texture to update
  40701. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40702. */
  40703. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40704. /**
  40705. * Update the sampling mode of a given texture
  40706. * @param texture defines the texture to update
  40707. * @param wrapU defines the texture wrap mode of the u coordinates
  40708. * @param wrapV defines the texture wrap mode of the v coordinates
  40709. * @param wrapR defines the texture wrap mode of the r coordinates
  40710. */
  40711. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40712. /** @hidden */
  40713. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40714. width: number;
  40715. height: number;
  40716. layers?: number;
  40717. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40718. /** @hidden */
  40719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40720. /** @hidden */
  40721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40722. /**
  40723. * Update a portion of an internal texture
  40724. * @param texture defines the texture to update
  40725. * @param imageData defines the data to store into the texture
  40726. * @param xOffset defines the x coordinates of the update rectangle
  40727. * @param yOffset defines the y coordinates of the update rectangle
  40728. * @param width defines the width of the update rectangle
  40729. * @param height defines the height of the update rectangle
  40730. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40731. * @param lod defines the lod level to update (0 by default)
  40732. */
  40733. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40734. /** @hidden */
  40735. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40736. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40737. private _prepareWebGLTexture;
  40738. /** @hidden */
  40739. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40740. private _getDepthStencilBuffer;
  40741. /** @hidden */
  40742. _releaseFramebufferObjects(texture: InternalTexture): void;
  40743. /** @hidden */
  40744. _releaseTexture(texture: InternalTexture): void;
  40745. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40746. protected _setProgram(program: WebGLProgram): void;
  40747. protected _boundUniforms: {
  40748. [key: number]: WebGLUniformLocation;
  40749. };
  40750. /**
  40751. * Binds an effect to the webGL context
  40752. * @param effect defines the effect to bind
  40753. */
  40754. bindSamplers(effect: Effect): void;
  40755. private _activateCurrentTexture;
  40756. /** @hidden */
  40757. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40758. /** @hidden */
  40759. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40760. /**
  40761. * Unbind all textures from the webGL context
  40762. */
  40763. unbindAllTextures(): void;
  40764. /**
  40765. * Sets a texture to the according uniform.
  40766. * @param channel The texture channel
  40767. * @param uniform The uniform to set
  40768. * @param texture The texture to apply
  40769. */
  40770. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40771. private _bindSamplerUniformToChannel;
  40772. private _getTextureWrapMode;
  40773. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40774. /**
  40775. * Sets an array of texture to the webGL context
  40776. * @param channel defines the channel where the texture array must be set
  40777. * @param uniform defines the associated uniform location
  40778. * @param textures defines the array of textures to bind
  40779. */
  40780. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40781. /** @hidden */
  40782. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40783. private _setTextureParameterFloat;
  40784. private _setTextureParameterInteger;
  40785. /**
  40786. * Unbind all vertex attributes from the webGL context
  40787. */
  40788. unbindAllAttributes(): void;
  40789. /**
  40790. * 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
  40791. */
  40792. releaseEffects(): void;
  40793. /**
  40794. * Dispose and release all associated resources
  40795. */
  40796. dispose(): void;
  40797. /**
  40798. * Attach a new callback raised when context lost event is fired
  40799. * @param callback defines the callback to call
  40800. */
  40801. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40802. /**
  40803. * Attach a new callback raised when context restored event is fired
  40804. * @param callback defines the callback to call
  40805. */
  40806. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40807. /**
  40808. * Get the current error code of the webGL context
  40809. * @returns the error code
  40810. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40811. */
  40812. getError(): number;
  40813. private _canRenderToFloatFramebuffer;
  40814. private _canRenderToHalfFloatFramebuffer;
  40815. private _canRenderToFramebuffer;
  40816. /** @hidden */
  40817. _getWebGLTextureType(type: number): number;
  40818. /** @hidden */
  40819. _getInternalFormat(format: number): number;
  40820. /** @hidden */
  40821. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40822. /** @hidden */
  40823. _getRGBAMultiSampleBufferFormat(type: number): number;
  40824. /** @hidden */
  40825. _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;
  40826. /**
  40827. * Loads a file from a url
  40828. * @param url url to load
  40829. * @param onSuccess callback called when the file successfully loads
  40830. * @param onProgress callback called while file is loading (if the server supports this mode)
  40831. * @param offlineProvider defines the offline provider for caching
  40832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40833. * @param onError callback called when the file fails to load
  40834. * @returns a file request object
  40835. * @hidden
  40836. */
  40837. 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;
  40838. /**
  40839. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40840. * @param x defines the x coordinate of the rectangle where pixels must be read
  40841. * @param y defines the y coordinate of the rectangle where pixels must be read
  40842. * @param width defines the width of the rectangle where pixels must be read
  40843. * @param height defines the height of the rectangle where pixels must be read
  40844. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40845. * @returns a Uint8Array containing RGBA colors
  40846. */
  40847. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40848. private static _IsSupported;
  40849. private static _HasMajorPerformanceCaveat;
  40850. /**
  40851. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40852. */
  40853. static get IsSupported(): boolean;
  40854. /**
  40855. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40856. * @returns true if the engine can be created
  40857. * @ignorenaming
  40858. */
  40859. static isSupported(): boolean;
  40860. /**
  40861. * 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)
  40862. */
  40863. static get HasMajorPerformanceCaveat(): boolean;
  40864. /**
  40865. * Find the next highest power of two.
  40866. * @param x Number to start search from.
  40867. * @return Next highest power of two.
  40868. */
  40869. static CeilingPOT(x: number): number;
  40870. /**
  40871. * Find the next lowest power of two.
  40872. * @param x Number to start search from.
  40873. * @return Next lowest power of two.
  40874. */
  40875. static FloorPOT(x: number): number;
  40876. /**
  40877. * Find the nearest power of two.
  40878. * @param x Number to start search from.
  40879. * @return Next nearest power of two.
  40880. */
  40881. static NearestPOT(x: number): number;
  40882. /**
  40883. * Get the closest exponent of two
  40884. * @param value defines the value to approximate
  40885. * @param max defines the maximum value to return
  40886. * @param mode defines how to define the closest value
  40887. * @returns closest exponent of two of the given value
  40888. */
  40889. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40890. /**
  40891. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40892. * @param func - the function to be called
  40893. * @param requester - the object that will request the next frame. Falls back to window.
  40894. * @returns frame number
  40895. */
  40896. static QueueNewFrame(func: () => void, requester?: any): number;
  40897. /**
  40898. * Gets host document
  40899. * @returns the host document object
  40900. */
  40901. getHostDocument(): Nullable<Document>;
  40902. }
  40903. }
  40904. declare module "babylonjs/Materials/Textures/internalTexture" {
  40905. import { Observable } from "babylonjs/Misc/observable";
  40906. import { Nullable, int } from "babylonjs/types";
  40907. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40909. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40910. /**
  40911. * Defines the source of the internal texture
  40912. */
  40913. export enum InternalTextureSource {
  40914. /**
  40915. * The source of the texture data is unknown
  40916. */
  40917. Unknown = 0,
  40918. /**
  40919. * Texture data comes from an URL
  40920. */
  40921. Url = 1,
  40922. /**
  40923. * Texture data is only used for temporary storage
  40924. */
  40925. Temp = 2,
  40926. /**
  40927. * Texture data comes from raw data (ArrayBuffer)
  40928. */
  40929. Raw = 3,
  40930. /**
  40931. * Texture content is dynamic (video or dynamic texture)
  40932. */
  40933. Dynamic = 4,
  40934. /**
  40935. * Texture content is generated by rendering to it
  40936. */
  40937. RenderTarget = 5,
  40938. /**
  40939. * Texture content is part of a multi render target process
  40940. */
  40941. MultiRenderTarget = 6,
  40942. /**
  40943. * Texture data comes from a cube data file
  40944. */
  40945. Cube = 7,
  40946. /**
  40947. * Texture data comes from a raw cube data
  40948. */
  40949. CubeRaw = 8,
  40950. /**
  40951. * Texture data come from a prefiltered cube data file
  40952. */
  40953. CubePrefiltered = 9,
  40954. /**
  40955. * Texture content is raw 3D data
  40956. */
  40957. Raw3D = 10,
  40958. /**
  40959. * Texture content is raw 2D array data
  40960. */
  40961. Raw2DArray = 11,
  40962. /**
  40963. * Texture content is a depth texture
  40964. */
  40965. Depth = 12,
  40966. /**
  40967. * Texture data comes from a raw cube data encoded with RGBD
  40968. */
  40969. CubeRawRGBD = 13
  40970. }
  40971. /**
  40972. * Class used to store data associated with WebGL texture data for the engine
  40973. * This class should not be used directly
  40974. */
  40975. export class InternalTexture {
  40976. /** @hidden */
  40977. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40978. /**
  40979. * Defines if the texture is ready
  40980. */
  40981. isReady: boolean;
  40982. /**
  40983. * Defines if the texture is a cube texture
  40984. */
  40985. isCube: boolean;
  40986. /**
  40987. * Defines if the texture contains 3D data
  40988. */
  40989. is3D: boolean;
  40990. /**
  40991. * Defines if the texture contains 2D array data
  40992. */
  40993. is2DArray: boolean;
  40994. /**
  40995. * Defines if the texture contains multiview data
  40996. */
  40997. isMultiview: boolean;
  40998. /**
  40999. * Gets the URL used to load this texture
  41000. */
  41001. url: string;
  41002. /**
  41003. * Gets the sampling mode of the texture
  41004. */
  41005. samplingMode: number;
  41006. /**
  41007. * Gets a boolean indicating if the texture needs mipmaps generation
  41008. */
  41009. generateMipMaps: boolean;
  41010. /**
  41011. * Gets the number of samples used by the texture (WebGL2+ only)
  41012. */
  41013. samples: number;
  41014. /**
  41015. * Gets the type of the texture (int, float...)
  41016. */
  41017. type: number;
  41018. /**
  41019. * Gets the format of the texture (RGB, RGBA...)
  41020. */
  41021. format: number;
  41022. /**
  41023. * Observable called when the texture is loaded
  41024. */
  41025. onLoadedObservable: Observable<InternalTexture>;
  41026. /**
  41027. * Gets the width of the texture
  41028. */
  41029. width: number;
  41030. /**
  41031. * Gets the height of the texture
  41032. */
  41033. height: number;
  41034. /**
  41035. * Gets the depth of the texture
  41036. */
  41037. depth: number;
  41038. /**
  41039. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41040. */
  41041. baseWidth: number;
  41042. /**
  41043. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41044. */
  41045. baseHeight: number;
  41046. /**
  41047. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41048. */
  41049. baseDepth: number;
  41050. /**
  41051. * Gets a boolean indicating if the texture is inverted on Y axis
  41052. */
  41053. invertY: boolean;
  41054. /** @hidden */
  41055. _invertVScale: boolean;
  41056. /** @hidden */
  41057. _associatedChannel: number;
  41058. /** @hidden */
  41059. _source: InternalTextureSource;
  41060. /** @hidden */
  41061. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41062. /** @hidden */
  41063. _bufferView: Nullable<ArrayBufferView>;
  41064. /** @hidden */
  41065. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41066. /** @hidden */
  41067. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41068. /** @hidden */
  41069. _size: number;
  41070. /** @hidden */
  41071. _extension: string;
  41072. /** @hidden */
  41073. _files: Nullable<string[]>;
  41074. /** @hidden */
  41075. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41076. /** @hidden */
  41077. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41078. /** @hidden */
  41079. _framebuffer: Nullable<WebGLFramebuffer>;
  41080. /** @hidden */
  41081. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41082. /** @hidden */
  41083. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41084. /** @hidden */
  41085. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41086. /** @hidden */
  41087. _attachments: Nullable<number[]>;
  41088. /** @hidden */
  41089. _textureArray: Nullable<InternalTexture[]>;
  41090. /** @hidden */
  41091. _cachedCoordinatesMode: Nullable<number>;
  41092. /** @hidden */
  41093. _cachedWrapU: Nullable<number>;
  41094. /** @hidden */
  41095. _cachedWrapV: Nullable<number>;
  41096. /** @hidden */
  41097. _cachedWrapR: Nullable<number>;
  41098. /** @hidden */
  41099. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41100. /** @hidden */
  41101. _isDisabled: boolean;
  41102. /** @hidden */
  41103. _compression: Nullable<string>;
  41104. /** @hidden */
  41105. _generateStencilBuffer: boolean;
  41106. /** @hidden */
  41107. _generateDepthBuffer: boolean;
  41108. /** @hidden */
  41109. _comparisonFunction: number;
  41110. /** @hidden */
  41111. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41112. /** @hidden */
  41113. _lodGenerationScale: number;
  41114. /** @hidden */
  41115. _lodGenerationOffset: number;
  41116. /** @hidden */
  41117. _depthStencilTexture: Nullable<InternalTexture>;
  41118. /** @hidden */
  41119. _colorTextureArray: Nullable<WebGLTexture>;
  41120. /** @hidden */
  41121. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41122. /** @hidden */
  41123. _lodTextureHigh: Nullable<BaseTexture>;
  41124. /** @hidden */
  41125. _lodTextureMid: Nullable<BaseTexture>;
  41126. /** @hidden */
  41127. _lodTextureLow: Nullable<BaseTexture>;
  41128. /** @hidden */
  41129. _isRGBD: boolean;
  41130. /** @hidden */
  41131. _linearSpecularLOD: boolean;
  41132. /** @hidden */
  41133. _irradianceTexture: Nullable<BaseTexture>;
  41134. /** @hidden */
  41135. _webGLTexture: Nullable<WebGLTexture>;
  41136. /** @hidden */
  41137. _references: number;
  41138. /** @hidden */
  41139. _gammaSpace: Nullable<boolean>;
  41140. private _engine;
  41141. /**
  41142. * Gets the Engine the texture belongs to.
  41143. * @returns The babylon engine
  41144. */
  41145. getEngine(): ThinEngine;
  41146. /**
  41147. * Gets the data source type of the texture
  41148. */
  41149. get source(): InternalTextureSource;
  41150. /**
  41151. * Creates a new InternalTexture
  41152. * @param engine defines the engine to use
  41153. * @param source defines the type of data that will be used
  41154. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41155. */
  41156. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41157. /**
  41158. * Increments the number of references (ie. the number of Texture that point to it)
  41159. */
  41160. incrementReferences(): void;
  41161. /**
  41162. * Change the size of the texture (not the size of the content)
  41163. * @param width defines the new width
  41164. * @param height defines the new height
  41165. * @param depth defines the new depth (1 by default)
  41166. */
  41167. updateSize(width: int, height: int, depth?: int): void;
  41168. /** @hidden */
  41169. _rebuild(): void;
  41170. /** @hidden */
  41171. _swapAndDie(target: InternalTexture): void;
  41172. /**
  41173. * Dispose the current allocated resources
  41174. */
  41175. dispose(): void;
  41176. }
  41177. }
  41178. declare module "babylonjs/Audio/analyser" {
  41179. import { Scene } from "babylonjs/scene";
  41180. /**
  41181. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41183. */
  41184. export class Analyser {
  41185. /**
  41186. * Gets or sets the smoothing
  41187. * @ignorenaming
  41188. */
  41189. SMOOTHING: number;
  41190. /**
  41191. * Gets or sets the FFT table size
  41192. * @ignorenaming
  41193. */
  41194. FFT_SIZE: number;
  41195. /**
  41196. * Gets or sets the bar graph amplitude
  41197. * @ignorenaming
  41198. */
  41199. BARGRAPHAMPLITUDE: number;
  41200. /**
  41201. * Gets or sets the position of the debug canvas
  41202. * @ignorenaming
  41203. */
  41204. DEBUGCANVASPOS: {
  41205. x: number;
  41206. y: number;
  41207. };
  41208. /**
  41209. * Gets or sets the debug canvas size
  41210. * @ignorenaming
  41211. */
  41212. DEBUGCANVASSIZE: {
  41213. width: number;
  41214. height: number;
  41215. };
  41216. private _byteFreqs;
  41217. private _byteTime;
  41218. private _floatFreqs;
  41219. private _webAudioAnalyser;
  41220. private _debugCanvas;
  41221. private _debugCanvasContext;
  41222. private _scene;
  41223. private _registerFunc;
  41224. private _audioEngine;
  41225. /**
  41226. * Creates a new analyser
  41227. * @param scene defines hosting scene
  41228. */
  41229. constructor(scene: Scene);
  41230. /**
  41231. * Get the number of data values you will have to play with for the visualization
  41232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41233. * @returns a number
  41234. */
  41235. getFrequencyBinCount(): number;
  41236. /**
  41237. * Gets the current frequency data as a byte array
  41238. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41239. * @returns a Uint8Array
  41240. */
  41241. getByteFrequencyData(): Uint8Array;
  41242. /**
  41243. * Gets the current waveform as a byte array
  41244. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41245. * @returns a Uint8Array
  41246. */
  41247. getByteTimeDomainData(): Uint8Array;
  41248. /**
  41249. * Gets the current frequency data as a float array
  41250. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41251. * @returns a Float32Array
  41252. */
  41253. getFloatFrequencyData(): Float32Array;
  41254. /**
  41255. * Renders the debug canvas
  41256. */
  41257. drawDebugCanvas(): void;
  41258. /**
  41259. * Stops rendering the debug canvas and removes it
  41260. */
  41261. stopDebugCanvas(): void;
  41262. /**
  41263. * Connects two audio nodes
  41264. * @param inputAudioNode defines first node to connect
  41265. * @param outputAudioNode defines second node to connect
  41266. */
  41267. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41268. /**
  41269. * Releases all associated resources
  41270. */
  41271. dispose(): void;
  41272. }
  41273. }
  41274. declare module "babylonjs/Audio/audioEngine" {
  41275. import { IDisposable } from "babylonjs/scene";
  41276. import { Analyser } from "babylonjs/Audio/analyser";
  41277. import { Nullable } from "babylonjs/types";
  41278. import { Observable } from "babylonjs/Misc/observable";
  41279. /**
  41280. * This represents an audio engine and it is responsible
  41281. * to play, synchronize and analyse sounds throughout the application.
  41282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41283. */
  41284. export interface IAudioEngine extends IDisposable {
  41285. /**
  41286. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41287. */
  41288. readonly canUseWebAudio: boolean;
  41289. /**
  41290. * Gets the current AudioContext if available.
  41291. */
  41292. readonly audioContext: Nullable<AudioContext>;
  41293. /**
  41294. * The master gain node defines the global audio volume of your audio engine.
  41295. */
  41296. readonly masterGain: GainNode;
  41297. /**
  41298. * Gets whether or not mp3 are supported by your browser.
  41299. */
  41300. readonly isMP3supported: boolean;
  41301. /**
  41302. * Gets whether or not ogg are supported by your browser.
  41303. */
  41304. readonly isOGGsupported: boolean;
  41305. /**
  41306. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41307. * @ignoreNaming
  41308. */
  41309. WarnedWebAudioUnsupported: boolean;
  41310. /**
  41311. * Defines if the audio engine relies on a custom unlocked button.
  41312. * In this case, the embedded button will not be displayed.
  41313. */
  41314. useCustomUnlockedButton: boolean;
  41315. /**
  41316. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41317. */
  41318. readonly unlocked: boolean;
  41319. /**
  41320. * Event raised when audio has been unlocked on the browser.
  41321. */
  41322. onAudioUnlockedObservable: Observable<AudioEngine>;
  41323. /**
  41324. * Event raised when audio has been locked on the browser.
  41325. */
  41326. onAudioLockedObservable: Observable<AudioEngine>;
  41327. /**
  41328. * Flags the audio engine in Locked state.
  41329. * This happens due to new browser policies preventing audio to autoplay.
  41330. */
  41331. lock(): void;
  41332. /**
  41333. * Unlocks the audio engine once a user action has been done on the dom.
  41334. * This is helpful to resume play once browser policies have been satisfied.
  41335. */
  41336. unlock(): void;
  41337. /**
  41338. * Gets the global volume sets on the master gain.
  41339. * @returns the global volume if set or -1 otherwise
  41340. */
  41341. getGlobalVolume(): number;
  41342. /**
  41343. * Sets the global volume of your experience (sets on the master gain).
  41344. * @param newVolume Defines the new global volume of the application
  41345. */
  41346. setGlobalVolume(newVolume: number): void;
  41347. /**
  41348. * Connect the audio engine to an audio analyser allowing some amazing
  41349. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41351. * @param analyser The analyser to connect to the engine
  41352. */
  41353. connectToAnalyser(analyser: Analyser): void;
  41354. }
  41355. /**
  41356. * This represents the default audio engine used in babylon.
  41357. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41358. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41359. */
  41360. export class AudioEngine implements IAudioEngine {
  41361. private _audioContext;
  41362. private _audioContextInitialized;
  41363. private _muteButton;
  41364. private _hostElement;
  41365. /**
  41366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41367. */
  41368. canUseWebAudio: boolean;
  41369. /**
  41370. * The master gain node defines the global audio volume of your audio engine.
  41371. */
  41372. masterGain: GainNode;
  41373. /**
  41374. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41375. * @ignoreNaming
  41376. */
  41377. WarnedWebAudioUnsupported: boolean;
  41378. /**
  41379. * Gets whether or not mp3 are supported by your browser.
  41380. */
  41381. isMP3supported: boolean;
  41382. /**
  41383. * Gets whether or not ogg are supported by your browser.
  41384. */
  41385. isOGGsupported: boolean;
  41386. /**
  41387. * Gets whether audio has been unlocked on the device.
  41388. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41389. * a user interaction has happened.
  41390. */
  41391. unlocked: 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. * Event raised when audio has been unlocked on the browser.
  41399. */
  41400. onAudioUnlockedObservable: Observable<AudioEngine>;
  41401. /**
  41402. * Event raised when audio has been locked on the browser.
  41403. */
  41404. onAudioLockedObservable: Observable<AudioEngine>;
  41405. /**
  41406. * Gets the current AudioContext if available.
  41407. */
  41408. get audioContext(): Nullable<AudioContext>;
  41409. private _connectedAnalyser;
  41410. /**
  41411. * Instantiates a new audio engine.
  41412. *
  41413. * There should be only one per page as some browsers restrict the number
  41414. * of audio contexts you can create.
  41415. * @param hostElement defines the host element where to display the mute icon if necessary
  41416. */
  41417. constructor(hostElement?: Nullable<HTMLElement>);
  41418. /**
  41419. * Flags the audio engine in Locked state.
  41420. * This happens due to new browser policies preventing audio to autoplay.
  41421. */
  41422. lock(): void;
  41423. /**
  41424. * Unlocks the audio engine once a user action has been done on the dom.
  41425. * This is helpful to resume play once browser policies have been satisfied.
  41426. */
  41427. unlock(): void;
  41428. private _resumeAudioContext;
  41429. private _initializeAudioContext;
  41430. private _tryToRun;
  41431. private _triggerRunningState;
  41432. private _triggerSuspendedState;
  41433. private _displayMuteButton;
  41434. private _moveButtonToTopLeft;
  41435. private _onResize;
  41436. private _hideMuteButton;
  41437. /**
  41438. * Destroy and release the resources associated with the audio ccontext.
  41439. */
  41440. dispose(): void;
  41441. /**
  41442. * Gets the global volume sets on the master gain.
  41443. * @returns the global volume if set or -1 otherwise
  41444. */
  41445. getGlobalVolume(): number;
  41446. /**
  41447. * Sets the global volume of your experience (sets on the master gain).
  41448. * @param newVolume Defines the new global volume of the application
  41449. */
  41450. setGlobalVolume(newVolume: number): void;
  41451. /**
  41452. * Connect the audio engine to an audio analyser allowing some amazing
  41453. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41455. * @param analyser The analyser to connect to the engine
  41456. */
  41457. connectToAnalyser(analyser: Analyser): void;
  41458. }
  41459. }
  41460. declare module "babylonjs/Loading/loadingScreen" {
  41461. /**
  41462. * Interface used to present a loading screen while loading a scene
  41463. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41464. */
  41465. export interface ILoadingScreen {
  41466. /**
  41467. * Function called to display the loading screen
  41468. */
  41469. displayLoadingUI: () => void;
  41470. /**
  41471. * Function called to hide the loading screen
  41472. */
  41473. hideLoadingUI: () => void;
  41474. /**
  41475. * Gets or sets the color to use for the background
  41476. */
  41477. loadingUIBackgroundColor: string;
  41478. /**
  41479. * Gets or sets the text to display while loading
  41480. */
  41481. loadingUIText: string;
  41482. }
  41483. /**
  41484. * Class used for the default loading screen
  41485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41486. */
  41487. export class DefaultLoadingScreen implements ILoadingScreen {
  41488. private _renderingCanvas;
  41489. private _loadingText;
  41490. private _loadingDivBackgroundColor;
  41491. private _loadingDiv;
  41492. private _loadingTextDiv;
  41493. /** Gets or sets the logo url to use for the default loading screen */
  41494. static DefaultLogoUrl: string;
  41495. /** Gets or sets the spinner url to use for the default loading screen */
  41496. static DefaultSpinnerUrl: string;
  41497. /**
  41498. * Creates a new default loading screen
  41499. * @param _renderingCanvas defines the canvas used to render the scene
  41500. * @param _loadingText defines the default text to display
  41501. * @param _loadingDivBackgroundColor defines the default background color
  41502. */
  41503. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41504. /**
  41505. * Function called to display the loading screen
  41506. */
  41507. displayLoadingUI(): void;
  41508. /**
  41509. * Function called to hide the loading screen
  41510. */
  41511. hideLoadingUI(): void;
  41512. /**
  41513. * Gets or sets the text to display while loading
  41514. */
  41515. set loadingUIText(text: string);
  41516. get loadingUIText(): string;
  41517. /**
  41518. * Gets or sets the color to use for the background
  41519. */
  41520. get loadingUIBackgroundColor(): string;
  41521. set loadingUIBackgroundColor(color: string);
  41522. private _resizeLoadingUI;
  41523. }
  41524. }
  41525. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41526. /**
  41527. * Interface for any object that can request an animation frame
  41528. */
  41529. export interface ICustomAnimationFrameRequester {
  41530. /**
  41531. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41532. */
  41533. renderFunction?: Function;
  41534. /**
  41535. * Called to request the next frame to render to
  41536. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41537. */
  41538. requestAnimationFrame: Function;
  41539. /**
  41540. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41541. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41542. */
  41543. requestID?: number;
  41544. }
  41545. }
  41546. declare module "babylonjs/Misc/performanceMonitor" {
  41547. /**
  41548. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41549. */
  41550. export class PerformanceMonitor {
  41551. private _enabled;
  41552. private _rollingFrameTime;
  41553. private _lastFrameTimeMs;
  41554. /**
  41555. * constructor
  41556. * @param frameSampleSize The number of samples required to saturate the sliding window
  41557. */
  41558. constructor(frameSampleSize?: number);
  41559. /**
  41560. * Samples current frame
  41561. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41562. */
  41563. sampleFrame(timeMs?: number): void;
  41564. /**
  41565. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41566. */
  41567. get averageFrameTime(): number;
  41568. /**
  41569. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41570. */
  41571. get averageFrameTimeVariance(): number;
  41572. /**
  41573. * Returns the frame time of the most recent frame
  41574. */
  41575. get instantaneousFrameTime(): number;
  41576. /**
  41577. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41578. */
  41579. get averageFPS(): number;
  41580. /**
  41581. * Returns the average framerate in frames per second using the most recent frame time
  41582. */
  41583. get instantaneousFPS(): number;
  41584. /**
  41585. * Returns true if enough samples have been taken to completely fill the sliding window
  41586. */
  41587. get isSaturated(): boolean;
  41588. /**
  41589. * Enables contributions to the sliding window sample set
  41590. */
  41591. enable(): void;
  41592. /**
  41593. * Disables contributions to the sliding window sample set
  41594. * Samples will not be interpolated over the disabled period
  41595. */
  41596. disable(): void;
  41597. /**
  41598. * Returns true if sampling is enabled
  41599. */
  41600. get isEnabled(): boolean;
  41601. /**
  41602. * Resets performance monitor
  41603. */
  41604. reset(): void;
  41605. }
  41606. /**
  41607. * RollingAverage
  41608. *
  41609. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41610. */
  41611. export class RollingAverage {
  41612. /**
  41613. * Current average
  41614. */
  41615. average: number;
  41616. /**
  41617. * Current variance
  41618. */
  41619. variance: number;
  41620. protected _samples: Array<number>;
  41621. protected _sampleCount: number;
  41622. protected _pos: number;
  41623. protected _m2: number;
  41624. /**
  41625. * constructor
  41626. * @param length The number of samples required to saturate the sliding window
  41627. */
  41628. constructor(length: number);
  41629. /**
  41630. * Adds a sample to the sample set
  41631. * @param v The sample value
  41632. */
  41633. add(v: number): void;
  41634. /**
  41635. * Returns previously added values or null if outside of history or outside the sliding window domain
  41636. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41637. * @return Value previously recorded with add() or null if outside of range
  41638. */
  41639. history(i: number): number;
  41640. /**
  41641. * Returns true if enough samples have been taken to completely fill the sliding window
  41642. * @return true if sample-set saturated
  41643. */
  41644. isSaturated(): boolean;
  41645. /**
  41646. * Resets the rolling average (equivalent to 0 samples taken so far)
  41647. */
  41648. reset(): void;
  41649. /**
  41650. * Wraps a value around the sample range boundaries
  41651. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41652. * @return Wrapped position in sample range
  41653. */
  41654. protected _wrapPosition(i: number): number;
  41655. }
  41656. }
  41657. declare module "babylonjs/Misc/perfCounter" {
  41658. /**
  41659. * This class is used to track a performance counter which is number based.
  41660. * The user has access to many properties which give statistics of different nature.
  41661. *
  41662. * The implementer can track two kinds of Performance Counter: time and count.
  41663. * 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.
  41664. * 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.
  41665. */
  41666. export class PerfCounter {
  41667. /**
  41668. * Gets or sets a global boolean to turn on and off all the counters
  41669. */
  41670. static Enabled: boolean;
  41671. /**
  41672. * Returns the smallest value ever
  41673. */
  41674. get min(): number;
  41675. /**
  41676. * Returns the biggest value ever
  41677. */
  41678. get max(): number;
  41679. /**
  41680. * Returns the average value since the performance counter is running
  41681. */
  41682. get average(): number;
  41683. /**
  41684. * Returns the average value of the last second the counter was monitored
  41685. */
  41686. get lastSecAverage(): number;
  41687. /**
  41688. * Returns the current value
  41689. */
  41690. get current(): number;
  41691. /**
  41692. * Gets the accumulated total
  41693. */
  41694. get total(): number;
  41695. /**
  41696. * Gets the total value count
  41697. */
  41698. get count(): number;
  41699. /**
  41700. * Creates a new counter
  41701. */
  41702. constructor();
  41703. /**
  41704. * Call this method to start monitoring a new frame.
  41705. * 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.
  41706. */
  41707. fetchNewFrame(): void;
  41708. /**
  41709. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41710. * @param newCount the count value to add to the monitored count
  41711. * @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.
  41712. */
  41713. addCount(newCount: number, fetchResult: boolean): void;
  41714. /**
  41715. * Start monitoring this performance counter
  41716. */
  41717. beginMonitoring(): void;
  41718. /**
  41719. * Compute the time lapsed since the previous beginMonitoring() call.
  41720. * @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
  41721. */
  41722. endMonitoring(newFrame?: boolean): void;
  41723. private _fetchResult;
  41724. private _startMonitoringTime;
  41725. private _min;
  41726. private _max;
  41727. private _average;
  41728. private _current;
  41729. private _totalValueCount;
  41730. private _totalAccumulated;
  41731. private _lastSecAverage;
  41732. private _lastSecAccumulated;
  41733. private _lastSecTime;
  41734. private _lastSecValueCount;
  41735. }
  41736. }
  41737. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41739. import { Nullable } from "babylonjs/types";
  41740. module "babylonjs/Engines/thinEngine" {
  41741. interface ThinEngine {
  41742. /** @hidden */
  41743. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41744. }
  41745. }
  41746. }
  41747. declare module "babylonjs/Engines/engine" {
  41748. import { Observable } from "babylonjs/Misc/observable";
  41749. import { Nullable } from "babylonjs/types";
  41750. import { Scene } from "babylonjs/scene";
  41751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41752. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41753. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41754. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41755. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41756. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41757. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41758. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41759. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41760. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41761. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41762. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41763. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41764. import "babylonjs/Engines/Extensions/engine.alpha";
  41765. import "babylonjs/Engines/Extensions/engine.readTexture";
  41766. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41767. import { Material } from "babylonjs/Materials/material";
  41768. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41769. /**
  41770. * Defines the interface used by display changed events
  41771. */
  41772. export interface IDisplayChangedEventArgs {
  41773. /** Gets the vrDisplay object (if any) */
  41774. vrDisplay: Nullable<any>;
  41775. /** Gets a boolean indicating if webVR is supported */
  41776. vrSupported: boolean;
  41777. }
  41778. /**
  41779. * Defines the interface used by objects containing a viewport (like a camera)
  41780. */
  41781. interface IViewportOwnerLike {
  41782. /**
  41783. * Gets or sets the viewport
  41784. */
  41785. viewport: IViewportLike;
  41786. }
  41787. /**
  41788. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41789. */
  41790. export class Engine extends ThinEngine {
  41791. /** Defines that alpha blending is disabled */
  41792. static readonly ALPHA_DISABLE: number;
  41793. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41794. static readonly ALPHA_ADD: number;
  41795. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41796. static readonly ALPHA_COMBINE: number;
  41797. /** Defines that alpha blending to DEST - SRC * DEST */
  41798. static readonly ALPHA_SUBTRACT: number;
  41799. /** Defines that alpha blending to SRC * DEST */
  41800. static readonly ALPHA_MULTIPLY: number;
  41801. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41802. static readonly ALPHA_MAXIMIZED: number;
  41803. /** Defines that alpha blending to SRC + DEST */
  41804. static readonly ALPHA_ONEONE: number;
  41805. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41806. static readonly ALPHA_PREMULTIPLIED: number;
  41807. /**
  41808. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41809. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41810. */
  41811. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41812. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41813. static readonly ALPHA_INTERPOLATE: number;
  41814. /**
  41815. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41816. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41817. */
  41818. static readonly ALPHA_SCREENMODE: number;
  41819. /** Defines that the ressource is not delayed*/
  41820. static readonly DELAYLOADSTATE_NONE: number;
  41821. /** Defines that the ressource was successfully delay loaded */
  41822. static readonly DELAYLOADSTATE_LOADED: number;
  41823. /** Defines that the ressource is currently delay loading */
  41824. static readonly DELAYLOADSTATE_LOADING: number;
  41825. /** Defines that the ressource is delayed and has not started loading */
  41826. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41827. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41828. static readonly NEVER: number;
  41829. /** 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 */
  41830. static readonly ALWAYS: number;
  41831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41832. static readonly LESS: number;
  41833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41834. static readonly EQUAL: number;
  41835. /** 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 */
  41836. static readonly LEQUAL: number;
  41837. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41838. static readonly GREATER: number;
  41839. /** 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 */
  41840. static readonly GEQUAL: number;
  41841. /** 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 */
  41842. static readonly NOTEQUAL: number;
  41843. /** Passed to stencilOperation to specify that stencil value must be kept */
  41844. static readonly KEEP: number;
  41845. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41846. static readonly REPLACE: number;
  41847. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41848. static readonly INCR: number;
  41849. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41850. static readonly DECR: number;
  41851. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41852. static readonly INVERT: number;
  41853. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41854. static readonly INCR_WRAP: number;
  41855. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41856. static readonly DECR_WRAP: number;
  41857. /** Texture is not repeating outside of 0..1 UVs */
  41858. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41859. /** Texture is repeating outside of 0..1 UVs */
  41860. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41861. /** Texture is repeating and mirrored */
  41862. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41863. /** ALPHA */
  41864. static readonly TEXTUREFORMAT_ALPHA: number;
  41865. /** LUMINANCE */
  41866. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41867. /** LUMINANCE_ALPHA */
  41868. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41869. /** RGB */
  41870. static readonly TEXTUREFORMAT_RGB: number;
  41871. /** RGBA */
  41872. static readonly TEXTUREFORMAT_RGBA: number;
  41873. /** RED */
  41874. static readonly TEXTUREFORMAT_RED: number;
  41875. /** RED (2nd reference) */
  41876. static readonly TEXTUREFORMAT_R: number;
  41877. /** RG */
  41878. static readonly TEXTUREFORMAT_RG: number;
  41879. /** RED_INTEGER */
  41880. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41881. /** RED_INTEGER (2nd reference) */
  41882. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41883. /** RG_INTEGER */
  41884. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41885. /** RGB_INTEGER */
  41886. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41887. /** RGBA_INTEGER */
  41888. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41889. /** UNSIGNED_BYTE */
  41890. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41891. /** UNSIGNED_BYTE (2nd reference) */
  41892. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41893. /** FLOAT */
  41894. static readonly TEXTURETYPE_FLOAT: number;
  41895. /** HALF_FLOAT */
  41896. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41897. /** BYTE */
  41898. static readonly TEXTURETYPE_BYTE: number;
  41899. /** SHORT */
  41900. static readonly TEXTURETYPE_SHORT: number;
  41901. /** UNSIGNED_SHORT */
  41902. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41903. /** INT */
  41904. static readonly TEXTURETYPE_INT: number;
  41905. /** UNSIGNED_INT */
  41906. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41907. /** UNSIGNED_SHORT_4_4_4_4 */
  41908. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41909. /** UNSIGNED_SHORT_5_5_5_1 */
  41910. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41911. /** UNSIGNED_SHORT_5_6_5 */
  41912. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41913. /** UNSIGNED_INT_2_10_10_10_REV */
  41914. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41915. /** UNSIGNED_INT_24_8 */
  41916. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41917. /** UNSIGNED_INT_10F_11F_11F_REV */
  41918. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41919. /** UNSIGNED_INT_5_9_9_9_REV */
  41920. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41921. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41922. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41923. /** nearest is mag = nearest and min = nearest and mip = linear */
  41924. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41925. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41926. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41927. /** Trilinear is mag = linear and min = linear and mip = linear */
  41928. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41929. /** nearest is mag = nearest and min = nearest and mip = linear */
  41930. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41931. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41932. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41933. /** Trilinear is mag = linear and min = linear and mip = linear */
  41934. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41935. /** mag = nearest and min = nearest and mip = nearest */
  41936. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41937. /** mag = nearest and min = linear and mip = nearest */
  41938. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41939. /** mag = nearest and min = linear and mip = linear */
  41940. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41941. /** mag = nearest and min = linear and mip = none */
  41942. static readonly TEXTURE_NEAREST_LINEAR: number;
  41943. /** mag = nearest and min = nearest and mip = none */
  41944. static readonly TEXTURE_NEAREST_NEAREST: number;
  41945. /** mag = linear and min = nearest and mip = nearest */
  41946. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41947. /** mag = linear and min = nearest and mip = linear */
  41948. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41949. /** mag = linear and min = linear and mip = none */
  41950. static readonly TEXTURE_LINEAR_LINEAR: number;
  41951. /** mag = linear and min = nearest and mip = none */
  41952. static readonly TEXTURE_LINEAR_NEAREST: number;
  41953. /** Explicit coordinates mode */
  41954. static readonly TEXTURE_EXPLICIT_MODE: number;
  41955. /** Spherical coordinates mode */
  41956. static readonly TEXTURE_SPHERICAL_MODE: number;
  41957. /** Planar coordinates mode */
  41958. static readonly TEXTURE_PLANAR_MODE: number;
  41959. /** Cubic coordinates mode */
  41960. static readonly TEXTURE_CUBIC_MODE: number;
  41961. /** Projection coordinates mode */
  41962. static readonly TEXTURE_PROJECTION_MODE: number;
  41963. /** Skybox coordinates mode */
  41964. static readonly TEXTURE_SKYBOX_MODE: number;
  41965. /** Inverse Cubic coordinates mode */
  41966. static readonly TEXTURE_INVCUBIC_MODE: number;
  41967. /** Equirectangular coordinates mode */
  41968. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41969. /** Equirectangular Fixed coordinates mode */
  41970. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41971. /** Equirectangular Fixed Mirrored coordinates mode */
  41972. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41973. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41974. static readonly SCALEMODE_FLOOR: number;
  41975. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41976. static readonly SCALEMODE_NEAREST: number;
  41977. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41978. static readonly SCALEMODE_CEILING: number;
  41979. /**
  41980. * Returns the current npm package of the sdk
  41981. */
  41982. static get NpmPackage(): string;
  41983. /**
  41984. * Returns the current version of the framework
  41985. */
  41986. static get Version(): string;
  41987. /** Gets the list of created engines */
  41988. static get Instances(): Engine[];
  41989. /**
  41990. * Gets the latest created engine
  41991. */
  41992. static get LastCreatedEngine(): Nullable<Engine>;
  41993. /**
  41994. * Gets the latest created scene
  41995. */
  41996. static get LastCreatedScene(): Nullable<Scene>;
  41997. /**
  41998. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41999. * @param flag defines which part of the materials must be marked as dirty
  42000. * @param predicate defines a predicate used to filter which materials should be affected
  42001. */
  42002. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42003. /**
  42004. * Method called to create the default loading screen.
  42005. * This can be overriden in your own app.
  42006. * @param canvas The rendering canvas element
  42007. * @returns The loading screen
  42008. */
  42009. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42010. /**
  42011. * Method called to create the default rescale post process on each engine.
  42012. */
  42013. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42014. /**
  42015. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42016. **/
  42017. enableOfflineSupport: boolean;
  42018. /**
  42019. * 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)
  42020. **/
  42021. disableManifestCheck: boolean;
  42022. /**
  42023. * Gets the list of created scenes
  42024. */
  42025. scenes: Scene[];
  42026. /**
  42027. * Event raised when a new scene is created
  42028. */
  42029. onNewSceneAddedObservable: Observable<Scene>;
  42030. /**
  42031. * Gets the list of created postprocesses
  42032. */
  42033. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42034. /**
  42035. * Gets a boolean indicating if the pointer is currently locked
  42036. */
  42037. isPointerLock: boolean;
  42038. /**
  42039. * Observable event triggered each time the rendering canvas is resized
  42040. */
  42041. onResizeObservable: Observable<Engine>;
  42042. /**
  42043. * Observable event triggered each time the canvas loses focus
  42044. */
  42045. onCanvasBlurObservable: Observable<Engine>;
  42046. /**
  42047. * Observable event triggered each time the canvas gains focus
  42048. */
  42049. onCanvasFocusObservable: Observable<Engine>;
  42050. /**
  42051. * Observable event triggered each time the canvas receives pointerout event
  42052. */
  42053. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42054. /**
  42055. * Observable raised when the engine begins a new frame
  42056. */
  42057. onBeginFrameObservable: Observable<Engine>;
  42058. /**
  42059. * If set, will be used to request the next animation frame for the render loop
  42060. */
  42061. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42062. /**
  42063. * Observable raised when the engine ends the current frame
  42064. */
  42065. onEndFrameObservable: Observable<Engine>;
  42066. /**
  42067. * Observable raised when the engine is about to compile a shader
  42068. */
  42069. onBeforeShaderCompilationObservable: Observable<Engine>;
  42070. /**
  42071. * Observable raised when the engine has jsut compiled a shader
  42072. */
  42073. onAfterShaderCompilationObservable: Observable<Engine>;
  42074. /**
  42075. * Gets the audio engine
  42076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42077. * @ignorenaming
  42078. */
  42079. static audioEngine: IAudioEngine;
  42080. /**
  42081. * Default AudioEngine factory responsible of creating the Audio Engine.
  42082. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42083. */
  42084. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42085. /**
  42086. * Default offline support factory responsible of creating a tool used to store data locally.
  42087. * By default, this will create a Database object if the workload has been embedded.
  42088. */
  42089. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42090. private _loadingScreen;
  42091. private _pointerLockRequested;
  42092. private _rescalePostProcess;
  42093. private _deterministicLockstep;
  42094. private _lockstepMaxSteps;
  42095. private _timeStep;
  42096. protected get _supportsHardwareTextureRescaling(): boolean;
  42097. private _fps;
  42098. private _deltaTime;
  42099. /** @hidden */
  42100. _drawCalls: PerfCounter;
  42101. /** 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 */
  42102. canvasTabIndex: number;
  42103. /**
  42104. * Turn this value on if you want to pause FPS computation when in background
  42105. */
  42106. disablePerformanceMonitorInBackground: boolean;
  42107. private _performanceMonitor;
  42108. /**
  42109. * Gets the performance monitor attached to this engine
  42110. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42111. */
  42112. get performanceMonitor(): PerformanceMonitor;
  42113. private _onFocus;
  42114. private _onBlur;
  42115. private _onCanvasPointerOut;
  42116. private _onCanvasBlur;
  42117. private _onCanvasFocus;
  42118. private _onFullscreenChange;
  42119. private _onPointerLockChange;
  42120. /**
  42121. * Gets the HTML element used to attach event listeners
  42122. * @returns a HTML element
  42123. */
  42124. getInputElement(): Nullable<HTMLElement>;
  42125. /**
  42126. * Creates a new engine
  42127. * @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
  42128. * @param antialias defines enable antialiasing (default: false)
  42129. * @param options defines further options to be sent to the getContext() function
  42130. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42131. */
  42132. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42133. /**
  42134. * Gets current aspect ratio
  42135. * @param viewportOwner defines the camera to use to get the aspect ratio
  42136. * @param useScreen defines if screen size must be used (or the current render target if any)
  42137. * @returns a number defining the aspect ratio
  42138. */
  42139. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42140. /**
  42141. * Gets current screen aspect ratio
  42142. * @returns a number defining the aspect ratio
  42143. */
  42144. getScreenAspectRatio(): number;
  42145. /**
  42146. * Gets the client rect of the HTML canvas attached with the current webGL context
  42147. * @returns a client rectanglee
  42148. */
  42149. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42150. /**
  42151. * Gets the client rect of the HTML element used for events
  42152. * @returns a client rectanglee
  42153. */
  42154. getInputElementClientRect(): Nullable<ClientRect>;
  42155. /**
  42156. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42157. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42158. * @returns true if engine is in deterministic lock step mode
  42159. */
  42160. isDeterministicLockStep(): boolean;
  42161. /**
  42162. * Gets the max steps when engine is running in deterministic lock step
  42163. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42164. * @returns the max steps
  42165. */
  42166. getLockstepMaxSteps(): number;
  42167. /**
  42168. * Returns the time in ms between steps when using deterministic lock step.
  42169. * @returns time step in (ms)
  42170. */
  42171. getTimeStep(): number;
  42172. /**
  42173. * Force the mipmap generation for the given render target texture
  42174. * @param texture defines the render target texture to use
  42175. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42176. */
  42177. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42178. /** States */
  42179. /**
  42180. * Set various states to the webGL context
  42181. * @param culling defines backface culling state
  42182. * @param zOffset defines the value to apply to zOffset (0 by default)
  42183. * @param force defines if states must be applied even if cache is up to date
  42184. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42185. */
  42186. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42187. /**
  42188. * Set the z offset to apply to current rendering
  42189. * @param value defines the offset to apply
  42190. */
  42191. setZOffset(value: number): void;
  42192. /**
  42193. * Gets the current value of the zOffset
  42194. * @returns the current zOffset state
  42195. */
  42196. getZOffset(): number;
  42197. /**
  42198. * Enable or disable depth buffering
  42199. * @param enable defines the state to set
  42200. */
  42201. setDepthBuffer(enable: boolean): void;
  42202. /**
  42203. * Gets a boolean indicating if depth writing is enabled
  42204. * @returns the current depth writing state
  42205. */
  42206. getDepthWrite(): boolean;
  42207. /**
  42208. * Enable or disable depth writing
  42209. * @param enable defines the state to set
  42210. */
  42211. setDepthWrite(enable: boolean): void;
  42212. /**
  42213. * Gets a boolean indicating if stencil buffer is enabled
  42214. * @returns the current stencil buffer state
  42215. */
  42216. getStencilBuffer(): boolean;
  42217. /**
  42218. * Enable or disable the stencil buffer
  42219. * @param enable defines if the stencil buffer must be enabled or disabled
  42220. */
  42221. setStencilBuffer(enable: boolean): void;
  42222. /**
  42223. * Gets the current stencil mask
  42224. * @returns a number defining the new stencil mask to use
  42225. */
  42226. getStencilMask(): number;
  42227. /**
  42228. * Sets the current stencil mask
  42229. * @param mask defines the new stencil mask to use
  42230. */
  42231. setStencilMask(mask: number): void;
  42232. /**
  42233. * Gets the current stencil function
  42234. * @returns a number defining the stencil function to use
  42235. */
  42236. getStencilFunction(): number;
  42237. /**
  42238. * Gets the current stencil reference value
  42239. * @returns a number defining the stencil reference value to use
  42240. */
  42241. getStencilFunctionReference(): number;
  42242. /**
  42243. * Gets the current stencil mask
  42244. * @returns a number defining the stencil mask to use
  42245. */
  42246. getStencilFunctionMask(): number;
  42247. /**
  42248. * Sets the current stencil function
  42249. * @param stencilFunc defines the new stencil function to use
  42250. */
  42251. setStencilFunction(stencilFunc: number): void;
  42252. /**
  42253. * Sets the current stencil reference
  42254. * @param reference defines the new stencil reference to use
  42255. */
  42256. setStencilFunctionReference(reference: number): void;
  42257. /**
  42258. * Sets the current stencil mask
  42259. * @param mask defines the new stencil mask to use
  42260. */
  42261. setStencilFunctionMask(mask: number): void;
  42262. /**
  42263. * Gets the current stencil operation when stencil fails
  42264. * @returns a number defining stencil operation to use when stencil fails
  42265. */
  42266. getStencilOperationFail(): number;
  42267. /**
  42268. * Gets the current stencil operation when depth fails
  42269. * @returns a number defining stencil operation to use when depth fails
  42270. */
  42271. getStencilOperationDepthFail(): number;
  42272. /**
  42273. * Gets the current stencil operation when stencil passes
  42274. * @returns a number defining stencil operation to use when stencil passes
  42275. */
  42276. getStencilOperationPass(): number;
  42277. /**
  42278. * Sets the stencil operation to use when stencil fails
  42279. * @param operation defines the stencil operation to use when stencil fails
  42280. */
  42281. setStencilOperationFail(operation: number): void;
  42282. /**
  42283. * Sets the stencil operation to use when depth fails
  42284. * @param operation defines the stencil operation to use when depth fails
  42285. */
  42286. setStencilOperationDepthFail(operation: number): void;
  42287. /**
  42288. * Sets the stencil operation to use when stencil passes
  42289. * @param operation defines the stencil operation to use when stencil passes
  42290. */
  42291. setStencilOperationPass(operation: number): void;
  42292. /**
  42293. * Sets a boolean indicating if the dithering state is enabled or disabled
  42294. * @param value defines the dithering state
  42295. */
  42296. setDitheringState(value: boolean): void;
  42297. /**
  42298. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42299. * @param value defines the rasterizer state
  42300. */
  42301. setRasterizerState(value: boolean): void;
  42302. /**
  42303. * Gets the current depth function
  42304. * @returns a number defining the depth function
  42305. */
  42306. getDepthFunction(): Nullable<number>;
  42307. /**
  42308. * Sets the current depth function
  42309. * @param depthFunc defines the function to use
  42310. */
  42311. setDepthFunction(depthFunc: number): void;
  42312. /**
  42313. * Sets the current depth function to GREATER
  42314. */
  42315. setDepthFunctionToGreater(): void;
  42316. /**
  42317. * Sets the current depth function to GEQUAL
  42318. */
  42319. setDepthFunctionToGreaterOrEqual(): void;
  42320. /**
  42321. * Sets the current depth function to LESS
  42322. */
  42323. setDepthFunctionToLess(): void;
  42324. /**
  42325. * Sets the current depth function to LEQUAL
  42326. */
  42327. setDepthFunctionToLessOrEqual(): void;
  42328. private _cachedStencilBuffer;
  42329. private _cachedStencilFunction;
  42330. private _cachedStencilMask;
  42331. private _cachedStencilOperationPass;
  42332. private _cachedStencilOperationFail;
  42333. private _cachedStencilOperationDepthFail;
  42334. private _cachedStencilReference;
  42335. /**
  42336. * Caches the the state of the stencil buffer
  42337. */
  42338. cacheStencilState(): void;
  42339. /**
  42340. * Restores the state of the stencil buffer
  42341. */
  42342. restoreStencilState(): void;
  42343. /**
  42344. * Directly set the WebGL Viewport
  42345. * @param x defines the x coordinate of the viewport (in screen space)
  42346. * @param y defines the y coordinate of the viewport (in screen space)
  42347. * @param width defines the width of the viewport (in screen space)
  42348. * @param height defines the height of the viewport (in screen space)
  42349. * @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
  42350. */
  42351. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42352. /**
  42353. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42354. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42355. * @param y defines the y-coordinate of the corner of the clear rectangle
  42356. * @param width defines the width of the clear rectangle
  42357. * @param height defines the height of the clear rectangle
  42358. * @param clearColor defines the clear color
  42359. */
  42360. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42361. /**
  42362. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42363. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42364. * @param y defines the y-coordinate of the corner of the clear rectangle
  42365. * @param width defines the width of the clear rectangle
  42366. * @param height defines the height of the clear rectangle
  42367. */
  42368. enableScissor(x: number, y: number, width: number, height: number): void;
  42369. /**
  42370. * Disable previously set scissor test rectangle
  42371. */
  42372. disableScissor(): void;
  42373. protected _reportDrawCall(): void;
  42374. /**
  42375. * Initializes a webVR display and starts listening to display change events
  42376. * The onVRDisplayChangedObservable will be notified upon these changes
  42377. * @returns The onVRDisplayChangedObservable
  42378. */
  42379. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42380. /** @hidden */
  42381. _prepareVRComponent(): void;
  42382. /** @hidden */
  42383. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42384. /** @hidden */
  42385. _submitVRFrame(): void;
  42386. /**
  42387. * Call this function to leave webVR mode
  42388. * Will do nothing if webVR is not supported or if there is no webVR device
  42389. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42390. */
  42391. disableVR(): void;
  42392. /**
  42393. * Gets a boolean indicating that the system is in VR mode and is presenting
  42394. * @returns true if VR mode is engaged
  42395. */
  42396. isVRPresenting(): boolean;
  42397. /** @hidden */
  42398. _requestVRFrame(): void;
  42399. /** @hidden */
  42400. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42401. /**
  42402. * Gets the source code of the vertex shader associated with a specific webGL program
  42403. * @param program defines the program to use
  42404. * @returns a string containing the source code of the vertex shader associated with the program
  42405. */
  42406. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42407. /**
  42408. * Gets the source code of the fragment shader associated with a specific webGL program
  42409. * @param program defines the program to use
  42410. * @returns a string containing the source code of the fragment shader associated with the program
  42411. */
  42412. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42413. /**
  42414. * Sets a depth stencil texture from a render target to the according uniform.
  42415. * @param channel The texture channel
  42416. * @param uniform The uniform to set
  42417. * @param texture The render target texture containing the depth stencil texture to apply
  42418. */
  42419. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42420. /**
  42421. * Sets a texture to the webGL context from a postprocess
  42422. * @param channel defines the channel to use
  42423. * @param postProcess defines the source postprocess
  42424. */
  42425. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42426. /**
  42427. * Binds the output of the passed in post process to the texture channel specified
  42428. * @param channel The channel the texture should be bound to
  42429. * @param postProcess The post process which's output should be bound
  42430. */
  42431. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42432. protected _rebuildBuffers(): void;
  42433. /** @hidden */
  42434. _renderFrame(): void;
  42435. _renderLoop(): void;
  42436. /** @hidden */
  42437. _renderViews(): boolean;
  42438. /**
  42439. * Toggle full screen mode
  42440. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42441. */
  42442. switchFullscreen(requestPointerLock: boolean): void;
  42443. /**
  42444. * Enters full screen mode
  42445. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42446. */
  42447. enterFullscreen(requestPointerLock: boolean): void;
  42448. /**
  42449. * Exits full screen mode
  42450. */
  42451. exitFullscreen(): void;
  42452. /**
  42453. * Enters Pointerlock mode
  42454. */
  42455. enterPointerlock(): void;
  42456. /**
  42457. * Exits Pointerlock mode
  42458. */
  42459. exitPointerlock(): void;
  42460. /**
  42461. * Begin a new frame
  42462. */
  42463. beginFrame(): void;
  42464. /**
  42465. * Enf the current frame
  42466. */
  42467. endFrame(): void;
  42468. resize(): void;
  42469. /**
  42470. * Force a specific size of the canvas
  42471. * @param width defines the new canvas' width
  42472. * @param height defines the new canvas' height
  42473. * @returns true if the size was changed
  42474. */
  42475. setSize(width: number, height: number): boolean;
  42476. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42477. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42478. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42479. _releaseTexture(texture: InternalTexture): void;
  42480. /**
  42481. * @hidden
  42482. * Rescales a texture
  42483. * @param source input texutre
  42484. * @param destination destination texture
  42485. * @param scene scene to use to render the resize
  42486. * @param internalFormat format to use when resizing
  42487. * @param onComplete callback to be called when resize has completed
  42488. */
  42489. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42490. /**
  42491. * Gets the current framerate
  42492. * @returns a number representing the framerate
  42493. */
  42494. getFps(): number;
  42495. /**
  42496. * Gets the time spent between current and previous frame
  42497. * @returns a number representing the delta time in ms
  42498. */
  42499. getDeltaTime(): number;
  42500. private _measureFps;
  42501. /** @hidden */
  42502. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42503. /**
  42504. * Updates the sample count of a render target texture
  42505. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42506. * @param texture defines the texture to update
  42507. * @param samples defines the sample count to set
  42508. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42509. */
  42510. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42511. /**
  42512. * Updates a depth texture Comparison Mode and Function.
  42513. * If the comparison Function is equal to 0, the mode will be set to none.
  42514. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42515. * @param texture The texture to set the comparison function for
  42516. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42517. */
  42518. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42519. /**
  42520. * Creates a webGL buffer to use with instanciation
  42521. * @param capacity defines the size of the buffer
  42522. * @returns the webGL buffer
  42523. */
  42524. createInstancesBuffer(capacity: number): DataBuffer;
  42525. /**
  42526. * Delete a webGL buffer used with instanciation
  42527. * @param buffer defines the webGL buffer to delete
  42528. */
  42529. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42530. private _clientWaitAsync;
  42531. /** @hidden */
  42532. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42533. dispose(): void;
  42534. private _disableTouchAction;
  42535. /**
  42536. * Display the loading screen
  42537. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42538. */
  42539. displayLoadingUI(): void;
  42540. /**
  42541. * Hide the loading screen
  42542. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42543. */
  42544. hideLoadingUI(): void;
  42545. /**
  42546. * Gets the current loading screen object
  42547. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42548. */
  42549. get loadingScreen(): ILoadingScreen;
  42550. /**
  42551. * Sets the current loading screen object
  42552. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42553. */
  42554. set loadingScreen(loadingScreen: ILoadingScreen);
  42555. /**
  42556. * Sets the current loading screen text
  42557. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42558. */
  42559. set loadingUIText(text: string);
  42560. /**
  42561. * Sets the current loading screen background color
  42562. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42563. */
  42564. set loadingUIBackgroundColor(color: string);
  42565. /** Pointerlock and fullscreen */
  42566. /**
  42567. * Ask the browser to promote the current element to pointerlock mode
  42568. * @param element defines the DOM element to promote
  42569. */
  42570. static _RequestPointerlock(element: HTMLElement): void;
  42571. /**
  42572. * Asks the browser to exit pointerlock mode
  42573. */
  42574. static _ExitPointerlock(): void;
  42575. /**
  42576. * Ask the browser to promote the current element to fullscreen rendering mode
  42577. * @param element defines the DOM element to promote
  42578. */
  42579. static _RequestFullscreen(element: HTMLElement): void;
  42580. /**
  42581. * Asks the browser to exit fullscreen mode
  42582. */
  42583. static _ExitFullscreen(): void;
  42584. }
  42585. }
  42586. declare module "babylonjs/Engines/engineStore" {
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Engine } from "babylonjs/Engines/engine";
  42589. import { Scene } from "babylonjs/scene";
  42590. /**
  42591. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42592. * during the life time of the application.
  42593. */
  42594. export class EngineStore {
  42595. /** Gets the list of created engines */
  42596. static Instances: import("babylonjs/Engines/engine").Engine[];
  42597. /** @hidden */
  42598. static _LastCreatedScene: Nullable<Scene>;
  42599. /**
  42600. * Gets the latest created engine
  42601. */
  42602. static get LastCreatedEngine(): Nullable<Engine>;
  42603. /**
  42604. * Gets the latest created scene
  42605. */
  42606. static get LastCreatedScene(): Nullable<Scene>;
  42607. /**
  42608. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42609. * @ignorenaming
  42610. */
  42611. static UseFallbackTexture: boolean;
  42612. /**
  42613. * Texture content used if a texture cannot loaded
  42614. * @ignorenaming
  42615. */
  42616. static FallbackTexture: string;
  42617. }
  42618. }
  42619. declare module "babylonjs/Misc/promise" {
  42620. /**
  42621. * Helper class that provides a small promise polyfill
  42622. */
  42623. export class PromisePolyfill {
  42624. /**
  42625. * Static function used to check if the polyfill is required
  42626. * If this is the case then the function will inject the polyfill to window.Promise
  42627. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42628. */
  42629. static Apply(force?: boolean): void;
  42630. }
  42631. }
  42632. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42633. /**
  42634. * Interface for screenshot methods with describe argument called `size` as object with options
  42635. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42636. */
  42637. export interface IScreenshotSize {
  42638. /**
  42639. * number in pixels for canvas height
  42640. */
  42641. height?: number;
  42642. /**
  42643. * multiplier allowing render at a higher or lower resolution
  42644. * If value is defined then height and width will be ignored and taken from camera
  42645. */
  42646. precision?: number;
  42647. /**
  42648. * number in pixels for canvas width
  42649. */
  42650. width?: number;
  42651. }
  42652. }
  42653. declare module "babylonjs/Misc/tools" {
  42654. import { Nullable, float } from "babylonjs/types";
  42655. import { DomManagement } from "babylonjs/Misc/domManagement";
  42656. import { WebRequest } from "babylonjs/Misc/webRequest";
  42657. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42658. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42659. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42660. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42661. import { Camera } from "babylonjs/Cameras/camera";
  42662. import { Engine } from "babylonjs/Engines/engine";
  42663. interface IColor4Like {
  42664. r: float;
  42665. g: float;
  42666. b: float;
  42667. a: float;
  42668. }
  42669. /**
  42670. * Class containing a set of static utilities functions
  42671. */
  42672. export class Tools {
  42673. /**
  42674. * Gets or sets the base URL to use to load assets
  42675. */
  42676. static get BaseUrl(): string;
  42677. static set BaseUrl(value: string);
  42678. /**
  42679. * Enable/Disable Custom HTTP Request Headers globally.
  42680. * default = false
  42681. * @see CustomRequestHeaders
  42682. */
  42683. static UseCustomRequestHeaders: boolean;
  42684. /**
  42685. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42686. * i.e. when loading files, where the server/service expects an Authorization header
  42687. */
  42688. static CustomRequestHeaders: {
  42689. [key: string]: string;
  42690. };
  42691. /**
  42692. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42693. */
  42694. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42695. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42696. /**
  42697. * Default behaviour for cors in the application.
  42698. * It can be a string if the expected behavior is identical in the entire app.
  42699. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42700. */
  42701. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42702. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42703. /**
  42704. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42705. * @ignorenaming
  42706. */
  42707. static get UseFallbackTexture(): boolean;
  42708. static set UseFallbackTexture(value: boolean);
  42709. /**
  42710. * Use this object to register external classes like custom textures or material
  42711. * to allow the laoders to instantiate them
  42712. */
  42713. static get RegisteredExternalClasses(): {
  42714. [key: string]: Object;
  42715. };
  42716. static set RegisteredExternalClasses(classes: {
  42717. [key: string]: Object;
  42718. });
  42719. /**
  42720. * Texture content used if a texture cannot loaded
  42721. * @ignorenaming
  42722. */
  42723. static get fallbackTexture(): string;
  42724. static set fallbackTexture(value: string);
  42725. /**
  42726. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42727. * @param u defines the coordinate on X axis
  42728. * @param v defines the coordinate on Y axis
  42729. * @param width defines the width of the source data
  42730. * @param height defines the height of the source data
  42731. * @param pixels defines the source byte array
  42732. * @param color defines the output color
  42733. */
  42734. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42735. /**
  42736. * Interpolates between a and b via alpha
  42737. * @param a The lower value (returned when alpha = 0)
  42738. * @param b The upper value (returned when alpha = 1)
  42739. * @param alpha The interpolation-factor
  42740. * @return The mixed value
  42741. */
  42742. static Mix(a: number, b: number, alpha: number): number;
  42743. /**
  42744. * Tries to instantiate a new object from a given class name
  42745. * @param className defines the class name to instantiate
  42746. * @returns the new object or null if the system was not able to do the instantiation
  42747. */
  42748. static Instantiate(className: string): any;
  42749. /**
  42750. * Provides a slice function that will work even on IE
  42751. * @param data defines the array to slice
  42752. * @param start defines the start of the data (optional)
  42753. * @param end defines the end of the data (optional)
  42754. * @returns the new sliced array
  42755. */
  42756. static Slice<T>(data: T, start?: number, end?: number): T;
  42757. /**
  42758. * Polyfill for setImmediate
  42759. * @param action defines the action to execute after the current execution block
  42760. */
  42761. static SetImmediate(action: () => void): void;
  42762. /**
  42763. * Function indicating if a number is an exponent of 2
  42764. * @param value defines the value to test
  42765. * @returns true if the value is an exponent of 2
  42766. */
  42767. static IsExponentOfTwo(value: number): boolean;
  42768. private static _tmpFloatArray;
  42769. /**
  42770. * Returns the nearest 32-bit single precision float representation of a Number
  42771. * @param value A Number. If the parameter is of a different type, it will get converted
  42772. * to a number or to NaN if it cannot be converted
  42773. * @returns number
  42774. */
  42775. static FloatRound(value: number): number;
  42776. /**
  42777. * Extracts the filename from a path
  42778. * @param path defines the path to use
  42779. * @returns the filename
  42780. */
  42781. static GetFilename(path: string): string;
  42782. /**
  42783. * Extracts the "folder" part of a path (everything before the filename).
  42784. * @param uri The URI to extract the info from
  42785. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42786. * @returns The "folder" part of the path
  42787. */
  42788. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42789. /**
  42790. * Extracts text content from a DOM element hierarchy
  42791. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42792. */
  42793. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42794. /**
  42795. * Convert an angle in radians to degrees
  42796. * @param angle defines the angle to convert
  42797. * @returns the angle in degrees
  42798. */
  42799. static ToDegrees(angle: number): number;
  42800. /**
  42801. * Convert an angle in degrees to radians
  42802. * @param angle defines the angle to convert
  42803. * @returns the angle in radians
  42804. */
  42805. static ToRadians(angle: number): number;
  42806. /**
  42807. * Returns an array if obj is not an array
  42808. * @param obj defines the object to evaluate as an array
  42809. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42810. * @returns either obj directly if obj is an array or a new array containing obj
  42811. */
  42812. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42813. /**
  42814. * Gets the pointer prefix to use
  42815. * @param engine defines the engine we are finding the prefix for
  42816. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42817. */
  42818. static GetPointerPrefix(engine: Engine): string;
  42819. /**
  42820. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42821. * @param url define the url we are trying
  42822. * @param element define the dom element where to configure the cors policy
  42823. */
  42824. static SetCorsBehavior(url: string | string[], element: {
  42825. crossOrigin: string | null;
  42826. }): void;
  42827. /**
  42828. * Removes unwanted characters from an url
  42829. * @param url defines the url to clean
  42830. * @returns the cleaned url
  42831. */
  42832. static CleanUrl(url: string): string;
  42833. /**
  42834. * Gets or sets a function used to pre-process url before using them to load assets
  42835. */
  42836. static get PreprocessUrl(): (url: string) => string;
  42837. static set PreprocessUrl(processor: (url: string) => string);
  42838. /**
  42839. * Loads an image as an HTMLImageElement.
  42840. * @param input url string, ArrayBuffer, or Blob to load
  42841. * @param onLoad callback called when the image successfully loads
  42842. * @param onError callback called when the image fails to load
  42843. * @param offlineProvider offline provider for caching
  42844. * @param mimeType optional mime type
  42845. * @returns the HTMLImageElement of the loaded image
  42846. */
  42847. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42848. /**
  42849. * Loads a file from a url
  42850. * @param url url string, ArrayBuffer, or Blob to load
  42851. * @param onSuccess callback called when the file successfully loads
  42852. * @param onProgress callback called while file is loading (if the server supports this mode)
  42853. * @param offlineProvider defines the offline provider for caching
  42854. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42855. * @param onError callback called when the file fails to load
  42856. * @returns a file request object
  42857. */
  42858. 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;
  42859. /**
  42860. * Loads a file from a url
  42861. * @param url the file url to load
  42862. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42863. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42864. */
  42865. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42866. /**
  42867. * Load a script (identified by an url). When the url returns, the
  42868. * content of this file is added into a new script element, attached to the DOM (body element)
  42869. * @param scriptUrl defines the url of the script to laod
  42870. * @param onSuccess defines the callback called when the script is loaded
  42871. * @param onError defines the callback to call if an error occurs
  42872. * @param scriptId defines the id of the script element
  42873. */
  42874. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42875. /**
  42876. * Load an asynchronous script (identified by an url). When the url returns, the
  42877. * content of this file is added into a new script element, attached to the DOM (body element)
  42878. * @param scriptUrl defines the url of the script to laod
  42879. * @param scriptId defines the id of the script element
  42880. * @returns a promise request object
  42881. */
  42882. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42883. /**
  42884. * Loads a file from a blob
  42885. * @param fileToLoad defines the blob to use
  42886. * @param callback defines the callback to call when data is loaded
  42887. * @param progressCallback defines the callback to call during loading process
  42888. * @returns a file request object
  42889. */
  42890. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42891. /**
  42892. * Reads a file from a File object
  42893. * @param file defines the file to load
  42894. * @param onSuccess defines the callback to call when data is loaded
  42895. * @param onProgress defines the callback to call during loading process
  42896. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42897. * @param onError defines the callback to call when an error occurs
  42898. * @returns a file request object
  42899. */
  42900. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42901. /**
  42902. * Creates a data url from a given string content
  42903. * @param content defines the content to convert
  42904. * @returns the new data url link
  42905. */
  42906. static FileAsURL(content: string): string;
  42907. /**
  42908. * Format the given number to a specific decimal format
  42909. * @param value defines the number to format
  42910. * @param decimals defines the number of decimals to use
  42911. * @returns the formatted string
  42912. */
  42913. static Format(value: number, decimals?: number): string;
  42914. /**
  42915. * Tries to copy an object by duplicating every property
  42916. * @param source defines the source object
  42917. * @param destination defines the target object
  42918. * @param doNotCopyList defines a list of properties to avoid
  42919. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42920. */
  42921. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42922. /**
  42923. * Gets a boolean indicating if the given object has no own property
  42924. * @param obj defines the object to test
  42925. * @returns true if object has no own property
  42926. */
  42927. static IsEmpty(obj: any): boolean;
  42928. /**
  42929. * Function used to register events at window level
  42930. * @param windowElement defines the Window object to use
  42931. * @param events defines the events to register
  42932. */
  42933. static RegisterTopRootEvents(windowElement: Window, events: {
  42934. name: string;
  42935. handler: Nullable<(e: FocusEvent) => any>;
  42936. }[]): void;
  42937. /**
  42938. * Function used to unregister events from window level
  42939. * @param windowElement defines the Window object to use
  42940. * @param events defines the events to unregister
  42941. */
  42942. static UnregisterTopRootEvents(windowElement: Window, events: {
  42943. name: string;
  42944. handler: Nullable<(e: FocusEvent) => any>;
  42945. }[]): void;
  42946. /**
  42947. * @ignore
  42948. */
  42949. static _ScreenshotCanvas: HTMLCanvasElement;
  42950. /**
  42951. * Dumps the current bound framebuffer
  42952. * @param width defines the rendering width
  42953. * @param height defines the rendering height
  42954. * @param engine defines the hosting engine
  42955. * @param successCallback defines the callback triggered once the data are available
  42956. * @param mimeType defines the mime type of the result
  42957. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42958. */
  42959. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42960. /**
  42961. * Converts the canvas data to blob.
  42962. * This acts as a polyfill for browsers not supporting the to blob function.
  42963. * @param canvas Defines the canvas to extract the data from
  42964. * @param successCallback Defines the callback triggered once the data are available
  42965. * @param mimeType Defines the mime type of the result
  42966. */
  42967. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42968. /**
  42969. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42970. * @param successCallback defines the callback triggered once the data are available
  42971. * @param mimeType defines the mime type of the result
  42972. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42973. */
  42974. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42975. /**
  42976. * Downloads a blob in the browser
  42977. * @param blob defines the blob to download
  42978. * @param fileName defines the name of the downloaded file
  42979. */
  42980. static Download(blob: Blob, fileName: string): void;
  42981. /**
  42982. * Captures a screenshot of the current rendering
  42983. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42984. * @param engine defines the rendering engine
  42985. * @param camera defines the source camera
  42986. * @param size This parameter can be set to a single number or to an object with the
  42987. * following (optional) properties: precision, width, height. If a single number is passed,
  42988. * it will be used for both width and height. If an object is passed, the screenshot size
  42989. * will be derived from the parameters. The precision property is a multiplier allowing
  42990. * rendering at a higher or lower resolution
  42991. * @param successCallback defines the callback receives a single parameter which contains the
  42992. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42993. * src parameter of an <img> to display it
  42994. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42995. * Check your browser for supported MIME types
  42996. */
  42997. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42998. /**
  42999. * Captures a screenshot of the current rendering
  43000. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43001. * @param engine defines the rendering engine
  43002. * @param camera defines the source camera
  43003. * @param size This parameter can be set to a single number or to an object with the
  43004. * following (optional) properties: precision, width, height. If a single number is passed,
  43005. * it will be used for both width and height. If an object is passed, the screenshot size
  43006. * will be derived from the parameters. The precision property is a multiplier allowing
  43007. * rendering at a higher or lower resolution
  43008. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43009. * Check your browser for supported MIME types
  43010. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43011. * to the src parameter of an <img> to display it
  43012. */
  43013. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43014. /**
  43015. * Generates an image screenshot from the specified camera.
  43016. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43017. * @param engine The engine to use for rendering
  43018. * @param camera The camera to use for rendering
  43019. * @param size This parameter can be set to a single number or to an object with the
  43020. * following (optional) properties: precision, width, height. If a single number is passed,
  43021. * it will be used for both width and height. If an object is passed, the screenshot size
  43022. * will be derived from the parameters. The precision property is a multiplier allowing
  43023. * rendering at a higher or lower resolution
  43024. * @param successCallback The callback receives a single parameter which contains the
  43025. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43026. * src parameter of an <img> to display it
  43027. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43028. * Check your browser for supported MIME types
  43029. * @param samples Texture samples (default: 1)
  43030. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43031. * @param fileName A name for for the downloaded file.
  43032. */
  43033. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43034. /**
  43035. * Generates an image screenshot from the specified camera.
  43036. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43037. * @param engine The engine to use for rendering
  43038. * @param camera The camera to use for rendering
  43039. * @param size This parameter can be set to a single number or to an object with the
  43040. * following (optional) properties: precision, width, height. If a single number is passed,
  43041. * it will be used for both width and height. If an object is passed, the screenshot size
  43042. * will be derived from the parameters. The precision property is a multiplier allowing
  43043. * rendering at a higher or lower resolution
  43044. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43045. * Check your browser for supported MIME types
  43046. * @param samples Texture samples (default: 1)
  43047. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43048. * @param fileName A name for for the downloaded file.
  43049. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43050. * to the src parameter of an <img> to display it
  43051. */
  43052. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43053. /**
  43054. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43055. * Be aware Math.random() could cause collisions, but:
  43056. * "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"
  43057. * @returns a pseudo random id
  43058. */
  43059. static RandomId(): string;
  43060. /**
  43061. * Test if the given uri is a base64 string
  43062. * @param uri The uri to test
  43063. * @return True if the uri is a base64 string or false otherwise
  43064. */
  43065. static IsBase64(uri: string): boolean;
  43066. /**
  43067. * Decode the given base64 uri.
  43068. * @param uri The uri to decode
  43069. * @return The decoded base64 data.
  43070. */
  43071. static DecodeBase64(uri: string): ArrayBuffer;
  43072. /**
  43073. * Gets the absolute url.
  43074. * @param url the input url
  43075. * @return the absolute url
  43076. */
  43077. static GetAbsoluteUrl(url: string): string;
  43078. /**
  43079. * No log
  43080. */
  43081. static readonly NoneLogLevel: number;
  43082. /**
  43083. * Only message logs
  43084. */
  43085. static readonly MessageLogLevel: number;
  43086. /**
  43087. * Only warning logs
  43088. */
  43089. static readonly WarningLogLevel: number;
  43090. /**
  43091. * Only error logs
  43092. */
  43093. static readonly ErrorLogLevel: number;
  43094. /**
  43095. * All logs
  43096. */
  43097. static readonly AllLogLevel: number;
  43098. /**
  43099. * Gets a value indicating the number of loading errors
  43100. * @ignorenaming
  43101. */
  43102. static get errorsCount(): number;
  43103. /**
  43104. * Callback called when a new log is added
  43105. */
  43106. static OnNewCacheEntry: (entry: string) => void;
  43107. /**
  43108. * Log a message to the console
  43109. * @param message defines the message to log
  43110. */
  43111. static Log(message: string): void;
  43112. /**
  43113. * Write a warning message to the console
  43114. * @param message defines the message to log
  43115. */
  43116. static Warn(message: string): void;
  43117. /**
  43118. * Write an error message to the console
  43119. * @param message defines the message to log
  43120. */
  43121. static Error(message: string): void;
  43122. /**
  43123. * Gets current log cache (list of logs)
  43124. */
  43125. static get LogCache(): string;
  43126. /**
  43127. * Clears the log cache
  43128. */
  43129. static ClearLogCache(): void;
  43130. /**
  43131. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43132. */
  43133. static set LogLevels(level: number);
  43134. /**
  43135. * Checks if the window object exists
  43136. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43137. */
  43138. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43139. /**
  43140. * No performance log
  43141. */
  43142. static readonly PerformanceNoneLogLevel: number;
  43143. /**
  43144. * Use user marks to log performance
  43145. */
  43146. static readonly PerformanceUserMarkLogLevel: number;
  43147. /**
  43148. * Log performance to the console
  43149. */
  43150. static readonly PerformanceConsoleLogLevel: number;
  43151. private static _performance;
  43152. /**
  43153. * Sets the current performance log level
  43154. */
  43155. static set PerformanceLogLevel(level: number);
  43156. private static _StartPerformanceCounterDisabled;
  43157. private static _EndPerformanceCounterDisabled;
  43158. private static _StartUserMark;
  43159. private static _EndUserMark;
  43160. private static _StartPerformanceConsole;
  43161. private static _EndPerformanceConsole;
  43162. /**
  43163. * Starts a performance counter
  43164. */
  43165. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43166. /**
  43167. * Ends a specific performance coutner
  43168. */
  43169. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43170. /**
  43171. * Gets either window.performance.now() if supported or Date.now() else
  43172. */
  43173. static get Now(): number;
  43174. /**
  43175. * This method will return the name of the class used to create the instance of the given object.
  43176. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43177. * @param object the object to get the class name from
  43178. * @param isType defines if the object is actually a type
  43179. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43180. */
  43181. static GetClassName(object: any, isType?: boolean): string;
  43182. /**
  43183. * Gets the first element of an array satisfying a given predicate
  43184. * @param array defines the array to browse
  43185. * @param predicate defines the predicate to use
  43186. * @returns null if not found or the element
  43187. */
  43188. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43189. /**
  43190. * This method will return the name of the full name of the class, including its owning module (if any).
  43191. * 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).
  43192. * @param object the object to get the class name from
  43193. * @param isType defines if the object is actually a type
  43194. * @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.
  43195. * @ignorenaming
  43196. */
  43197. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43198. /**
  43199. * Returns a promise that resolves after the given amount of time.
  43200. * @param delay Number of milliseconds to delay
  43201. * @returns Promise that resolves after the given amount of time
  43202. */
  43203. static DelayAsync(delay: number): Promise<void>;
  43204. /**
  43205. * Utility function to detect if the current user agent is Safari
  43206. * @returns whether or not the current user agent is safari
  43207. */
  43208. static IsSafari(): boolean;
  43209. }
  43210. /**
  43211. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43212. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43213. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43214. * @param name The name of the class, case should be preserved
  43215. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43216. */
  43217. export function className(name: string, module?: string): (target: Object) => void;
  43218. /**
  43219. * An implementation of a loop for asynchronous functions.
  43220. */
  43221. export class AsyncLoop {
  43222. /**
  43223. * Defines the number of iterations for the loop
  43224. */
  43225. iterations: number;
  43226. /**
  43227. * Defines the current index of the loop.
  43228. */
  43229. index: number;
  43230. private _done;
  43231. private _fn;
  43232. private _successCallback;
  43233. /**
  43234. * Constructor.
  43235. * @param iterations the number of iterations.
  43236. * @param func the function to run each iteration
  43237. * @param successCallback the callback that will be called upon succesful execution
  43238. * @param offset starting offset.
  43239. */
  43240. constructor(
  43241. /**
  43242. * Defines the number of iterations for the loop
  43243. */
  43244. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43245. /**
  43246. * Execute the next iteration. Must be called after the last iteration was finished.
  43247. */
  43248. executeNext(): void;
  43249. /**
  43250. * Break the loop and run the success callback.
  43251. */
  43252. breakLoop(): void;
  43253. /**
  43254. * Create and run an async loop.
  43255. * @param iterations the number of iterations.
  43256. * @param fn the function to run each iteration
  43257. * @param successCallback the callback that will be called upon succesful execution
  43258. * @param offset starting offset.
  43259. * @returns the created async loop object
  43260. */
  43261. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43262. /**
  43263. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43264. * @param iterations total number of iterations
  43265. * @param syncedIterations number of synchronous iterations in each async iteration.
  43266. * @param fn the function to call each iteration.
  43267. * @param callback a success call back that will be called when iterating stops.
  43268. * @param breakFunction a break condition (optional)
  43269. * @param timeout timeout settings for the setTimeout function. default - 0.
  43270. * @returns the created async loop object
  43271. */
  43272. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43273. }
  43274. }
  43275. declare module "babylonjs/Misc/stringDictionary" {
  43276. import { Nullable } from "babylonjs/types";
  43277. /**
  43278. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43279. * The underlying implementation relies on an associative array to ensure the best performances.
  43280. * The value can be anything including 'null' but except 'undefined'
  43281. */
  43282. export class StringDictionary<T> {
  43283. /**
  43284. * This will clear this dictionary and copy the content from the 'source' one.
  43285. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43286. * @param source the dictionary to take the content from and copy to this dictionary
  43287. */
  43288. copyFrom(source: StringDictionary<T>): void;
  43289. /**
  43290. * Get a value based from its key
  43291. * @param key the given key to get the matching value from
  43292. * @return the value if found, otherwise undefined is returned
  43293. */
  43294. get(key: string): T | undefined;
  43295. /**
  43296. * Get a value from its key or add it if it doesn't exist.
  43297. * This method will ensure you that a given key/data will be present in the dictionary.
  43298. * @param key the given key to get the matching value from
  43299. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43300. * The factory will only be invoked if there's no data for the given key.
  43301. * @return the value corresponding to the key.
  43302. */
  43303. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43304. /**
  43305. * Get a value from its key if present in the dictionary otherwise add it
  43306. * @param key the key to get the value from
  43307. * @param val if there's no such key/value pair in the dictionary add it with this value
  43308. * @return the value corresponding to the key
  43309. */
  43310. getOrAdd(key: string, val: T): T;
  43311. /**
  43312. * Check if there's a given key in the dictionary
  43313. * @param key the key to check for
  43314. * @return true if the key is present, false otherwise
  43315. */
  43316. contains(key: string): boolean;
  43317. /**
  43318. * Add a new key and its corresponding value
  43319. * @param key the key to add
  43320. * @param value the value corresponding to the key
  43321. * @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
  43322. */
  43323. add(key: string, value: T): boolean;
  43324. /**
  43325. * Update a specific value associated to a key
  43326. * @param key defines the key to use
  43327. * @param value defines the value to store
  43328. * @returns true if the value was updated (or false if the key was not found)
  43329. */
  43330. set(key: string, value: T): boolean;
  43331. /**
  43332. * Get the element of the given key and remove it from the dictionary
  43333. * @param key defines the key to search
  43334. * @returns the value associated with the key or null if not found
  43335. */
  43336. getAndRemove(key: string): Nullable<T>;
  43337. /**
  43338. * Remove a key/value from the dictionary.
  43339. * @param key the key to remove
  43340. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43341. */
  43342. remove(key: string): boolean;
  43343. /**
  43344. * Clear the whole content of the dictionary
  43345. */
  43346. clear(): void;
  43347. /**
  43348. * Gets the current count
  43349. */
  43350. get count(): number;
  43351. /**
  43352. * Execute a callback on each key/val of the dictionary.
  43353. * Note that you can remove any element in this dictionary in the callback implementation
  43354. * @param callback the callback to execute on a given key/value pair
  43355. */
  43356. forEach(callback: (key: string, val: T) => void): void;
  43357. /**
  43358. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43359. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43360. * Note that you can remove any element in this dictionary in the callback implementation
  43361. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43362. * @returns the first item
  43363. */
  43364. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43365. private _count;
  43366. private _data;
  43367. }
  43368. }
  43369. declare module "babylonjs/Collisions/collisionCoordinator" {
  43370. import { Nullable } from "babylonjs/types";
  43371. import { Scene } from "babylonjs/scene";
  43372. import { Vector3 } from "babylonjs/Maths/math.vector";
  43373. import { Collider } from "babylonjs/Collisions/collider";
  43374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43375. /** @hidden */
  43376. export interface ICollisionCoordinator {
  43377. createCollider(): Collider;
  43378. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43379. init(scene: Scene): void;
  43380. }
  43381. /** @hidden */
  43382. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43383. private _scene;
  43384. private _scaledPosition;
  43385. private _scaledVelocity;
  43386. private _finalPosition;
  43387. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43388. createCollider(): Collider;
  43389. init(scene: Scene): void;
  43390. private _collideWithWorld;
  43391. }
  43392. }
  43393. declare module "babylonjs/Inputs/scene.inputManager" {
  43394. import { Nullable } from "babylonjs/types";
  43395. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43396. import { Vector2 } from "babylonjs/Maths/math.vector";
  43397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43398. import { Scene } from "babylonjs/scene";
  43399. /**
  43400. * Class used to manage all inputs for the scene.
  43401. */
  43402. export class InputManager {
  43403. /** The distance in pixel that you have to move to prevent some events */
  43404. static DragMovementThreshold: number;
  43405. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43406. static LongPressDelay: number;
  43407. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43408. static DoubleClickDelay: number;
  43409. /** If you need to check double click without raising a single click at first click, enable this flag */
  43410. static ExclusiveDoubleClickMode: boolean;
  43411. /** 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. */
  43412. private _alreadyAttached;
  43413. private _wheelEventName;
  43414. private _onPointerMove;
  43415. private _onPointerDown;
  43416. private _onPointerUp;
  43417. private _initClickEvent;
  43418. private _initActionManager;
  43419. private _delayedSimpleClick;
  43420. private _delayedSimpleClickTimeout;
  43421. private _previousDelayedSimpleClickTimeout;
  43422. private _meshPickProceed;
  43423. private _previousButtonPressed;
  43424. private _currentPickResult;
  43425. private _previousPickResult;
  43426. private _totalPointersPressed;
  43427. private _doubleClickOccured;
  43428. private _pointerOverMesh;
  43429. private _pickedDownMesh;
  43430. private _pickedUpMesh;
  43431. private _pointerX;
  43432. private _pointerY;
  43433. private _unTranslatedPointerX;
  43434. private _unTranslatedPointerY;
  43435. private _startingPointerPosition;
  43436. private _previousStartingPointerPosition;
  43437. private _startingPointerTime;
  43438. private _previousStartingPointerTime;
  43439. private _pointerCaptures;
  43440. private _meshUnderPointerId;
  43441. private _onKeyDown;
  43442. private _onKeyUp;
  43443. private _onCanvasFocusObserver;
  43444. private _onCanvasBlurObserver;
  43445. private _scene;
  43446. /**
  43447. * Creates a new InputManager
  43448. * @param scene defines the hosting scene
  43449. */
  43450. constructor(scene: Scene);
  43451. /**
  43452. * Gets the mesh that is currently under the pointer
  43453. */
  43454. get meshUnderPointer(): Nullable<AbstractMesh>;
  43455. /**
  43456. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43457. * @param pointerId the pointer id to use
  43458. * @returns The mesh under this pointer id or null if not found
  43459. */
  43460. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43461. /**
  43462. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43463. */
  43464. get unTranslatedPointer(): Vector2;
  43465. /**
  43466. * Gets or sets the current on-screen X position of the pointer
  43467. */
  43468. get pointerX(): number;
  43469. set pointerX(value: number);
  43470. /**
  43471. * Gets or sets the current on-screen Y position of the pointer
  43472. */
  43473. get pointerY(): number;
  43474. set pointerY(value: number);
  43475. private _updatePointerPosition;
  43476. private _processPointerMove;
  43477. private _setRayOnPointerInfo;
  43478. private _checkPrePointerObservable;
  43479. /**
  43480. * Use this method to simulate a pointer move on a mesh
  43481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43484. */
  43485. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43486. /**
  43487. * Use this method to simulate a pointer down on a mesh
  43488. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43489. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43490. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43491. */
  43492. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43493. private _processPointerDown;
  43494. /** @hidden */
  43495. _isPointerSwiping(): boolean;
  43496. /**
  43497. * Use this method to simulate a pointer up on a mesh
  43498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43501. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43502. */
  43503. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43504. private _processPointerUp;
  43505. /**
  43506. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43507. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43508. * @returns true if the pointer was captured
  43509. */
  43510. isPointerCaptured(pointerId?: number): boolean;
  43511. /**
  43512. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43513. * @param attachUp defines if you want to attach events to pointerup
  43514. * @param attachDown defines if you want to attach events to pointerdown
  43515. * @param attachMove defines if you want to attach events to pointermove
  43516. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43517. */
  43518. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43519. /**
  43520. * Detaches all event handlers
  43521. */
  43522. detachControl(): void;
  43523. /**
  43524. * Force the value of meshUnderPointer
  43525. * @param mesh defines the mesh to use
  43526. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43527. */
  43528. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43529. /**
  43530. * Gets the mesh under the pointer
  43531. * @returns a Mesh or null if no mesh is under the pointer
  43532. */
  43533. getPointerOverMesh(): Nullable<AbstractMesh>;
  43534. }
  43535. }
  43536. declare module "babylonjs/Animations/animationGroup" {
  43537. import { Animatable } from "babylonjs/Animations/animatable";
  43538. import { Animation } from "babylonjs/Animations/animation";
  43539. import { Scene, IDisposable } from "babylonjs/scene";
  43540. import { Observable } from "babylonjs/Misc/observable";
  43541. import { Nullable } from "babylonjs/types";
  43542. import "babylonjs/Animations/animatable";
  43543. /**
  43544. * This class defines the direct association between an animation and a target
  43545. */
  43546. export class TargetedAnimation {
  43547. /**
  43548. * Animation to perform
  43549. */
  43550. animation: Animation;
  43551. /**
  43552. * Target to animate
  43553. */
  43554. target: any;
  43555. /**
  43556. * Returns the string "TargetedAnimation"
  43557. * @returns "TargetedAnimation"
  43558. */
  43559. getClassName(): string;
  43560. /**
  43561. * Serialize the object
  43562. * @returns the JSON object representing the current entity
  43563. */
  43564. serialize(): any;
  43565. }
  43566. /**
  43567. * Use this class to create coordinated animations on multiple targets
  43568. */
  43569. export class AnimationGroup implements IDisposable {
  43570. /** The name of the animation group */
  43571. name: string;
  43572. private _scene;
  43573. private _targetedAnimations;
  43574. private _animatables;
  43575. private _from;
  43576. private _to;
  43577. private _isStarted;
  43578. private _isPaused;
  43579. private _speedRatio;
  43580. private _loopAnimation;
  43581. private _isAdditive;
  43582. /**
  43583. * Gets or sets the unique id of the node
  43584. */
  43585. uniqueId: number;
  43586. /**
  43587. * This observable will notify when one animation have ended
  43588. */
  43589. onAnimationEndObservable: Observable<TargetedAnimation>;
  43590. /**
  43591. * Observer raised when one animation loops
  43592. */
  43593. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43594. /**
  43595. * Observer raised when all animations have looped
  43596. */
  43597. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43598. /**
  43599. * This observable will notify when all animations have ended.
  43600. */
  43601. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43602. /**
  43603. * This observable will notify when all animations have paused.
  43604. */
  43605. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43606. /**
  43607. * This observable will notify when all animations are playing.
  43608. */
  43609. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43610. /**
  43611. * Gets the first frame
  43612. */
  43613. get from(): number;
  43614. /**
  43615. * Gets the last frame
  43616. */
  43617. get to(): number;
  43618. /**
  43619. * Define if the animations are started
  43620. */
  43621. get isStarted(): boolean;
  43622. /**
  43623. * Gets a value indicating that the current group is playing
  43624. */
  43625. get isPlaying(): boolean;
  43626. /**
  43627. * Gets or sets the speed ratio to use for all animations
  43628. */
  43629. get speedRatio(): number;
  43630. /**
  43631. * Gets or sets the speed ratio to use for all animations
  43632. */
  43633. set speedRatio(value: number);
  43634. /**
  43635. * Gets or sets if all animations should loop or not
  43636. */
  43637. get loopAnimation(): boolean;
  43638. set loopAnimation(value: boolean);
  43639. /**
  43640. * Gets or sets if all animations should be evaluated additively
  43641. */
  43642. get isAdditive(): boolean;
  43643. set isAdditive(value: boolean);
  43644. /**
  43645. * Gets the targeted animations for this animation group
  43646. */
  43647. get targetedAnimations(): Array<TargetedAnimation>;
  43648. /**
  43649. * returning the list of animatables controlled by this animation group.
  43650. */
  43651. get animatables(): Array<Animatable>;
  43652. /**
  43653. * Gets the list of target animations
  43654. */
  43655. get children(): TargetedAnimation[];
  43656. /**
  43657. * Instantiates a new Animation Group.
  43658. * This helps managing several animations at once.
  43659. * @see https://doc.babylonjs.com/how_to/group
  43660. * @param name Defines the name of the group
  43661. * @param scene Defines the scene the group belongs to
  43662. */
  43663. constructor(
  43664. /** The name of the animation group */
  43665. name: string, scene?: Nullable<Scene>);
  43666. /**
  43667. * Add an animation (with its target) in the group
  43668. * @param animation defines the animation we want to add
  43669. * @param target defines the target of the animation
  43670. * @returns the TargetedAnimation object
  43671. */
  43672. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43673. /**
  43674. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43675. * It can add constant keys at begin or end
  43676. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43677. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43678. * @returns the animation group
  43679. */
  43680. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43681. private _animationLoopCount;
  43682. private _animationLoopFlags;
  43683. private _processLoop;
  43684. /**
  43685. * Start all animations on given targets
  43686. * @param loop defines if animations must loop
  43687. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43688. * @param from defines the from key (optional)
  43689. * @param to defines the to key (optional)
  43690. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43691. * @returns the current animation group
  43692. */
  43693. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43694. /**
  43695. * Pause all animations
  43696. * @returns the animation group
  43697. */
  43698. pause(): AnimationGroup;
  43699. /**
  43700. * Play all animations to initial state
  43701. * This function will start() the animations if they were not started or will restart() them if they were paused
  43702. * @param loop defines if animations must loop
  43703. * @returns the animation group
  43704. */
  43705. play(loop?: boolean): AnimationGroup;
  43706. /**
  43707. * Reset all animations to initial state
  43708. * @returns the animation group
  43709. */
  43710. reset(): AnimationGroup;
  43711. /**
  43712. * Restart animations from key 0
  43713. * @returns the animation group
  43714. */
  43715. restart(): AnimationGroup;
  43716. /**
  43717. * Stop all animations
  43718. * @returns the animation group
  43719. */
  43720. stop(): AnimationGroup;
  43721. /**
  43722. * Set animation weight for all animatables
  43723. * @param weight defines the weight to use
  43724. * @return the animationGroup
  43725. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43726. */
  43727. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43728. /**
  43729. * Synchronize and normalize all animatables with a source animatable
  43730. * @param root defines the root animatable to synchronize with
  43731. * @return the animationGroup
  43732. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43733. */
  43734. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43735. /**
  43736. * Goes to a specific frame in this animation group
  43737. * @param frame the frame number to go to
  43738. * @return the animationGroup
  43739. */
  43740. goToFrame(frame: number): AnimationGroup;
  43741. /**
  43742. * Dispose all associated resources
  43743. */
  43744. dispose(): void;
  43745. private _checkAnimationGroupEnded;
  43746. /**
  43747. * Clone the current animation group and returns a copy
  43748. * @param newName defines the name of the new group
  43749. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43750. * @returns the new aniamtion group
  43751. */
  43752. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43753. /**
  43754. * Serializes the animationGroup to an object
  43755. * @returns Serialized object
  43756. */
  43757. serialize(): any;
  43758. /**
  43759. * Returns a new AnimationGroup object parsed from the source provided.
  43760. * @param parsedAnimationGroup defines the source
  43761. * @param scene defines the scene that will receive the animationGroup
  43762. * @returns a new AnimationGroup
  43763. */
  43764. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43765. /**
  43766. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43767. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43768. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43769. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43770. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43771. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43772. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43773. */
  43774. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43775. /**
  43776. * Returns the string "AnimationGroup"
  43777. * @returns "AnimationGroup"
  43778. */
  43779. getClassName(): string;
  43780. /**
  43781. * Creates a detailled string about the object
  43782. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43783. * @returns a string representing the object
  43784. */
  43785. toString(fullDetails?: boolean): string;
  43786. }
  43787. }
  43788. declare module "babylonjs/scene" {
  43789. import { Nullable } from "babylonjs/types";
  43790. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43791. import { Observable } from "babylonjs/Misc/observable";
  43792. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43793. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43794. import { Geometry } from "babylonjs/Meshes/geometry";
  43795. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43798. import { Mesh } from "babylonjs/Meshes/mesh";
  43799. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43800. import { Bone } from "babylonjs/Bones/bone";
  43801. import { Skeleton } from "babylonjs/Bones/skeleton";
  43802. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43803. import { Camera } from "babylonjs/Cameras/camera";
  43804. import { AbstractScene } from "babylonjs/abstractScene";
  43805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43806. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43807. import { Material } from "babylonjs/Materials/material";
  43808. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43809. import { Effect } from "babylonjs/Materials/effect";
  43810. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43811. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43812. import { Light } from "babylonjs/Lights/light";
  43813. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43814. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43815. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43816. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43817. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43818. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43819. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43820. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43821. import { Engine } from "babylonjs/Engines/engine";
  43822. import { Node } from "babylonjs/node";
  43823. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43824. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43825. import { WebRequest } from "babylonjs/Misc/webRequest";
  43826. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43827. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43828. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43829. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43830. import { Plane } from "babylonjs/Maths/math.plane";
  43831. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43833. import { Ray } from "babylonjs/Culling/ray";
  43834. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43835. import { Animation } from "babylonjs/Animations/animation";
  43836. import { Animatable } from "babylonjs/Animations/animatable";
  43837. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43838. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43839. import { Collider } from "babylonjs/Collisions/collider";
  43840. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43841. /**
  43842. * Define an interface for all classes that will hold resources
  43843. */
  43844. export interface IDisposable {
  43845. /**
  43846. * Releases all held resources
  43847. */
  43848. dispose(): void;
  43849. }
  43850. /** Interface defining initialization parameters for Scene class */
  43851. export interface SceneOptions {
  43852. /**
  43853. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43854. * It will improve performance when the number of geometries becomes important.
  43855. */
  43856. useGeometryUniqueIdsMap?: boolean;
  43857. /**
  43858. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43859. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43860. */
  43861. useMaterialMeshMap?: boolean;
  43862. /**
  43863. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43864. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43865. */
  43866. useClonedMeshMap?: boolean;
  43867. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43868. virtual?: boolean;
  43869. }
  43870. /**
  43871. * Represents a scene to be rendered by the engine.
  43872. * @see https://doc.babylonjs.com/features/scene
  43873. */
  43874. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43875. /** The fog is deactivated */
  43876. static readonly FOGMODE_NONE: number;
  43877. /** The fog density is following an exponential function */
  43878. static readonly FOGMODE_EXP: number;
  43879. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43880. static readonly FOGMODE_EXP2: number;
  43881. /** The fog density is following a linear function. */
  43882. static readonly FOGMODE_LINEAR: number;
  43883. /**
  43884. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43885. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43886. */
  43887. static MinDeltaTime: number;
  43888. /**
  43889. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43891. */
  43892. static MaxDeltaTime: number;
  43893. /**
  43894. * Factory used to create the default material.
  43895. * @param name The name of the material to create
  43896. * @param scene The scene to create the material for
  43897. * @returns The default material
  43898. */
  43899. static DefaultMaterialFactory(scene: Scene): Material;
  43900. /**
  43901. * Factory used to create the a collision coordinator.
  43902. * @returns The collision coordinator
  43903. */
  43904. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43905. /** @hidden */
  43906. _inputManager: InputManager;
  43907. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43908. cameraToUseForPointers: Nullable<Camera>;
  43909. /** @hidden */
  43910. readonly _isScene: boolean;
  43911. /** @hidden */
  43912. _blockEntityCollection: boolean;
  43913. /**
  43914. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43915. */
  43916. autoClear: boolean;
  43917. /**
  43918. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  43919. */
  43920. autoClearDepthAndStencil: boolean;
  43921. /**
  43922. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  43923. */
  43924. clearColor: Color4;
  43925. /**
  43926. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  43927. */
  43928. ambientColor: Color3;
  43929. /**
  43930. * This is use to store the default BRDF lookup for PBR materials in your scene.
  43931. * It should only be one of the following (if not the default embedded one):
  43932. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  43933. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  43934. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  43935. * The material properties need to be setup according to the type of texture in use.
  43936. */
  43937. environmentBRDFTexture: BaseTexture;
  43938. /**
  43939. * Texture used in all pbr material as the reflection texture.
  43940. * As in the majority of the scene they are the same (exception for multi room and so on),
  43941. * this is easier to reference from here than from all the materials.
  43942. */
  43943. get environmentTexture(): Nullable<BaseTexture>;
  43944. /**
  43945. * Texture used in all pbr material as the reflection texture.
  43946. * As in the majority of the scene they are the same (exception for multi room and so on),
  43947. * this is easier to set here than in all the materials.
  43948. */
  43949. set environmentTexture(value: Nullable<BaseTexture>);
  43950. /** @hidden */
  43951. protected _environmentIntensity: number;
  43952. /**
  43953. * Intensity of the environment in all pbr material.
  43954. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43955. * As in the majority of the scene they are the same (exception for multi room and so on),
  43956. * this is easier to reference from here than from all the materials.
  43957. */
  43958. get environmentIntensity(): number;
  43959. /**
  43960. * Intensity of the environment in all pbr material.
  43961. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  43962. * As in the majority of the scene they are the same (exception for multi room and so on),
  43963. * this is easier to set here than in all the materials.
  43964. */
  43965. set environmentIntensity(value: number);
  43966. /** @hidden */
  43967. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43968. /**
  43969. * Default image processing configuration used either in the rendering
  43970. * Forward main pass or through the imageProcessingPostProcess if present.
  43971. * As in the majority of the scene they are the same (exception for multi camera),
  43972. * this is easier to reference from here than from all the materials and post process.
  43973. *
  43974. * No setter as we it is a shared configuration, you can set the values instead.
  43975. */
  43976. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43977. private _forceWireframe;
  43978. /**
  43979. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43980. */
  43981. set forceWireframe(value: boolean);
  43982. get forceWireframe(): boolean;
  43983. private _skipFrustumClipping;
  43984. /**
  43985. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43986. */
  43987. set skipFrustumClipping(value: boolean);
  43988. get skipFrustumClipping(): boolean;
  43989. private _forcePointsCloud;
  43990. /**
  43991. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43992. */
  43993. set forcePointsCloud(value: boolean);
  43994. get forcePointsCloud(): boolean;
  43995. /**
  43996. * Gets or sets the active clipplane 1
  43997. */
  43998. clipPlane: Nullable<Plane>;
  43999. /**
  44000. * Gets or sets the active clipplane 2
  44001. */
  44002. clipPlane2: Nullable<Plane>;
  44003. /**
  44004. * Gets or sets the active clipplane 3
  44005. */
  44006. clipPlane3: Nullable<Plane>;
  44007. /**
  44008. * Gets or sets the active clipplane 4
  44009. */
  44010. clipPlane4: Nullable<Plane>;
  44011. /**
  44012. * Gets or sets the active clipplane 5
  44013. */
  44014. clipPlane5: Nullable<Plane>;
  44015. /**
  44016. * Gets or sets the active clipplane 6
  44017. */
  44018. clipPlane6: Nullable<Plane>;
  44019. /**
  44020. * Gets or sets a boolean indicating if animations are enabled
  44021. */
  44022. animationsEnabled: boolean;
  44023. private _animationPropertiesOverride;
  44024. /**
  44025. * Gets or sets the animation properties override
  44026. */
  44027. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44028. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44029. /**
  44030. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44031. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44032. */
  44033. useConstantAnimationDeltaTime: boolean;
  44034. /**
  44035. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44036. * Please note that it requires to run a ray cast through the scene on every frame
  44037. */
  44038. constantlyUpdateMeshUnderPointer: boolean;
  44039. /**
  44040. * Defines the HTML cursor to use when hovering over interactive elements
  44041. */
  44042. hoverCursor: string;
  44043. /**
  44044. * Defines the HTML default cursor to use (empty by default)
  44045. */
  44046. defaultCursor: string;
  44047. /**
  44048. * Defines whether cursors are handled by the scene.
  44049. */
  44050. doNotHandleCursors: boolean;
  44051. /**
  44052. * This is used to call preventDefault() on pointer down
  44053. * in order to block unwanted artifacts like system double clicks
  44054. */
  44055. preventDefaultOnPointerDown: boolean;
  44056. /**
  44057. * This is used to call preventDefault() on pointer up
  44058. * in order to block unwanted artifacts like system double clicks
  44059. */
  44060. preventDefaultOnPointerUp: boolean;
  44061. /**
  44062. * Gets or sets user defined metadata
  44063. */
  44064. metadata: any;
  44065. /**
  44066. * For internal use only. Please do not use.
  44067. */
  44068. reservedDataStore: any;
  44069. /**
  44070. * Gets the name of the plugin used to load this scene (null by default)
  44071. */
  44072. loadingPluginName: string;
  44073. /**
  44074. * Use this array to add regular expressions used to disable offline support for specific urls
  44075. */
  44076. disableOfflineSupportExceptionRules: RegExp[];
  44077. /**
  44078. * An event triggered when the scene is disposed.
  44079. */
  44080. onDisposeObservable: Observable<Scene>;
  44081. private _onDisposeObserver;
  44082. /** Sets a function to be executed when this scene is disposed. */
  44083. set onDispose(callback: () => void);
  44084. /**
  44085. * An event triggered before rendering the scene (right after animations and physics)
  44086. */
  44087. onBeforeRenderObservable: Observable<Scene>;
  44088. private _onBeforeRenderObserver;
  44089. /** Sets a function to be executed before rendering this scene */
  44090. set beforeRender(callback: Nullable<() => void>);
  44091. /**
  44092. * An event triggered after rendering the scene
  44093. */
  44094. onAfterRenderObservable: Observable<Scene>;
  44095. /**
  44096. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44097. */
  44098. onAfterRenderCameraObservable: Observable<Camera>;
  44099. private _onAfterRenderObserver;
  44100. /** Sets a function to be executed after rendering this scene */
  44101. set afterRender(callback: Nullable<() => void>);
  44102. /**
  44103. * An event triggered before animating the scene
  44104. */
  44105. onBeforeAnimationsObservable: Observable<Scene>;
  44106. /**
  44107. * An event triggered after animations processing
  44108. */
  44109. onAfterAnimationsObservable: Observable<Scene>;
  44110. /**
  44111. * An event triggered before draw calls are ready to be sent
  44112. */
  44113. onBeforeDrawPhaseObservable: Observable<Scene>;
  44114. /**
  44115. * An event triggered after draw calls have been sent
  44116. */
  44117. onAfterDrawPhaseObservable: Observable<Scene>;
  44118. /**
  44119. * An event triggered when the scene is ready
  44120. */
  44121. onReadyObservable: Observable<Scene>;
  44122. /**
  44123. * An event triggered before rendering a camera
  44124. */
  44125. onBeforeCameraRenderObservable: Observable<Camera>;
  44126. private _onBeforeCameraRenderObserver;
  44127. /** Sets a function to be executed before rendering a camera*/
  44128. set beforeCameraRender(callback: () => void);
  44129. /**
  44130. * An event triggered after rendering a camera
  44131. */
  44132. onAfterCameraRenderObservable: Observable<Camera>;
  44133. private _onAfterCameraRenderObserver;
  44134. /** Sets a function to be executed after rendering a camera*/
  44135. set afterCameraRender(callback: () => void);
  44136. /**
  44137. * An event triggered when active meshes evaluation is about to start
  44138. */
  44139. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44140. /**
  44141. * An event triggered when active meshes evaluation is done
  44142. */
  44143. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44144. /**
  44145. * An event triggered when particles rendering is about to start
  44146. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44147. */
  44148. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44149. /**
  44150. * An event triggered when particles rendering is done
  44151. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44152. */
  44153. onAfterParticlesRenderingObservable: Observable<Scene>;
  44154. /**
  44155. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44156. */
  44157. onDataLoadedObservable: Observable<Scene>;
  44158. /**
  44159. * An event triggered when a camera is created
  44160. */
  44161. onNewCameraAddedObservable: Observable<Camera>;
  44162. /**
  44163. * An event triggered when a camera is removed
  44164. */
  44165. onCameraRemovedObservable: Observable<Camera>;
  44166. /**
  44167. * An event triggered when a light is created
  44168. */
  44169. onNewLightAddedObservable: Observable<Light>;
  44170. /**
  44171. * An event triggered when a light is removed
  44172. */
  44173. onLightRemovedObservable: Observable<Light>;
  44174. /**
  44175. * An event triggered when a geometry is created
  44176. */
  44177. onNewGeometryAddedObservable: Observable<Geometry>;
  44178. /**
  44179. * An event triggered when a geometry is removed
  44180. */
  44181. onGeometryRemovedObservable: Observable<Geometry>;
  44182. /**
  44183. * An event triggered when a transform node is created
  44184. */
  44185. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44186. /**
  44187. * An event triggered when a transform node is removed
  44188. */
  44189. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44190. /**
  44191. * An event triggered when a mesh is created
  44192. */
  44193. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44194. /**
  44195. * An event triggered when a mesh is removed
  44196. */
  44197. onMeshRemovedObservable: Observable<AbstractMesh>;
  44198. /**
  44199. * An event triggered when a skeleton is created
  44200. */
  44201. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44202. /**
  44203. * An event triggered when a skeleton is removed
  44204. */
  44205. onSkeletonRemovedObservable: Observable<Skeleton>;
  44206. /**
  44207. * An event triggered when a material is created
  44208. */
  44209. onNewMaterialAddedObservable: Observable<Material>;
  44210. /**
  44211. * An event triggered when a material is removed
  44212. */
  44213. onMaterialRemovedObservable: Observable<Material>;
  44214. /**
  44215. * An event triggered when a texture is created
  44216. */
  44217. onNewTextureAddedObservable: Observable<BaseTexture>;
  44218. /**
  44219. * An event triggered when a texture is removed
  44220. */
  44221. onTextureRemovedObservable: Observable<BaseTexture>;
  44222. /**
  44223. * An event triggered when render targets are about to be rendered
  44224. * Can happen multiple times per frame.
  44225. */
  44226. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44227. /**
  44228. * An event triggered when render targets were rendered.
  44229. * Can happen multiple times per frame.
  44230. */
  44231. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44232. /**
  44233. * An event triggered before calculating deterministic simulation step
  44234. */
  44235. onBeforeStepObservable: Observable<Scene>;
  44236. /**
  44237. * An event triggered after calculating deterministic simulation step
  44238. */
  44239. onAfterStepObservable: Observable<Scene>;
  44240. /**
  44241. * An event triggered when the activeCamera property is updated
  44242. */
  44243. onActiveCameraChanged: Observable<Scene>;
  44244. /**
  44245. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44246. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44247. * 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)
  44248. */
  44249. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44250. /**
  44251. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44252. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44253. * 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)
  44254. */
  44255. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44256. /**
  44257. * This Observable will when a mesh has been imported into the scene.
  44258. */
  44259. onMeshImportedObservable: Observable<AbstractMesh>;
  44260. /**
  44261. * This Observable will when an animation file has been imported into the scene.
  44262. */
  44263. onAnimationFileImportedObservable: Observable<Scene>;
  44264. /**
  44265. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44266. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44267. */
  44268. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44269. /** @hidden */
  44270. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44271. /**
  44272. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44273. */
  44274. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44275. /**
  44276. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44277. */
  44278. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44279. /**
  44280. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44281. */
  44282. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44283. /** Callback called when a pointer move is detected */
  44284. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44285. /** Callback called when a pointer down is detected */
  44286. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44287. /** Callback called when a pointer up is detected */
  44288. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44289. /** Callback called when a pointer pick is detected */
  44290. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44291. /**
  44292. * 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).
  44293. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44294. */
  44295. onPrePointerObservable: Observable<PointerInfoPre>;
  44296. /**
  44297. * Observable event triggered each time an input event is received from the rendering canvas
  44298. */
  44299. onPointerObservable: Observable<PointerInfo>;
  44300. /**
  44301. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44302. */
  44303. get unTranslatedPointer(): Vector2;
  44304. /**
  44305. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44306. */
  44307. static get DragMovementThreshold(): number;
  44308. static set DragMovementThreshold(value: number);
  44309. /**
  44310. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44311. */
  44312. static get LongPressDelay(): number;
  44313. static set LongPressDelay(value: number);
  44314. /**
  44315. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44316. */
  44317. static get DoubleClickDelay(): number;
  44318. static set DoubleClickDelay(value: number);
  44319. /** If you need to check double click without raising a single click at first click, enable this flag */
  44320. static get ExclusiveDoubleClickMode(): boolean;
  44321. static set ExclusiveDoubleClickMode(value: boolean);
  44322. /** @hidden */
  44323. _mirroredCameraPosition: Nullable<Vector3>;
  44324. /**
  44325. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44326. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44327. */
  44328. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44329. /**
  44330. * Observable event triggered each time an keyboard event is received from the hosting window
  44331. */
  44332. onKeyboardObservable: Observable<KeyboardInfo>;
  44333. private _useRightHandedSystem;
  44334. /**
  44335. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44336. */
  44337. set useRightHandedSystem(value: boolean);
  44338. get useRightHandedSystem(): boolean;
  44339. private _timeAccumulator;
  44340. private _currentStepId;
  44341. private _currentInternalStep;
  44342. /**
  44343. * Sets the step Id used by deterministic lock step
  44344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44345. * @param newStepId defines the step Id
  44346. */
  44347. setStepId(newStepId: number): void;
  44348. /**
  44349. * Gets the step Id used by deterministic lock step
  44350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44351. * @returns the step Id
  44352. */
  44353. getStepId(): number;
  44354. /**
  44355. * Gets the internal step used by deterministic lock step
  44356. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44357. * @returns the internal step
  44358. */
  44359. getInternalStep(): number;
  44360. private _fogEnabled;
  44361. /**
  44362. * Gets or sets a boolean indicating if fog is enabled on this scene
  44363. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44364. * (Default is true)
  44365. */
  44366. set fogEnabled(value: boolean);
  44367. get fogEnabled(): boolean;
  44368. private _fogMode;
  44369. /**
  44370. * Gets or sets the fog mode to use
  44371. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44372. * | mode | value |
  44373. * | --- | --- |
  44374. * | FOGMODE_NONE | 0 |
  44375. * | FOGMODE_EXP | 1 |
  44376. * | FOGMODE_EXP2 | 2 |
  44377. * | FOGMODE_LINEAR | 3 |
  44378. */
  44379. set fogMode(value: number);
  44380. get fogMode(): number;
  44381. /**
  44382. * Gets or sets the fog color to use
  44383. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44384. * (Default is Color3(0.2, 0.2, 0.3))
  44385. */
  44386. fogColor: Color3;
  44387. /**
  44388. * Gets or sets the fog density to use
  44389. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44390. * (Default is 0.1)
  44391. */
  44392. fogDensity: number;
  44393. /**
  44394. * Gets or sets the fog start distance to use
  44395. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44396. * (Default is 0)
  44397. */
  44398. fogStart: number;
  44399. /**
  44400. * Gets or sets the fog end distance to use
  44401. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44402. * (Default is 1000)
  44403. */
  44404. fogEnd: number;
  44405. /**
  44406. * Flag indicating that the frame buffer binding is handled by another component
  44407. */
  44408. prePass: boolean;
  44409. private _shadowsEnabled;
  44410. /**
  44411. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44412. */
  44413. set shadowsEnabled(value: boolean);
  44414. get shadowsEnabled(): boolean;
  44415. private _lightsEnabled;
  44416. /**
  44417. * Gets or sets a boolean indicating if lights are enabled on this scene
  44418. */
  44419. set lightsEnabled(value: boolean);
  44420. get lightsEnabled(): boolean;
  44421. /** All of the active cameras added to this scene. */
  44422. activeCameras: Camera[];
  44423. /** @hidden */
  44424. _activeCamera: Nullable<Camera>;
  44425. /** Gets or sets the current active camera */
  44426. get activeCamera(): Nullable<Camera>;
  44427. set activeCamera(value: Nullable<Camera>);
  44428. private _defaultMaterial;
  44429. /** The default material used on meshes when no material is affected */
  44430. get defaultMaterial(): Material;
  44431. /** The default material used on meshes when no material is affected */
  44432. set defaultMaterial(value: Material);
  44433. private _texturesEnabled;
  44434. /**
  44435. * Gets or sets a boolean indicating if textures are enabled on this scene
  44436. */
  44437. set texturesEnabled(value: boolean);
  44438. get texturesEnabled(): boolean;
  44439. /**
  44440. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44441. */
  44442. physicsEnabled: boolean;
  44443. /**
  44444. * Gets or sets a boolean indicating if particles are enabled on this scene
  44445. */
  44446. particlesEnabled: boolean;
  44447. /**
  44448. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44449. */
  44450. spritesEnabled: boolean;
  44451. private _skeletonsEnabled;
  44452. /**
  44453. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44454. */
  44455. set skeletonsEnabled(value: boolean);
  44456. get skeletonsEnabled(): boolean;
  44457. /**
  44458. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44459. */
  44460. lensFlaresEnabled: boolean;
  44461. /**
  44462. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44463. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44464. */
  44465. collisionsEnabled: boolean;
  44466. private _collisionCoordinator;
  44467. /** @hidden */
  44468. get collisionCoordinator(): ICollisionCoordinator;
  44469. /**
  44470. * Defines the gravity applied to this scene (used only for collisions)
  44471. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44472. */
  44473. gravity: Vector3;
  44474. /**
  44475. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44476. */
  44477. postProcessesEnabled: boolean;
  44478. /**
  44479. * Gets the current postprocess manager
  44480. */
  44481. postProcessManager: PostProcessManager;
  44482. /**
  44483. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44484. */
  44485. renderTargetsEnabled: boolean;
  44486. /**
  44487. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44488. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44489. */
  44490. dumpNextRenderTargets: boolean;
  44491. /**
  44492. * The list of user defined render targets added to the scene
  44493. */
  44494. customRenderTargets: RenderTargetTexture[];
  44495. /**
  44496. * Defines if texture loading must be delayed
  44497. * If true, textures will only be loaded when they need to be rendered
  44498. */
  44499. useDelayedTextureLoading: boolean;
  44500. /**
  44501. * Gets the list of meshes imported to the scene through SceneLoader
  44502. */
  44503. importedMeshesFiles: String[];
  44504. /**
  44505. * Gets or sets a boolean indicating if probes are enabled on this scene
  44506. */
  44507. probesEnabled: boolean;
  44508. /**
  44509. * Gets or sets the current offline provider to use to store scene data
  44510. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44511. */
  44512. offlineProvider: IOfflineProvider;
  44513. /**
  44514. * Gets or sets the action manager associated with the scene
  44515. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44516. */
  44517. actionManager: AbstractActionManager;
  44518. private _meshesForIntersections;
  44519. /**
  44520. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44521. */
  44522. proceduralTexturesEnabled: boolean;
  44523. private _engine;
  44524. private _totalVertices;
  44525. /** @hidden */
  44526. _activeIndices: PerfCounter;
  44527. /** @hidden */
  44528. _activeParticles: PerfCounter;
  44529. /** @hidden */
  44530. _activeBones: PerfCounter;
  44531. private _animationRatio;
  44532. /** @hidden */
  44533. _animationTimeLast: number;
  44534. /** @hidden */
  44535. _animationTime: number;
  44536. /**
  44537. * Gets or sets a general scale for animation speed
  44538. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44539. */
  44540. animationTimeScale: number;
  44541. /** @hidden */
  44542. _cachedMaterial: Nullable<Material>;
  44543. /** @hidden */
  44544. _cachedEffect: Nullable<Effect>;
  44545. /** @hidden */
  44546. _cachedVisibility: Nullable<number>;
  44547. private _renderId;
  44548. private _frameId;
  44549. private _executeWhenReadyTimeoutId;
  44550. private _intermediateRendering;
  44551. private _viewUpdateFlag;
  44552. private _projectionUpdateFlag;
  44553. /** @hidden */
  44554. _toBeDisposed: Nullable<IDisposable>[];
  44555. private _activeRequests;
  44556. /** @hidden */
  44557. _pendingData: any[];
  44558. private _isDisposed;
  44559. /**
  44560. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44561. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44562. */
  44563. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44564. private _activeMeshes;
  44565. private _processedMaterials;
  44566. private _renderTargets;
  44567. /** @hidden */
  44568. _activeParticleSystems: SmartArray<IParticleSystem>;
  44569. private _activeSkeletons;
  44570. private _softwareSkinnedMeshes;
  44571. private _renderingManager;
  44572. /** @hidden */
  44573. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44574. private _transformMatrix;
  44575. private _sceneUbo;
  44576. /** @hidden */
  44577. _viewMatrix: Matrix;
  44578. private _projectionMatrix;
  44579. /** @hidden */
  44580. _forcedViewPosition: Nullable<Vector3>;
  44581. /** @hidden */
  44582. _frustumPlanes: Plane[];
  44583. /**
  44584. * Gets the list of frustum planes (built from the active camera)
  44585. */
  44586. get frustumPlanes(): Plane[];
  44587. /**
  44588. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44589. * This is useful if there are more lights that the maximum simulteanous authorized
  44590. */
  44591. requireLightSorting: boolean;
  44592. /** @hidden */
  44593. readonly useMaterialMeshMap: boolean;
  44594. /** @hidden */
  44595. readonly useClonedMeshMap: boolean;
  44596. private _externalData;
  44597. private _uid;
  44598. /**
  44599. * @hidden
  44600. * Backing store of defined scene components.
  44601. */
  44602. _components: ISceneComponent[];
  44603. /**
  44604. * @hidden
  44605. * Backing store of defined scene components.
  44606. */
  44607. _serializableComponents: ISceneSerializableComponent[];
  44608. /**
  44609. * List of components to register on the next registration step.
  44610. */
  44611. private _transientComponents;
  44612. /**
  44613. * Registers the transient components if needed.
  44614. */
  44615. private _registerTransientComponents;
  44616. /**
  44617. * @hidden
  44618. * Add a component to the scene.
  44619. * Note that the ccomponent could be registered on th next frame if this is called after
  44620. * the register component stage.
  44621. * @param component Defines the component to add to the scene
  44622. */
  44623. _addComponent(component: ISceneComponent): void;
  44624. /**
  44625. * @hidden
  44626. * Gets a component from the scene.
  44627. * @param name defines the name of the component to retrieve
  44628. * @returns the component or null if not present
  44629. */
  44630. _getComponent(name: string): Nullable<ISceneComponent>;
  44631. /**
  44632. * @hidden
  44633. * Defines the actions happening before camera updates.
  44634. */
  44635. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44636. /**
  44637. * @hidden
  44638. * Defines the actions happening before clear the canvas.
  44639. */
  44640. _beforeClearStage: Stage<SimpleStageAction>;
  44641. /**
  44642. * @hidden
  44643. * Defines the actions when collecting render targets for the frame.
  44644. */
  44645. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44646. /**
  44647. * @hidden
  44648. * Defines the actions happening for one camera in the frame.
  44649. */
  44650. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44651. /**
  44652. * @hidden
  44653. * Defines the actions happening during the per mesh ready checks.
  44654. */
  44655. _isReadyForMeshStage: Stage<MeshStageAction>;
  44656. /**
  44657. * @hidden
  44658. * Defines the actions happening before evaluate active mesh checks.
  44659. */
  44660. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44661. /**
  44662. * @hidden
  44663. * Defines the actions happening during the evaluate sub mesh checks.
  44664. */
  44665. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44666. /**
  44667. * @hidden
  44668. * Defines the actions happening during the active mesh stage.
  44669. */
  44670. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44671. /**
  44672. * @hidden
  44673. * Defines the actions happening during the per camera render target step.
  44674. */
  44675. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44676. /**
  44677. * @hidden
  44678. * Defines the actions happening just before the active camera is drawing.
  44679. */
  44680. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44681. /**
  44682. * @hidden
  44683. * Defines the actions happening just before a render target is drawing.
  44684. */
  44685. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44686. /**
  44687. * @hidden
  44688. * Defines the actions happening just before a rendering group is drawing.
  44689. */
  44690. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44691. /**
  44692. * @hidden
  44693. * Defines the actions happening just before a mesh is drawing.
  44694. */
  44695. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44696. /**
  44697. * @hidden
  44698. * Defines the actions happening just after a mesh has been drawn.
  44699. */
  44700. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44701. /**
  44702. * @hidden
  44703. * Defines the actions happening just after a rendering group has been drawn.
  44704. */
  44705. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44706. /**
  44707. * @hidden
  44708. * Defines the actions happening just after the active camera has been drawn.
  44709. */
  44710. _afterCameraDrawStage: Stage<CameraStageAction>;
  44711. /**
  44712. * @hidden
  44713. * Defines the actions happening just after a render target has been drawn.
  44714. */
  44715. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44716. /**
  44717. * @hidden
  44718. * Defines the actions happening just after rendering all cameras and computing intersections.
  44719. */
  44720. _afterRenderStage: Stage<SimpleStageAction>;
  44721. /**
  44722. * @hidden
  44723. * Defines the actions happening when a pointer move event happens.
  44724. */
  44725. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44726. /**
  44727. * @hidden
  44728. * Defines the actions happening when a pointer down event happens.
  44729. */
  44730. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44731. /**
  44732. * @hidden
  44733. * Defines the actions happening when a pointer up event happens.
  44734. */
  44735. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44736. /**
  44737. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44738. */
  44739. private geometriesByUniqueId;
  44740. /**
  44741. * Creates a new Scene
  44742. * @param engine defines the engine to use to render this scene
  44743. * @param options defines the scene options
  44744. */
  44745. constructor(engine: Engine, options?: SceneOptions);
  44746. /**
  44747. * Gets a string identifying the name of the class
  44748. * @returns "Scene" string
  44749. */
  44750. getClassName(): string;
  44751. private _defaultMeshCandidates;
  44752. /**
  44753. * @hidden
  44754. */
  44755. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44756. private _defaultSubMeshCandidates;
  44757. /**
  44758. * @hidden
  44759. */
  44760. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44761. /**
  44762. * Sets the default candidate providers for the scene.
  44763. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44764. * and getCollidingSubMeshCandidates to their default function
  44765. */
  44766. setDefaultCandidateProviders(): void;
  44767. /**
  44768. * Gets the mesh that is currently under the pointer
  44769. */
  44770. get meshUnderPointer(): Nullable<AbstractMesh>;
  44771. /**
  44772. * Gets or sets the current on-screen X position of the pointer
  44773. */
  44774. get pointerX(): number;
  44775. set pointerX(value: number);
  44776. /**
  44777. * Gets or sets the current on-screen Y position of the pointer
  44778. */
  44779. get pointerY(): number;
  44780. set pointerY(value: number);
  44781. /**
  44782. * Gets the cached material (ie. the latest rendered one)
  44783. * @returns the cached material
  44784. */
  44785. getCachedMaterial(): Nullable<Material>;
  44786. /**
  44787. * Gets the cached effect (ie. the latest rendered one)
  44788. * @returns the cached effect
  44789. */
  44790. getCachedEffect(): Nullable<Effect>;
  44791. /**
  44792. * Gets the cached visibility state (ie. the latest rendered one)
  44793. * @returns the cached visibility state
  44794. */
  44795. getCachedVisibility(): Nullable<number>;
  44796. /**
  44797. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44798. * @param material defines the current material
  44799. * @param effect defines the current effect
  44800. * @param visibility defines the current visibility state
  44801. * @returns true if one parameter is not cached
  44802. */
  44803. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44804. /**
  44805. * Gets the engine associated with the scene
  44806. * @returns an Engine
  44807. */
  44808. getEngine(): Engine;
  44809. /**
  44810. * Gets the total number of vertices rendered per frame
  44811. * @returns the total number of vertices rendered per frame
  44812. */
  44813. getTotalVertices(): number;
  44814. /**
  44815. * Gets the performance counter for total vertices
  44816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44817. */
  44818. get totalVerticesPerfCounter(): PerfCounter;
  44819. /**
  44820. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44821. * @returns the total number of active indices rendered per frame
  44822. */
  44823. getActiveIndices(): number;
  44824. /**
  44825. * Gets the performance counter for active indices
  44826. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44827. */
  44828. get totalActiveIndicesPerfCounter(): PerfCounter;
  44829. /**
  44830. * Gets the total number of active particles rendered per frame
  44831. * @returns the total number of active particles rendered per frame
  44832. */
  44833. getActiveParticles(): number;
  44834. /**
  44835. * Gets the performance counter for active particles
  44836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44837. */
  44838. get activeParticlesPerfCounter(): PerfCounter;
  44839. /**
  44840. * Gets the total number of active bones rendered per frame
  44841. * @returns the total number of active bones rendered per frame
  44842. */
  44843. getActiveBones(): number;
  44844. /**
  44845. * Gets the performance counter for active bones
  44846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44847. */
  44848. get activeBonesPerfCounter(): PerfCounter;
  44849. /**
  44850. * Gets the array of active meshes
  44851. * @returns an array of AbstractMesh
  44852. */
  44853. getActiveMeshes(): SmartArray<AbstractMesh>;
  44854. /**
  44855. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44856. * @returns a number
  44857. */
  44858. getAnimationRatio(): number;
  44859. /**
  44860. * Gets an unique Id for the current render phase
  44861. * @returns a number
  44862. */
  44863. getRenderId(): number;
  44864. /**
  44865. * Gets an unique Id for the current frame
  44866. * @returns a number
  44867. */
  44868. getFrameId(): number;
  44869. /** Call this function if you want to manually increment the render Id*/
  44870. incrementRenderId(): void;
  44871. private _createUbo;
  44872. /**
  44873. * Use this method to simulate a pointer move on a mesh
  44874. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44875. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44876. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44877. * @returns the current scene
  44878. */
  44879. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44880. /**
  44881. * Use this method to simulate a pointer down on a mesh
  44882. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44883. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44884. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44885. * @returns the current scene
  44886. */
  44887. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44888. /**
  44889. * Use this method to simulate a pointer up on a mesh
  44890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44893. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44894. * @returns the current scene
  44895. */
  44896. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44897. /**
  44898. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44899. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44900. * @returns true if the pointer was captured
  44901. */
  44902. isPointerCaptured(pointerId?: number): boolean;
  44903. /**
  44904. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44905. * @param attachUp defines if you want to attach events to pointerup
  44906. * @param attachDown defines if you want to attach events to pointerdown
  44907. * @param attachMove defines if you want to attach events to pointermove
  44908. */
  44909. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44910. /** Detaches all event handlers*/
  44911. detachControl(): void;
  44912. /**
  44913. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44914. * Delay loaded resources are not taking in account
  44915. * @return true if all required resources are ready
  44916. */
  44917. isReady(): boolean;
  44918. /** Resets all cached information relative to material (including effect and visibility) */
  44919. resetCachedMaterial(): void;
  44920. /**
  44921. * Registers a function to be called before every frame render
  44922. * @param func defines the function to register
  44923. */
  44924. registerBeforeRender(func: () => void): void;
  44925. /**
  44926. * Unregisters a function called before every frame render
  44927. * @param func defines the function to unregister
  44928. */
  44929. unregisterBeforeRender(func: () => void): void;
  44930. /**
  44931. * Registers a function to be called after every frame render
  44932. * @param func defines the function to register
  44933. */
  44934. registerAfterRender(func: () => void): void;
  44935. /**
  44936. * Unregisters a function called after every frame render
  44937. * @param func defines the function to unregister
  44938. */
  44939. unregisterAfterRender(func: () => void): void;
  44940. private _executeOnceBeforeRender;
  44941. /**
  44942. * The provided function will run before render once and will be disposed afterwards.
  44943. * A timeout delay can be provided so that the function will be executed in N ms.
  44944. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  44945. * @param func The function to be executed.
  44946. * @param timeout optional delay in ms
  44947. */
  44948. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  44949. /** @hidden */
  44950. _addPendingData(data: any): void;
  44951. /** @hidden */
  44952. _removePendingData(data: any): void;
  44953. /**
  44954. * Returns the number of items waiting to be loaded
  44955. * @returns the number of items waiting to be loaded
  44956. */
  44957. getWaitingItemsCount(): number;
  44958. /**
  44959. * Returns a boolean indicating if the scene is still loading data
  44960. */
  44961. get isLoading(): boolean;
  44962. /**
  44963. * Registers a function to be executed when the scene is ready
  44964. * @param {Function} func - the function to be executed
  44965. */
  44966. executeWhenReady(func: () => void): void;
  44967. /**
  44968. * Returns a promise that resolves when the scene is ready
  44969. * @returns A promise that resolves when the scene is ready
  44970. */
  44971. whenReadyAsync(): Promise<void>;
  44972. /** @hidden */
  44973. _checkIsReady(): void;
  44974. /**
  44975. * Gets all animatable attached to the scene
  44976. */
  44977. get animatables(): Animatable[];
  44978. /**
  44979. * Resets the last animation time frame.
  44980. * Useful to override when animations start running when loading a scene for the first time.
  44981. */
  44982. resetLastAnimationTimeFrame(): void;
  44983. /**
  44984. * Gets the current view matrix
  44985. * @returns a Matrix
  44986. */
  44987. getViewMatrix(): Matrix;
  44988. /**
  44989. * Gets the current projection matrix
  44990. * @returns a Matrix
  44991. */
  44992. getProjectionMatrix(): Matrix;
  44993. /**
  44994. * Gets the current transform matrix
  44995. * @returns a Matrix made of View * Projection
  44996. */
  44997. getTransformMatrix(): Matrix;
  44998. /**
  44999. * Sets the current transform matrix
  45000. * @param viewL defines the View matrix to use
  45001. * @param projectionL defines the Projection matrix to use
  45002. * @param viewR defines the right View matrix to use (if provided)
  45003. * @param projectionR defines the right Projection matrix to use (if provided)
  45004. */
  45005. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45006. /**
  45007. * Gets the uniform buffer used to store scene data
  45008. * @returns a UniformBuffer
  45009. */
  45010. getSceneUniformBuffer(): UniformBuffer;
  45011. /**
  45012. * Gets an unique (relatively to the current scene) Id
  45013. * @returns an unique number for the scene
  45014. */
  45015. getUniqueId(): number;
  45016. /**
  45017. * Add a mesh to the list of scene's meshes
  45018. * @param newMesh defines the mesh to add
  45019. * @param recursive if all child meshes should also be added to the scene
  45020. */
  45021. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45022. /**
  45023. * Remove a mesh for the list of scene's meshes
  45024. * @param toRemove defines the mesh to remove
  45025. * @param recursive if all child meshes should also be removed from the scene
  45026. * @returns the index where the mesh was in the mesh list
  45027. */
  45028. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45029. /**
  45030. * Add a transform node to the list of scene's transform nodes
  45031. * @param newTransformNode defines the transform node to add
  45032. */
  45033. addTransformNode(newTransformNode: TransformNode): void;
  45034. /**
  45035. * Remove a transform node for the list of scene's transform nodes
  45036. * @param toRemove defines the transform node to remove
  45037. * @returns the index where the transform node was in the transform node list
  45038. */
  45039. removeTransformNode(toRemove: TransformNode): number;
  45040. /**
  45041. * Remove a skeleton for the list of scene's skeletons
  45042. * @param toRemove defines the skeleton to remove
  45043. * @returns the index where the skeleton was in the skeleton list
  45044. */
  45045. removeSkeleton(toRemove: Skeleton): number;
  45046. /**
  45047. * Remove a morph target for the list of scene's morph targets
  45048. * @param toRemove defines the morph target to remove
  45049. * @returns the index where the morph target was in the morph target list
  45050. */
  45051. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45052. /**
  45053. * Remove a light for the list of scene's lights
  45054. * @param toRemove defines the light to remove
  45055. * @returns the index where the light was in the light list
  45056. */
  45057. removeLight(toRemove: Light): number;
  45058. /**
  45059. * Remove a camera for the list of scene's cameras
  45060. * @param toRemove defines the camera to remove
  45061. * @returns the index where the camera was in the camera list
  45062. */
  45063. removeCamera(toRemove: Camera): number;
  45064. /**
  45065. * Remove a particle system for the list of scene's particle systems
  45066. * @param toRemove defines the particle system to remove
  45067. * @returns the index where the particle system was in the particle system list
  45068. */
  45069. removeParticleSystem(toRemove: IParticleSystem): number;
  45070. /**
  45071. * Remove a animation for the list of scene's animations
  45072. * @param toRemove defines the animation to remove
  45073. * @returns the index where the animation was in the animation list
  45074. */
  45075. removeAnimation(toRemove: Animation): number;
  45076. /**
  45077. * Will stop the animation of the given target
  45078. * @param target - the target
  45079. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45080. * @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)
  45081. */
  45082. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45083. /**
  45084. * Removes the given animation group from this scene.
  45085. * @param toRemove The animation group to remove
  45086. * @returns The index of the removed animation group
  45087. */
  45088. removeAnimationGroup(toRemove: AnimationGroup): number;
  45089. /**
  45090. * Removes the given multi-material from this scene.
  45091. * @param toRemove The multi-material to remove
  45092. * @returns The index of the removed multi-material
  45093. */
  45094. removeMultiMaterial(toRemove: MultiMaterial): number;
  45095. /**
  45096. * Removes the given material from this scene.
  45097. * @param toRemove The material to remove
  45098. * @returns The index of the removed material
  45099. */
  45100. removeMaterial(toRemove: Material): number;
  45101. /**
  45102. * Removes the given action manager from this scene.
  45103. * @param toRemove The action manager to remove
  45104. * @returns The index of the removed action manager
  45105. */
  45106. removeActionManager(toRemove: AbstractActionManager): number;
  45107. /**
  45108. * Removes the given texture from this scene.
  45109. * @param toRemove The texture to remove
  45110. * @returns The index of the removed texture
  45111. */
  45112. removeTexture(toRemove: BaseTexture): number;
  45113. /**
  45114. * Adds the given light to this scene
  45115. * @param newLight The light to add
  45116. */
  45117. addLight(newLight: Light): void;
  45118. /**
  45119. * Sorts the list list based on light priorities
  45120. */
  45121. sortLightsByPriority(): void;
  45122. /**
  45123. * Adds the given camera to this scene
  45124. * @param newCamera The camera to add
  45125. */
  45126. addCamera(newCamera: Camera): void;
  45127. /**
  45128. * Adds the given skeleton to this scene
  45129. * @param newSkeleton The skeleton to add
  45130. */
  45131. addSkeleton(newSkeleton: Skeleton): void;
  45132. /**
  45133. * Adds the given particle system to this scene
  45134. * @param newParticleSystem The particle system to add
  45135. */
  45136. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45137. /**
  45138. * Adds the given animation to this scene
  45139. * @param newAnimation The animation to add
  45140. */
  45141. addAnimation(newAnimation: Animation): void;
  45142. /**
  45143. * Adds the given animation group to this scene.
  45144. * @param newAnimationGroup The animation group to add
  45145. */
  45146. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45147. /**
  45148. * Adds the given multi-material to this scene
  45149. * @param newMultiMaterial The multi-material to add
  45150. */
  45151. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45152. /**
  45153. * Adds the given material to this scene
  45154. * @param newMaterial The material to add
  45155. */
  45156. addMaterial(newMaterial: Material): void;
  45157. /**
  45158. * Adds the given morph target to this scene
  45159. * @param newMorphTargetManager The morph target to add
  45160. */
  45161. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45162. /**
  45163. * Adds the given geometry to this scene
  45164. * @param newGeometry The geometry to add
  45165. */
  45166. addGeometry(newGeometry: Geometry): void;
  45167. /**
  45168. * Adds the given action manager to this scene
  45169. * @param newActionManager The action manager to add
  45170. */
  45171. addActionManager(newActionManager: AbstractActionManager): void;
  45172. /**
  45173. * Adds the given texture to this scene.
  45174. * @param newTexture The texture to add
  45175. */
  45176. addTexture(newTexture: BaseTexture): void;
  45177. /**
  45178. * Switch active camera
  45179. * @param newCamera defines the new active camera
  45180. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45181. */
  45182. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45183. /**
  45184. * sets the active camera of the scene using its ID
  45185. * @param id defines the camera's ID
  45186. * @return the new active camera or null if none found.
  45187. */
  45188. setActiveCameraByID(id: string): Nullable<Camera>;
  45189. /**
  45190. * sets the active camera of the scene using its name
  45191. * @param name defines the camera's name
  45192. * @returns the new active camera or null if none found.
  45193. */
  45194. setActiveCameraByName(name: string): Nullable<Camera>;
  45195. /**
  45196. * get an animation group using its name
  45197. * @param name defines the material's name
  45198. * @return the animation group or null if none found.
  45199. */
  45200. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45201. /**
  45202. * Get a material using its unique id
  45203. * @param uniqueId defines the material's unique id
  45204. * @return the material or null if none found.
  45205. */
  45206. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45207. /**
  45208. * get a material using its id
  45209. * @param id defines the material's ID
  45210. * @return the material or null if none found.
  45211. */
  45212. getMaterialByID(id: string): Nullable<Material>;
  45213. /**
  45214. * Gets a the last added material using a given id
  45215. * @param id defines the material's ID
  45216. * @return the last material with the given id or null if none found.
  45217. */
  45218. getLastMaterialByID(id: string): Nullable<Material>;
  45219. /**
  45220. * Gets a material using its name
  45221. * @param name defines the material's name
  45222. * @return the material or null if none found.
  45223. */
  45224. getMaterialByName(name: string): Nullable<Material>;
  45225. /**
  45226. * Get a texture using its unique id
  45227. * @param uniqueId defines the texture's unique id
  45228. * @return the texture or null if none found.
  45229. */
  45230. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45231. /**
  45232. * Gets a camera using its id
  45233. * @param id defines the id to look for
  45234. * @returns the camera or null if not found
  45235. */
  45236. getCameraByID(id: string): Nullable<Camera>;
  45237. /**
  45238. * Gets a camera using its unique id
  45239. * @param uniqueId defines the unique id to look for
  45240. * @returns the camera or null if not found
  45241. */
  45242. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45243. /**
  45244. * Gets a camera using its name
  45245. * @param name defines the camera's name
  45246. * @return the camera or null if none found.
  45247. */
  45248. getCameraByName(name: string): Nullable<Camera>;
  45249. /**
  45250. * Gets a bone using its id
  45251. * @param id defines the bone's id
  45252. * @return the bone or null if not found
  45253. */
  45254. getBoneByID(id: string): Nullable<Bone>;
  45255. /**
  45256. * Gets a bone using its id
  45257. * @param name defines the bone's name
  45258. * @return the bone or null if not found
  45259. */
  45260. getBoneByName(name: string): Nullable<Bone>;
  45261. /**
  45262. * Gets a light node using its name
  45263. * @param name defines the the light's name
  45264. * @return the light or null if none found.
  45265. */
  45266. getLightByName(name: string): Nullable<Light>;
  45267. /**
  45268. * Gets a light node using its id
  45269. * @param id defines the light's id
  45270. * @return the light or null if none found.
  45271. */
  45272. getLightByID(id: string): Nullable<Light>;
  45273. /**
  45274. * Gets a light node using its scene-generated unique ID
  45275. * @param uniqueId defines the light's unique id
  45276. * @return the light or null if none found.
  45277. */
  45278. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45279. /**
  45280. * Gets a particle system by id
  45281. * @param id defines the particle system id
  45282. * @return the corresponding system or null if none found
  45283. */
  45284. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45285. /**
  45286. * Gets a geometry using its ID
  45287. * @param id defines the geometry's id
  45288. * @return the geometry or null if none found.
  45289. */
  45290. getGeometryByID(id: string): Nullable<Geometry>;
  45291. private _getGeometryByUniqueID;
  45292. /**
  45293. * Add a new geometry to this scene
  45294. * @param geometry defines the geometry to be added to the scene.
  45295. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45296. * @return a boolean defining if the geometry was added or not
  45297. */
  45298. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45299. /**
  45300. * Removes an existing geometry
  45301. * @param geometry defines the geometry to be removed from the scene
  45302. * @return a boolean defining if the geometry was removed or not
  45303. */
  45304. removeGeometry(geometry: Geometry): boolean;
  45305. /**
  45306. * Gets the list of geometries attached to the scene
  45307. * @returns an array of Geometry
  45308. */
  45309. getGeometries(): Geometry[];
  45310. /**
  45311. * Gets the first added mesh found of a given ID
  45312. * @param id defines the id to search for
  45313. * @return the mesh found or null if not found at all
  45314. */
  45315. getMeshByID(id: string): Nullable<AbstractMesh>;
  45316. /**
  45317. * Gets a list of meshes using their id
  45318. * @param id defines the id to search for
  45319. * @returns a list of meshes
  45320. */
  45321. getMeshesByID(id: string): Array<AbstractMesh>;
  45322. /**
  45323. * Gets the first added transform node found of a given ID
  45324. * @param id defines the id to search for
  45325. * @return the found transform node or null if not found at all.
  45326. */
  45327. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45328. /**
  45329. * Gets a transform node with its auto-generated unique id
  45330. * @param uniqueId efines the unique id to search for
  45331. * @return the found transform node or null if not found at all.
  45332. */
  45333. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45334. /**
  45335. * Gets a list of transform nodes using their id
  45336. * @param id defines the id to search for
  45337. * @returns a list of transform nodes
  45338. */
  45339. getTransformNodesByID(id: string): Array<TransformNode>;
  45340. /**
  45341. * Gets a mesh with its auto-generated unique id
  45342. * @param uniqueId defines the unique id to search for
  45343. * @return the found mesh or null if not found at all.
  45344. */
  45345. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45346. /**
  45347. * Gets a the last added mesh using a given id
  45348. * @param id defines the id to search for
  45349. * @return the found mesh or null if not found at all.
  45350. */
  45351. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45352. /**
  45353. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45354. * @param id defines the id to search for
  45355. * @return the found node or null if not found at all
  45356. */
  45357. getLastEntryByID(id: string): Nullable<Node>;
  45358. /**
  45359. * Gets a node (Mesh, Camera, Light) using a given id
  45360. * @param id defines the id to search for
  45361. * @return the found node or null if not found at all
  45362. */
  45363. getNodeByID(id: string): Nullable<Node>;
  45364. /**
  45365. * Gets a node (Mesh, Camera, Light) using a given name
  45366. * @param name defines the name to search for
  45367. * @return the found node or null if not found at all.
  45368. */
  45369. getNodeByName(name: string): Nullable<Node>;
  45370. /**
  45371. * Gets a mesh using a given name
  45372. * @param name defines the name to search for
  45373. * @return the found mesh or null if not found at all.
  45374. */
  45375. getMeshByName(name: string): Nullable<AbstractMesh>;
  45376. /**
  45377. * Gets a transform node using a given name
  45378. * @param name defines the name to search for
  45379. * @return the found transform node or null if not found at all.
  45380. */
  45381. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45382. /**
  45383. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45384. * @param id defines the id to search for
  45385. * @return the found skeleton or null if not found at all.
  45386. */
  45387. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45388. /**
  45389. * Gets a skeleton using a given auto generated unique id
  45390. * @param uniqueId defines the unique id to search for
  45391. * @return the found skeleton or null if not found at all.
  45392. */
  45393. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45394. /**
  45395. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45396. * @param id defines the id to search for
  45397. * @return the found skeleton or null if not found at all.
  45398. */
  45399. getSkeletonById(id: string): Nullable<Skeleton>;
  45400. /**
  45401. * Gets a skeleton using a given name
  45402. * @param name defines the name to search for
  45403. * @return the found skeleton or null if not found at all.
  45404. */
  45405. getSkeletonByName(name: string): Nullable<Skeleton>;
  45406. /**
  45407. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45408. * @param id defines the id to search for
  45409. * @return the found morph target manager or null if not found at all.
  45410. */
  45411. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45412. /**
  45413. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45414. * @param id defines the id to search for
  45415. * @return the found morph target or null if not found at all.
  45416. */
  45417. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45418. /**
  45419. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45420. * @param name defines the name to search for
  45421. * @return the found morph target or null if not found at all.
  45422. */
  45423. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45424. /**
  45425. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45426. * @param name defines the name to search for
  45427. * @return the found post process or null if not found at all.
  45428. */
  45429. getPostProcessByName(name: string): Nullable<PostProcess>;
  45430. /**
  45431. * Gets a boolean indicating if the given mesh is active
  45432. * @param mesh defines the mesh to look for
  45433. * @returns true if the mesh is in the active list
  45434. */
  45435. isActiveMesh(mesh: AbstractMesh): boolean;
  45436. /**
  45437. * Return a unique id as a string which can serve as an identifier for the scene
  45438. */
  45439. get uid(): string;
  45440. /**
  45441. * Add an externaly attached data from its key.
  45442. * This method call will fail and return false, if such key already exists.
  45443. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45444. * @param key the unique key that identifies the data
  45445. * @param data the data object to associate to the key for this Engine instance
  45446. * @return true if no such key were already present and the data was added successfully, false otherwise
  45447. */
  45448. addExternalData<T>(key: string, data: T): boolean;
  45449. /**
  45450. * Get an externaly attached data from its key
  45451. * @param key the unique key that identifies the data
  45452. * @return the associated data, if present (can be null), or undefined if not present
  45453. */
  45454. getExternalData<T>(key: string): Nullable<T>;
  45455. /**
  45456. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45457. * @param key the unique key that identifies the data
  45458. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45459. * @return the associated data, can be null if the factory returned null.
  45460. */
  45461. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45462. /**
  45463. * Remove an externaly attached data from the Engine instance
  45464. * @param key the unique key that identifies the data
  45465. * @return true if the data was successfully removed, false if it doesn't exist
  45466. */
  45467. removeExternalData(key: string): boolean;
  45468. private _evaluateSubMesh;
  45469. /**
  45470. * Clear the processed materials smart array preventing retention point in material dispose.
  45471. */
  45472. freeProcessedMaterials(): void;
  45473. private _preventFreeActiveMeshesAndRenderingGroups;
  45474. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45475. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45476. * when disposing several meshes in a row or a hierarchy of meshes.
  45477. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45478. */
  45479. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45480. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45481. /**
  45482. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45483. */
  45484. freeActiveMeshes(): void;
  45485. /**
  45486. * Clear the info related to rendering groups preventing retention points during dispose.
  45487. */
  45488. freeRenderingGroups(): void;
  45489. /** @hidden */
  45490. _isInIntermediateRendering(): boolean;
  45491. /**
  45492. * Lambda returning the list of potentially active meshes.
  45493. */
  45494. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45495. /**
  45496. * Lambda returning the list of potentially active sub meshes.
  45497. */
  45498. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45499. /**
  45500. * Lambda returning the list of potentially intersecting sub meshes.
  45501. */
  45502. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45503. /**
  45504. * Lambda returning the list of potentially colliding sub meshes.
  45505. */
  45506. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45507. private _activeMeshesFrozen;
  45508. private _skipEvaluateActiveMeshesCompletely;
  45509. /**
  45510. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45511. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45512. * @param onSuccess optional success callback
  45513. * @param onError optional error callback
  45514. * @returns the current scene
  45515. */
  45516. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45517. /**
  45518. * Use this function to restart evaluating active meshes on every frame
  45519. * @returns the current scene
  45520. */
  45521. unfreezeActiveMeshes(): Scene;
  45522. private _evaluateActiveMeshes;
  45523. private _activeMesh;
  45524. /**
  45525. * Update the transform matrix to update from the current active camera
  45526. * @param force defines a boolean used to force the update even if cache is up to date
  45527. */
  45528. updateTransformMatrix(force?: boolean): void;
  45529. private _bindFrameBuffer;
  45530. /** @hidden */
  45531. _allowPostProcessClearColor: boolean;
  45532. /** @hidden */
  45533. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45534. private _processSubCameras;
  45535. private _checkIntersections;
  45536. /** @hidden */
  45537. _advancePhysicsEngineStep(step: number): void;
  45538. /**
  45539. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45540. */
  45541. getDeterministicFrameTime: () => number;
  45542. /** @hidden */
  45543. _animate(): void;
  45544. /** Execute all animations (for a frame) */
  45545. animate(): void;
  45546. /**
  45547. * Render the scene
  45548. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45549. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45550. */
  45551. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45552. /**
  45553. * Freeze all materials
  45554. * A frozen material will not be updatable but should be faster to render
  45555. */
  45556. freezeMaterials(): void;
  45557. /**
  45558. * Unfreeze all materials
  45559. * A frozen material will not be updatable but should be faster to render
  45560. */
  45561. unfreezeMaterials(): void;
  45562. /**
  45563. * Releases all held ressources
  45564. */
  45565. dispose(): void;
  45566. /**
  45567. * Gets if the scene is already disposed
  45568. */
  45569. get isDisposed(): boolean;
  45570. /**
  45571. * Call this function to reduce memory footprint of the scene.
  45572. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45573. */
  45574. clearCachedVertexData(): void;
  45575. /**
  45576. * This function will remove the local cached buffer data from texture.
  45577. * It will save memory but will prevent the texture from being rebuilt
  45578. */
  45579. cleanCachedTextureBuffer(): void;
  45580. /**
  45581. * Get the world extend vectors with an optional filter
  45582. *
  45583. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45584. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45585. */
  45586. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45587. min: Vector3;
  45588. max: Vector3;
  45589. };
  45590. /**
  45591. * Creates a ray that can be used to pick in the scene
  45592. * @param x defines the x coordinate of the origin (on-screen)
  45593. * @param y defines the y coordinate of the origin (on-screen)
  45594. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45595. * @param camera defines the camera to use for the picking
  45596. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45597. * @returns a Ray
  45598. */
  45599. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45600. /**
  45601. * Creates a ray that can be used to pick in the scene
  45602. * @param x defines the x coordinate of the origin (on-screen)
  45603. * @param y defines the y coordinate of the origin (on-screen)
  45604. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45605. * @param result defines the ray where to store the picking ray
  45606. * @param camera defines the camera to use for the picking
  45607. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45608. * @returns the current scene
  45609. */
  45610. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45611. /**
  45612. * Creates a ray that can be used to pick in the scene
  45613. * @param x defines the x coordinate of the origin (on-screen)
  45614. * @param y defines the y coordinate of the origin (on-screen)
  45615. * @param camera defines the camera to use for the picking
  45616. * @returns a Ray
  45617. */
  45618. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45619. /**
  45620. * Creates a ray that can be used to pick in the scene
  45621. * @param x defines the x coordinate of the origin (on-screen)
  45622. * @param y defines the y coordinate of the origin (on-screen)
  45623. * @param result defines the ray where to store the picking ray
  45624. * @param camera defines the camera to use for the picking
  45625. * @returns the current scene
  45626. */
  45627. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45628. /** Launch a ray to try to pick a mesh in the scene
  45629. * @param x position on screen
  45630. * @param y position on screen
  45631. * @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
  45632. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45633. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45634. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45635. * @returns a PickingInfo
  45636. */
  45637. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45638. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45639. * @param x position on screen
  45640. * @param y position on screen
  45641. * @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
  45642. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45643. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45644. * @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)
  45645. */
  45646. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45647. /** Use the given ray to pick a mesh in the scene
  45648. * @param ray The ray to use to pick meshes
  45649. * @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
  45650. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45651. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45652. * @returns a PickingInfo
  45653. */
  45654. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45655. /**
  45656. * Launch a ray to try to pick a mesh in the scene
  45657. * @param x X position on screen
  45658. * @param y Y position on screen
  45659. * @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
  45660. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45662. * @returns an array of PickingInfo
  45663. */
  45664. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45665. /**
  45666. * Launch a ray to try to pick a mesh in the scene
  45667. * @param ray Ray to use
  45668. * @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
  45669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45670. * @returns an array of PickingInfo
  45671. */
  45672. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45673. /**
  45674. * Force the value of meshUnderPointer
  45675. * @param mesh defines the mesh to use
  45676. * @param pointerId optional pointer id when using more than one pointer
  45677. */
  45678. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45679. /**
  45680. * Gets the mesh under the pointer
  45681. * @returns a Mesh or null if no mesh is under the pointer
  45682. */
  45683. getPointerOverMesh(): Nullable<AbstractMesh>;
  45684. /** @hidden */
  45685. _rebuildGeometries(): void;
  45686. /** @hidden */
  45687. _rebuildTextures(): void;
  45688. private _getByTags;
  45689. /**
  45690. * Get a list of meshes by tags
  45691. * @param tagsQuery defines the tags query to use
  45692. * @param forEach defines a predicate used to filter results
  45693. * @returns an array of Mesh
  45694. */
  45695. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45696. /**
  45697. * Get a list of cameras by tags
  45698. * @param tagsQuery defines the tags query to use
  45699. * @param forEach defines a predicate used to filter results
  45700. * @returns an array of Camera
  45701. */
  45702. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45703. /**
  45704. * Get a list of lights by tags
  45705. * @param tagsQuery defines the tags query to use
  45706. * @param forEach defines a predicate used to filter results
  45707. * @returns an array of Light
  45708. */
  45709. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45710. /**
  45711. * Get a list of materials by tags
  45712. * @param tagsQuery defines the tags query to use
  45713. * @param forEach defines a predicate used to filter results
  45714. * @returns an array of Material
  45715. */
  45716. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45717. /**
  45718. * Get a list of transform nodes by tags
  45719. * @param tagsQuery defines the tags query to use
  45720. * @param forEach defines a predicate used to filter results
  45721. * @returns an array of TransformNode
  45722. */
  45723. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45724. /**
  45725. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45726. * This allowed control for front to back rendering or reversly depending of the special needs.
  45727. *
  45728. * @param renderingGroupId The rendering group id corresponding to its index
  45729. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45730. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45731. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45732. */
  45733. 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;
  45734. /**
  45735. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45736. *
  45737. * @param renderingGroupId The rendering group id corresponding to its index
  45738. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45739. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45740. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45741. */
  45742. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45743. /**
  45744. * Gets the current auto clear configuration for one rendering group of the rendering
  45745. * manager.
  45746. * @param index the rendering group index to get the information for
  45747. * @returns The auto clear setup for the requested rendering group
  45748. */
  45749. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45750. private _blockMaterialDirtyMechanism;
  45751. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45752. get blockMaterialDirtyMechanism(): boolean;
  45753. set blockMaterialDirtyMechanism(value: boolean);
  45754. /**
  45755. * Will flag all materials as dirty to trigger new shader compilation
  45756. * @param flag defines the flag used to specify which material part must be marked as dirty
  45757. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45758. */
  45759. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45760. /** @hidden */
  45761. _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;
  45762. /** @hidden */
  45763. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45764. /** @hidden */
  45765. _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;
  45766. /** @hidden */
  45767. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45768. /** @hidden */
  45769. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45770. /** @hidden */
  45771. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45772. }
  45773. }
  45774. declare module "babylonjs/assetContainer" {
  45775. import { AbstractScene } from "babylonjs/abstractScene";
  45776. import { Scene } from "babylonjs/scene";
  45777. import { Mesh } from "babylonjs/Meshes/mesh";
  45778. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45779. import { Skeleton } from "babylonjs/Bones/skeleton";
  45780. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45781. import { Animatable } from "babylonjs/Animations/animatable";
  45782. import { Nullable } from "babylonjs/types";
  45783. import { Node } from "babylonjs/node";
  45784. /**
  45785. * Set of assets to keep when moving a scene into an asset container.
  45786. */
  45787. export class KeepAssets extends AbstractScene {
  45788. }
  45789. /**
  45790. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45791. */
  45792. export class InstantiatedEntries {
  45793. /**
  45794. * List of new root nodes (eg. nodes with no parent)
  45795. */
  45796. rootNodes: TransformNode[];
  45797. /**
  45798. * List of new skeletons
  45799. */
  45800. skeletons: Skeleton[];
  45801. /**
  45802. * List of new animation groups
  45803. */
  45804. animationGroups: AnimationGroup[];
  45805. }
  45806. /**
  45807. * Container with a set of assets that can be added or removed from a scene.
  45808. */
  45809. export class AssetContainer extends AbstractScene {
  45810. private _wasAddedToScene;
  45811. /**
  45812. * The scene the AssetContainer belongs to.
  45813. */
  45814. scene: Scene;
  45815. /**
  45816. * Instantiates an AssetContainer.
  45817. * @param scene The scene the AssetContainer belongs to.
  45818. */
  45819. constructor(scene: Scene);
  45820. /**
  45821. * Instantiate or clone all meshes and add the new ones to the scene.
  45822. * Skeletons and animation groups will all be cloned
  45823. * @param nameFunction defines an optional function used to get new names for clones
  45824. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45825. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45826. */
  45827. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45828. /**
  45829. * Adds all the assets from the container to the scene.
  45830. */
  45831. addAllToScene(): void;
  45832. /**
  45833. * Removes all the assets in the container from the scene
  45834. */
  45835. removeAllFromScene(): void;
  45836. /**
  45837. * Disposes all the assets in the container
  45838. */
  45839. dispose(): void;
  45840. private _moveAssets;
  45841. /**
  45842. * Removes all the assets contained in the scene and adds them to the container.
  45843. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45844. */
  45845. moveAllFromScene(keepAssets?: KeepAssets): void;
  45846. /**
  45847. * 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.
  45848. * @returns the root mesh
  45849. */
  45850. createRootMesh(): Mesh;
  45851. /**
  45852. * Merge animations (direct and animation groups) from this asset container into a scene
  45853. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45854. * @param animatables set of animatables to retarget to a node from the scene
  45855. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45856. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45857. */
  45858. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45859. }
  45860. }
  45861. declare module "babylonjs/abstractScene" {
  45862. import { Scene } from "babylonjs/scene";
  45863. import { Nullable } from "babylonjs/types";
  45864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45865. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45866. import { Geometry } from "babylonjs/Meshes/geometry";
  45867. import { Skeleton } from "babylonjs/Bones/skeleton";
  45868. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45869. import { AssetContainer } from "babylonjs/assetContainer";
  45870. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45871. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45873. import { Material } from "babylonjs/Materials/material";
  45874. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45875. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45876. import { Camera } from "babylonjs/Cameras/camera";
  45877. import { Light } from "babylonjs/Lights/light";
  45878. import { Node } from "babylonjs/node";
  45879. import { Animation } from "babylonjs/Animations/animation";
  45880. /**
  45881. * Defines how the parser contract is defined.
  45882. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45883. */
  45884. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45885. /**
  45886. * Defines how the individual parser contract is defined.
  45887. * These parser can parse an individual asset
  45888. */
  45889. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45890. /**
  45891. * Base class of the scene acting as a container for the different elements composing a scene.
  45892. * This class is dynamically extended by the different components of the scene increasing
  45893. * flexibility and reducing coupling
  45894. */
  45895. export abstract class AbstractScene {
  45896. /**
  45897. * Stores the list of available parsers in the application.
  45898. */
  45899. private static _BabylonFileParsers;
  45900. /**
  45901. * Stores the list of available individual parsers in the application.
  45902. */
  45903. private static _IndividualBabylonFileParsers;
  45904. /**
  45905. * Adds a parser in the list of available ones
  45906. * @param name Defines the name of the parser
  45907. * @param parser Defines the parser to add
  45908. */
  45909. static AddParser(name: string, parser: BabylonFileParser): void;
  45910. /**
  45911. * Gets a general parser from the list of avaialble ones
  45912. * @param name Defines the name of the parser
  45913. * @returns the requested parser or null
  45914. */
  45915. static GetParser(name: string): Nullable<BabylonFileParser>;
  45916. /**
  45917. * Adds n individual parser in the list of available ones
  45918. * @param name Defines the name of the parser
  45919. * @param parser Defines the parser to add
  45920. */
  45921. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  45922. /**
  45923. * Gets an individual parser from the list of avaialble ones
  45924. * @param name Defines the name of the parser
  45925. * @returns the requested parser or null
  45926. */
  45927. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  45928. /**
  45929. * Parser json data and populate both a scene and its associated container object
  45930. * @param jsonData Defines the data to parse
  45931. * @param scene Defines the scene to parse the data for
  45932. * @param container Defines the container attached to the parsing sequence
  45933. * @param rootUrl Defines the root url of the data
  45934. */
  45935. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  45936. /**
  45937. * Gets the list of root nodes (ie. nodes with no parent)
  45938. */
  45939. rootNodes: Node[];
  45940. /** All of the cameras added to this scene
  45941. * @see https://doc.babylonjs.com/babylon101/cameras
  45942. */
  45943. cameras: Camera[];
  45944. /**
  45945. * All of the lights added to this scene
  45946. * @see https://doc.babylonjs.com/babylon101/lights
  45947. */
  45948. lights: Light[];
  45949. /**
  45950. * All of the (abstract) meshes added to this scene
  45951. */
  45952. meshes: AbstractMesh[];
  45953. /**
  45954. * The list of skeletons added to the scene
  45955. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  45956. */
  45957. skeletons: Skeleton[];
  45958. /**
  45959. * All of the particle systems added to this scene
  45960. * @see https://doc.babylonjs.com/babylon101/particles
  45961. */
  45962. particleSystems: IParticleSystem[];
  45963. /**
  45964. * Gets a list of Animations associated with the scene
  45965. */
  45966. animations: Animation[];
  45967. /**
  45968. * All of the animation groups added to this scene
  45969. * @see https://doc.babylonjs.com/how_to/group
  45970. */
  45971. animationGroups: AnimationGroup[];
  45972. /**
  45973. * All of the multi-materials added to this scene
  45974. * @see https://doc.babylonjs.com/how_to/multi_materials
  45975. */
  45976. multiMaterials: MultiMaterial[];
  45977. /**
  45978. * All of the materials added to this scene
  45979. * In the context of a Scene, it is not supposed to be modified manually.
  45980. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  45981. * Note also that the order of the Material within the array is not significant and might change.
  45982. * @see https://doc.babylonjs.com/babylon101/materials
  45983. */
  45984. materials: Material[];
  45985. /**
  45986. * The list of morph target managers added to the scene
  45987. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45988. */
  45989. morphTargetManagers: MorphTargetManager[];
  45990. /**
  45991. * The list of geometries used in the scene.
  45992. */
  45993. geometries: Geometry[];
  45994. /**
  45995. * All of the tranform nodes added to this scene
  45996. * In the context of a Scene, it is not supposed to be modified manually.
  45997. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45998. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45999. * @see https://doc.babylonjs.com/how_to/transformnode
  46000. */
  46001. transformNodes: TransformNode[];
  46002. /**
  46003. * ActionManagers available on the scene.
  46004. */
  46005. actionManagers: AbstractActionManager[];
  46006. /**
  46007. * Textures to keep.
  46008. */
  46009. textures: BaseTexture[];
  46010. /** @hidden */
  46011. protected _environmentTexture: Nullable<BaseTexture>;
  46012. /**
  46013. * Texture used in all pbr material as the reflection texture.
  46014. * As in the majority of the scene they are the same (exception for multi room and so on),
  46015. * this is easier to reference from here than from all the materials.
  46016. */
  46017. get environmentTexture(): Nullable<BaseTexture>;
  46018. set environmentTexture(value: Nullable<BaseTexture>);
  46019. /**
  46020. * The list of postprocesses added to the scene
  46021. */
  46022. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46023. /**
  46024. * @returns all meshes, lights, cameras, transformNodes and bones
  46025. */
  46026. getNodes(): Array<Node>;
  46027. }
  46028. }
  46029. declare module "babylonjs/Audio/sound" {
  46030. import { Observable } from "babylonjs/Misc/observable";
  46031. import { Vector3 } from "babylonjs/Maths/math.vector";
  46032. import { Nullable } from "babylonjs/types";
  46033. import { Scene } from "babylonjs/scene";
  46034. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46035. /**
  46036. * Interface used to define options for Sound class
  46037. */
  46038. export interface ISoundOptions {
  46039. /**
  46040. * Does the sound autoplay once loaded.
  46041. */
  46042. autoplay?: boolean;
  46043. /**
  46044. * Does the sound loop after it finishes playing once.
  46045. */
  46046. loop?: boolean;
  46047. /**
  46048. * Sound's volume
  46049. */
  46050. volume?: number;
  46051. /**
  46052. * Is it a spatial sound?
  46053. */
  46054. spatialSound?: boolean;
  46055. /**
  46056. * Maximum distance to hear that sound
  46057. */
  46058. maxDistance?: number;
  46059. /**
  46060. * Uses user defined attenuation function
  46061. */
  46062. useCustomAttenuation?: boolean;
  46063. /**
  46064. * Define the roll off factor of spatial sounds.
  46065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46066. */
  46067. rolloffFactor?: number;
  46068. /**
  46069. * Define the reference distance the sound should be heard perfectly.
  46070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46071. */
  46072. refDistance?: number;
  46073. /**
  46074. * Define the distance attenuation model the sound will follow.
  46075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46076. */
  46077. distanceModel?: string;
  46078. /**
  46079. * Defines the playback speed (1 by default)
  46080. */
  46081. playbackRate?: number;
  46082. /**
  46083. * Defines if the sound is from a streaming source
  46084. */
  46085. streaming?: boolean;
  46086. /**
  46087. * Defines an optional length (in seconds) inside the sound file
  46088. */
  46089. length?: number;
  46090. /**
  46091. * Defines an optional offset (in seconds) inside the sound file
  46092. */
  46093. offset?: number;
  46094. /**
  46095. * If true, URLs will not be required to state the audio file codec to use.
  46096. */
  46097. skipCodecCheck?: boolean;
  46098. }
  46099. /**
  46100. * Defines a sound that can be played in the application.
  46101. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46102. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46103. */
  46104. export class Sound {
  46105. /**
  46106. * The name of the sound in the scene.
  46107. */
  46108. name: string;
  46109. /**
  46110. * Does the sound autoplay once loaded.
  46111. */
  46112. autoplay: boolean;
  46113. /**
  46114. * Does the sound loop after it finishes playing once.
  46115. */
  46116. loop: boolean;
  46117. /**
  46118. * Does the sound use a custom attenuation curve to simulate the falloff
  46119. * happening when the source gets further away from the camera.
  46120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46121. */
  46122. useCustomAttenuation: boolean;
  46123. /**
  46124. * The sound track id this sound belongs to.
  46125. */
  46126. soundTrackId: number;
  46127. /**
  46128. * Is this sound currently played.
  46129. */
  46130. isPlaying: boolean;
  46131. /**
  46132. * Is this sound currently paused.
  46133. */
  46134. isPaused: boolean;
  46135. /**
  46136. * Does this sound enables spatial sound.
  46137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46138. */
  46139. spatialSound: boolean;
  46140. /**
  46141. * Define the reference distance the sound should be heard perfectly.
  46142. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46143. */
  46144. refDistance: number;
  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 max distance the sound should be heard (intensity just became 0 at this point).
  46152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46153. */
  46154. maxDistance: 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. * @hidden
  46162. * Back Compat
  46163. **/
  46164. onended: () => any;
  46165. /**
  46166. * Gets or sets an object used to store user defined information for the sound.
  46167. */
  46168. metadata: any;
  46169. /**
  46170. * Observable event when the current playing sound finishes.
  46171. */
  46172. onEndedObservable: Observable<Sound>;
  46173. private _panningModel;
  46174. private _playbackRate;
  46175. private _streaming;
  46176. private _startTime;
  46177. private _startOffset;
  46178. private _position;
  46179. /** @hidden */
  46180. _positionInEmitterSpace: boolean;
  46181. private _localDirection;
  46182. private _volume;
  46183. private _isReadyToPlay;
  46184. private _isDirectional;
  46185. private _readyToPlayCallback;
  46186. private _audioBuffer;
  46187. private _soundSource;
  46188. private _streamingSource;
  46189. private _soundPanner;
  46190. private _soundGain;
  46191. private _inputAudioNode;
  46192. private _outputAudioNode;
  46193. private _coneInnerAngle;
  46194. private _coneOuterAngle;
  46195. private _coneOuterGain;
  46196. private _scene;
  46197. private _connectedTransformNode;
  46198. private _customAttenuationFunction;
  46199. private _registerFunc;
  46200. private _isOutputConnected;
  46201. private _htmlAudioElement;
  46202. private _urlType;
  46203. private _length?;
  46204. private _offset?;
  46205. /** @hidden */
  46206. static _SceneComponentInitialization: (scene: Scene) => void;
  46207. /**
  46208. * Create a sound and attach it to a scene
  46209. * @param name Name of your sound
  46210. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46211. * @param scene defines the scene the sound belongs to
  46212. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46213. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46214. */
  46215. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46216. /**
  46217. * Release the sound and its associated resources
  46218. */
  46219. dispose(): void;
  46220. /**
  46221. * Gets if the sounds is ready to be played or not.
  46222. * @returns true if ready, otherwise false
  46223. */
  46224. isReady(): boolean;
  46225. private _soundLoaded;
  46226. /**
  46227. * Sets the data of the sound from an audiobuffer
  46228. * @param audioBuffer The audioBuffer containing the data
  46229. */
  46230. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46231. /**
  46232. * Updates the current sounds options such as maxdistance, loop...
  46233. * @param options A JSON object containing values named as the object properties
  46234. */
  46235. updateOptions(options: ISoundOptions): void;
  46236. private _createSpatialParameters;
  46237. private _updateSpatialParameters;
  46238. /**
  46239. * Switch the panning model to HRTF:
  46240. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46242. */
  46243. switchPanningModelToHRTF(): void;
  46244. /**
  46245. * Switch the panning model to Equal Power:
  46246. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46247. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46248. */
  46249. switchPanningModelToEqualPower(): void;
  46250. private _switchPanningModel;
  46251. /**
  46252. * Connect this sound to a sound track audio node like gain...
  46253. * @param soundTrackAudioNode the sound track audio node to connect to
  46254. */
  46255. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46256. /**
  46257. * Transform this sound into a directional source
  46258. * @param coneInnerAngle Size of the inner cone in degree
  46259. * @param coneOuterAngle Size of the outer cone in degree
  46260. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46261. */
  46262. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46263. /**
  46264. * Gets or sets the inner angle for the directional cone.
  46265. */
  46266. get directionalConeInnerAngle(): number;
  46267. /**
  46268. * Gets or sets the inner angle for the directional cone.
  46269. */
  46270. set directionalConeInnerAngle(value: number);
  46271. /**
  46272. * Gets or sets the outer angle for the directional cone.
  46273. */
  46274. get directionalConeOuterAngle(): number;
  46275. /**
  46276. * Gets or sets the outer angle for the directional cone.
  46277. */
  46278. set directionalConeOuterAngle(value: number);
  46279. /**
  46280. * Sets the position of the emitter if spatial sound is enabled
  46281. * @param newPosition Defines the new posisiton
  46282. */
  46283. setPosition(newPosition: Vector3): void;
  46284. /**
  46285. * Sets the local direction of the emitter if spatial sound is enabled
  46286. * @param newLocalDirection Defines the new local direction
  46287. */
  46288. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46289. private _updateDirection;
  46290. /** @hidden */
  46291. updateDistanceFromListener(): void;
  46292. /**
  46293. * Sets a new custom attenuation function for the sound.
  46294. * @param callback Defines the function used for the attenuation
  46295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46296. */
  46297. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46298. /**
  46299. * Play the sound
  46300. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46301. * @param offset (optional) Start the sound at a specific time in seconds
  46302. * @param length (optional) Sound duration (in seconds)
  46303. */
  46304. play(time?: number, offset?: number, length?: number): void;
  46305. private _onended;
  46306. /**
  46307. * Stop the sound
  46308. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46309. */
  46310. stop(time?: number): void;
  46311. /**
  46312. * Put the sound in pause
  46313. */
  46314. pause(): void;
  46315. /**
  46316. * Sets a dedicated volume for this sounds
  46317. * @param newVolume Define the new volume of the sound
  46318. * @param time Define time for gradual change to new volume
  46319. */
  46320. setVolume(newVolume: number, time?: number): void;
  46321. /**
  46322. * Set the sound play back rate
  46323. * @param newPlaybackRate Define the playback rate the sound should be played at
  46324. */
  46325. setPlaybackRate(newPlaybackRate: number): void;
  46326. /**
  46327. * Gets the volume of the sound.
  46328. * @returns the volume of the sound
  46329. */
  46330. getVolume(): number;
  46331. /**
  46332. * Attach the sound to a dedicated mesh
  46333. * @param transformNode The transform node to connect the sound with
  46334. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46335. */
  46336. attachToMesh(transformNode: TransformNode): void;
  46337. /**
  46338. * Detach the sound from the previously attached mesh
  46339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46340. */
  46341. detachFromMesh(): void;
  46342. private _onRegisterAfterWorldMatrixUpdate;
  46343. /**
  46344. * Clone the current sound in the scene.
  46345. * @returns the new sound clone
  46346. */
  46347. clone(): Nullable<Sound>;
  46348. /**
  46349. * Gets the current underlying audio buffer containing the data
  46350. * @returns the audio buffer
  46351. */
  46352. getAudioBuffer(): Nullable<AudioBuffer>;
  46353. /**
  46354. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46355. * @returns the source node
  46356. */
  46357. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46358. /**
  46359. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46360. * @returns the gain node
  46361. */
  46362. getSoundGain(): Nullable<GainNode>;
  46363. /**
  46364. * Serializes the Sound in a JSON representation
  46365. * @returns the JSON representation of the sound
  46366. */
  46367. serialize(): any;
  46368. /**
  46369. * Parse a JSON representation of a sound to innstantiate in a given scene
  46370. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46371. * @param scene Define the scene the new parsed sound should be created in
  46372. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46373. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46374. * @returns the newly parsed sound
  46375. */
  46376. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46377. }
  46378. }
  46379. declare module "babylonjs/Actions/directAudioActions" {
  46380. import { Action } from "babylonjs/Actions/action";
  46381. import { Condition } from "babylonjs/Actions/condition";
  46382. import { Sound } from "babylonjs/Audio/sound";
  46383. /**
  46384. * This defines an action helpful to play a defined sound on a triggered action.
  46385. */
  46386. export class PlaySoundAction extends Action {
  46387. private _sound;
  46388. /**
  46389. * Instantiate the action
  46390. * @param triggerOptions defines the trigger options
  46391. * @param sound defines the sound to play
  46392. * @param condition defines the trigger related conditions
  46393. */
  46394. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46395. /** @hidden */
  46396. _prepare(): void;
  46397. /**
  46398. * Execute the action and play the sound.
  46399. */
  46400. execute(): void;
  46401. /**
  46402. * Serializes the actions and its related information.
  46403. * @param parent defines the object to serialize in
  46404. * @returns the serialized object
  46405. */
  46406. serialize(parent: any): any;
  46407. }
  46408. /**
  46409. * This defines an action helpful to stop a defined sound on a triggered action.
  46410. */
  46411. export class StopSoundAction extends Action {
  46412. private _sound;
  46413. /**
  46414. * Instantiate the action
  46415. * @param triggerOptions defines the trigger options
  46416. * @param sound defines the sound to stop
  46417. * @param condition defines the trigger related conditions
  46418. */
  46419. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46420. /** @hidden */
  46421. _prepare(): void;
  46422. /**
  46423. * Execute the action and stop the sound.
  46424. */
  46425. execute(): void;
  46426. /**
  46427. * Serializes the actions and its related information.
  46428. * @param parent defines the object to serialize in
  46429. * @returns the serialized object
  46430. */
  46431. serialize(parent: any): any;
  46432. }
  46433. }
  46434. declare module "babylonjs/Actions/interpolateValueAction" {
  46435. import { Action } from "babylonjs/Actions/action";
  46436. import { Condition } from "babylonjs/Actions/condition";
  46437. import { Observable } from "babylonjs/Misc/observable";
  46438. /**
  46439. * This defines an action responsible to change the value of a property
  46440. * by interpolating between its current value and the newly set one once triggered.
  46441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46442. */
  46443. export class InterpolateValueAction extends Action {
  46444. /**
  46445. * Defines the path of the property where the value should be interpolated
  46446. */
  46447. propertyPath: string;
  46448. /**
  46449. * Defines the target value at the end of the interpolation.
  46450. */
  46451. value: any;
  46452. /**
  46453. * Defines the time it will take for the property to interpolate to the value.
  46454. */
  46455. duration: number;
  46456. /**
  46457. * Defines if the other scene animations should be stopped when the action has been triggered
  46458. */
  46459. stopOtherAnimations?: boolean;
  46460. /**
  46461. * Defines a callback raised once the interpolation animation has been done.
  46462. */
  46463. onInterpolationDone?: () => void;
  46464. /**
  46465. * Observable triggered once the interpolation animation has been done.
  46466. */
  46467. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46468. private _target;
  46469. private _effectiveTarget;
  46470. private _property;
  46471. /**
  46472. * Instantiate the action
  46473. * @param triggerOptions defines the trigger options
  46474. * @param target defines the object containing the value to interpolate
  46475. * @param propertyPath defines the path to the property in the target object
  46476. * @param value defines the target value at the end of the interpolation
  46477. * @param duration deines the time it will take for the property to interpolate to the value.
  46478. * @param condition defines the trigger related conditions
  46479. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46480. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46481. */
  46482. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46483. /** @hidden */
  46484. _prepare(): void;
  46485. /**
  46486. * Execute the action starts the value interpolation.
  46487. */
  46488. execute(): void;
  46489. /**
  46490. * Serializes the actions and its related information.
  46491. * @param parent defines the object to serialize in
  46492. * @returns the serialized object
  46493. */
  46494. serialize(parent: any): any;
  46495. }
  46496. }
  46497. declare module "babylonjs/Actions/index" {
  46498. export * from "babylonjs/Actions/abstractActionManager";
  46499. export * from "babylonjs/Actions/action";
  46500. export * from "babylonjs/Actions/actionEvent";
  46501. export * from "babylonjs/Actions/actionManager";
  46502. export * from "babylonjs/Actions/condition";
  46503. export * from "babylonjs/Actions/directActions";
  46504. export * from "babylonjs/Actions/directAudioActions";
  46505. export * from "babylonjs/Actions/interpolateValueAction";
  46506. }
  46507. declare module "babylonjs/Animations/index" {
  46508. export * from "babylonjs/Animations/animatable";
  46509. export * from "babylonjs/Animations/animation";
  46510. export * from "babylonjs/Animations/animationGroup";
  46511. export * from "babylonjs/Animations/animationPropertiesOverride";
  46512. export * from "babylonjs/Animations/easing";
  46513. export * from "babylonjs/Animations/runtimeAnimation";
  46514. export * from "babylonjs/Animations/animationEvent";
  46515. export * from "babylonjs/Animations/animationGroup";
  46516. export * from "babylonjs/Animations/animationKey";
  46517. export * from "babylonjs/Animations/animationRange";
  46518. export * from "babylonjs/Animations/animatable.interface";
  46519. }
  46520. declare module "babylonjs/Audio/soundTrack" {
  46521. import { Sound } from "babylonjs/Audio/sound";
  46522. import { Analyser } from "babylonjs/Audio/analyser";
  46523. import { Scene } from "babylonjs/scene";
  46524. /**
  46525. * Options allowed during the creation of a sound track.
  46526. */
  46527. export interface ISoundTrackOptions {
  46528. /**
  46529. * The volume the sound track should take during creation
  46530. */
  46531. volume?: number;
  46532. /**
  46533. * Define if the sound track is the main sound track of the scene
  46534. */
  46535. mainTrack?: boolean;
  46536. }
  46537. /**
  46538. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46539. * It will be also used in a future release to apply effects on a specific track.
  46540. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46541. */
  46542. export class SoundTrack {
  46543. /**
  46544. * The unique identifier of the sound track in the scene.
  46545. */
  46546. id: number;
  46547. /**
  46548. * The list of sounds included in the sound track.
  46549. */
  46550. soundCollection: Array<Sound>;
  46551. private _outputAudioNode;
  46552. private _scene;
  46553. private _connectedAnalyser;
  46554. private _options;
  46555. private _isInitialized;
  46556. /**
  46557. * Creates a new sound track.
  46558. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46559. * @param scene Define the scene the sound track belongs to
  46560. * @param options
  46561. */
  46562. constructor(scene: Scene, options?: ISoundTrackOptions);
  46563. private _initializeSoundTrackAudioGraph;
  46564. /**
  46565. * Release the sound track and its associated resources
  46566. */
  46567. dispose(): void;
  46568. /**
  46569. * Adds a sound to this sound track
  46570. * @param sound define the cound to add
  46571. * @ignoreNaming
  46572. */
  46573. AddSound(sound: Sound): void;
  46574. /**
  46575. * Removes a sound to this sound track
  46576. * @param sound define the cound to remove
  46577. * @ignoreNaming
  46578. */
  46579. RemoveSound(sound: Sound): void;
  46580. /**
  46581. * Set a global volume for the full sound track.
  46582. * @param newVolume Define the new volume of the sound track
  46583. */
  46584. setVolume(newVolume: number): void;
  46585. /**
  46586. * Switch the panning model to HRTF:
  46587. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46589. */
  46590. switchPanningModelToHRTF(): void;
  46591. /**
  46592. * Switch the panning model to Equal Power:
  46593. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46595. */
  46596. switchPanningModelToEqualPower(): void;
  46597. /**
  46598. * Connect the sound track to an audio analyser allowing some amazing
  46599. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46600. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46601. * @param analyser The analyser to connect to the engine
  46602. */
  46603. connectToAnalyser(analyser: Analyser): void;
  46604. }
  46605. }
  46606. declare module "babylonjs/Audio/audioSceneComponent" {
  46607. import { Sound } from "babylonjs/Audio/sound";
  46608. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46609. import { Nullable } from "babylonjs/types";
  46610. import { Vector3 } from "babylonjs/Maths/math.vector";
  46611. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46612. import { Scene } from "babylonjs/scene";
  46613. import { AbstractScene } from "babylonjs/abstractScene";
  46614. import "babylonjs/Audio/audioEngine";
  46615. module "babylonjs/abstractScene" {
  46616. interface AbstractScene {
  46617. /**
  46618. * The list of sounds used in the scene.
  46619. */
  46620. sounds: Nullable<Array<Sound>>;
  46621. }
  46622. }
  46623. module "babylonjs/scene" {
  46624. interface Scene {
  46625. /**
  46626. * @hidden
  46627. * Backing field
  46628. */
  46629. _mainSoundTrack: SoundTrack;
  46630. /**
  46631. * The main sound track played by the scene.
  46632. * It cotains your primary collection of sounds.
  46633. */
  46634. mainSoundTrack: SoundTrack;
  46635. /**
  46636. * The list of sound tracks added to the scene
  46637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46638. */
  46639. soundTracks: Nullable<Array<SoundTrack>>;
  46640. /**
  46641. * Gets a sound using a given name
  46642. * @param name defines the name to search for
  46643. * @return the found sound or null if not found at all.
  46644. */
  46645. getSoundByName(name: string): Nullable<Sound>;
  46646. /**
  46647. * Gets or sets if audio support is enabled
  46648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46649. */
  46650. audioEnabled: boolean;
  46651. /**
  46652. * Gets or sets if audio will be output to headphones
  46653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46654. */
  46655. headphone: boolean;
  46656. /**
  46657. * Gets or sets custom audio listener position provider
  46658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46659. */
  46660. audioListenerPositionProvider: Nullable<() => Vector3>;
  46661. /**
  46662. * Gets or sets a refresh rate when using 3D audio positioning
  46663. */
  46664. audioPositioningRefreshRate: number;
  46665. }
  46666. }
  46667. /**
  46668. * Defines the sound scene component responsible to manage any sounds
  46669. * in a given scene.
  46670. */
  46671. export class AudioSceneComponent implements ISceneSerializableComponent {
  46672. private static _CameraDirectionLH;
  46673. private static _CameraDirectionRH;
  46674. /**
  46675. * The component name helpfull to identify the component in the list of scene components.
  46676. */
  46677. readonly name: string;
  46678. /**
  46679. * The scene the component belongs to.
  46680. */
  46681. scene: Scene;
  46682. private _audioEnabled;
  46683. /**
  46684. * Gets whether audio is enabled or not.
  46685. * Please use related enable/disable method to switch state.
  46686. */
  46687. get audioEnabled(): boolean;
  46688. private _headphone;
  46689. /**
  46690. * Gets whether audio is outputing to headphone or not.
  46691. * Please use the according Switch methods to change output.
  46692. */
  46693. get headphone(): boolean;
  46694. /**
  46695. * Gets or sets a refresh rate when using 3D audio positioning
  46696. */
  46697. audioPositioningRefreshRate: number;
  46698. private _audioListenerPositionProvider;
  46699. /**
  46700. * Gets the current audio listener position provider
  46701. */
  46702. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46703. /**
  46704. * Sets a custom listener position for all sounds in the scene
  46705. * By default, this is the position of the first active camera
  46706. */
  46707. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46708. /**
  46709. * Creates a new instance of the component for the given scene
  46710. * @param scene Defines the scene to register the component in
  46711. */
  46712. constructor(scene: Scene);
  46713. /**
  46714. * Registers the component in a given scene
  46715. */
  46716. register(): void;
  46717. /**
  46718. * Rebuilds the elements related to this component in case of
  46719. * context lost for instance.
  46720. */
  46721. rebuild(): void;
  46722. /**
  46723. * Serializes the component data to the specified json object
  46724. * @param serializationObject The object to serialize to
  46725. */
  46726. serialize(serializationObject: any): void;
  46727. /**
  46728. * Adds all the elements from the container to the scene
  46729. * @param container the container holding the elements
  46730. */
  46731. addFromContainer(container: AbstractScene): void;
  46732. /**
  46733. * Removes all the elements in the container from the scene
  46734. * @param container contains the elements to remove
  46735. * @param dispose if the removed element should be disposed (default: false)
  46736. */
  46737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46738. /**
  46739. * Disposes the component and the associated ressources.
  46740. */
  46741. dispose(): void;
  46742. /**
  46743. * Disables audio in the associated scene.
  46744. */
  46745. disableAudio(): void;
  46746. /**
  46747. * Enables audio in the associated scene.
  46748. */
  46749. enableAudio(): void;
  46750. /**
  46751. * Switch audio to headphone output.
  46752. */
  46753. switchAudioModeForHeadphones(): void;
  46754. /**
  46755. * Switch audio to normal speakers.
  46756. */
  46757. switchAudioModeForNormalSpeakers(): void;
  46758. private _cachedCameraDirection;
  46759. private _cachedCameraPosition;
  46760. private _lastCheck;
  46761. private _afterRender;
  46762. }
  46763. }
  46764. declare module "babylonjs/Audio/weightedsound" {
  46765. import { Sound } from "babylonjs/Audio/sound";
  46766. /**
  46767. * Wraps one or more Sound objects and selects one with random weight for playback.
  46768. */
  46769. export class WeightedSound {
  46770. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46771. loop: boolean;
  46772. private _coneInnerAngle;
  46773. private _coneOuterAngle;
  46774. private _volume;
  46775. /** A Sound is currently playing. */
  46776. isPlaying: boolean;
  46777. /** A Sound is currently paused. */
  46778. isPaused: boolean;
  46779. private _sounds;
  46780. private _weights;
  46781. private _currentIndex?;
  46782. /**
  46783. * Creates a new WeightedSound from the list of sounds given.
  46784. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46785. * @param sounds Array of Sounds that will be selected from.
  46786. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46787. */
  46788. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46789. /**
  46790. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46791. */
  46792. get directionalConeInnerAngle(): number;
  46793. /**
  46794. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46795. */
  46796. set directionalConeInnerAngle(value: number);
  46797. /**
  46798. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46799. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46800. */
  46801. get directionalConeOuterAngle(): number;
  46802. /**
  46803. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46804. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46805. */
  46806. set directionalConeOuterAngle(value: number);
  46807. /**
  46808. * Playback volume.
  46809. */
  46810. get volume(): number;
  46811. /**
  46812. * Playback volume.
  46813. */
  46814. set volume(value: number);
  46815. private _onended;
  46816. /**
  46817. * Suspend playback
  46818. */
  46819. pause(): void;
  46820. /**
  46821. * Stop playback
  46822. */
  46823. stop(): void;
  46824. /**
  46825. * Start playback.
  46826. * @param startOffset Position the clip head at a specific time in seconds.
  46827. */
  46828. play(startOffset?: number): void;
  46829. }
  46830. }
  46831. declare module "babylonjs/Audio/index" {
  46832. export * from "babylonjs/Audio/analyser";
  46833. export * from "babylonjs/Audio/audioEngine";
  46834. export * from "babylonjs/Audio/audioSceneComponent";
  46835. export * from "babylonjs/Audio/sound";
  46836. export * from "babylonjs/Audio/soundTrack";
  46837. export * from "babylonjs/Audio/weightedsound";
  46838. }
  46839. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46840. import { Behavior } from "babylonjs/Behaviors/behavior";
  46841. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46842. import { BackEase } from "babylonjs/Animations/easing";
  46843. /**
  46844. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46845. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46846. */
  46847. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46848. /**
  46849. * Gets the name of the behavior.
  46850. */
  46851. get name(): string;
  46852. /**
  46853. * The easing function used by animations
  46854. */
  46855. static EasingFunction: BackEase;
  46856. /**
  46857. * The easing mode used by animations
  46858. */
  46859. static EasingMode: number;
  46860. /**
  46861. * The duration of the animation, in milliseconds
  46862. */
  46863. transitionDuration: number;
  46864. /**
  46865. * Length of the distance animated by the transition when lower radius is reached
  46866. */
  46867. lowerRadiusTransitionRange: number;
  46868. /**
  46869. * Length of the distance animated by the transition when upper radius is reached
  46870. */
  46871. upperRadiusTransitionRange: number;
  46872. private _autoTransitionRange;
  46873. /**
  46874. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46875. */
  46876. get autoTransitionRange(): boolean;
  46877. /**
  46878. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46879. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46880. */
  46881. set autoTransitionRange(value: boolean);
  46882. private _attachedCamera;
  46883. private _onAfterCheckInputsObserver;
  46884. private _onMeshTargetChangedObserver;
  46885. /**
  46886. * Initializes the behavior.
  46887. */
  46888. init(): void;
  46889. /**
  46890. * Attaches the behavior to its arc rotate camera.
  46891. * @param camera Defines the camera to attach the behavior to
  46892. */
  46893. attach(camera: ArcRotateCamera): void;
  46894. /**
  46895. * Detaches the behavior from its current arc rotate camera.
  46896. */
  46897. detach(): void;
  46898. private _radiusIsAnimating;
  46899. private _radiusBounceTransition;
  46900. private _animatables;
  46901. private _cachedWheelPrecision;
  46902. /**
  46903. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46904. * @param radiusLimit The limit to check against.
  46905. * @return Bool to indicate if at limit.
  46906. */
  46907. private _isRadiusAtLimit;
  46908. /**
  46909. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46910. * @param radiusDelta The delta by which to animate to. Can be negative.
  46911. */
  46912. private _applyBoundRadiusAnimation;
  46913. /**
  46914. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46915. */
  46916. protected _clearAnimationLocks(): void;
  46917. /**
  46918. * Stops and removes all animations that have been applied to the camera
  46919. */
  46920. stopAllAnimations(): void;
  46921. }
  46922. }
  46923. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  46924. import { Behavior } from "babylonjs/Behaviors/behavior";
  46925. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46926. import { ExponentialEase } from "babylonjs/Animations/easing";
  46927. import { Nullable } from "babylonjs/types";
  46928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46929. import { Vector3 } from "babylonjs/Maths/math.vector";
  46930. /**
  46931. * 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.
  46932. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46933. */
  46934. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46935. /**
  46936. * Gets the name of the behavior.
  46937. */
  46938. get name(): string;
  46939. private _mode;
  46940. private _radiusScale;
  46941. private _positionScale;
  46942. private _defaultElevation;
  46943. private _elevationReturnTime;
  46944. private _elevationReturnWaitTime;
  46945. private _zoomStopsAnimation;
  46946. private _framingTime;
  46947. /**
  46948. * The easing function used by animations
  46949. */
  46950. static EasingFunction: ExponentialEase;
  46951. /**
  46952. * The easing mode used by animations
  46953. */
  46954. static EasingMode: number;
  46955. /**
  46956. * Sets the current mode used by the behavior
  46957. */
  46958. set mode(mode: number);
  46959. /**
  46960. * Gets current mode used by the behavior.
  46961. */
  46962. get mode(): number;
  46963. /**
  46964. * Sets the scale applied to the radius (1 by default)
  46965. */
  46966. set radiusScale(radius: number);
  46967. /**
  46968. * Gets the scale applied to the radius
  46969. */
  46970. get radiusScale(): number;
  46971. /**
  46972. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46973. */
  46974. set positionScale(scale: number);
  46975. /**
  46976. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46977. */
  46978. get positionScale(): number;
  46979. /**
  46980. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46981. * behaviour is triggered, in radians.
  46982. */
  46983. set defaultElevation(elevation: number);
  46984. /**
  46985. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46986. * behaviour is triggered, in radians.
  46987. */
  46988. get defaultElevation(): number;
  46989. /**
  46990. * Sets the time (in milliseconds) taken to return to the default beta position.
  46991. * Negative value indicates camera should not return to default.
  46992. */
  46993. set elevationReturnTime(speed: number);
  46994. /**
  46995. * Gets the time (in milliseconds) taken to return to the default beta position.
  46996. * Negative value indicates camera should not return to default.
  46997. */
  46998. get elevationReturnTime(): number;
  46999. /**
  47000. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47001. */
  47002. set elevationReturnWaitTime(time: number);
  47003. /**
  47004. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47005. */
  47006. get elevationReturnWaitTime(): number;
  47007. /**
  47008. * Sets the flag that indicates if user zooming should stop animation.
  47009. */
  47010. set zoomStopsAnimation(flag: boolean);
  47011. /**
  47012. * Gets the flag that indicates if user zooming should stop animation.
  47013. */
  47014. get zoomStopsAnimation(): boolean;
  47015. /**
  47016. * Sets the transition time when framing the mesh, in milliseconds
  47017. */
  47018. set framingTime(time: number);
  47019. /**
  47020. * Gets the transition time when framing the mesh, in milliseconds
  47021. */
  47022. get framingTime(): number;
  47023. /**
  47024. * Define if the behavior should automatically change the configured
  47025. * camera limits and sensibilities.
  47026. */
  47027. autoCorrectCameraLimitsAndSensibility: boolean;
  47028. private _onPrePointerObservableObserver;
  47029. private _onAfterCheckInputsObserver;
  47030. private _onMeshTargetChangedObserver;
  47031. private _attachedCamera;
  47032. private _isPointerDown;
  47033. private _lastInteractionTime;
  47034. /**
  47035. * Initializes the behavior.
  47036. */
  47037. init(): void;
  47038. /**
  47039. * Attaches the behavior to its arc rotate camera.
  47040. * @param camera Defines the camera to attach the behavior to
  47041. */
  47042. attach(camera: ArcRotateCamera): void;
  47043. /**
  47044. * Detaches the behavior from its current arc rotate camera.
  47045. */
  47046. detach(): void;
  47047. private _animatables;
  47048. private _betaIsAnimating;
  47049. private _betaTransition;
  47050. private _radiusTransition;
  47051. private _vectorTransition;
  47052. /**
  47053. * Targets the given mesh and updates zoom level accordingly.
  47054. * @param mesh The mesh to target.
  47055. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47056. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47057. */
  47058. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47059. /**
  47060. * Targets the given mesh with its children and updates zoom level accordingly.
  47061. * @param mesh The mesh to target.
  47062. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47063. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47064. */
  47065. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47066. /**
  47067. * Targets the given meshes with their children and updates zoom level accordingly.
  47068. * @param meshes The mesh to target.
  47069. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47070. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47071. */
  47072. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47073. /**
  47074. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47075. * @param minimumWorld Determines the smaller position of the bounding box extend
  47076. * @param maximumWorld Determines the bigger position of the bounding box extend
  47077. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47078. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47079. */
  47080. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47081. /**
  47082. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47083. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47084. * frustum width.
  47085. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47086. * to fully enclose the mesh in the viewing frustum.
  47087. */
  47088. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47089. /**
  47090. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47091. * is automatically returned to its default position (expected to be above ground plane).
  47092. */
  47093. private _maintainCameraAboveGround;
  47094. /**
  47095. * Returns the frustum slope based on the canvas ratio and camera FOV
  47096. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47097. */
  47098. private _getFrustumSlope;
  47099. /**
  47100. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47101. */
  47102. private _clearAnimationLocks;
  47103. /**
  47104. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47105. */
  47106. private _applyUserInteraction;
  47107. /**
  47108. * Stops and removes all animations that have been applied to the camera
  47109. */
  47110. stopAllAnimations(): void;
  47111. /**
  47112. * Gets a value indicating if the user is moving the camera
  47113. */
  47114. get isUserIsMoving(): boolean;
  47115. /**
  47116. * The camera can move all the way towards the mesh.
  47117. */
  47118. static IgnoreBoundsSizeMode: number;
  47119. /**
  47120. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47121. */
  47122. static FitFrustumSidesMode: number;
  47123. }
  47124. }
  47125. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47126. import { Nullable } from "babylonjs/types";
  47127. import { Camera } from "babylonjs/Cameras/camera";
  47128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47129. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47130. /**
  47131. * Base class for Camera Pointer Inputs.
  47132. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47133. * for example usage.
  47134. */
  47135. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47136. /**
  47137. * Defines the camera the input is attached to.
  47138. */
  47139. abstract camera: Camera;
  47140. /**
  47141. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47142. */
  47143. protected _altKey: boolean;
  47144. protected _ctrlKey: boolean;
  47145. protected _metaKey: boolean;
  47146. protected _shiftKey: boolean;
  47147. /**
  47148. * Which mouse buttons were pressed at time of last mouse event.
  47149. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47150. */
  47151. protected _buttonsPressed: number;
  47152. /**
  47153. * Defines the buttons associated with the input to handle camera move.
  47154. */
  47155. buttons: number[];
  47156. /**
  47157. * Attach the input controls to a specific dom element to get the input from.
  47158. * @param element Defines the element the controls should be listened from
  47159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47160. */
  47161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47162. /**
  47163. * Detach the current controls from the specified dom element.
  47164. * @param element Defines the element to stop listening the inputs from
  47165. */
  47166. detachControl(element: Nullable<HTMLElement>): void;
  47167. /**
  47168. * Gets the class name of the current input.
  47169. * @returns the class name
  47170. */
  47171. getClassName(): string;
  47172. /**
  47173. * Get the friendly name associated with the input class.
  47174. * @returns the input friendly name
  47175. */
  47176. getSimpleName(): string;
  47177. /**
  47178. * Called on pointer POINTERDOUBLETAP event.
  47179. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47180. */
  47181. protected onDoubleTap(type: string): void;
  47182. /**
  47183. * Called on pointer POINTERMOVE event if only a single touch is active.
  47184. * Override this method to provide functionality.
  47185. */
  47186. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47187. /**
  47188. * Called on pointer POINTERMOVE event if multiple touches are active.
  47189. * Override this method to provide functionality.
  47190. */
  47191. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47192. /**
  47193. * Called on JS contextmenu event.
  47194. * Override this method to provide functionality.
  47195. */
  47196. protected onContextMenu(evt: PointerEvent): void;
  47197. /**
  47198. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47199. * press.
  47200. * Override this method to provide functionality.
  47201. */
  47202. protected onButtonDown(evt: PointerEvent): void;
  47203. /**
  47204. * Called each time a new POINTERUP event occurs. Ie, for each button
  47205. * release.
  47206. * Override this method to provide functionality.
  47207. */
  47208. protected onButtonUp(evt: PointerEvent): void;
  47209. /**
  47210. * Called when window becomes inactive.
  47211. * Override this method to provide functionality.
  47212. */
  47213. protected onLostFocus(): void;
  47214. private _pointerInput;
  47215. private _observer;
  47216. private _onLostFocus;
  47217. private pointA;
  47218. private pointB;
  47219. }
  47220. }
  47221. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47222. import { Nullable } from "babylonjs/types";
  47223. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47224. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47225. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47226. /**
  47227. * Manage the pointers inputs to control an arc rotate camera.
  47228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47229. */
  47230. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47231. /**
  47232. * Defines the camera the input is attached to.
  47233. */
  47234. camera: ArcRotateCamera;
  47235. /**
  47236. * Gets the class name of the current input.
  47237. * @returns the class name
  47238. */
  47239. getClassName(): string;
  47240. /**
  47241. * Defines the buttons associated with the input to handle camera move.
  47242. */
  47243. buttons: number[];
  47244. /**
  47245. * Defines the pointer angular sensibility along the X axis or how fast is
  47246. * the camera rotating.
  47247. */
  47248. angularSensibilityX: number;
  47249. /**
  47250. * Defines the pointer angular sensibility along the Y axis or how fast is
  47251. * the camera rotating.
  47252. */
  47253. angularSensibilityY: number;
  47254. /**
  47255. * Defines the pointer pinch precision or how fast is the camera zooming.
  47256. */
  47257. pinchPrecision: number;
  47258. /**
  47259. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47260. * from 0.
  47261. * It defines the percentage of current camera.radius to use as delta when
  47262. * pinch zoom is used.
  47263. */
  47264. pinchDeltaPercentage: number;
  47265. /**
  47266. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47267. * that any object in the plane at the camera's target point will scale
  47268. * perfectly with finger motion.
  47269. * Overrides pinchDeltaPercentage and pinchPrecision.
  47270. */
  47271. useNaturalPinchZoom: boolean;
  47272. /**
  47273. * Defines the pointer panning sensibility or how fast is the camera moving.
  47274. */
  47275. panningSensibility: number;
  47276. /**
  47277. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47278. */
  47279. multiTouchPanning: boolean;
  47280. /**
  47281. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47282. * zoom (pinch) through multitouch.
  47283. */
  47284. multiTouchPanAndZoom: boolean;
  47285. /**
  47286. * Revers pinch action direction.
  47287. */
  47288. pinchInwards: boolean;
  47289. private _isPanClick;
  47290. private _twoFingerActivityCount;
  47291. private _isPinching;
  47292. /**
  47293. * Called on pointer POINTERMOVE event if only a single touch is active.
  47294. */
  47295. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47296. /**
  47297. * Called on pointer POINTERDOUBLETAP event.
  47298. */
  47299. protected onDoubleTap(type: string): void;
  47300. /**
  47301. * Called on pointer POINTERMOVE event if multiple touches are active.
  47302. */
  47303. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47304. /**
  47305. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47306. * press.
  47307. */
  47308. protected onButtonDown(evt: PointerEvent): void;
  47309. /**
  47310. * Called each time a new POINTERUP event occurs. Ie, for each button
  47311. * release.
  47312. */
  47313. protected onButtonUp(evt: PointerEvent): void;
  47314. /**
  47315. * Called when window becomes inactive.
  47316. */
  47317. protected onLostFocus(): void;
  47318. }
  47319. }
  47320. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47321. import { Nullable } from "babylonjs/types";
  47322. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47324. /**
  47325. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47327. */
  47328. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47329. /**
  47330. * Defines the camera the input is attached to.
  47331. */
  47332. camera: ArcRotateCamera;
  47333. /**
  47334. * Defines the list of key codes associated with the up action (increase alpha)
  47335. */
  47336. keysUp: number[];
  47337. /**
  47338. * Defines the list of key codes associated with the down action (decrease alpha)
  47339. */
  47340. keysDown: number[];
  47341. /**
  47342. * Defines the list of key codes associated with the left action (increase beta)
  47343. */
  47344. keysLeft: number[];
  47345. /**
  47346. * Defines the list of key codes associated with the right action (decrease beta)
  47347. */
  47348. keysRight: number[];
  47349. /**
  47350. * Defines the list of key codes associated with the reset action.
  47351. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47352. */
  47353. keysReset: number[];
  47354. /**
  47355. * Defines the panning sensibility of the inputs.
  47356. * (How fast is the camera panning)
  47357. */
  47358. panningSensibility: number;
  47359. /**
  47360. * Defines the zooming sensibility of the inputs.
  47361. * (How fast is the camera zooming)
  47362. */
  47363. zoomingSensibility: number;
  47364. /**
  47365. * Defines whether maintaining the alt key down switch the movement mode from
  47366. * orientation to zoom.
  47367. */
  47368. useAltToZoom: boolean;
  47369. /**
  47370. * Rotation speed of the camera
  47371. */
  47372. angularSpeed: number;
  47373. private _keys;
  47374. private _ctrlPressed;
  47375. private _altPressed;
  47376. private _onCanvasBlurObserver;
  47377. private _onKeyboardObserver;
  47378. private _engine;
  47379. private _scene;
  47380. /**
  47381. * Attach the input controls to a specific dom element to get the input from.
  47382. * @param element Defines the element the controls should be listened from
  47383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47384. */
  47385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47386. /**
  47387. * Detach the current controls from the specified dom element.
  47388. * @param element Defines the element to stop listening the inputs from
  47389. */
  47390. detachControl(element: Nullable<HTMLElement>): void;
  47391. /**
  47392. * Update the current camera state depending on the inputs that have been used this frame.
  47393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47394. */
  47395. checkInputs(): void;
  47396. /**
  47397. * Gets the class name of the current intput.
  47398. * @returns the class name
  47399. */
  47400. getClassName(): string;
  47401. /**
  47402. * Get the friendly name associated with the input class.
  47403. * @returns the input friendly name
  47404. */
  47405. getSimpleName(): string;
  47406. }
  47407. }
  47408. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47409. import { Nullable } from "babylonjs/types";
  47410. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47412. /**
  47413. * Manage the mouse wheel inputs to control an arc rotate camera.
  47414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47415. */
  47416. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47417. /**
  47418. * Defines the camera the input is attached to.
  47419. */
  47420. camera: ArcRotateCamera;
  47421. /**
  47422. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47423. */
  47424. wheelPrecision: number;
  47425. /**
  47426. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47427. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47428. */
  47429. wheelDeltaPercentage: number;
  47430. private _wheel;
  47431. private _observer;
  47432. private computeDeltaFromMouseWheelLegacyEvent;
  47433. /**
  47434. * Attach the input controls to a specific dom element to get the input from.
  47435. * @param element Defines the element the controls should be listened from
  47436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47437. */
  47438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47439. /**
  47440. * Detach the current controls from the specified dom element.
  47441. * @param element Defines the element to stop listening the inputs from
  47442. */
  47443. detachControl(element: Nullable<HTMLElement>): void;
  47444. /**
  47445. * Gets the class name of the current intput.
  47446. * @returns the class name
  47447. */
  47448. getClassName(): string;
  47449. /**
  47450. * Get the friendly name associated with the input class.
  47451. * @returns the input friendly name
  47452. */
  47453. getSimpleName(): string;
  47454. }
  47455. }
  47456. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47457. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47458. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47459. /**
  47460. * Default Inputs manager for the ArcRotateCamera.
  47461. * It groups all the default supported inputs for ease of use.
  47462. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47463. */
  47464. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47465. /**
  47466. * Instantiates a new ArcRotateCameraInputsManager.
  47467. * @param camera Defines the camera the inputs belong to
  47468. */
  47469. constructor(camera: ArcRotateCamera);
  47470. /**
  47471. * Add mouse wheel input support to the input manager.
  47472. * @returns the current input manager
  47473. */
  47474. addMouseWheel(): ArcRotateCameraInputsManager;
  47475. /**
  47476. * Add pointers input support to the input manager.
  47477. * @returns the current input manager
  47478. */
  47479. addPointers(): ArcRotateCameraInputsManager;
  47480. /**
  47481. * Add keyboard input support to the input manager.
  47482. * @returns the current input manager
  47483. */
  47484. addKeyboard(): ArcRotateCameraInputsManager;
  47485. }
  47486. }
  47487. declare module "babylonjs/Cameras/arcRotateCamera" {
  47488. import { Observable } from "babylonjs/Misc/observable";
  47489. import { Nullable } from "babylonjs/types";
  47490. import { Scene } from "babylonjs/scene";
  47491. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47493. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47494. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47495. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47496. import { Camera } from "babylonjs/Cameras/camera";
  47497. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47498. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47499. import { Collider } from "babylonjs/Collisions/collider";
  47500. /**
  47501. * This represents an orbital type of camera.
  47502. *
  47503. * 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.
  47504. * 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.
  47505. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47506. */
  47507. export class ArcRotateCamera extends TargetCamera {
  47508. /**
  47509. * Defines the rotation angle of the camera along the longitudinal axis.
  47510. */
  47511. alpha: number;
  47512. /**
  47513. * Defines the rotation angle of the camera along the latitudinal axis.
  47514. */
  47515. beta: number;
  47516. /**
  47517. * Defines the radius of the camera from it s target point.
  47518. */
  47519. radius: number;
  47520. protected _target: Vector3;
  47521. protected _targetHost: Nullable<AbstractMesh>;
  47522. /**
  47523. * Defines the target point of the camera.
  47524. * The camera looks towards it form the radius distance.
  47525. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47526. */
  47527. get target(): Vector3;
  47528. set target(value: Vector3);
  47529. /**
  47530. * Define the current local position of the camera in the scene
  47531. */
  47532. get position(): Vector3;
  47533. set position(newPosition: Vector3);
  47534. protected _upToYMatrix: Matrix;
  47535. protected _YToUpMatrix: Matrix;
  47536. /**
  47537. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47538. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47539. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47540. */
  47541. set upVector(vec: Vector3);
  47542. get upVector(): Vector3;
  47543. /**
  47544. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47545. */
  47546. setMatUp(): void;
  47547. /**
  47548. * Current inertia value on the longitudinal axis.
  47549. * The bigger this number the longer it will take for the camera to stop.
  47550. */
  47551. inertialAlphaOffset: number;
  47552. /**
  47553. * Current inertia value on the latitudinal axis.
  47554. * The bigger this number the longer it will take for the camera to stop.
  47555. */
  47556. inertialBetaOffset: number;
  47557. /**
  47558. * Current inertia value on the radius axis.
  47559. * The bigger this number the longer it will take for the camera to stop.
  47560. */
  47561. inertialRadiusOffset: number;
  47562. /**
  47563. * Minimum allowed angle on the longitudinal axis.
  47564. * This can help limiting how the Camera is able to move in the scene.
  47565. */
  47566. lowerAlphaLimit: Nullable<number>;
  47567. /**
  47568. * Maximum allowed angle on the longitudinal axis.
  47569. * This can help limiting how the Camera is able to move in the scene.
  47570. */
  47571. upperAlphaLimit: Nullable<number>;
  47572. /**
  47573. * Minimum allowed angle on the latitudinal axis.
  47574. * This can help limiting how the Camera is able to move in the scene.
  47575. */
  47576. lowerBetaLimit: number;
  47577. /**
  47578. * Maximum allowed angle on the latitudinal axis.
  47579. * This can help limiting how the Camera is able to move in the scene.
  47580. */
  47581. upperBetaLimit: number;
  47582. /**
  47583. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47584. * This can help limiting how the Camera is able to move in the scene.
  47585. */
  47586. lowerRadiusLimit: Nullable<number>;
  47587. /**
  47588. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47589. * This can help limiting how the Camera is able to move in the scene.
  47590. */
  47591. upperRadiusLimit: Nullable<number>;
  47592. /**
  47593. * Defines the current inertia value used during panning of the camera along the X axis.
  47594. */
  47595. inertialPanningX: number;
  47596. /**
  47597. * Defines the current inertia value used during panning of the camera along the Y axis.
  47598. */
  47599. inertialPanningY: number;
  47600. /**
  47601. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47602. * Basically if your fingers moves away from more than this distance you will be considered
  47603. * in pinch mode.
  47604. */
  47605. pinchToPanMaxDistance: number;
  47606. /**
  47607. * Defines the maximum distance the camera can pan.
  47608. * This could help keeping the cammera always in your scene.
  47609. */
  47610. panningDistanceLimit: Nullable<number>;
  47611. /**
  47612. * Defines the target of the camera before paning.
  47613. */
  47614. panningOriginTarget: Vector3;
  47615. /**
  47616. * Defines the value of the inertia used during panning.
  47617. * 0 would mean stop inertia and one would mean no decelleration at all.
  47618. */
  47619. panningInertia: number;
  47620. /**
  47621. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47622. */
  47623. get angularSensibilityX(): number;
  47624. set angularSensibilityX(value: number);
  47625. /**
  47626. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47627. */
  47628. get angularSensibilityY(): number;
  47629. set angularSensibilityY(value: number);
  47630. /**
  47631. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47632. */
  47633. get pinchPrecision(): number;
  47634. set pinchPrecision(value: number);
  47635. /**
  47636. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47637. * It will be used instead of pinchDeltaPrecision if different from 0.
  47638. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47639. */
  47640. get pinchDeltaPercentage(): number;
  47641. set pinchDeltaPercentage(value: number);
  47642. /**
  47643. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47644. * and pinch delta percentage.
  47645. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47646. * that any object in the plane at the camera's target point will scale
  47647. * perfectly with finger motion.
  47648. */
  47649. get useNaturalPinchZoom(): boolean;
  47650. set useNaturalPinchZoom(value: boolean);
  47651. /**
  47652. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47653. */
  47654. get panningSensibility(): number;
  47655. set panningSensibility(value: number);
  47656. /**
  47657. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47658. */
  47659. get keysUp(): number[];
  47660. set keysUp(value: number[]);
  47661. /**
  47662. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47663. */
  47664. get keysDown(): number[];
  47665. set keysDown(value: number[]);
  47666. /**
  47667. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47668. */
  47669. get keysLeft(): number[];
  47670. set keysLeft(value: number[]);
  47671. /**
  47672. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47673. */
  47674. get keysRight(): number[];
  47675. set keysRight(value: number[]);
  47676. /**
  47677. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47678. */
  47679. get wheelPrecision(): number;
  47680. set wheelPrecision(value: number);
  47681. /**
  47682. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47683. * It will be used instead of pinchDeltaPrecision if different from 0.
  47684. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47685. */
  47686. get wheelDeltaPercentage(): number;
  47687. set wheelDeltaPercentage(value: number);
  47688. /**
  47689. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47690. */
  47691. zoomOnFactor: number;
  47692. /**
  47693. * Defines a screen offset for the camera position.
  47694. */
  47695. targetScreenOffset: Vector2;
  47696. /**
  47697. * Allows the camera to be completely reversed.
  47698. * If false the camera can not arrive upside down.
  47699. */
  47700. allowUpsideDown: boolean;
  47701. /**
  47702. * Define if double tap/click is used to restore the previously saved state of the camera.
  47703. */
  47704. useInputToRestoreState: boolean;
  47705. /** @hidden */
  47706. _viewMatrix: Matrix;
  47707. /** @hidden */
  47708. _useCtrlForPanning: boolean;
  47709. /** @hidden */
  47710. _panningMouseButton: number;
  47711. /**
  47712. * Defines the input associated to the camera.
  47713. */
  47714. inputs: ArcRotateCameraInputsManager;
  47715. /** @hidden */
  47716. _reset: () => void;
  47717. /**
  47718. * Defines the allowed panning axis.
  47719. */
  47720. panningAxis: Vector3;
  47721. protected _localDirection: Vector3;
  47722. protected _transformedDirection: Vector3;
  47723. private _bouncingBehavior;
  47724. /**
  47725. * Gets the bouncing behavior of the camera if it has been enabled.
  47726. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47727. */
  47728. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47729. /**
  47730. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47731. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47732. */
  47733. get useBouncingBehavior(): boolean;
  47734. set useBouncingBehavior(value: boolean);
  47735. private _framingBehavior;
  47736. /**
  47737. * Gets the framing behavior of the camera if it has been enabled.
  47738. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47739. */
  47740. get framingBehavior(): Nullable<FramingBehavior>;
  47741. /**
  47742. * Defines if the framing behavior of the camera is enabled on the camera.
  47743. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47744. */
  47745. get useFramingBehavior(): boolean;
  47746. set useFramingBehavior(value: boolean);
  47747. private _autoRotationBehavior;
  47748. /**
  47749. * Gets the auto rotation behavior of the camera if it has been enabled.
  47750. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47751. */
  47752. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47753. /**
  47754. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47755. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47756. */
  47757. get useAutoRotationBehavior(): boolean;
  47758. set useAutoRotationBehavior(value: boolean);
  47759. /**
  47760. * Observable triggered when the mesh target has been changed on the camera.
  47761. */
  47762. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47763. /**
  47764. * Event raised when the camera is colliding with a mesh.
  47765. */
  47766. onCollide: (collidedMesh: AbstractMesh) => void;
  47767. /**
  47768. * Defines whether the camera should check collision with the objects oh the scene.
  47769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47770. */
  47771. checkCollisions: boolean;
  47772. /**
  47773. * Defines the collision radius of the camera.
  47774. * This simulates a sphere around the camera.
  47775. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47776. */
  47777. collisionRadius: Vector3;
  47778. protected _collider: Collider;
  47779. protected _previousPosition: Vector3;
  47780. protected _collisionVelocity: Vector3;
  47781. protected _newPosition: Vector3;
  47782. protected _previousAlpha: number;
  47783. protected _previousBeta: number;
  47784. protected _previousRadius: number;
  47785. protected _collisionTriggered: boolean;
  47786. protected _targetBoundingCenter: Nullable<Vector3>;
  47787. private _computationVector;
  47788. /**
  47789. * Instantiates a new ArcRotateCamera in a given scene
  47790. * @param name Defines the name of the camera
  47791. * @param alpha Defines the camera rotation along the logitudinal axis
  47792. * @param beta Defines the camera rotation along the latitudinal axis
  47793. * @param radius Defines the camera distance from its target
  47794. * @param target Defines the camera target
  47795. * @param scene Defines the scene the camera belongs to
  47796. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47797. */
  47798. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47799. /** @hidden */
  47800. _initCache(): void;
  47801. /** @hidden */
  47802. _updateCache(ignoreParentClass?: boolean): void;
  47803. protected _getTargetPosition(): Vector3;
  47804. private _storedAlpha;
  47805. private _storedBeta;
  47806. private _storedRadius;
  47807. private _storedTarget;
  47808. private _storedTargetScreenOffset;
  47809. /**
  47810. * Stores the current state of the camera (alpha, beta, radius and target)
  47811. * @returns the camera itself
  47812. */
  47813. storeState(): Camera;
  47814. /**
  47815. * @hidden
  47816. * Restored camera state. You must call storeState() first
  47817. */
  47818. _restoreStateValues(): boolean;
  47819. /** @hidden */
  47820. _isSynchronizedViewMatrix(): boolean;
  47821. /**
  47822. * Attached controls to the current camera.
  47823. * @param element Defines the element the controls should be listened from
  47824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47825. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47826. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47827. */
  47828. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47829. /**
  47830. * Detach the current controls from the camera.
  47831. * The camera will stop reacting to inputs.
  47832. * @param element Defines the element to stop listening the inputs from
  47833. */
  47834. detachControl(element: HTMLElement): void;
  47835. /** @hidden */
  47836. _checkInputs(): void;
  47837. protected _checkLimits(): void;
  47838. /**
  47839. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47840. */
  47841. rebuildAnglesAndRadius(): void;
  47842. /**
  47843. * Use a position to define the current camera related information like alpha, beta and radius
  47844. * @param position Defines the position to set the camera at
  47845. */
  47846. setPosition(position: Vector3): void;
  47847. /**
  47848. * Defines the target the camera should look at.
  47849. * This will automatically adapt alpha beta and radius to fit within the new target.
  47850. * @param target Defines the new target as a Vector or a mesh
  47851. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47852. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47853. */
  47854. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47855. /** @hidden */
  47856. _getViewMatrix(): Matrix;
  47857. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47858. /**
  47859. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47860. * @param meshes Defines the mesh to zoom on
  47861. * @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)
  47862. */
  47863. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47864. /**
  47865. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47866. * The target will be changed but the radius
  47867. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47868. * @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)
  47869. */
  47870. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47871. min: Vector3;
  47872. max: Vector3;
  47873. distance: number;
  47874. }, doNotUpdateMaxZ?: boolean): void;
  47875. /**
  47876. * @override
  47877. * Override Camera.createRigCamera
  47878. */
  47879. createRigCamera(name: string, cameraIndex: number): Camera;
  47880. /**
  47881. * @hidden
  47882. * @override
  47883. * Override Camera._updateRigCameras
  47884. */
  47885. _updateRigCameras(): void;
  47886. /**
  47887. * Destroy the camera and release the current resources hold by it.
  47888. */
  47889. dispose(): void;
  47890. /**
  47891. * Gets the current object class name.
  47892. * @return the class name
  47893. */
  47894. getClassName(): string;
  47895. }
  47896. }
  47897. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47898. import { Behavior } from "babylonjs/Behaviors/behavior";
  47899. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47900. /**
  47901. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47902. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47903. */
  47904. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47905. /**
  47906. * Gets the name of the behavior.
  47907. */
  47908. get name(): string;
  47909. private _zoomStopsAnimation;
  47910. private _idleRotationSpeed;
  47911. private _idleRotationWaitTime;
  47912. private _idleRotationSpinupTime;
  47913. /**
  47914. * Sets the flag that indicates if user zooming should stop animation.
  47915. */
  47916. set zoomStopsAnimation(flag: boolean);
  47917. /**
  47918. * Gets the flag that indicates if user zooming should stop animation.
  47919. */
  47920. get zoomStopsAnimation(): boolean;
  47921. /**
  47922. * Sets the default speed at which the camera rotates around the model.
  47923. */
  47924. set idleRotationSpeed(speed: number);
  47925. /**
  47926. * Gets the default speed at which the camera rotates around the model.
  47927. */
  47928. get idleRotationSpeed(): number;
  47929. /**
  47930. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  47931. */
  47932. set idleRotationWaitTime(time: number);
  47933. /**
  47934. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  47935. */
  47936. get idleRotationWaitTime(): number;
  47937. /**
  47938. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47939. */
  47940. set idleRotationSpinupTime(time: number);
  47941. /**
  47942. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47943. */
  47944. get idleRotationSpinupTime(): number;
  47945. /**
  47946. * Gets a value indicating if the camera is currently rotating because of this behavior
  47947. */
  47948. get rotationInProgress(): boolean;
  47949. private _onPrePointerObservableObserver;
  47950. private _onAfterCheckInputsObserver;
  47951. private _attachedCamera;
  47952. private _isPointerDown;
  47953. private _lastFrameTime;
  47954. private _lastInteractionTime;
  47955. private _cameraRotationSpeed;
  47956. /**
  47957. * Initializes the behavior.
  47958. */
  47959. init(): void;
  47960. /**
  47961. * Attaches the behavior to its arc rotate camera.
  47962. * @param camera Defines the camera to attach the behavior to
  47963. */
  47964. attach(camera: ArcRotateCamera): void;
  47965. /**
  47966. * Detaches the behavior from its current arc rotate camera.
  47967. */
  47968. detach(): void;
  47969. /**
  47970. * Returns true if user is scrolling.
  47971. * @return true if user is scrolling.
  47972. */
  47973. private _userIsZooming;
  47974. private _lastFrameRadius;
  47975. private _shouldAnimationStopForInteraction;
  47976. /**
  47977. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47978. */
  47979. private _applyUserInteraction;
  47980. private _userIsMoving;
  47981. }
  47982. }
  47983. declare module "babylonjs/Behaviors/Cameras/index" {
  47984. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47985. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47986. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  47987. }
  47988. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  47989. import { Mesh } from "babylonjs/Meshes/mesh";
  47990. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47991. import { Behavior } from "babylonjs/Behaviors/behavior";
  47992. /**
  47993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47994. */
  47995. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47996. private ui;
  47997. /**
  47998. * The name of the behavior
  47999. */
  48000. name: string;
  48001. /**
  48002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48003. */
  48004. distanceAwayFromFace: number;
  48005. /**
  48006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48007. */
  48008. distanceAwayFromBottomOfFace: number;
  48009. private _faceVectors;
  48010. private _target;
  48011. private _scene;
  48012. private _onRenderObserver;
  48013. private _tmpMatrix;
  48014. private _tmpVector;
  48015. /**
  48016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48017. * @param ui The transform node that should be attched to the mesh
  48018. */
  48019. constructor(ui: TransformNode);
  48020. /**
  48021. * Initializes the behavior
  48022. */
  48023. init(): void;
  48024. private _closestFace;
  48025. private _zeroVector;
  48026. private _lookAtTmpMatrix;
  48027. private _lookAtToRef;
  48028. /**
  48029. * Attaches the AttachToBoxBehavior to the passed in mesh
  48030. * @param target The mesh that the specified node will be attached to
  48031. */
  48032. attach(target: Mesh): void;
  48033. /**
  48034. * Detaches the behavior from the mesh
  48035. */
  48036. detach(): void;
  48037. }
  48038. }
  48039. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48040. import { Behavior } from "babylonjs/Behaviors/behavior";
  48041. import { Mesh } from "babylonjs/Meshes/mesh";
  48042. /**
  48043. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48044. */
  48045. export class FadeInOutBehavior implements Behavior<Mesh> {
  48046. /**
  48047. * Time in milliseconds to delay before fading in (Default: 0)
  48048. */
  48049. delay: number;
  48050. /**
  48051. * Time in milliseconds for the mesh to fade in (Default: 300)
  48052. */
  48053. fadeInTime: number;
  48054. private _millisecondsPerFrame;
  48055. private _hovered;
  48056. private _hoverValue;
  48057. private _ownerNode;
  48058. /**
  48059. * Instatiates the FadeInOutBehavior
  48060. */
  48061. constructor();
  48062. /**
  48063. * The name of the behavior
  48064. */
  48065. get name(): string;
  48066. /**
  48067. * Initializes the behavior
  48068. */
  48069. init(): void;
  48070. /**
  48071. * Attaches the fade behavior on the passed in mesh
  48072. * @param ownerNode The mesh that will be faded in/out once attached
  48073. */
  48074. attach(ownerNode: Mesh): void;
  48075. /**
  48076. * Detaches the behavior from the mesh
  48077. */
  48078. detach(): void;
  48079. /**
  48080. * Triggers the mesh to begin fading in or out
  48081. * @param value if the object should fade in or out (true to fade in)
  48082. */
  48083. fadeIn(value: boolean): void;
  48084. private _update;
  48085. private _setAllVisibility;
  48086. }
  48087. }
  48088. declare module "babylonjs/Misc/pivotTools" {
  48089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48090. /**
  48091. * Class containing a set of static utilities functions for managing Pivots
  48092. * @hidden
  48093. */
  48094. export class PivotTools {
  48095. private static _PivotCached;
  48096. private static _OldPivotPoint;
  48097. private static _PivotTranslation;
  48098. private static _PivotTmpVector;
  48099. private static _PivotPostMultiplyPivotMatrix;
  48100. /** @hidden */
  48101. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48102. /** @hidden */
  48103. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48104. }
  48105. }
  48106. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48107. import { Scene } from "babylonjs/scene";
  48108. import { Vector4 } from "babylonjs/Maths/math.vector";
  48109. import { Mesh } from "babylonjs/Meshes/mesh";
  48110. import { Nullable } from "babylonjs/types";
  48111. import { Plane } from "babylonjs/Maths/math.plane";
  48112. /**
  48113. * Class containing static functions to help procedurally build meshes
  48114. */
  48115. export class PlaneBuilder {
  48116. /**
  48117. * Creates a plane mesh
  48118. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48119. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48120. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48124. * @param name defines the name of the mesh
  48125. * @param options defines the options used to create the mesh
  48126. * @param scene defines the hosting scene
  48127. * @returns the plane mesh
  48128. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48129. */
  48130. static CreatePlane(name: string, options: {
  48131. size?: number;
  48132. width?: number;
  48133. height?: number;
  48134. sideOrientation?: number;
  48135. frontUVs?: Vector4;
  48136. backUVs?: Vector4;
  48137. updatable?: boolean;
  48138. sourcePlane?: Plane;
  48139. }, scene?: Nullable<Scene>): Mesh;
  48140. }
  48141. }
  48142. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48143. import { Behavior } from "babylonjs/Behaviors/behavior";
  48144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48145. import { Observable } from "babylonjs/Misc/observable";
  48146. import { Vector3 } from "babylonjs/Maths/math.vector";
  48147. import { Ray } from "babylonjs/Culling/ray";
  48148. import "babylonjs/Meshes/Builders/planeBuilder";
  48149. /**
  48150. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48151. */
  48152. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48153. private static _AnyMouseID;
  48154. /**
  48155. * Abstract mesh the behavior is set on
  48156. */
  48157. attachedNode: AbstractMesh;
  48158. private _dragPlane;
  48159. private _scene;
  48160. private _pointerObserver;
  48161. private _beforeRenderObserver;
  48162. private static _planeScene;
  48163. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48164. /**
  48165. * 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)
  48166. */
  48167. maxDragAngle: number;
  48168. /**
  48169. * @hidden
  48170. */
  48171. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48172. /**
  48173. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48174. */
  48175. currentDraggingPointerID: number;
  48176. /**
  48177. * The last position where the pointer hit the drag plane in world space
  48178. */
  48179. lastDragPosition: Vector3;
  48180. /**
  48181. * If the behavior is currently in a dragging state
  48182. */
  48183. dragging: boolean;
  48184. /**
  48185. * 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)
  48186. */
  48187. dragDeltaRatio: number;
  48188. /**
  48189. * If the drag plane orientation should be updated during the dragging (Default: true)
  48190. */
  48191. updateDragPlane: boolean;
  48192. private _debugMode;
  48193. private _moving;
  48194. /**
  48195. * Fires each time the attached mesh is dragged with the pointer
  48196. * * delta between last drag position and current drag position in world space
  48197. * * dragDistance along the drag axis
  48198. * * dragPlaneNormal normal of the current drag plane used during the drag
  48199. * * dragPlanePoint in world space where the drag intersects the drag plane
  48200. */
  48201. onDragObservable: Observable<{
  48202. delta: Vector3;
  48203. dragPlanePoint: Vector3;
  48204. dragPlaneNormal: Vector3;
  48205. dragDistance: number;
  48206. pointerId: number;
  48207. }>;
  48208. /**
  48209. * Fires each time a drag begins (eg. mouse down on mesh)
  48210. */
  48211. onDragStartObservable: Observable<{
  48212. dragPlanePoint: Vector3;
  48213. pointerId: number;
  48214. }>;
  48215. /**
  48216. * Fires each time a drag ends (eg. mouse release after drag)
  48217. */
  48218. onDragEndObservable: Observable<{
  48219. dragPlanePoint: Vector3;
  48220. pointerId: number;
  48221. }>;
  48222. /**
  48223. * If the attached mesh should be moved when dragged
  48224. */
  48225. moveAttached: boolean;
  48226. /**
  48227. * If the drag behavior will react to drag events (Default: true)
  48228. */
  48229. enabled: boolean;
  48230. /**
  48231. * If pointer events should start and release the drag (Default: true)
  48232. */
  48233. startAndReleaseDragOnPointerEvents: boolean;
  48234. /**
  48235. * If camera controls should be detached during the drag
  48236. */
  48237. detachCameraControls: boolean;
  48238. /**
  48239. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48240. */
  48241. useObjectOrientationForDragging: boolean;
  48242. private _options;
  48243. /**
  48244. * Gets the options used by the behavior
  48245. */
  48246. get options(): {
  48247. dragAxis?: Vector3;
  48248. dragPlaneNormal?: Vector3;
  48249. };
  48250. /**
  48251. * Sets the options used by the behavior
  48252. */
  48253. set options(options: {
  48254. dragAxis?: Vector3;
  48255. dragPlaneNormal?: Vector3;
  48256. });
  48257. /**
  48258. * Creates a pointer drag behavior that can be attached to a mesh
  48259. * @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)
  48260. */
  48261. constructor(options?: {
  48262. dragAxis?: Vector3;
  48263. dragPlaneNormal?: Vector3;
  48264. });
  48265. /**
  48266. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48267. */
  48268. validateDrag: (targetPosition: Vector3) => boolean;
  48269. /**
  48270. * The name of the behavior
  48271. */
  48272. get name(): string;
  48273. /**
  48274. * Initializes the behavior
  48275. */
  48276. init(): void;
  48277. private _tmpVector;
  48278. private _alternatePickedPoint;
  48279. private _worldDragAxis;
  48280. private _targetPosition;
  48281. private _attachedElement;
  48282. /**
  48283. * Attaches the drag behavior the passed in mesh
  48284. * @param ownerNode The mesh that will be dragged around once attached
  48285. * @param predicate Predicate to use for pick filtering
  48286. */
  48287. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48288. /**
  48289. * Force relase the drag action by code.
  48290. */
  48291. releaseDrag(): void;
  48292. private _startDragRay;
  48293. private _lastPointerRay;
  48294. /**
  48295. * Simulates the start of a pointer drag event on the behavior
  48296. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48297. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48298. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48299. */
  48300. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48301. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48302. private _dragDelta;
  48303. protected _moveDrag(ray: Ray): void;
  48304. private _pickWithRayOnDragPlane;
  48305. private _pointA;
  48306. private _pointC;
  48307. private _localAxis;
  48308. private _lookAt;
  48309. private _updateDragPlanePosition;
  48310. /**
  48311. * Detaches the behavior from the mesh
  48312. */
  48313. detach(): void;
  48314. }
  48315. }
  48316. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48317. import { Mesh } from "babylonjs/Meshes/mesh";
  48318. import { Behavior } from "babylonjs/Behaviors/behavior";
  48319. /**
  48320. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48321. */
  48322. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48323. private _dragBehaviorA;
  48324. private _dragBehaviorB;
  48325. private _startDistance;
  48326. private _initialScale;
  48327. private _targetScale;
  48328. private _ownerNode;
  48329. private _sceneRenderObserver;
  48330. /**
  48331. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48332. */
  48333. constructor();
  48334. /**
  48335. * The name of the behavior
  48336. */
  48337. get name(): string;
  48338. /**
  48339. * Initializes the behavior
  48340. */
  48341. init(): void;
  48342. private _getCurrentDistance;
  48343. /**
  48344. * Attaches the scale behavior the passed in mesh
  48345. * @param ownerNode The mesh that will be scaled around once attached
  48346. */
  48347. attach(ownerNode: Mesh): void;
  48348. /**
  48349. * Detaches the behavior from the mesh
  48350. */
  48351. detach(): void;
  48352. }
  48353. }
  48354. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48355. import { Behavior } from "babylonjs/Behaviors/behavior";
  48356. import { Mesh } from "babylonjs/Meshes/mesh";
  48357. import { Observable } from "babylonjs/Misc/observable";
  48358. /**
  48359. * 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
  48360. */
  48361. export class SixDofDragBehavior implements Behavior<Mesh> {
  48362. private static _virtualScene;
  48363. private _ownerNode;
  48364. private _sceneRenderObserver;
  48365. private _scene;
  48366. private _targetPosition;
  48367. private _virtualOriginMesh;
  48368. private _virtualDragMesh;
  48369. private _pointerObserver;
  48370. private _moving;
  48371. private _startingOrientation;
  48372. private _attachedElement;
  48373. /**
  48374. * 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)
  48375. */
  48376. private zDragFactor;
  48377. /**
  48378. * If the object should rotate to face the drag origin
  48379. */
  48380. rotateDraggedObject: boolean;
  48381. /**
  48382. * If the behavior is currently in a dragging state
  48383. */
  48384. dragging: boolean;
  48385. /**
  48386. * 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)
  48387. */
  48388. dragDeltaRatio: number;
  48389. /**
  48390. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48391. */
  48392. currentDraggingPointerID: number;
  48393. /**
  48394. * If camera controls should be detached during the drag
  48395. */
  48396. detachCameraControls: boolean;
  48397. /**
  48398. * Fires each time a drag starts
  48399. */
  48400. onDragStartObservable: Observable<{}>;
  48401. /**
  48402. * Fires each time a drag ends (eg. mouse release after drag)
  48403. */
  48404. onDragEndObservable: Observable<{}>;
  48405. /**
  48406. * 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
  48407. */
  48408. constructor();
  48409. /**
  48410. * The name of the behavior
  48411. */
  48412. get name(): string;
  48413. /**
  48414. * Initializes the behavior
  48415. */
  48416. init(): void;
  48417. /**
  48418. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48419. */
  48420. private get _pointerCamera();
  48421. /**
  48422. * Attaches the scale behavior the passed in mesh
  48423. * @param ownerNode The mesh that will be scaled around once attached
  48424. */
  48425. attach(ownerNode: Mesh): void;
  48426. /**
  48427. * Detaches the behavior from the mesh
  48428. */
  48429. detach(): void;
  48430. }
  48431. }
  48432. declare module "babylonjs/Behaviors/Meshes/index" {
  48433. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48434. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48435. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48436. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48437. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48438. }
  48439. declare module "babylonjs/Behaviors/index" {
  48440. export * from "babylonjs/Behaviors/behavior";
  48441. export * from "babylonjs/Behaviors/Cameras/index";
  48442. export * from "babylonjs/Behaviors/Meshes/index";
  48443. }
  48444. declare module "babylonjs/Bones/boneIKController" {
  48445. import { Bone } from "babylonjs/Bones/bone";
  48446. import { Vector3 } from "babylonjs/Maths/math.vector";
  48447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48448. import { Nullable } from "babylonjs/types";
  48449. /**
  48450. * Class used to apply inverse kinematics to bones
  48451. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48452. */
  48453. export class BoneIKController {
  48454. private static _tmpVecs;
  48455. private static _tmpQuat;
  48456. private static _tmpMats;
  48457. /**
  48458. * Gets or sets the target mesh
  48459. */
  48460. targetMesh: AbstractMesh;
  48461. /** Gets or sets the mesh used as pole */
  48462. poleTargetMesh: AbstractMesh;
  48463. /**
  48464. * Gets or sets the bone used as pole
  48465. */
  48466. poleTargetBone: Nullable<Bone>;
  48467. /**
  48468. * Gets or sets the target position
  48469. */
  48470. targetPosition: Vector3;
  48471. /**
  48472. * Gets or sets the pole target position
  48473. */
  48474. poleTargetPosition: Vector3;
  48475. /**
  48476. * Gets or sets the pole target local offset
  48477. */
  48478. poleTargetLocalOffset: Vector3;
  48479. /**
  48480. * Gets or sets the pole angle
  48481. */
  48482. poleAngle: number;
  48483. /**
  48484. * Gets or sets the mesh associated with the controller
  48485. */
  48486. mesh: AbstractMesh;
  48487. /**
  48488. * 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)
  48489. */
  48490. slerpAmount: number;
  48491. private _bone1Quat;
  48492. private _bone1Mat;
  48493. private _bone2Ang;
  48494. private _bone1;
  48495. private _bone2;
  48496. private _bone1Length;
  48497. private _bone2Length;
  48498. private _maxAngle;
  48499. private _maxReach;
  48500. private _rightHandedSystem;
  48501. private _bendAxis;
  48502. private _slerping;
  48503. private _adjustRoll;
  48504. /**
  48505. * Gets or sets maximum allowed angle
  48506. */
  48507. get maxAngle(): number;
  48508. set maxAngle(value: number);
  48509. /**
  48510. * Creates a new BoneIKController
  48511. * @param mesh defines the mesh to control
  48512. * @param bone defines the bone to control
  48513. * @param options defines options to set up the controller
  48514. */
  48515. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48516. targetMesh?: AbstractMesh;
  48517. poleTargetMesh?: AbstractMesh;
  48518. poleTargetBone?: Bone;
  48519. poleTargetLocalOffset?: Vector3;
  48520. poleAngle?: number;
  48521. bendAxis?: Vector3;
  48522. maxAngle?: number;
  48523. slerpAmount?: number;
  48524. });
  48525. private _setMaxAngle;
  48526. /**
  48527. * Force the controller to update the bones
  48528. */
  48529. update(): void;
  48530. }
  48531. }
  48532. declare module "babylonjs/Bones/boneLookController" {
  48533. import { Vector3 } from "babylonjs/Maths/math.vector";
  48534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48535. import { Bone } from "babylonjs/Bones/bone";
  48536. import { Space } from "babylonjs/Maths/math.axis";
  48537. /**
  48538. * Class used to make a bone look toward a point in space
  48539. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48540. */
  48541. export class BoneLookController {
  48542. private static _tmpVecs;
  48543. private static _tmpQuat;
  48544. private static _tmpMats;
  48545. /**
  48546. * The target Vector3 that the bone will look at
  48547. */
  48548. target: Vector3;
  48549. /**
  48550. * The mesh that the bone is attached to
  48551. */
  48552. mesh: AbstractMesh;
  48553. /**
  48554. * The bone that will be looking to the target
  48555. */
  48556. bone: Bone;
  48557. /**
  48558. * The up axis of the coordinate system that is used when the bone is rotated
  48559. */
  48560. upAxis: Vector3;
  48561. /**
  48562. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48563. */
  48564. upAxisSpace: Space;
  48565. /**
  48566. * Used to make an adjustment to the yaw of the bone
  48567. */
  48568. adjustYaw: number;
  48569. /**
  48570. * Used to make an adjustment to the pitch of the bone
  48571. */
  48572. adjustPitch: number;
  48573. /**
  48574. * Used to make an adjustment to the roll of the bone
  48575. */
  48576. adjustRoll: number;
  48577. /**
  48578. * 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)
  48579. */
  48580. slerpAmount: number;
  48581. private _minYaw;
  48582. private _maxYaw;
  48583. private _minPitch;
  48584. private _maxPitch;
  48585. private _minYawSin;
  48586. private _minYawCos;
  48587. private _maxYawSin;
  48588. private _maxYawCos;
  48589. private _midYawConstraint;
  48590. private _minPitchTan;
  48591. private _maxPitchTan;
  48592. private _boneQuat;
  48593. private _slerping;
  48594. private _transformYawPitch;
  48595. private _transformYawPitchInv;
  48596. private _firstFrameSkipped;
  48597. private _yawRange;
  48598. private _fowardAxis;
  48599. /**
  48600. * Gets or sets the minimum yaw angle that the bone can look to
  48601. */
  48602. get minYaw(): number;
  48603. set minYaw(value: number);
  48604. /**
  48605. * Gets or sets the maximum yaw angle that the bone can look to
  48606. */
  48607. get maxYaw(): number;
  48608. set maxYaw(value: number);
  48609. /**
  48610. * Gets or sets the minimum pitch angle that the bone can look to
  48611. */
  48612. get minPitch(): number;
  48613. set minPitch(value: number);
  48614. /**
  48615. * Gets or sets the maximum pitch angle that the bone can look to
  48616. */
  48617. get maxPitch(): number;
  48618. set maxPitch(value: number);
  48619. /**
  48620. * Create a BoneLookController
  48621. * @param mesh the mesh that the bone belongs to
  48622. * @param bone the bone that will be looking to the target
  48623. * @param target the target Vector3 to look at
  48624. * @param options optional settings:
  48625. * * maxYaw: the maximum angle the bone will yaw to
  48626. * * minYaw: the minimum angle the bone will yaw to
  48627. * * maxPitch: the maximum angle the bone will pitch to
  48628. * * minPitch: the minimum angle the bone will yaw to
  48629. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48630. * * upAxis: the up axis of the coordinate system
  48631. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48632. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48633. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48634. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48635. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48636. * * adjustRoll: used to make an adjustment to the roll of the bone
  48637. **/
  48638. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48639. maxYaw?: number;
  48640. minYaw?: number;
  48641. maxPitch?: number;
  48642. minPitch?: number;
  48643. slerpAmount?: number;
  48644. upAxis?: Vector3;
  48645. upAxisSpace?: Space;
  48646. yawAxis?: Vector3;
  48647. pitchAxis?: Vector3;
  48648. adjustYaw?: number;
  48649. adjustPitch?: number;
  48650. adjustRoll?: number;
  48651. });
  48652. /**
  48653. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48654. */
  48655. update(): void;
  48656. private _getAngleDiff;
  48657. private _getAngleBetween;
  48658. private _isAngleBetween;
  48659. }
  48660. }
  48661. declare module "babylonjs/Bones/index" {
  48662. export * from "babylonjs/Bones/bone";
  48663. export * from "babylonjs/Bones/boneIKController";
  48664. export * from "babylonjs/Bones/boneLookController";
  48665. export * from "babylonjs/Bones/skeleton";
  48666. }
  48667. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48668. import { Nullable } from "babylonjs/types";
  48669. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48671. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48672. /**
  48673. * Manage the gamepad inputs to control an arc rotate camera.
  48674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48675. */
  48676. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48677. /**
  48678. * Defines the camera the input is attached to.
  48679. */
  48680. camera: ArcRotateCamera;
  48681. /**
  48682. * Defines the gamepad the input is gathering event from.
  48683. */
  48684. gamepad: Nullable<Gamepad>;
  48685. /**
  48686. * Defines the gamepad rotation sensiblity.
  48687. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48688. */
  48689. gamepadRotationSensibility: number;
  48690. /**
  48691. * Defines the gamepad move sensiblity.
  48692. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48693. */
  48694. gamepadMoveSensibility: number;
  48695. private _yAxisScale;
  48696. /**
  48697. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48698. */
  48699. get invertYAxis(): boolean;
  48700. set invertYAxis(value: boolean);
  48701. private _onGamepadConnectedObserver;
  48702. private _onGamepadDisconnectedObserver;
  48703. /**
  48704. * Attach the input controls to a specific dom element to get the input from.
  48705. * @param element Defines the element the controls should be listened from
  48706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48707. */
  48708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48709. /**
  48710. * Detach the current controls from the specified dom element.
  48711. * @param element Defines the element to stop listening the inputs from
  48712. */
  48713. detachControl(element: Nullable<HTMLElement>): void;
  48714. /**
  48715. * Update the current camera state depending on the inputs that have been used this frame.
  48716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48717. */
  48718. checkInputs(): void;
  48719. /**
  48720. * Gets the class name of the current intput.
  48721. * @returns the class name
  48722. */
  48723. getClassName(): string;
  48724. /**
  48725. * Get the friendly name associated with the input class.
  48726. * @returns the input friendly name
  48727. */
  48728. getSimpleName(): string;
  48729. }
  48730. }
  48731. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48732. import { Nullable } from "babylonjs/types";
  48733. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48734. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48735. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48736. interface ArcRotateCameraInputsManager {
  48737. /**
  48738. * Add orientation input support to the input manager.
  48739. * @returns the current input manager
  48740. */
  48741. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48742. }
  48743. }
  48744. /**
  48745. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48746. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48747. */
  48748. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48749. /**
  48750. * Defines the camera the input is attached to.
  48751. */
  48752. camera: ArcRotateCamera;
  48753. /**
  48754. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48755. */
  48756. alphaCorrection: number;
  48757. /**
  48758. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48759. */
  48760. gammaCorrection: number;
  48761. private _alpha;
  48762. private _gamma;
  48763. private _dirty;
  48764. private _deviceOrientationHandler;
  48765. /**
  48766. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48767. */
  48768. constructor();
  48769. /**
  48770. * Attach the input controls to a specific dom element to get the input from.
  48771. * @param element Defines the element the controls should be listened from
  48772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48773. */
  48774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48775. /** @hidden */
  48776. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48777. /**
  48778. * Update the current camera state depending on the inputs that have been used this frame.
  48779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48780. */
  48781. checkInputs(): void;
  48782. /**
  48783. * Detach the current controls from the specified dom element.
  48784. * @param element Defines the element to stop listening the inputs from
  48785. */
  48786. detachControl(element: Nullable<HTMLElement>): void;
  48787. /**
  48788. * Gets the class name of the current intput.
  48789. * @returns the class name
  48790. */
  48791. getClassName(): string;
  48792. /**
  48793. * Get the friendly name associated with the input class.
  48794. * @returns the input friendly name
  48795. */
  48796. getSimpleName(): string;
  48797. }
  48798. }
  48799. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48800. import { Nullable } from "babylonjs/types";
  48801. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48802. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48803. /**
  48804. * Listen to mouse events to control the camera.
  48805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48806. */
  48807. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48808. /**
  48809. * Defines the camera the input is attached to.
  48810. */
  48811. camera: FlyCamera;
  48812. /**
  48813. * Defines if touch is enabled. (Default is true.)
  48814. */
  48815. touchEnabled: boolean;
  48816. /**
  48817. * Defines the buttons associated with the input to handle camera rotation.
  48818. */
  48819. buttons: number[];
  48820. /**
  48821. * Assign buttons for Yaw control.
  48822. */
  48823. buttonsYaw: number[];
  48824. /**
  48825. * Assign buttons for Pitch control.
  48826. */
  48827. buttonsPitch: number[];
  48828. /**
  48829. * Assign buttons for Roll control.
  48830. */
  48831. buttonsRoll: number[];
  48832. /**
  48833. * Detect if any button is being pressed while mouse is moved.
  48834. * -1 = Mouse locked.
  48835. * 0 = Left button.
  48836. * 1 = Middle Button.
  48837. * 2 = Right Button.
  48838. */
  48839. activeButton: number;
  48840. /**
  48841. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48842. * Higher values reduce its sensitivity.
  48843. */
  48844. angularSensibility: number;
  48845. private _observer;
  48846. private _rollObserver;
  48847. private previousPosition;
  48848. private noPreventDefault;
  48849. private element;
  48850. /**
  48851. * Listen to mouse events to control the camera.
  48852. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48854. */
  48855. constructor(touchEnabled?: boolean);
  48856. /**
  48857. * Attach the mouse control to the HTML DOM element.
  48858. * @param element Defines the element that listens to the input events.
  48859. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48860. */
  48861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48862. /**
  48863. * Detach the current controls from the specified dom element.
  48864. * @param element Defines the element to stop listening the inputs from
  48865. */
  48866. detachControl(element: Nullable<HTMLElement>): void;
  48867. /**
  48868. * Gets the class name of the current input.
  48869. * @returns the class name.
  48870. */
  48871. getClassName(): string;
  48872. /**
  48873. * Get the friendly name associated with the input class.
  48874. * @returns the input's friendly name.
  48875. */
  48876. getSimpleName(): string;
  48877. private _pointerInput;
  48878. private _onMouseMove;
  48879. /**
  48880. * Rotate camera by mouse offset.
  48881. */
  48882. private rotateCamera;
  48883. }
  48884. }
  48885. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48886. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48887. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48888. /**
  48889. * Default Inputs manager for the FlyCamera.
  48890. * It groups all the default supported inputs for ease of use.
  48891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48892. */
  48893. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48894. /**
  48895. * Instantiates a new FlyCameraInputsManager.
  48896. * @param camera Defines the camera the inputs belong to.
  48897. */
  48898. constructor(camera: FlyCamera);
  48899. /**
  48900. * Add keyboard input support to the input manager.
  48901. * @returns the new FlyCameraKeyboardMoveInput().
  48902. */
  48903. addKeyboard(): FlyCameraInputsManager;
  48904. /**
  48905. * Add mouse input support to the input manager.
  48906. * @param touchEnabled Enable touch screen support.
  48907. * @returns the new FlyCameraMouseInput().
  48908. */
  48909. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48910. }
  48911. }
  48912. declare module "babylonjs/Cameras/flyCamera" {
  48913. import { Scene } from "babylonjs/scene";
  48914. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48916. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48917. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  48918. /**
  48919. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48920. * such as in a 3D Space Shooter or a Flight Simulator.
  48921. */
  48922. export class FlyCamera extends TargetCamera {
  48923. /**
  48924. * Define the collision ellipsoid of the camera.
  48925. * This is helpful for simulating a camera body, like a player's body.
  48926. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48927. */
  48928. ellipsoid: Vector3;
  48929. /**
  48930. * Define an offset for the position of the ellipsoid around the camera.
  48931. * This can be helpful if the camera is attached away from the player's body center,
  48932. * such as at its head.
  48933. */
  48934. ellipsoidOffset: Vector3;
  48935. /**
  48936. * Enable or disable collisions of the camera with the rest of the scene objects.
  48937. */
  48938. checkCollisions: boolean;
  48939. /**
  48940. * Enable or disable gravity on the camera.
  48941. */
  48942. applyGravity: boolean;
  48943. /**
  48944. * Define the current direction the camera is moving to.
  48945. */
  48946. cameraDirection: Vector3;
  48947. /**
  48948. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  48949. * This overrides and empties cameraRotation.
  48950. */
  48951. rotationQuaternion: Quaternion;
  48952. /**
  48953. * Track Roll to maintain the wanted Rolling when looking around.
  48954. */
  48955. _trackRoll: number;
  48956. /**
  48957. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  48958. */
  48959. rollCorrect: number;
  48960. /**
  48961. * Mimic a banked turn, Rolling the camera when Yawing.
  48962. * It's recommended to use rollCorrect = 10 for faster banking correction.
  48963. */
  48964. bankedTurn: boolean;
  48965. /**
  48966. * Limit in radians for how much Roll banking will add. (Default: 90°)
  48967. */
  48968. bankedTurnLimit: number;
  48969. /**
  48970. * Value of 0 disables the banked Roll.
  48971. * Value of 1 is equal to the Yaw angle in radians.
  48972. */
  48973. bankedTurnMultiplier: number;
  48974. /**
  48975. * The inputs manager loads all the input sources, such as keyboard and mouse.
  48976. */
  48977. inputs: FlyCameraInputsManager;
  48978. /**
  48979. * Gets the input sensibility for mouse input.
  48980. * Higher values reduce sensitivity.
  48981. */
  48982. get angularSensibility(): number;
  48983. /**
  48984. * Sets the input sensibility for a mouse input.
  48985. * Higher values reduce sensitivity.
  48986. */
  48987. set angularSensibility(value: number);
  48988. /**
  48989. * Get the keys for camera movement forward.
  48990. */
  48991. get keysForward(): number[];
  48992. /**
  48993. * Set the keys for camera movement forward.
  48994. */
  48995. set keysForward(value: number[]);
  48996. /**
  48997. * Get the keys for camera movement backward.
  48998. */
  48999. get keysBackward(): number[];
  49000. set keysBackward(value: number[]);
  49001. /**
  49002. * Get the keys for camera movement up.
  49003. */
  49004. get keysUp(): number[];
  49005. /**
  49006. * Set the keys for camera movement up.
  49007. */
  49008. set keysUp(value: number[]);
  49009. /**
  49010. * Get the keys for camera movement down.
  49011. */
  49012. get keysDown(): number[];
  49013. /**
  49014. * Set the keys for camera movement down.
  49015. */
  49016. set keysDown(value: number[]);
  49017. /**
  49018. * Get the keys for camera movement left.
  49019. */
  49020. get keysLeft(): number[];
  49021. /**
  49022. * Set the keys for camera movement left.
  49023. */
  49024. set keysLeft(value: number[]);
  49025. /**
  49026. * Set the keys for camera movement right.
  49027. */
  49028. get keysRight(): number[];
  49029. /**
  49030. * Set the keys for camera movement right.
  49031. */
  49032. set keysRight(value: number[]);
  49033. /**
  49034. * Event raised when the camera collides with a mesh in the scene.
  49035. */
  49036. onCollide: (collidedMesh: AbstractMesh) => void;
  49037. private _collider;
  49038. private _needMoveForGravity;
  49039. private _oldPosition;
  49040. private _diffPosition;
  49041. private _newPosition;
  49042. /** @hidden */
  49043. _localDirection: Vector3;
  49044. /** @hidden */
  49045. _transformedDirection: Vector3;
  49046. /**
  49047. * Instantiates a FlyCamera.
  49048. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49049. * such as in a 3D Space Shooter or a Flight Simulator.
  49050. * @param name Define the name of the camera in the scene.
  49051. * @param position Define the starting position of the camera in the scene.
  49052. * @param scene Define the scene the camera belongs to.
  49053. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49054. */
  49055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49056. /**
  49057. * Attach a control to the HTML DOM element.
  49058. * @param element Defines the element that listens to the input events.
  49059. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49060. */
  49061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49062. /**
  49063. * Detach a control from the HTML DOM element.
  49064. * The camera will stop reacting to that input.
  49065. * @param element Defines the element that listens to the input events.
  49066. */
  49067. detachControl(element: HTMLElement): void;
  49068. private _collisionMask;
  49069. /**
  49070. * Get the mask that the camera ignores in collision events.
  49071. */
  49072. get collisionMask(): number;
  49073. /**
  49074. * Set the mask that the camera ignores in collision events.
  49075. */
  49076. set collisionMask(mask: number);
  49077. /** @hidden */
  49078. _collideWithWorld(displacement: Vector3): void;
  49079. /** @hidden */
  49080. private _onCollisionPositionChange;
  49081. /** @hidden */
  49082. _checkInputs(): void;
  49083. /** @hidden */
  49084. _decideIfNeedsToMove(): boolean;
  49085. /** @hidden */
  49086. _updatePosition(): void;
  49087. /**
  49088. * Restore the Roll to its target value at the rate specified.
  49089. * @param rate - Higher means slower restoring.
  49090. * @hidden
  49091. */
  49092. restoreRoll(rate: number): void;
  49093. /**
  49094. * Destroy the camera and release the current resources held by it.
  49095. */
  49096. dispose(): void;
  49097. /**
  49098. * Get the current object class name.
  49099. * @returns the class name.
  49100. */
  49101. getClassName(): string;
  49102. }
  49103. }
  49104. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49105. import { Nullable } from "babylonjs/types";
  49106. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49107. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49108. /**
  49109. * Listen to keyboard events to control the camera.
  49110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49111. */
  49112. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49113. /**
  49114. * Defines the camera the input is attached to.
  49115. */
  49116. camera: FlyCamera;
  49117. /**
  49118. * The list of keyboard keys used to control the forward move of the camera.
  49119. */
  49120. keysForward: number[];
  49121. /**
  49122. * The list of keyboard keys used to control the backward move of the camera.
  49123. */
  49124. keysBackward: number[];
  49125. /**
  49126. * The list of keyboard keys used to control the forward move of the camera.
  49127. */
  49128. keysUp: number[];
  49129. /**
  49130. * The list of keyboard keys used to control the backward move of the camera.
  49131. */
  49132. keysDown: number[];
  49133. /**
  49134. * The list of keyboard keys used to control the right strafe move of the camera.
  49135. */
  49136. keysRight: number[];
  49137. /**
  49138. * The list of keyboard keys used to control the left strafe move of the camera.
  49139. */
  49140. keysLeft: number[];
  49141. private _keys;
  49142. private _onCanvasBlurObserver;
  49143. private _onKeyboardObserver;
  49144. private _engine;
  49145. private _scene;
  49146. /**
  49147. * Attach the input controls to a specific dom element to get the input from.
  49148. * @param element Defines the element the controls should be listened from
  49149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49150. */
  49151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49152. /**
  49153. * Detach the current controls from the specified dom element.
  49154. * @param element Defines the element to stop listening the inputs from
  49155. */
  49156. detachControl(element: Nullable<HTMLElement>): void;
  49157. /**
  49158. * Gets the class name of the current intput.
  49159. * @returns the class name
  49160. */
  49161. getClassName(): string;
  49162. /** @hidden */
  49163. _onLostFocus(e: FocusEvent): void;
  49164. /**
  49165. * Get the friendly name associated with the input class.
  49166. * @returns the input friendly name
  49167. */
  49168. getSimpleName(): string;
  49169. /**
  49170. * Update the current camera state depending on the inputs that have been used this frame.
  49171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49172. */
  49173. checkInputs(): void;
  49174. }
  49175. }
  49176. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49177. import { Nullable } from "babylonjs/types";
  49178. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49180. /**
  49181. * Manage the mouse wheel inputs to control a follow camera.
  49182. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49183. */
  49184. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49185. /**
  49186. * Defines the camera the input is attached to.
  49187. */
  49188. camera: FollowCamera;
  49189. /**
  49190. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49191. */
  49192. axisControlRadius: boolean;
  49193. /**
  49194. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49195. */
  49196. axisControlHeight: boolean;
  49197. /**
  49198. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49199. */
  49200. axisControlRotation: boolean;
  49201. /**
  49202. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49203. * relation to mouseWheel events.
  49204. */
  49205. wheelPrecision: number;
  49206. /**
  49207. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49208. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49209. */
  49210. wheelDeltaPercentage: number;
  49211. private _wheel;
  49212. private _observer;
  49213. /**
  49214. * Attach the input controls to a specific dom element to get the input from.
  49215. * @param element Defines the element the controls should be listened from
  49216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49217. */
  49218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49219. /**
  49220. * Detach the current controls from the specified dom element.
  49221. * @param element Defines the element to stop listening the inputs from
  49222. */
  49223. detachControl(element: Nullable<HTMLElement>): void;
  49224. /**
  49225. * Gets the class name of the current intput.
  49226. * @returns the class name
  49227. */
  49228. getClassName(): string;
  49229. /**
  49230. * Get the friendly name associated with the input class.
  49231. * @returns the input friendly name
  49232. */
  49233. getSimpleName(): string;
  49234. }
  49235. }
  49236. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49237. import { Nullable } from "babylonjs/types";
  49238. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49239. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49240. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49241. /**
  49242. * Manage the pointers inputs to control an follow camera.
  49243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49244. */
  49245. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49246. /**
  49247. * Defines the camera the input is attached to.
  49248. */
  49249. camera: FollowCamera;
  49250. /**
  49251. * Gets the class name of the current input.
  49252. * @returns the class name
  49253. */
  49254. getClassName(): string;
  49255. /**
  49256. * Defines the pointer angular sensibility along the X axis or how fast is
  49257. * the camera rotating.
  49258. * A negative number will reverse the axis direction.
  49259. */
  49260. angularSensibilityX: number;
  49261. /**
  49262. * Defines the pointer angular sensibility along the Y axis or how fast is
  49263. * the camera rotating.
  49264. * A negative number will reverse the axis direction.
  49265. */
  49266. angularSensibilityY: number;
  49267. /**
  49268. * Defines the pointer pinch precision or how fast is the camera zooming.
  49269. * A negative number will reverse the axis direction.
  49270. */
  49271. pinchPrecision: number;
  49272. /**
  49273. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49274. * from 0.
  49275. * It defines the percentage of current camera.radius to use as delta when
  49276. * pinch zoom is used.
  49277. */
  49278. pinchDeltaPercentage: number;
  49279. /**
  49280. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49281. */
  49282. axisXControlRadius: boolean;
  49283. /**
  49284. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49285. */
  49286. axisXControlHeight: boolean;
  49287. /**
  49288. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49289. */
  49290. axisXControlRotation: boolean;
  49291. /**
  49292. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49293. */
  49294. axisYControlRadius: boolean;
  49295. /**
  49296. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49297. */
  49298. axisYControlHeight: boolean;
  49299. /**
  49300. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49301. */
  49302. axisYControlRotation: boolean;
  49303. /**
  49304. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49305. */
  49306. axisPinchControlRadius: boolean;
  49307. /**
  49308. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49309. */
  49310. axisPinchControlHeight: boolean;
  49311. /**
  49312. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49313. */
  49314. axisPinchControlRotation: boolean;
  49315. /**
  49316. * Log error messages if basic misconfiguration has occurred.
  49317. */
  49318. warningEnable: boolean;
  49319. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49320. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49321. private _warningCounter;
  49322. private _warning;
  49323. }
  49324. }
  49325. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49326. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49327. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49328. /**
  49329. * Default Inputs manager for the FollowCamera.
  49330. * It groups all the default supported inputs for ease of use.
  49331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49332. */
  49333. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49334. /**
  49335. * Instantiates a new FollowCameraInputsManager.
  49336. * @param camera Defines the camera the inputs belong to
  49337. */
  49338. constructor(camera: FollowCamera);
  49339. /**
  49340. * Add keyboard input support to the input manager.
  49341. * @returns the current input manager
  49342. */
  49343. addKeyboard(): FollowCameraInputsManager;
  49344. /**
  49345. * Add mouse wheel input support to the input manager.
  49346. * @returns the current input manager
  49347. */
  49348. addMouseWheel(): FollowCameraInputsManager;
  49349. /**
  49350. * Add pointers input support to the input manager.
  49351. * @returns the current input manager
  49352. */
  49353. addPointers(): FollowCameraInputsManager;
  49354. /**
  49355. * Add orientation input support to the input manager.
  49356. * @returns the current input manager
  49357. */
  49358. addVRDeviceOrientation(): FollowCameraInputsManager;
  49359. }
  49360. }
  49361. declare module "babylonjs/Cameras/followCamera" {
  49362. import { Nullable } from "babylonjs/types";
  49363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49364. import { Scene } from "babylonjs/scene";
  49365. import { Vector3 } from "babylonjs/Maths/math.vector";
  49366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49367. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49368. /**
  49369. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49370. * an arc rotate version arcFollowCamera are available.
  49371. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49372. */
  49373. export class FollowCamera extends TargetCamera {
  49374. /**
  49375. * Distance the follow camera should follow an object at
  49376. */
  49377. radius: number;
  49378. /**
  49379. * Minimum allowed distance of the camera to the axis of rotation
  49380. * (The camera can not get closer).
  49381. * This can help limiting how the Camera is able to move in the scene.
  49382. */
  49383. lowerRadiusLimit: Nullable<number>;
  49384. /**
  49385. * Maximum allowed distance of the camera to the axis of rotation
  49386. * (The camera can not get further).
  49387. * This can help limiting how the Camera is able to move in the scene.
  49388. */
  49389. upperRadiusLimit: Nullable<number>;
  49390. /**
  49391. * Define a rotation offset between the camera and the object it follows
  49392. */
  49393. rotationOffset: number;
  49394. /**
  49395. * Minimum allowed angle to camera position relative to target object.
  49396. * This can help limiting how the Camera is able to move in the scene.
  49397. */
  49398. lowerRotationOffsetLimit: Nullable<number>;
  49399. /**
  49400. * Maximum allowed angle to camera position relative to target object.
  49401. * This can help limiting how the Camera is able to move in the scene.
  49402. */
  49403. upperRotationOffsetLimit: Nullable<number>;
  49404. /**
  49405. * Define a height offset between the camera and the object it follows.
  49406. * It can help following an object from the top (like a car chaing a plane)
  49407. */
  49408. heightOffset: number;
  49409. /**
  49410. * Minimum allowed height of camera position relative to target object.
  49411. * This can help limiting how the Camera is able to move in the scene.
  49412. */
  49413. lowerHeightOffsetLimit: Nullable<number>;
  49414. /**
  49415. * Maximum allowed height of camera position relative to target object.
  49416. * This can help limiting how the Camera is able to move in the scene.
  49417. */
  49418. upperHeightOffsetLimit: Nullable<number>;
  49419. /**
  49420. * Define how fast the camera can accelerate to follow it s target.
  49421. */
  49422. cameraAcceleration: number;
  49423. /**
  49424. * Define the speed limit of the camera following an object.
  49425. */
  49426. maxCameraSpeed: number;
  49427. /**
  49428. * Define the target of the camera.
  49429. */
  49430. lockedTarget: Nullable<AbstractMesh>;
  49431. /**
  49432. * Defines the input associated with the camera.
  49433. */
  49434. inputs: FollowCameraInputsManager;
  49435. /**
  49436. * Instantiates the follow camera.
  49437. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49438. * @param name Define the name of the camera in the scene
  49439. * @param position Define the position of the camera
  49440. * @param scene Define the scene the camera belong to
  49441. * @param lockedTarget Define the target of the camera
  49442. */
  49443. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49444. private _follow;
  49445. /**
  49446. * Attached controls to the current camera.
  49447. * @param element Defines the element the controls should be listened from
  49448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49449. */
  49450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49451. /**
  49452. * Detach the current controls from the camera.
  49453. * The camera will stop reacting to inputs.
  49454. * @param element Defines the element to stop listening the inputs from
  49455. */
  49456. detachControl(element: HTMLElement): void;
  49457. /** @hidden */
  49458. _checkInputs(): void;
  49459. private _checkLimits;
  49460. /**
  49461. * Gets the camera class name.
  49462. * @returns the class name
  49463. */
  49464. getClassName(): string;
  49465. }
  49466. /**
  49467. * Arc Rotate version of the follow camera.
  49468. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49469. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49470. */
  49471. export class ArcFollowCamera extends TargetCamera {
  49472. /** The longitudinal angle of the camera */
  49473. alpha: number;
  49474. /** The latitudinal angle of the camera */
  49475. beta: number;
  49476. /** The radius of the camera from its target */
  49477. radius: number;
  49478. private _cartesianCoordinates;
  49479. /** Define the camera target (the mesh it should follow) */
  49480. private _meshTarget;
  49481. /**
  49482. * Instantiates a new ArcFollowCamera
  49483. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49484. * @param name Define the name of the camera
  49485. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49486. * @param beta Define the rotation angle of the camera around the elevation axis
  49487. * @param radius Define the radius of the camera from its target point
  49488. * @param target Define the target of the camera
  49489. * @param scene Define the scene the camera belongs to
  49490. */
  49491. constructor(name: string,
  49492. /** The longitudinal angle of the camera */
  49493. alpha: number,
  49494. /** The latitudinal angle of the camera */
  49495. beta: number,
  49496. /** The radius of the camera from its target */
  49497. radius: number,
  49498. /** Define the camera target (the mesh it should follow) */
  49499. target: Nullable<AbstractMesh>, scene: Scene);
  49500. private _follow;
  49501. /** @hidden */
  49502. _checkInputs(): void;
  49503. /**
  49504. * Returns the class name of the object.
  49505. * It is mostly used internally for serialization purposes.
  49506. */
  49507. getClassName(): string;
  49508. }
  49509. }
  49510. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49511. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49512. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49513. import { Nullable } from "babylonjs/types";
  49514. /**
  49515. * Manage the keyboard inputs to control the movement of a follow camera.
  49516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49517. */
  49518. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49519. /**
  49520. * Defines the camera the input is attached to.
  49521. */
  49522. camera: FollowCamera;
  49523. /**
  49524. * Defines the list of key codes associated with the up action (increase heightOffset)
  49525. */
  49526. keysHeightOffsetIncr: number[];
  49527. /**
  49528. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49529. */
  49530. keysHeightOffsetDecr: number[];
  49531. /**
  49532. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49533. */
  49534. keysHeightOffsetModifierAlt: boolean;
  49535. /**
  49536. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49537. */
  49538. keysHeightOffsetModifierCtrl: boolean;
  49539. /**
  49540. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49541. */
  49542. keysHeightOffsetModifierShift: boolean;
  49543. /**
  49544. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49545. */
  49546. keysRotationOffsetIncr: number[];
  49547. /**
  49548. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49549. */
  49550. keysRotationOffsetDecr: number[];
  49551. /**
  49552. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49553. */
  49554. keysRotationOffsetModifierAlt: boolean;
  49555. /**
  49556. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49557. */
  49558. keysRotationOffsetModifierCtrl: boolean;
  49559. /**
  49560. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49561. */
  49562. keysRotationOffsetModifierShift: boolean;
  49563. /**
  49564. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49565. */
  49566. keysRadiusIncr: number[];
  49567. /**
  49568. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49569. */
  49570. keysRadiusDecr: number[];
  49571. /**
  49572. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49573. */
  49574. keysRadiusModifierAlt: boolean;
  49575. /**
  49576. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49577. */
  49578. keysRadiusModifierCtrl: boolean;
  49579. /**
  49580. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49581. */
  49582. keysRadiusModifierShift: boolean;
  49583. /**
  49584. * Defines the rate of change of heightOffset.
  49585. */
  49586. heightSensibility: number;
  49587. /**
  49588. * Defines the rate of change of rotationOffset.
  49589. */
  49590. rotationSensibility: number;
  49591. /**
  49592. * Defines the rate of change of radius.
  49593. */
  49594. radiusSensibility: number;
  49595. private _keys;
  49596. private _ctrlPressed;
  49597. private _altPressed;
  49598. private _shiftPressed;
  49599. private _onCanvasBlurObserver;
  49600. private _onKeyboardObserver;
  49601. private _engine;
  49602. private _scene;
  49603. /**
  49604. * Attach the input controls to a specific dom element to get the input from.
  49605. * @param element Defines the element the controls should be listened from
  49606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49607. */
  49608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49609. /**
  49610. * Detach the current controls from the specified dom element.
  49611. * @param element Defines the element to stop listening the inputs from
  49612. */
  49613. detachControl(element: Nullable<HTMLElement>): void;
  49614. /**
  49615. * Update the current camera state depending on the inputs that have been used this frame.
  49616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49617. */
  49618. checkInputs(): void;
  49619. /**
  49620. * Gets the class name of the current input.
  49621. * @returns the class name
  49622. */
  49623. getClassName(): string;
  49624. /**
  49625. * Get the friendly name associated with the input class.
  49626. * @returns the input friendly name
  49627. */
  49628. getSimpleName(): string;
  49629. /**
  49630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49631. * allow modification of the heightOffset value.
  49632. */
  49633. private _modifierHeightOffset;
  49634. /**
  49635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49636. * allow modification of the rotationOffset value.
  49637. */
  49638. private _modifierRotationOffset;
  49639. /**
  49640. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49641. * allow modification of the radius value.
  49642. */
  49643. private _modifierRadius;
  49644. }
  49645. }
  49646. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49647. import { Nullable } from "babylonjs/types";
  49648. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49649. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49650. import { Observable } from "babylonjs/Misc/observable";
  49651. module "babylonjs/Cameras/freeCameraInputsManager" {
  49652. interface FreeCameraInputsManager {
  49653. /**
  49654. * @hidden
  49655. */
  49656. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49657. /**
  49658. * Add orientation input support to the input manager.
  49659. * @returns the current input manager
  49660. */
  49661. addDeviceOrientation(): FreeCameraInputsManager;
  49662. }
  49663. }
  49664. /**
  49665. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49666. * Screen rotation is taken into account.
  49667. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49668. */
  49669. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49670. private _camera;
  49671. private _screenOrientationAngle;
  49672. private _constantTranform;
  49673. private _screenQuaternion;
  49674. private _alpha;
  49675. private _beta;
  49676. private _gamma;
  49677. /**
  49678. * Can be used to detect if a device orientation sensor is available on a device
  49679. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49680. * @returns a promise that will resolve on orientation change
  49681. */
  49682. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49683. /**
  49684. * @hidden
  49685. */
  49686. _onDeviceOrientationChangedObservable: Observable<void>;
  49687. /**
  49688. * Instantiates a new input
  49689. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49690. */
  49691. constructor();
  49692. /**
  49693. * Define the camera controlled by the input.
  49694. */
  49695. get camera(): FreeCamera;
  49696. set camera(camera: FreeCamera);
  49697. /**
  49698. * Attach the input controls to a specific dom element to get the input from.
  49699. * @param element Defines the element the controls should be listened from
  49700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49701. */
  49702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49703. private _orientationChanged;
  49704. private _deviceOrientation;
  49705. /**
  49706. * Detach the current controls from the specified dom element.
  49707. * @param element Defines the element to stop listening the inputs from
  49708. */
  49709. detachControl(element: Nullable<HTMLElement>): void;
  49710. /**
  49711. * Update the current camera state depending on the inputs that have been used this frame.
  49712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49713. */
  49714. checkInputs(): void;
  49715. /**
  49716. * Gets the class name of the current intput.
  49717. * @returns the class name
  49718. */
  49719. getClassName(): string;
  49720. /**
  49721. * Get the friendly name associated with the input class.
  49722. * @returns the input friendly name
  49723. */
  49724. getSimpleName(): string;
  49725. }
  49726. }
  49727. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49728. import { Nullable } from "babylonjs/types";
  49729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49731. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49732. /**
  49733. * Manage the gamepad inputs to control a free camera.
  49734. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49735. */
  49736. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49737. /**
  49738. * Define the camera the input is attached to.
  49739. */
  49740. camera: FreeCamera;
  49741. /**
  49742. * Define the Gamepad controlling the input
  49743. */
  49744. gamepad: Nullable<Gamepad>;
  49745. /**
  49746. * Defines the gamepad rotation sensiblity.
  49747. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49748. */
  49749. gamepadAngularSensibility: number;
  49750. /**
  49751. * Defines the gamepad move sensiblity.
  49752. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49753. */
  49754. gamepadMoveSensibility: number;
  49755. private _yAxisScale;
  49756. /**
  49757. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49758. */
  49759. get invertYAxis(): boolean;
  49760. set invertYAxis(value: boolean);
  49761. private _onGamepadConnectedObserver;
  49762. private _onGamepadDisconnectedObserver;
  49763. private _cameraTransform;
  49764. private _deltaTransform;
  49765. private _vector3;
  49766. private _vector2;
  49767. /**
  49768. * Attach the input controls to a specific dom element to get the input from.
  49769. * @param element Defines the element the controls should be listened from
  49770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49771. */
  49772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49773. /**
  49774. * Detach the current controls from the specified dom element.
  49775. * @param element Defines the element to stop listening the inputs from
  49776. */
  49777. detachControl(element: Nullable<HTMLElement>): void;
  49778. /**
  49779. * Update the current camera state depending on the inputs that have been used this frame.
  49780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49781. */
  49782. checkInputs(): void;
  49783. /**
  49784. * Gets the class name of the current intput.
  49785. * @returns the class name
  49786. */
  49787. getClassName(): string;
  49788. /**
  49789. * Get the friendly name associated with the input class.
  49790. * @returns the input friendly name
  49791. */
  49792. getSimpleName(): string;
  49793. }
  49794. }
  49795. declare module "babylonjs/Misc/virtualJoystick" {
  49796. import { Nullable } from "babylonjs/types";
  49797. import { Vector3 } from "babylonjs/Maths/math.vector";
  49798. /**
  49799. * Defines the potential axis of a Joystick
  49800. */
  49801. export enum JoystickAxis {
  49802. /** X axis */
  49803. X = 0,
  49804. /** Y axis */
  49805. Y = 1,
  49806. /** Z axis */
  49807. Z = 2
  49808. }
  49809. /**
  49810. * Represents the different customization options available
  49811. * for VirtualJoystick
  49812. */
  49813. interface VirtualJoystickCustomizations {
  49814. /**
  49815. * Size of the joystick's puck
  49816. */
  49817. puckSize: number;
  49818. /**
  49819. * Size of the joystick's container
  49820. */
  49821. containerSize: number;
  49822. /**
  49823. * Color of the joystick && puck
  49824. */
  49825. color: string;
  49826. /**
  49827. * Image URL for the joystick's puck
  49828. */
  49829. puckImage?: string;
  49830. /**
  49831. * Image URL for the joystick's container
  49832. */
  49833. containerImage?: string;
  49834. /**
  49835. * Defines the unmoving position of the joystick container
  49836. */
  49837. position?: {
  49838. x: number;
  49839. y: number;
  49840. };
  49841. /**
  49842. * Defines whether or not the joystick container is always visible
  49843. */
  49844. alwaysVisible: boolean;
  49845. /**
  49846. * Defines whether or not to limit the movement of the puck to the joystick's container
  49847. */
  49848. limitToContainer: boolean;
  49849. }
  49850. /**
  49851. * Class used to define virtual joystick (used in touch mode)
  49852. */
  49853. export class VirtualJoystick {
  49854. /**
  49855. * Gets or sets a boolean indicating that left and right values must be inverted
  49856. */
  49857. reverseLeftRight: boolean;
  49858. /**
  49859. * Gets or sets a boolean indicating that up and down values must be inverted
  49860. */
  49861. reverseUpDown: boolean;
  49862. /**
  49863. * Gets the offset value for the position (ie. the change of the position value)
  49864. */
  49865. deltaPosition: Vector3;
  49866. /**
  49867. * Gets a boolean indicating if the virtual joystick was pressed
  49868. */
  49869. pressed: boolean;
  49870. /**
  49871. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49872. */
  49873. static Canvas: Nullable<HTMLCanvasElement>;
  49874. /**
  49875. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49876. */
  49877. limitToContainer: boolean;
  49878. private static _globalJoystickIndex;
  49879. private static _alwaysVisibleSticks;
  49880. private static vjCanvasContext;
  49881. private static vjCanvasWidth;
  49882. private static vjCanvasHeight;
  49883. private static halfWidth;
  49884. private static _GetDefaultOptions;
  49885. private _action;
  49886. private _axisTargetedByLeftAndRight;
  49887. private _axisTargetedByUpAndDown;
  49888. private _joystickSensibility;
  49889. private _inversedSensibility;
  49890. private _joystickPointerID;
  49891. private _joystickColor;
  49892. private _joystickPointerPos;
  49893. private _joystickPreviousPointerPos;
  49894. private _joystickPointerStartPos;
  49895. private _deltaJoystickVector;
  49896. private _leftJoystick;
  49897. private _touches;
  49898. private _joystickPosition;
  49899. private _alwaysVisible;
  49900. private _puckImage;
  49901. private _containerImage;
  49902. private _joystickPuckSize;
  49903. private _joystickContainerSize;
  49904. private _clearPuckSize;
  49905. private _clearContainerSize;
  49906. private _clearPuckSizeOffset;
  49907. private _clearContainerSizeOffset;
  49908. private _onPointerDownHandlerRef;
  49909. private _onPointerMoveHandlerRef;
  49910. private _onPointerUpHandlerRef;
  49911. private _onResize;
  49912. /**
  49913. * Creates a new virtual joystick
  49914. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49915. * @param customizations Defines the options we want to customize the VirtualJoystick
  49916. */
  49917. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  49918. /**
  49919. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  49920. * @param newJoystickSensibility defines the new sensibility
  49921. */
  49922. setJoystickSensibility(newJoystickSensibility: number): void;
  49923. private _onPointerDown;
  49924. private _onPointerMove;
  49925. private _onPointerUp;
  49926. /**
  49927. * Change the color of the virtual joystick
  49928. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  49929. */
  49930. setJoystickColor(newColor: string): void;
  49931. /**
  49932. * Size of the joystick's container
  49933. */
  49934. set containerSize(newSize: number);
  49935. get containerSize(): number;
  49936. /**
  49937. * Size of the joystick's puck
  49938. */
  49939. set puckSize(newSize: number);
  49940. get puckSize(): number;
  49941. /**
  49942. * Clears the set position of the joystick
  49943. */
  49944. clearPosition(): void;
  49945. /**
  49946. * Defines whether or not the joystick container is always visible
  49947. */
  49948. set alwaysVisible(value: boolean);
  49949. get alwaysVisible(): boolean;
  49950. /**
  49951. * Sets the constant position of the Joystick container
  49952. * @param x X axis coordinate
  49953. * @param y Y axis coordinate
  49954. */
  49955. setPosition(x: number, y: number): void;
  49956. /**
  49957. * Defines a callback to call when the joystick is touched
  49958. * @param action defines the callback
  49959. */
  49960. setActionOnTouch(action: () => any): void;
  49961. /**
  49962. * Defines which axis you'd like to control for left & right
  49963. * @param axis defines the axis to use
  49964. */
  49965. setAxisForLeftRight(axis: JoystickAxis): void;
  49966. /**
  49967. * Defines which axis you'd like to control for up & down
  49968. * @param axis defines the axis to use
  49969. */
  49970. setAxisForUpDown(axis: JoystickAxis): void;
  49971. /**
  49972. * Clears the canvas from the previous puck / container draw
  49973. */
  49974. private _clearPreviousDraw;
  49975. /**
  49976. * Loads `urlPath` to be used for the container's image
  49977. * @param urlPath defines the urlPath of an image to use
  49978. */
  49979. setContainerImage(urlPath: string): void;
  49980. /**
  49981. * Loads `urlPath` to be used for the puck's image
  49982. * @param urlPath defines the urlPath of an image to use
  49983. */
  49984. setPuckImage(urlPath: string): void;
  49985. /**
  49986. * Draws the Virtual Joystick's container
  49987. */
  49988. private _drawContainer;
  49989. /**
  49990. * Draws the Virtual Joystick's puck
  49991. */
  49992. private _drawPuck;
  49993. private _drawVirtualJoystick;
  49994. /**
  49995. * Release internal HTML canvas
  49996. */
  49997. releaseCanvas(): void;
  49998. }
  49999. }
  50000. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50001. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50002. import { Nullable } from "babylonjs/types";
  50003. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50004. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50005. module "babylonjs/Cameras/freeCameraInputsManager" {
  50006. interface FreeCameraInputsManager {
  50007. /**
  50008. * Add virtual joystick input support to the input manager.
  50009. * @returns the current input manager
  50010. */
  50011. addVirtualJoystick(): FreeCameraInputsManager;
  50012. }
  50013. }
  50014. /**
  50015. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50016. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50017. */
  50018. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50019. /**
  50020. * Defines the camera the input is attached to.
  50021. */
  50022. camera: FreeCamera;
  50023. private _leftjoystick;
  50024. private _rightjoystick;
  50025. /**
  50026. * Gets the left stick of the virtual joystick.
  50027. * @returns The virtual Joystick
  50028. */
  50029. getLeftJoystick(): VirtualJoystick;
  50030. /**
  50031. * Gets the right stick of the virtual joystick.
  50032. * @returns The virtual Joystick
  50033. */
  50034. getRightJoystick(): VirtualJoystick;
  50035. /**
  50036. * Update the current camera state depending on the inputs that have been used this frame.
  50037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50038. */
  50039. checkInputs(): void;
  50040. /**
  50041. * Attach the input controls to a specific dom element to get the input from.
  50042. * @param element Defines the element the controls should be listened from
  50043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50044. */
  50045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50046. /**
  50047. * Detach the current controls from the specified dom element.
  50048. * @param element Defines the element to stop listening the inputs from
  50049. */
  50050. detachControl(element: Nullable<HTMLElement>): void;
  50051. /**
  50052. * Gets the class name of the current intput.
  50053. * @returns the class name
  50054. */
  50055. getClassName(): string;
  50056. /**
  50057. * Get the friendly name associated with the input class.
  50058. * @returns the input friendly name
  50059. */
  50060. getSimpleName(): string;
  50061. }
  50062. }
  50063. declare module "babylonjs/Cameras/Inputs/index" {
  50064. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50065. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50066. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50067. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50068. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50069. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50070. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50071. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50072. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50073. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50074. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50075. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50076. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50077. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50078. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50079. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50080. }
  50081. declare module "babylonjs/Cameras/touchCamera" {
  50082. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50083. import { Scene } from "babylonjs/scene";
  50084. import { Vector3 } from "babylonjs/Maths/math.vector";
  50085. /**
  50086. * This represents a FPS type of camera controlled by touch.
  50087. * This is like a universal camera minus the Gamepad controls.
  50088. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50089. */
  50090. export class TouchCamera extends FreeCamera {
  50091. /**
  50092. * Defines the touch sensibility for rotation.
  50093. * The higher the faster.
  50094. */
  50095. get touchAngularSensibility(): number;
  50096. set touchAngularSensibility(value: number);
  50097. /**
  50098. * Defines the touch sensibility for move.
  50099. * The higher the faster.
  50100. */
  50101. get touchMoveSensibility(): number;
  50102. set touchMoveSensibility(value: number);
  50103. /**
  50104. * Instantiates a new touch camera.
  50105. * This represents a FPS type of camera controlled by touch.
  50106. * This is like a universal camera minus the Gamepad controls.
  50107. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50108. * @param name Define the name of the camera in the scene
  50109. * @param position Define the start position of the camera in the scene
  50110. * @param scene Define the scene the camera belongs to
  50111. */
  50112. constructor(name: string, position: Vector3, scene: Scene);
  50113. /**
  50114. * Gets the current object class name.
  50115. * @return the class name
  50116. */
  50117. getClassName(): string;
  50118. /** @hidden */
  50119. _setupInputs(): void;
  50120. }
  50121. }
  50122. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50124. import { Scene } from "babylonjs/scene";
  50125. import { Vector3 } from "babylonjs/Maths/math.vector";
  50126. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50127. import { Axis } from "babylonjs/Maths/math.axis";
  50128. /**
  50129. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50130. * being tilted forward or back and left or right.
  50131. */
  50132. export class DeviceOrientationCamera extends FreeCamera {
  50133. private _initialQuaternion;
  50134. private _quaternionCache;
  50135. private _tmpDragQuaternion;
  50136. private _disablePointerInputWhenUsingDeviceOrientation;
  50137. /**
  50138. * Creates a new device orientation camera
  50139. * @param name The name of the camera
  50140. * @param position The start position camera
  50141. * @param scene The scene the camera belongs to
  50142. */
  50143. constructor(name: string, position: Vector3, scene: Scene);
  50144. /**
  50145. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50146. */
  50147. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50148. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50149. private _dragFactor;
  50150. /**
  50151. * Enabled turning on the y axis when the orientation sensor is active
  50152. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50153. */
  50154. enableHorizontalDragging(dragFactor?: number): void;
  50155. /**
  50156. * Gets the current instance class name ("DeviceOrientationCamera").
  50157. * This helps avoiding instanceof at run time.
  50158. * @returns the class name
  50159. */
  50160. getClassName(): string;
  50161. /**
  50162. * @hidden
  50163. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50164. */
  50165. _checkInputs(): void;
  50166. /**
  50167. * Reset the camera to its default orientation on the specified axis only.
  50168. * @param axis The axis to reset
  50169. */
  50170. resetToCurrentRotation(axis?: Axis): void;
  50171. }
  50172. }
  50173. declare module "babylonjs/Gamepads/xboxGamepad" {
  50174. import { Observable } from "babylonjs/Misc/observable";
  50175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50176. /**
  50177. * Defines supported buttons for XBox360 compatible gamepads
  50178. */
  50179. export enum Xbox360Button {
  50180. /** A */
  50181. A = 0,
  50182. /** B */
  50183. B = 1,
  50184. /** X */
  50185. X = 2,
  50186. /** Y */
  50187. Y = 3,
  50188. /** Left button */
  50189. LB = 4,
  50190. /** Right button */
  50191. RB = 5,
  50192. /** Back */
  50193. Back = 8,
  50194. /** Start */
  50195. Start = 9,
  50196. /** Left stick */
  50197. LeftStick = 10,
  50198. /** Right stick */
  50199. RightStick = 11
  50200. }
  50201. /** Defines values for XBox360 DPad */
  50202. export enum Xbox360Dpad {
  50203. /** Up */
  50204. Up = 12,
  50205. /** Down */
  50206. Down = 13,
  50207. /** Left */
  50208. Left = 14,
  50209. /** Right */
  50210. Right = 15
  50211. }
  50212. /**
  50213. * Defines a XBox360 gamepad
  50214. */
  50215. export class Xbox360Pad extends Gamepad {
  50216. private _leftTrigger;
  50217. private _rightTrigger;
  50218. private _onlefttriggerchanged;
  50219. private _onrighttriggerchanged;
  50220. private _onbuttondown;
  50221. private _onbuttonup;
  50222. private _ondpaddown;
  50223. private _ondpadup;
  50224. /** Observable raised when a button is pressed */
  50225. onButtonDownObservable: Observable<Xbox360Button>;
  50226. /** Observable raised when a button is released */
  50227. onButtonUpObservable: Observable<Xbox360Button>;
  50228. /** Observable raised when a pad is pressed */
  50229. onPadDownObservable: Observable<Xbox360Dpad>;
  50230. /** Observable raised when a pad is released */
  50231. onPadUpObservable: Observable<Xbox360Dpad>;
  50232. private _buttonA;
  50233. private _buttonB;
  50234. private _buttonX;
  50235. private _buttonY;
  50236. private _buttonBack;
  50237. private _buttonStart;
  50238. private _buttonLB;
  50239. private _buttonRB;
  50240. private _buttonLeftStick;
  50241. private _buttonRightStick;
  50242. private _dPadUp;
  50243. private _dPadDown;
  50244. private _dPadLeft;
  50245. private _dPadRight;
  50246. private _isXboxOnePad;
  50247. /**
  50248. * Creates a new XBox360 gamepad object
  50249. * @param id defines the id of this gamepad
  50250. * @param index defines its index
  50251. * @param gamepad defines the internal HTML gamepad object
  50252. * @param xboxOne defines if it is a XBox One gamepad
  50253. */
  50254. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50255. /**
  50256. * Defines the callback to call when left trigger is pressed
  50257. * @param callback defines the callback to use
  50258. */
  50259. onlefttriggerchanged(callback: (value: number) => void): void;
  50260. /**
  50261. * Defines the callback to call when right trigger is pressed
  50262. * @param callback defines the callback to use
  50263. */
  50264. onrighttriggerchanged(callback: (value: number) => void): void;
  50265. /**
  50266. * Gets the left trigger value
  50267. */
  50268. get leftTrigger(): number;
  50269. /**
  50270. * Sets the left trigger value
  50271. */
  50272. set leftTrigger(newValue: number);
  50273. /**
  50274. * Gets the right trigger value
  50275. */
  50276. get rightTrigger(): number;
  50277. /**
  50278. * Sets the right trigger value
  50279. */
  50280. set rightTrigger(newValue: number);
  50281. /**
  50282. * Defines the callback to call when a button is pressed
  50283. * @param callback defines the callback to use
  50284. */
  50285. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50286. /**
  50287. * Defines the callback to call when a button is released
  50288. * @param callback defines the callback to use
  50289. */
  50290. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50291. /**
  50292. * Defines the callback to call when a pad is pressed
  50293. * @param callback defines the callback to use
  50294. */
  50295. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50296. /**
  50297. * Defines the callback to call when a pad is released
  50298. * @param callback defines the callback to use
  50299. */
  50300. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50301. private _setButtonValue;
  50302. private _setDPadValue;
  50303. /**
  50304. * Gets the value of the `A` button
  50305. */
  50306. get buttonA(): number;
  50307. /**
  50308. * Sets the value of the `A` button
  50309. */
  50310. set buttonA(value: number);
  50311. /**
  50312. * Gets the value of the `B` button
  50313. */
  50314. get buttonB(): number;
  50315. /**
  50316. * Sets the value of the `B` button
  50317. */
  50318. set buttonB(value: number);
  50319. /**
  50320. * Gets the value of the `X` button
  50321. */
  50322. get buttonX(): number;
  50323. /**
  50324. * Sets the value of the `X` button
  50325. */
  50326. set buttonX(value: number);
  50327. /**
  50328. * Gets the value of the `Y` button
  50329. */
  50330. get buttonY(): number;
  50331. /**
  50332. * Sets the value of the `Y` button
  50333. */
  50334. set buttonY(value: number);
  50335. /**
  50336. * Gets the value of the `Start` button
  50337. */
  50338. get buttonStart(): number;
  50339. /**
  50340. * Sets the value of the `Start` button
  50341. */
  50342. set buttonStart(value: number);
  50343. /**
  50344. * Gets the value of the `Back` button
  50345. */
  50346. get buttonBack(): number;
  50347. /**
  50348. * Sets the value of the `Back` button
  50349. */
  50350. set buttonBack(value: number);
  50351. /**
  50352. * Gets the value of the `Left` button
  50353. */
  50354. get buttonLB(): number;
  50355. /**
  50356. * Sets the value of the `Left` button
  50357. */
  50358. set buttonLB(value: number);
  50359. /**
  50360. * Gets the value of the `Right` button
  50361. */
  50362. get buttonRB(): number;
  50363. /**
  50364. * Sets the value of the `Right` button
  50365. */
  50366. set buttonRB(value: number);
  50367. /**
  50368. * Gets the value of the Left joystick
  50369. */
  50370. get buttonLeftStick(): number;
  50371. /**
  50372. * Sets the value of the Left joystick
  50373. */
  50374. set buttonLeftStick(value: number);
  50375. /**
  50376. * Gets the value of the Right joystick
  50377. */
  50378. get buttonRightStick(): number;
  50379. /**
  50380. * Sets the value of the Right joystick
  50381. */
  50382. set buttonRightStick(value: number);
  50383. /**
  50384. * Gets the value of D-pad up
  50385. */
  50386. get dPadUp(): number;
  50387. /**
  50388. * Sets the value of D-pad up
  50389. */
  50390. set dPadUp(value: number);
  50391. /**
  50392. * Gets the value of D-pad down
  50393. */
  50394. get dPadDown(): number;
  50395. /**
  50396. * Sets the value of D-pad down
  50397. */
  50398. set dPadDown(value: number);
  50399. /**
  50400. * Gets the value of D-pad left
  50401. */
  50402. get dPadLeft(): number;
  50403. /**
  50404. * Sets the value of D-pad left
  50405. */
  50406. set dPadLeft(value: number);
  50407. /**
  50408. * Gets the value of D-pad right
  50409. */
  50410. get dPadRight(): number;
  50411. /**
  50412. * Sets the value of D-pad right
  50413. */
  50414. set dPadRight(value: number);
  50415. /**
  50416. * Force the gamepad to synchronize with device values
  50417. */
  50418. update(): void;
  50419. /**
  50420. * Disposes the gamepad
  50421. */
  50422. dispose(): void;
  50423. }
  50424. }
  50425. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50426. import { Observable } from "babylonjs/Misc/observable";
  50427. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50428. /**
  50429. * Defines supported buttons for DualShock compatible gamepads
  50430. */
  50431. export enum DualShockButton {
  50432. /** Cross */
  50433. Cross = 0,
  50434. /** Circle */
  50435. Circle = 1,
  50436. /** Square */
  50437. Square = 2,
  50438. /** Triangle */
  50439. Triangle = 3,
  50440. /** L1 */
  50441. L1 = 4,
  50442. /** R1 */
  50443. R1 = 5,
  50444. /** Share */
  50445. Share = 8,
  50446. /** Options */
  50447. Options = 9,
  50448. /** Left stick */
  50449. LeftStick = 10,
  50450. /** Right stick */
  50451. RightStick = 11
  50452. }
  50453. /** Defines values for DualShock DPad */
  50454. export enum DualShockDpad {
  50455. /** Up */
  50456. Up = 12,
  50457. /** Down */
  50458. Down = 13,
  50459. /** Left */
  50460. Left = 14,
  50461. /** Right */
  50462. Right = 15
  50463. }
  50464. /**
  50465. * Defines a DualShock gamepad
  50466. */
  50467. export class DualShockPad extends Gamepad {
  50468. private _leftTrigger;
  50469. private _rightTrigger;
  50470. private _onlefttriggerchanged;
  50471. private _onrighttriggerchanged;
  50472. private _onbuttondown;
  50473. private _onbuttonup;
  50474. private _ondpaddown;
  50475. private _ondpadup;
  50476. /** Observable raised when a button is pressed */
  50477. onButtonDownObservable: Observable<DualShockButton>;
  50478. /** Observable raised when a button is released */
  50479. onButtonUpObservable: Observable<DualShockButton>;
  50480. /** Observable raised when a pad is pressed */
  50481. onPadDownObservable: Observable<DualShockDpad>;
  50482. /** Observable raised when a pad is released */
  50483. onPadUpObservable: Observable<DualShockDpad>;
  50484. private _buttonCross;
  50485. private _buttonCircle;
  50486. private _buttonSquare;
  50487. private _buttonTriangle;
  50488. private _buttonShare;
  50489. private _buttonOptions;
  50490. private _buttonL1;
  50491. private _buttonR1;
  50492. private _buttonLeftStick;
  50493. private _buttonRightStick;
  50494. private _dPadUp;
  50495. private _dPadDown;
  50496. private _dPadLeft;
  50497. private _dPadRight;
  50498. /**
  50499. * Creates a new DualShock gamepad object
  50500. * @param id defines the id of this gamepad
  50501. * @param index defines its index
  50502. * @param gamepad defines the internal HTML gamepad object
  50503. */
  50504. constructor(id: string, index: number, gamepad: any);
  50505. /**
  50506. * Defines the callback to call when left trigger is pressed
  50507. * @param callback defines the callback to use
  50508. */
  50509. onlefttriggerchanged(callback: (value: number) => void): void;
  50510. /**
  50511. * Defines the callback to call when right trigger is pressed
  50512. * @param callback defines the callback to use
  50513. */
  50514. onrighttriggerchanged(callback: (value: number) => void): void;
  50515. /**
  50516. * Gets the left trigger value
  50517. */
  50518. get leftTrigger(): number;
  50519. /**
  50520. * Sets the left trigger value
  50521. */
  50522. set leftTrigger(newValue: number);
  50523. /**
  50524. * Gets the right trigger value
  50525. */
  50526. get rightTrigger(): number;
  50527. /**
  50528. * Sets the right trigger value
  50529. */
  50530. set rightTrigger(newValue: number);
  50531. /**
  50532. * Defines the callback to call when a button is pressed
  50533. * @param callback defines the callback to use
  50534. */
  50535. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50536. /**
  50537. * Defines the callback to call when a button is released
  50538. * @param callback defines the callback to use
  50539. */
  50540. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50541. /**
  50542. * Defines the callback to call when a pad is pressed
  50543. * @param callback defines the callback to use
  50544. */
  50545. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50546. /**
  50547. * Defines the callback to call when a pad is released
  50548. * @param callback defines the callback to use
  50549. */
  50550. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50551. private _setButtonValue;
  50552. private _setDPadValue;
  50553. /**
  50554. * Gets the value of the `Cross` button
  50555. */
  50556. get buttonCross(): number;
  50557. /**
  50558. * Sets the value of the `Cross` button
  50559. */
  50560. set buttonCross(value: number);
  50561. /**
  50562. * Gets the value of the `Circle` button
  50563. */
  50564. get buttonCircle(): number;
  50565. /**
  50566. * Sets the value of the `Circle` button
  50567. */
  50568. set buttonCircle(value: number);
  50569. /**
  50570. * Gets the value of the `Square` button
  50571. */
  50572. get buttonSquare(): number;
  50573. /**
  50574. * Sets the value of the `Square` button
  50575. */
  50576. set buttonSquare(value: number);
  50577. /**
  50578. * Gets the value of the `Triangle` button
  50579. */
  50580. get buttonTriangle(): number;
  50581. /**
  50582. * Sets the value of the `Triangle` button
  50583. */
  50584. set buttonTriangle(value: number);
  50585. /**
  50586. * Gets the value of the `Options` button
  50587. */
  50588. get buttonOptions(): number;
  50589. /**
  50590. * Sets the value of the `Options` button
  50591. */
  50592. set buttonOptions(value: number);
  50593. /**
  50594. * Gets the value of the `Share` button
  50595. */
  50596. get buttonShare(): number;
  50597. /**
  50598. * Sets the value of the `Share` button
  50599. */
  50600. set buttonShare(value: number);
  50601. /**
  50602. * Gets the value of the `L1` button
  50603. */
  50604. get buttonL1(): number;
  50605. /**
  50606. * Sets the value of the `L1` button
  50607. */
  50608. set buttonL1(value: number);
  50609. /**
  50610. * Gets the value of the `R1` button
  50611. */
  50612. get buttonR1(): number;
  50613. /**
  50614. * Sets the value of the `R1` button
  50615. */
  50616. set buttonR1(value: number);
  50617. /**
  50618. * Gets the value of the Left joystick
  50619. */
  50620. get buttonLeftStick(): number;
  50621. /**
  50622. * Sets the value of the Left joystick
  50623. */
  50624. set buttonLeftStick(value: number);
  50625. /**
  50626. * Gets the value of the Right joystick
  50627. */
  50628. get buttonRightStick(): number;
  50629. /**
  50630. * Sets the value of the Right joystick
  50631. */
  50632. set buttonRightStick(value: number);
  50633. /**
  50634. * Gets the value of D-pad up
  50635. */
  50636. get dPadUp(): number;
  50637. /**
  50638. * Sets the value of D-pad up
  50639. */
  50640. set dPadUp(value: number);
  50641. /**
  50642. * Gets the value of D-pad down
  50643. */
  50644. get dPadDown(): number;
  50645. /**
  50646. * Sets the value of D-pad down
  50647. */
  50648. set dPadDown(value: number);
  50649. /**
  50650. * Gets the value of D-pad left
  50651. */
  50652. get dPadLeft(): number;
  50653. /**
  50654. * Sets the value of D-pad left
  50655. */
  50656. set dPadLeft(value: number);
  50657. /**
  50658. * Gets the value of D-pad right
  50659. */
  50660. get dPadRight(): number;
  50661. /**
  50662. * Sets the value of D-pad right
  50663. */
  50664. set dPadRight(value: number);
  50665. /**
  50666. * Force the gamepad to synchronize with device values
  50667. */
  50668. update(): void;
  50669. /**
  50670. * Disposes the gamepad
  50671. */
  50672. dispose(): void;
  50673. }
  50674. }
  50675. declare module "babylonjs/Gamepads/gamepadManager" {
  50676. import { Observable } from "babylonjs/Misc/observable";
  50677. import { Nullable } from "babylonjs/types";
  50678. import { Scene } from "babylonjs/scene";
  50679. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50680. /**
  50681. * Manager for handling gamepads
  50682. */
  50683. export class GamepadManager {
  50684. private _scene?;
  50685. private _babylonGamepads;
  50686. private _oneGamepadConnected;
  50687. /** @hidden */
  50688. _isMonitoring: boolean;
  50689. private _gamepadEventSupported;
  50690. private _gamepadSupport?;
  50691. /**
  50692. * observable to be triggered when the gamepad controller has been connected
  50693. */
  50694. onGamepadConnectedObservable: Observable<Gamepad>;
  50695. /**
  50696. * observable to be triggered when the gamepad controller has been disconnected
  50697. */
  50698. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50699. private _onGamepadConnectedEvent;
  50700. private _onGamepadDisconnectedEvent;
  50701. /**
  50702. * Initializes the gamepad manager
  50703. * @param _scene BabylonJS scene
  50704. */
  50705. constructor(_scene?: Scene | undefined);
  50706. /**
  50707. * The gamepads in the game pad manager
  50708. */
  50709. get gamepads(): Gamepad[];
  50710. /**
  50711. * Get the gamepad controllers based on type
  50712. * @param type The type of gamepad controller
  50713. * @returns Nullable gamepad
  50714. */
  50715. getGamepadByType(type?: number): Nullable<Gamepad>;
  50716. /**
  50717. * Disposes the gamepad manager
  50718. */
  50719. dispose(): void;
  50720. private _addNewGamepad;
  50721. private _startMonitoringGamepads;
  50722. private _stopMonitoringGamepads;
  50723. /** @hidden */
  50724. _checkGamepadsStatus(): void;
  50725. private _updateGamepadObjects;
  50726. }
  50727. }
  50728. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50729. import { Nullable } from "babylonjs/types";
  50730. import { Scene } from "babylonjs/scene";
  50731. import { ISceneComponent } from "babylonjs/sceneComponent";
  50732. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50733. module "babylonjs/scene" {
  50734. interface Scene {
  50735. /** @hidden */
  50736. _gamepadManager: Nullable<GamepadManager>;
  50737. /**
  50738. * Gets the gamepad manager associated with the scene
  50739. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50740. */
  50741. gamepadManager: GamepadManager;
  50742. }
  50743. }
  50744. module "babylonjs/Cameras/freeCameraInputsManager" {
  50745. /**
  50746. * Interface representing a free camera inputs manager
  50747. */
  50748. interface FreeCameraInputsManager {
  50749. /**
  50750. * Adds gamepad input support to the FreeCameraInputsManager.
  50751. * @returns the FreeCameraInputsManager
  50752. */
  50753. addGamepad(): FreeCameraInputsManager;
  50754. }
  50755. }
  50756. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50757. /**
  50758. * Interface representing an arc rotate camera inputs manager
  50759. */
  50760. interface ArcRotateCameraInputsManager {
  50761. /**
  50762. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50763. * @returns the camera inputs manager
  50764. */
  50765. addGamepad(): ArcRotateCameraInputsManager;
  50766. }
  50767. }
  50768. /**
  50769. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50770. */
  50771. export class GamepadSystemSceneComponent implements ISceneComponent {
  50772. /**
  50773. * The component name helpfull to identify the component in the list of scene components.
  50774. */
  50775. readonly name: string;
  50776. /**
  50777. * The scene the component belongs to.
  50778. */
  50779. scene: Scene;
  50780. /**
  50781. * Creates a new instance of the component for the given scene
  50782. * @param scene Defines the scene to register the component in
  50783. */
  50784. constructor(scene: Scene);
  50785. /**
  50786. * Registers the component in a given scene
  50787. */
  50788. register(): void;
  50789. /**
  50790. * Rebuilds the elements related to this component in case of
  50791. * context lost for instance.
  50792. */
  50793. rebuild(): void;
  50794. /**
  50795. * Disposes the component and the associated ressources
  50796. */
  50797. dispose(): void;
  50798. private _beforeCameraUpdate;
  50799. }
  50800. }
  50801. declare module "babylonjs/Cameras/universalCamera" {
  50802. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50803. import { Scene } from "babylonjs/scene";
  50804. import { Vector3 } from "babylonjs/Maths/math.vector";
  50805. import "babylonjs/Gamepads/gamepadSceneComponent";
  50806. /**
  50807. * 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,
  50808. * which still works and will still be found in many Playgrounds.
  50809. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50810. */
  50811. export class UniversalCamera extends TouchCamera {
  50812. /**
  50813. * Defines the gamepad rotation sensiblity.
  50814. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50815. */
  50816. get gamepadAngularSensibility(): number;
  50817. set gamepadAngularSensibility(value: number);
  50818. /**
  50819. * Defines the gamepad move sensiblity.
  50820. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50821. */
  50822. get gamepadMoveSensibility(): number;
  50823. set gamepadMoveSensibility(value: number);
  50824. /**
  50825. * 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,
  50826. * which still works and will still be found in many Playgrounds.
  50827. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50828. * @param name Define the name of the camera in the scene
  50829. * @param position Define the start position of the camera in the scene
  50830. * @param scene Define the scene the camera belongs to
  50831. */
  50832. constructor(name: string, position: Vector3, scene: Scene);
  50833. /**
  50834. * Gets the current object class name.
  50835. * @return the class name
  50836. */
  50837. getClassName(): string;
  50838. }
  50839. }
  50840. declare module "babylonjs/Cameras/gamepadCamera" {
  50841. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50842. import { Scene } from "babylonjs/scene";
  50843. import { Vector3 } from "babylonjs/Maths/math.vector";
  50844. /**
  50845. * This represents a FPS type of camera. This is only here for back compat purpose.
  50846. * Please use the UniversalCamera instead as both are identical.
  50847. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50848. */
  50849. export class GamepadCamera extends UniversalCamera {
  50850. /**
  50851. * Instantiates a new Gamepad Camera
  50852. * This represents a FPS type of camera. This is only here for back compat purpose.
  50853. * Please use the UniversalCamera instead as both are identical.
  50854. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50855. * @param name Define the name of the camera in the scene
  50856. * @param position Define the start position of the camera in the scene
  50857. * @param scene Define the scene the camera belongs to
  50858. */
  50859. constructor(name: string, position: Vector3, scene: Scene);
  50860. /**
  50861. * Gets the current object class name.
  50862. * @return the class name
  50863. */
  50864. getClassName(): string;
  50865. }
  50866. }
  50867. declare module "babylonjs/Shaders/pass.fragment" {
  50868. /** @hidden */
  50869. export var passPixelShader: {
  50870. name: string;
  50871. shader: string;
  50872. };
  50873. }
  50874. declare module "babylonjs/Shaders/passCube.fragment" {
  50875. /** @hidden */
  50876. export var passCubePixelShader: {
  50877. name: string;
  50878. shader: string;
  50879. };
  50880. }
  50881. declare module "babylonjs/PostProcesses/passPostProcess" {
  50882. import { Nullable } from "babylonjs/types";
  50883. import { Camera } from "babylonjs/Cameras/camera";
  50884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50885. import { Engine } from "babylonjs/Engines/engine";
  50886. import "babylonjs/Shaders/pass.fragment";
  50887. import "babylonjs/Shaders/passCube.fragment";
  50888. import { Scene } from "babylonjs/scene";
  50889. /**
  50890. * PassPostProcess which produces an output the same as it's input
  50891. */
  50892. export class PassPostProcess extends PostProcess {
  50893. /**
  50894. * Gets a string identifying the name of the class
  50895. * @returns "PassPostProcess" string
  50896. */
  50897. getClassName(): string;
  50898. /**
  50899. * Creates the PassPostProcess
  50900. * @param name The name of the effect.
  50901. * @param options The required width/height ratio to downsize to before computing the render pass.
  50902. * @param camera The camera to apply the render pass to.
  50903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50904. * @param engine The engine which the post process will be applied. (default: current engine)
  50905. * @param reusable If the post process can be reused on the same frame. (default: false)
  50906. * @param textureType The type of texture to be used when performing the post processing.
  50907. * @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)
  50908. */
  50909. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50910. /** @hidden */
  50911. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50912. }
  50913. /**
  50914. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50915. */
  50916. export class PassCubePostProcess extends PostProcess {
  50917. private _face;
  50918. /**
  50919. * Gets or sets the cube face to display.
  50920. * * 0 is +X
  50921. * * 1 is -X
  50922. * * 2 is +Y
  50923. * * 3 is -Y
  50924. * * 4 is +Z
  50925. * * 5 is -Z
  50926. */
  50927. get face(): number;
  50928. set face(value: number);
  50929. /**
  50930. * Gets a string identifying the name of the class
  50931. * @returns "PassCubePostProcess" string
  50932. */
  50933. getClassName(): string;
  50934. /**
  50935. * Creates the PassCubePostProcess
  50936. * @param name The name of the effect.
  50937. * @param options The required width/height ratio to downsize to before computing the render pass.
  50938. * @param camera The camera to apply the render pass to.
  50939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50940. * @param engine The engine which the post process will be applied. (default: current engine)
  50941. * @param reusable If the post process can be reused on the same frame. (default: false)
  50942. * @param textureType The type of texture to be used when performing the post processing.
  50943. * @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)
  50944. */
  50945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50946. /** @hidden */
  50947. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  50948. }
  50949. }
  50950. declare module "babylonjs/Shaders/anaglyph.fragment" {
  50951. /** @hidden */
  50952. export var anaglyphPixelShader: {
  50953. name: string;
  50954. shader: string;
  50955. };
  50956. }
  50957. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  50958. import { Engine } from "babylonjs/Engines/engine";
  50959. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50960. import { Camera } from "babylonjs/Cameras/camera";
  50961. import "babylonjs/Shaders/anaglyph.fragment";
  50962. /**
  50963. * Postprocess used to generate anaglyphic rendering
  50964. */
  50965. export class AnaglyphPostProcess extends PostProcess {
  50966. private _passedProcess;
  50967. /**
  50968. * Gets a string identifying the name of the class
  50969. * @returns "AnaglyphPostProcess" string
  50970. */
  50971. getClassName(): string;
  50972. /**
  50973. * Creates a new AnaglyphPostProcess
  50974. * @param name defines postprocess name
  50975. * @param options defines creation options or target ratio scale
  50976. * @param rigCameras defines cameras using this postprocess
  50977. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  50978. * @param engine defines hosting engine
  50979. * @param reusable defines if the postprocess will be reused multiple times per frame
  50980. */
  50981. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  50982. }
  50983. }
  50984. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  50985. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  50986. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50987. import { Scene } from "babylonjs/scene";
  50988. import { Vector3 } from "babylonjs/Maths/math.vector";
  50989. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50990. /**
  50991. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  50992. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  50993. */
  50994. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  50995. /**
  50996. * Creates a new AnaglyphArcRotateCamera
  50997. * @param name defines camera name
  50998. * @param alpha defines alpha angle (in radians)
  50999. * @param beta defines beta angle (in radians)
  51000. * @param radius defines radius
  51001. * @param target defines camera target
  51002. * @param interaxialDistance defines distance between each color axis
  51003. * @param scene defines the hosting scene
  51004. */
  51005. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51006. /**
  51007. * Gets camera class name
  51008. * @returns AnaglyphArcRotateCamera
  51009. */
  51010. getClassName(): string;
  51011. }
  51012. }
  51013. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51014. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51015. import { Scene } from "babylonjs/scene";
  51016. import { Vector3 } from "babylonjs/Maths/math.vector";
  51017. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51018. /**
  51019. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51020. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51021. */
  51022. export class AnaglyphFreeCamera extends FreeCamera {
  51023. /**
  51024. * Creates a new AnaglyphFreeCamera
  51025. * @param name defines camera name
  51026. * @param position defines initial position
  51027. * @param interaxialDistance defines distance between each color axis
  51028. * @param scene defines the hosting scene
  51029. */
  51030. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51031. /**
  51032. * Gets camera class name
  51033. * @returns AnaglyphFreeCamera
  51034. */
  51035. getClassName(): string;
  51036. }
  51037. }
  51038. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51039. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51040. import { Scene } from "babylonjs/scene";
  51041. import { Vector3 } from "babylonjs/Maths/math.vector";
  51042. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51043. /**
  51044. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51045. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51046. */
  51047. export class AnaglyphGamepadCamera extends GamepadCamera {
  51048. /**
  51049. * Creates a new AnaglyphGamepadCamera
  51050. * @param name defines camera name
  51051. * @param position defines initial position
  51052. * @param interaxialDistance defines distance between each color axis
  51053. * @param scene defines the hosting scene
  51054. */
  51055. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51056. /**
  51057. * Gets camera class name
  51058. * @returns AnaglyphGamepadCamera
  51059. */
  51060. getClassName(): string;
  51061. }
  51062. }
  51063. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51064. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51065. import { Scene } from "babylonjs/scene";
  51066. import { Vector3 } from "babylonjs/Maths/math.vector";
  51067. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51068. /**
  51069. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51070. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51071. */
  51072. export class AnaglyphUniversalCamera extends UniversalCamera {
  51073. /**
  51074. * Creates a new AnaglyphUniversalCamera
  51075. * @param name defines camera name
  51076. * @param position defines initial position
  51077. * @param interaxialDistance defines distance between each color axis
  51078. * @param scene defines the hosting scene
  51079. */
  51080. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51081. /**
  51082. * Gets camera class name
  51083. * @returns AnaglyphUniversalCamera
  51084. */
  51085. getClassName(): string;
  51086. }
  51087. }
  51088. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51089. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51090. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51091. import { Scene } from "babylonjs/scene";
  51092. import { Vector3 } from "babylonjs/Maths/math.vector";
  51093. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51094. /**
  51095. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51096. * @see https://doc.babylonjs.com/features/cameras
  51097. */
  51098. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51099. /**
  51100. * Creates a new StereoscopicArcRotateCamera
  51101. * @param name defines camera name
  51102. * @param alpha defines alpha angle (in radians)
  51103. * @param beta defines beta angle (in radians)
  51104. * @param radius defines radius
  51105. * @param target defines camera target
  51106. * @param interaxialDistance defines distance between each color axis
  51107. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51108. * @param scene defines the hosting scene
  51109. */
  51110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51111. /**
  51112. * Gets camera class name
  51113. * @returns StereoscopicArcRotateCamera
  51114. */
  51115. getClassName(): string;
  51116. }
  51117. }
  51118. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51120. import { Scene } from "babylonjs/scene";
  51121. import { Vector3 } from "babylonjs/Maths/math.vector";
  51122. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51123. /**
  51124. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51125. * @see https://doc.babylonjs.com/features/cameras
  51126. */
  51127. export class StereoscopicFreeCamera extends FreeCamera {
  51128. /**
  51129. * Creates a new StereoscopicFreeCamera
  51130. * @param name defines camera name
  51131. * @param position defines initial position
  51132. * @param interaxialDistance defines distance between each color axis
  51133. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51134. * @param scene defines the hosting scene
  51135. */
  51136. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51137. /**
  51138. * Gets camera class name
  51139. * @returns StereoscopicFreeCamera
  51140. */
  51141. getClassName(): string;
  51142. }
  51143. }
  51144. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51145. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51146. import { Scene } from "babylonjs/scene";
  51147. import { Vector3 } from "babylonjs/Maths/math.vector";
  51148. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51149. /**
  51150. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51151. * @see https://doc.babylonjs.com/features/cameras
  51152. */
  51153. export class StereoscopicGamepadCamera extends GamepadCamera {
  51154. /**
  51155. * Creates a new StereoscopicGamepadCamera
  51156. * @param name defines camera name
  51157. * @param position defines initial position
  51158. * @param interaxialDistance defines distance between each color axis
  51159. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51160. * @param scene defines the hosting scene
  51161. */
  51162. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51163. /**
  51164. * Gets camera class name
  51165. * @returns StereoscopicGamepadCamera
  51166. */
  51167. getClassName(): string;
  51168. }
  51169. }
  51170. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51171. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51172. import { Scene } from "babylonjs/scene";
  51173. import { Vector3 } from "babylonjs/Maths/math.vector";
  51174. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51175. /**
  51176. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51177. * @see https://doc.babylonjs.com/features/cameras
  51178. */
  51179. export class StereoscopicUniversalCamera extends UniversalCamera {
  51180. /**
  51181. * Creates a new StereoscopicUniversalCamera
  51182. * @param name defines camera name
  51183. * @param position defines initial position
  51184. * @param interaxialDistance defines distance between each color axis
  51185. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51186. * @param scene defines the hosting scene
  51187. */
  51188. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51189. /**
  51190. * Gets camera class name
  51191. * @returns StereoscopicUniversalCamera
  51192. */
  51193. getClassName(): string;
  51194. }
  51195. }
  51196. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51197. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51198. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51199. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51200. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51201. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51202. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51203. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51204. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51205. }
  51206. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51207. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51208. import { Scene } from "babylonjs/scene";
  51209. import { Vector3 } from "babylonjs/Maths/math.vector";
  51210. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51211. /**
  51212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51213. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51214. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51215. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51216. */
  51217. export class VirtualJoysticksCamera extends FreeCamera {
  51218. /**
  51219. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51220. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51221. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51222. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51223. * @param name Define the name of the camera in the scene
  51224. * @param position Define the start position of the camera in the scene
  51225. * @param scene Define the scene the camera belongs to
  51226. */
  51227. constructor(name: string, position: Vector3, scene: Scene);
  51228. /**
  51229. * Gets the current object class name.
  51230. * @return the class name
  51231. */
  51232. getClassName(): string;
  51233. }
  51234. }
  51235. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51236. import { Matrix } from "babylonjs/Maths/math.vector";
  51237. /**
  51238. * This represents all the required metrics to create a VR camera.
  51239. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51240. */
  51241. export class VRCameraMetrics {
  51242. /**
  51243. * Define the horizontal resolution off the screen.
  51244. */
  51245. hResolution: number;
  51246. /**
  51247. * Define the vertical resolution off the screen.
  51248. */
  51249. vResolution: number;
  51250. /**
  51251. * Define the horizontal screen size.
  51252. */
  51253. hScreenSize: number;
  51254. /**
  51255. * Define the vertical screen size.
  51256. */
  51257. vScreenSize: number;
  51258. /**
  51259. * Define the vertical screen center position.
  51260. */
  51261. vScreenCenter: number;
  51262. /**
  51263. * Define the distance of the eyes to the screen.
  51264. */
  51265. eyeToScreenDistance: number;
  51266. /**
  51267. * Define the distance between both lenses
  51268. */
  51269. lensSeparationDistance: number;
  51270. /**
  51271. * Define the distance between both viewer's eyes.
  51272. */
  51273. interpupillaryDistance: number;
  51274. /**
  51275. * Define the distortion factor of the VR postprocess.
  51276. * Please, touch with care.
  51277. */
  51278. distortionK: number[];
  51279. /**
  51280. * Define the chromatic aberration correction factors for the VR post process.
  51281. */
  51282. chromaAbCorrection: number[];
  51283. /**
  51284. * Define the scale factor of the post process.
  51285. * The smaller the better but the slower.
  51286. */
  51287. postProcessScaleFactor: number;
  51288. /**
  51289. * Define an offset for the lens center.
  51290. */
  51291. lensCenterOffset: number;
  51292. /**
  51293. * Define if the current vr camera should compensate the distortion of the lense or not.
  51294. */
  51295. compensateDistortion: boolean;
  51296. /**
  51297. * Defines if multiview should be enabled when rendering (Default: false)
  51298. */
  51299. multiviewEnabled: boolean;
  51300. /**
  51301. * Gets the rendering aspect ratio based on the provided resolutions.
  51302. */
  51303. get aspectRatio(): number;
  51304. /**
  51305. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51306. */
  51307. get aspectRatioFov(): number;
  51308. /**
  51309. * @hidden
  51310. */
  51311. get leftHMatrix(): Matrix;
  51312. /**
  51313. * @hidden
  51314. */
  51315. get rightHMatrix(): Matrix;
  51316. /**
  51317. * @hidden
  51318. */
  51319. get leftPreViewMatrix(): Matrix;
  51320. /**
  51321. * @hidden
  51322. */
  51323. get rightPreViewMatrix(): Matrix;
  51324. /**
  51325. * Get the default VRMetrics based on the most generic setup.
  51326. * @returns the default vr metrics
  51327. */
  51328. static GetDefault(): VRCameraMetrics;
  51329. }
  51330. }
  51331. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51332. /** @hidden */
  51333. export var vrDistortionCorrectionPixelShader: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51339. import { Camera } from "babylonjs/Cameras/camera";
  51340. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51341. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51342. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51343. /**
  51344. * VRDistortionCorrectionPostProcess used for mobile VR
  51345. */
  51346. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51347. private _isRightEye;
  51348. private _distortionFactors;
  51349. private _postProcessScaleFactor;
  51350. private _lensCenterOffset;
  51351. private _scaleIn;
  51352. private _scaleFactor;
  51353. private _lensCenter;
  51354. /**
  51355. * Gets a string identifying the name of the class
  51356. * @returns "VRDistortionCorrectionPostProcess" string
  51357. */
  51358. getClassName(): string;
  51359. /**
  51360. * Initializes the VRDistortionCorrectionPostProcess
  51361. * @param name The name of the effect.
  51362. * @param camera The camera to apply the render pass to.
  51363. * @param isRightEye If this is for the right eye distortion
  51364. * @param vrMetrics All the required metrics for the VR camera
  51365. */
  51366. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51367. }
  51368. }
  51369. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51370. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51371. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51372. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51373. import { Scene } from "babylonjs/scene";
  51374. import { Vector3 } from "babylonjs/Maths/math.vector";
  51375. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51376. import "babylonjs/Cameras/RigModes/vrRigMode";
  51377. /**
  51378. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51379. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51380. */
  51381. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51382. /**
  51383. * Creates a new VRDeviceOrientationArcRotateCamera
  51384. * @param name defines camera name
  51385. * @param alpha defines the camera rotation along the logitudinal axis
  51386. * @param beta defines the camera rotation along the latitudinal axis
  51387. * @param radius defines the camera distance from its target
  51388. * @param target defines the camera target
  51389. * @param scene defines the scene the camera belongs to
  51390. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51391. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51392. */
  51393. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51394. /**
  51395. * Gets camera class name
  51396. * @returns VRDeviceOrientationArcRotateCamera
  51397. */
  51398. getClassName(): string;
  51399. }
  51400. }
  51401. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51402. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51403. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51404. import { Scene } from "babylonjs/scene";
  51405. import { Vector3 } from "babylonjs/Maths/math.vector";
  51406. import "babylonjs/Cameras/RigModes/vrRigMode";
  51407. /**
  51408. * Camera used to simulate VR rendering (based on FreeCamera)
  51409. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51410. */
  51411. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51412. /**
  51413. * Creates a new VRDeviceOrientationFreeCamera
  51414. * @param name defines camera name
  51415. * @param position defines the start position of the camera
  51416. * @param scene defines the scene the camera belongs to
  51417. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51418. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51419. */
  51420. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51421. /**
  51422. * Gets camera class name
  51423. * @returns VRDeviceOrientationFreeCamera
  51424. */
  51425. getClassName(): string;
  51426. }
  51427. }
  51428. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51429. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51430. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51431. import { Scene } from "babylonjs/scene";
  51432. import { Vector3 } from "babylonjs/Maths/math.vector";
  51433. import "babylonjs/Gamepads/gamepadSceneComponent";
  51434. /**
  51435. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51436. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51437. */
  51438. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51439. /**
  51440. * Creates a new VRDeviceOrientationGamepadCamera
  51441. * @param name defines camera name
  51442. * @param position defines the start position of the camera
  51443. * @param scene defines the scene the camera belongs to
  51444. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51445. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51446. */
  51447. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51448. /**
  51449. * Gets camera class name
  51450. * @returns VRDeviceOrientationGamepadCamera
  51451. */
  51452. getClassName(): string;
  51453. }
  51454. }
  51455. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51456. import { Scene } from "babylonjs/scene";
  51457. import { Texture } from "babylonjs/Materials/Textures/texture";
  51458. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51459. /**
  51460. * A class extending Texture allowing drawing on a texture
  51461. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51462. */
  51463. export class DynamicTexture extends Texture {
  51464. private _generateMipMaps;
  51465. private _canvas;
  51466. private _context;
  51467. /**
  51468. * Creates a DynamicTexture
  51469. * @param name defines the name of the texture
  51470. * @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
  51471. * @param scene defines the scene where you want the texture
  51472. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51473. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51474. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51475. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51476. */
  51477. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51478. /**
  51479. * Get the current class name of the texture useful for serialization or dynamic coding.
  51480. * @returns "DynamicTexture"
  51481. */
  51482. getClassName(): string;
  51483. /**
  51484. * Gets the current state of canRescale
  51485. */
  51486. get canRescale(): boolean;
  51487. private _recreate;
  51488. /**
  51489. * Scales the texture
  51490. * @param ratio the scale factor to apply to both width and height
  51491. */
  51492. scale(ratio: number): void;
  51493. /**
  51494. * Resizes the texture
  51495. * @param width the new width
  51496. * @param height the new height
  51497. */
  51498. scaleTo(width: number, height: number): void;
  51499. /**
  51500. * Gets the context of the canvas used by the texture
  51501. * @returns the canvas context of the dynamic texture
  51502. */
  51503. getContext(): CanvasRenderingContext2D;
  51504. /**
  51505. * Clears the texture
  51506. */
  51507. clear(): void;
  51508. /**
  51509. * Updates the texture
  51510. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51511. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51512. */
  51513. update(invertY?: boolean, premulAlpha?: boolean): void;
  51514. /**
  51515. * Draws text onto the texture
  51516. * @param text defines the text to be drawn
  51517. * @param x defines the placement of the text from the left
  51518. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51519. * @param font defines the font to be used with font-style, font-size, font-name
  51520. * @param color defines the color used for the text
  51521. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51522. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51523. * @param update defines whether texture is immediately update (default is true)
  51524. */
  51525. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51526. /**
  51527. * Clones the texture
  51528. * @returns the clone of the texture.
  51529. */
  51530. clone(): DynamicTexture;
  51531. /**
  51532. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51533. * @returns a serialized dynamic texture object
  51534. */
  51535. serialize(): any;
  51536. private _IsCanvasElement;
  51537. /** @hidden */
  51538. _rebuild(): void;
  51539. }
  51540. }
  51541. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51542. import { Scene } from "babylonjs/scene";
  51543. import { Color3 } from "babylonjs/Maths/math.color";
  51544. import { Mesh } from "babylonjs/Meshes/mesh";
  51545. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51546. import { Nullable } from "babylonjs/types";
  51547. /**
  51548. * Class containing static functions to help procedurally build meshes
  51549. */
  51550. export class GroundBuilder {
  51551. /**
  51552. * Creates a ground mesh
  51553. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51554. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51556. * @param name defines the name of the mesh
  51557. * @param options defines the options used to create the mesh
  51558. * @param scene defines the hosting scene
  51559. * @returns the ground mesh
  51560. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51561. */
  51562. static CreateGround(name: string, options: {
  51563. width?: number;
  51564. height?: number;
  51565. subdivisions?: number;
  51566. subdivisionsX?: number;
  51567. subdivisionsY?: number;
  51568. updatable?: boolean;
  51569. }, scene: any): Mesh;
  51570. /**
  51571. * Creates a tiled ground mesh
  51572. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51573. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51574. * * 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
  51575. * * 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
  51576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51577. * @param name defines the name of the mesh
  51578. * @param options defines the options used to create the mesh
  51579. * @param scene defines the hosting scene
  51580. * @returns the tiled ground mesh
  51581. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51582. */
  51583. static CreateTiledGround(name: string, options: {
  51584. xmin: number;
  51585. zmin: number;
  51586. xmax: number;
  51587. zmax: number;
  51588. subdivisions?: {
  51589. w: number;
  51590. h: number;
  51591. };
  51592. precision?: {
  51593. w: number;
  51594. h: number;
  51595. };
  51596. updatable?: boolean;
  51597. }, scene?: Nullable<Scene>): Mesh;
  51598. /**
  51599. * Creates a ground mesh from a height map
  51600. * * The parameter `url` sets the URL of the height map image resource.
  51601. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51602. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51603. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51604. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51605. * * 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.
  51606. * * 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).
  51607. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51609. * @param name defines the name of the mesh
  51610. * @param url defines the url to the height map
  51611. * @param options defines the options used to create the mesh
  51612. * @param scene defines the hosting scene
  51613. * @returns the ground mesh
  51614. * @see https://doc.babylonjs.com/babylon101/height_map
  51615. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51616. */
  51617. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51618. width?: number;
  51619. height?: number;
  51620. subdivisions?: number;
  51621. minHeight?: number;
  51622. maxHeight?: number;
  51623. colorFilter?: Color3;
  51624. alphaFilter?: number;
  51625. updatable?: boolean;
  51626. onReady?: (mesh: GroundMesh) => void;
  51627. }, scene?: Nullable<Scene>): GroundMesh;
  51628. }
  51629. }
  51630. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51631. import { Vector4 } from "babylonjs/Maths/math.vector";
  51632. import { Mesh } from "babylonjs/Meshes/mesh";
  51633. /**
  51634. * Class containing static functions to help procedurally build meshes
  51635. */
  51636. export class TorusBuilder {
  51637. /**
  51638. * Creates a torus mesh
  51639. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51640. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51641. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51645. * @param name defines the name of the mesh
  51646. * @param options defines the options used to create the mesh
  51647. * @param scene defines the hosting scene
  51648. * @returns the torus mesh
  51649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51650. */
  51651. static CreateTorus(name: string, options: {
  51652. diameter?: number;
  51653. thickness?: number;
  51654. tessellation?: number;
  51655. updatable?: boolean;
  51656. sideOrientation?: number;
  51657. frontUVs?: Vector4;
  51658. backUVs?: Vector4;
  51659. }, scene: any): Mesh;
  51660. }
  51661. }
  51662. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51663. import { Vector4 } from "babylonjs/Maths/math.vector";
  51664. import { Color4 } from "babylonjs/Maths/math.color";
  51665. import { Mesh } from "babylonjs/Meshes/mesh";
  51666. /**
  51667. * Class containing static functions to help procedurally build meshes
  51668. */
  51669. export class CylinderBuilder {
  51670. /**
  51671. * Creates a cylinder or a cone mesh
  51672. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51673. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51674. * * 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.
  51675. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51676. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51677. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51678. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51679. * * 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).
  51680. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51681. * * 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).
  51682. * * 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
  51683. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51684. * * 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
  51685. * * 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.
  51686. * * If `enclose` is false, a ring surface is one element.
  51687. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51688. * * 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
  51689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51692. * @param name defines the name of the mesh
  51693. * @param options defines the options used to create the mesh
  51694. * @param scene defines the hosting scene
  51695. * @returns the cylinder mesh
  51696. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51697. */
  51698. static CreateCylinder(name: string, options: {
  51699. height?: number;
  51700. diameterTop?: number;
  51701. diameterBottom?: number;
  51702. diameter?: number;
  51703. tessellation?: number;
  51704. subdivisions?: number;
  51705. arc?: number;
  51706. faceColors?: Color4[];
  51707. faceUV?: Vector4[];
  51708. updatable?: boolean;
  51709. hasRings?: boolean;
  51710. enclose?: boolean;
  51711. cap?: number;
  51712. sideOrientation?: number;
  51713. frontUVs?: Vector4;
  51714. backUVs?: Vector4;
  51715. }, scene: any): Mesh;
  51716. }
  51717. }
  51718. declare module "babylonjs/XR/webXRTypes" {
  51719. import { Nullable } from "babylonjs/types";
  51720. import { IDisposable } from "babylonjs/scene";
  51721. /**
  51722. * States of the webXR experience
  51723. */
  51724. export enum WebXRState {
  51725. /**
  51726. * Transitioning to being in XR mode
  51727. */
  51728. ENTERING_XR = 0,
  51729. /**
  51730. * Transitioning to non XR mode
  51731. */
  51732. EXITING_XR = 1,
  51733. /**
  51734. * In XR mode and presenting
  51735. */
  51736. IN_XR = 2,
  51737. /**
  51738. * Not entered XR mode
  51739. */
  51740. NOT_IN_XR = 3
  51741. }
  51742. /**
  51743. * Abstraction of the XR render target
  51744. */
  51745. export interface WebXRRenderTarget extends IDisposable {
  51746. /**
  51747. * xrpresent context of the canvas which can be used to display/mirror xr content
  51748. */
  51749. canvasContext: WebGLRenderingContext;
  51750. /**
  51751. * xr layer for the canvas
  51752. */
  51753. xrLayer: Nullable<XRWebGLLayer>;
  51754. /**
  51755. * Initializes the xr layer for the session
  51756. * @param xrSession xr session
  51757. * @returns a promise that will resolve once the XR Layer has been created
  51758. */
  51759. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51760. }
  51761. }
  51762. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51763. import { Nullable } from "babylonjs/types";
  51764. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51765. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51766. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51767. import { Observable } from "babylonjs/Misc/observable";
  51768. /**
  51769. * COnfiguration object for WebXR output canvas
  51770. */
  51771. export class WebXRManagedOutputCanvasOptions {
  51772. /**
  51773. * An optional canvas in case you wish to create it yourself and provide it here.
  51774. * If not provided, a new canvas will be created
  51775. */
  51776. canvasElement?: HTMLCanvasElement;
  51777. /**
  51778. * Options for this XR Layer output
  51779. */
  51780. canvasOptions?: XRWebGLLayerOptions;
  51781. /**
  51782. * CSS styling for a newly created canvas (if not provided)
  51783. */
  51784. newCanvasCssStyle?: string;
  51785. /**
  51786. * Get the default values of the configuration object
  51787. * @param engine defines the engine to use (can be null)
  51788. * @returns default values of this configuration object
  51789. */
  51790. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51791. }
  51792. /**
  51793. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51794. */
  51795. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51796. private _options;
  51797. private _canvas;
  51798. private _engine;
  51799. private _originalCanvasSize;
  51800. /**
  51801. * Rendering context of the canvas which can be used to display/mirror xr content
  51802. */
  51803. canvasContext: WebGLRenderingContext;
  51804. /**
  51805. * xr layer for the canvas
  51806. */
  51807. xrLayer: Nullable<XRWebGLLayer>;
  51808. /**
  51809. * Obseervers registered here will be triggered when the xr layer was initialized
  51810. */
  51811. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51812. /**
  51813. * Initializes the canvas to be added/removed upon entering/exiting xr
  51814. * @param _xrSessionManager The XR Session manager
  51815. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51816. */
  51817. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51818. /**
  51819. * Disposes of the object
  51820. */
  51821. dispose(): void;
  51822. /**
  51823. * Initializes the xr layer for the session
  51824. * @param xrSession xr session
  51825. * @returns a promise that will resolve once the XR Layer has been created
  51826. */
  51827. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51828. private _addCanvas;
  51829. private _removeCanvas;
  51830. private _setCanvasSize;
  51831. private _setManagedOutputCanvas;
  51832. }
  51833. }
  51834. declare module "babylonjs/XR/webXRSessionManager" {
  51835. import { Observable } from "babylonjs/Misc/observable";
  51836. import { Nullable } from "babylonjs/types";
  51837. import { IDisposable, Scene } from "babylonjs/scene";
  51838. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51839. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51840. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51841. /**
  51842. * Manages an XRSession to work with Babylon's engine
  51843. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51844. */
  51845. export class WebXRSessionManager implements IDisposable {
  51846. /** The scene which the session should be created for */
  51847. scene: Scene;
  51848. private _referenceSpace;
  51849. private _rttProvider;
  51850. private _sessionEnded;
  51851. private _xrNavigator;
  51852. private baseLayer;
  51853. /**
  51854. * The base reference space from which the session started. good if you want to reset your
  51855. * reference space
  51856. */
  51857. baseReferenceSpace: XRReferenceSpace;
  51858. /**
  51859. * Current XR frame
  51860. */
  51861. currentFrame: Nullable<XRFrame>;
  51862. /** WebXR timestamp updated every frame */
  51863. currentTimestamp: number;
  51864. /**
  51865. * Used just in case of a failure to initialize an immersive session.
  51866. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51867. */
  51868. defaultHeightCompensation: number;
  51869. /**
  51870. * Fires every time a new xrFrame arrives which can be used to update the camera
  51871. */
  51872. onXRFrameObservable: Observable<XRFrame>;
  51873. /**
  51874. * Fires when the reference space changed
  51875. */
  51876. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51877. /**
  51878. * Fires when the xr session is ended either by the device or manually done
  51879. */
  51880. onXRSessionEnded: Observable<any>;
  51881. /**
  51882. * Fires when the xr session is ended either by the device or manually done
  51883. */
  51884. onXRSessionInit: Observable<XRSession>;
  51885. /**
  51886. * Underlying xr session
  51887. */
  51888. session: XRSession;
  51889. /**
  51890. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51891. * or get the offset the player is currently at.
  51892. */
  51893. viewerReferenceSpace: XRReferenceSpace;
  51894. /**
  51895. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51896. * @param scene The scene which the session should be created for
  51897. */
  51898. constructor(
  51899. /** The scene which the session should be created for */
  51900. scene: Scene);
  51901. /**
  51902. * The current reference space used in this session. This reference space can constantly change!
  51903. * It is mainly used to offset the camera's position.
  51904. */
  51905. get referenceSpace(): XRReferenceSpace;
  51906. /**
  51907. * Set a new reference space and triggers the observable
  51908. */
  51909. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  51910. /**
  51911. * Disposes of the session manager
  51912. */
  51913. dispose(): void;
  51914. /**
  51915. * Stops the xrSession and restores the render loop
  51916. * @returns Promise which resolves after it exits XR
  51917. */
  51918. exitXRAsync(): Promise<void>;
  51919. /**
  51920. * Gets the correct render target texture to be rendered this frame for this eye
  51921. * @param eye the eye for which to get the render target
  51922. * @returns the render target for the specified eye
  51923. */
  51924. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  51925. /**
  51926. * Creates a WebXRRenderTarget object for the XR session
  51927. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  51928. * @param options optional options to provide when creating a new render target
  51929. * @returns a WebXR render target to which the session can render
  51930. */
  51931. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  51932. /**
  51933. * Initializes the manager
  51934. * After initialization enterXR can be called to start an XR session
  51935. * @returns Promise which resolves after it is initialized
  51936. */
  51937. initializeAsync(): Promise<void>;
  51938. /**
  51939. * Initializes an xr session
  51940. * @param xrSessionMode mode to initialize
  51941. * @param xrSessionInit defines optional and required values to pass to the session builder
  51942. * @returns a promise which will resolve once the session has been initialized
  51943. */
  51944. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  51945. /**
  51946. * Checks if a session would be supported for the creation options specified
  51947. * @param sessionMode session mode to check if supported eg. immersive-vr
  51948. * @returns A Promise that resolves to true if supported and false if not
  51949. */
  51950. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51951. /**
  51952. * Resets the reference space to the one started the session
  51953. */
  51954. resetReferenceSpace(): void;
  51955. /**
  51956. * Starts rendering to the xr layer
  51957. */
  51958. runXRRenderLoop(): void;
  51959. /**
  51960. * Sets the reference space on the xr session
  51961. * @param referenceSpaceType space to set
  51962. * @returns a promise that will resolve once the reference space has been set
  51963. */
  51964. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  51965. /**
  51966. * Updates the render state of the session
  51967. * @param state state to set
  51968. * @returns a promise that resolves once the render state has been updated
  51969. */
  51970. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  51971. /**
  51972. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  51973. * @param sessionMode defines the session to test
  51974. * @returns a promise with boolean as final value
  51975. */
  51976. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  51977. private _createRenderTargetTexture;
  51978. }
  51979. }
  51980. declare module "babylonjs/XR/webXRCamera" {
  51981. import { Vector3 } from "babylonjs/Maths/math.vector";
  51982. import { Scene } from "babylonjs/scene";
  51983. import { Camera } from "babylonjs/Cameras/camera";
  51984. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51985. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51986. import { Observable } from "babylonjs/Misc/observable";
  51987. /**
  51988. * WebXR Camera which holds the views for the xrSession
  51989. * @see https://doc.babylonjs.com/how_to/webxr_camera
  51990. */
  51991. export class WebXRCamera extends FreeCamera {
  51992. private _xrSessionManager;
  51993. private _firstFrame;
  51994. private _referenceQuaternion;
  51995. private _referencedPosition;
  51996. private _xrInvPositionCache;
  51997. private _xrInvQuaternionCache;
  51998. /**
  51999. * Observable raised before camera teleportation
  52000. */
  52001. onBeforeCameraTeleport: Observable<Vector3>;
  52002. /**
  52003. * Observable raised after camera teleportation
  52004. */
  52005. onAfterCameraTeleport: Observable<Vector3>;
  52006. /**
  52007. * Should position compensation execute on first frame.
  52008. * This is used when copying the position from a native (non XR) camera
  52009. */
  52010. compensateOnFirstFrame: boolean;
  52011. /**
  52012. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52013. * @param name the name of the camera
  52014. * @param scene the scene to add the camera to
  52015. * @param _xrSessionManager a constructed xr session manager
  52016. */
  52017. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52018. /**
  52019. * Return the user's height, unrelated to the current ground.
  52020. * This will be the y position of this camera, when ground level is 0.
  52021. */
  52022. get realWorldHeight(): number;
  52023. /** @hidden */
  52024. _updateForDualEyeDebugging(): void;
  52025. /**
  52026. * Sets this camera's transformation based on a non-vr camera
  52027. * @param otherCamera the non-vr camera to copy the transformation from
  52028. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52029. */
  52030. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52031. /**
  52032. * Gets the current instance class name ("WebXRCamera").
  52033. * @returns the class name
  52034. */
  52035. getClassName(): string;
  52036. private _rotate180;
  52037. private _updateFromXRSession;
  52038. private _updateNumberOfRigCameras;
  52039. private _updateReferenceSpace;
  52040. private _updateReferenceSpaceOffset;
  52041. }
  52042. }
  52043. declare module "babylonjs/XR/webXRFeaturesManager" {
  52044. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52045. import { IDisposable } from "babylonjs/scene";
  52046. /**
  52047. * Defining the interface required for a (webxr) feature
  52048. */
  52049. export interface IWebXRFeature extends IDisposable {
  52050. /**
  52051. * Is this feature attached
  52052. */
  52053. attached: boolean;
  52054. /**
  52055. * Should auto-attach be disabled?
  52056. */
  52057. disableAutoAttach: boolean;
  52058. /**
  52059. * Attach the feature to the session
  52060. * Will usually be called by the features manager
  52061. *
  52062. * @param force should attachment be forced (even when already attached)
  52063. * @returns true if successful.
  52064. */
  52065. attach(force?: boolean): boolean;
  52066. /**
  52067. * Detach the feature from the session
  52068. * Will usually be called by the features manager
  52069. *
  52070. * @returns true if successful.
  52071. */
  52072. detach(): boolean;
  52073. /**
  52074. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52075. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52076. *
  52077. * @returns whether or not the feature is compatible in this environment
  52078. */
  52079. isCompatible(): boolean;
  52080. /**
  52081. * Was this feature disposed;
  52082. */
  52083. isDisposed: boolean;
  52084. /**
  52085. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52086. */
  52087. xrNativeFeatureName?: string;
  52088. /**
  52089. * A list of (Babylon WebXR) features this feature depends on
  52090. */
  52091. dependsOn?: string[];
  52092. }
  52093. /**
  52094. * A list of the currently available features without referencing them
  52095. */
  52096. export class WebXRFeatureName {
  52097. /**
  52098. * The name of the anchor system feature
  52099. */
  52100. static readonly ANCHOR_SYSTEM: string;
  52101. /**
  52102. * The name of the background remover feature
  52103. */
  52104. static readonly BACKGROUND_REMOVER: string;
  52105. /**
  52106. * The name of the hit test feature
  52107. */
  52108. static readonly HIT_TEST: string;
  52109. /**
  52110. * physics impostors for xr controllers feature
  52111. */
  52112. static readonly PHYSICS_CONTROLLERS: string;
  52113. /**
  52114. * The name of the plane detection feature
  52115. */
  52116. static readonly PLANE_DETECTION: string;
  52117. /**
  52118. * The name of the pointer selection feature
  52119. */
  52120. static readonly POINTER_SELECTION: string;
  52121. /**
  52122. * The name of the teleportation feature
  52123. */
  52124. static readonly TELEPORTATION: string;
  52125. /**
  52126. * The name of the feature points feature.
  52127. */
  52128. static readonly FEATURE_POINTS: string;
  52129. /**
  52130. * The name of the hand tracking feature.
  52131. */
  52132. static readonly HAND_TRACKING: string;
  52133. }
  52134. /**
  52135. * Defining the constructor of a feature. Used to register the modules.
  52136. */
  52137. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52138. /**
  52139. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52140. * It is mainly used in AR sessions.
  52141. *
  52142. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52143. */
  52144. export class WebXRFeaturesManager implements IDisposable {
  52145. private _xrSessionManager;
  52146. private static readonly _AvailableFeatures;
  52147. private _features;
  52148. /**
  52149. * constructs a new features manages.
  52150. *
  52151. * @param _xrSessionManager an instance of WebXRSessionManager
  52152. */
  52153. constructor(_xrSessionManager: WebXRSessionManager);
  52154. /**
  52155. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52156. * Mainly used internally.
  52157. *
  52158. * @param featureName the name of the feature to register
  52159. * @param constructorFunction the function used to construct the module
  52160. * @param version the (babylon) version of the module
  52161. * @param stable is that a stable version of this module
  52162. */
  52163. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52164. /**
  52165. * Returns a constructor of a specific feature.
  52166. *
  52167. * @param featureName the name of the feature to construct
  52168. * @param version the version of the feature to load
  52169. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52170. * @param options optional options provided to the module.
  52171. * @returns a function that, when called, will return a new instance of this feature
  52172. */
  52173. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52174. /**
  52175. * Can be used to return the list of features currently registered
  52176. *
  52177. * @returns an Array of available features
  52178. */
  52179. static GetAvailableFeatures(): string[];
  52180. /**
  52181. * Gets the versions available for a specific feature
  52182. * @param featureName the name of the feature
  52183. * @returns an array with the available versions
  52184. */
  52185. static GetAvailableVersions(featureName: string): string[];
  52186. /**
  52187. * Return the latest unstable version of this feature
  52188. * @param featureName the name of the feature to search
  52189. * @returns the version number. if not found will return -1
  52190. */
  52191. static GetLatestVersionOfFeature(featureName: string): number;
  52192. /**
  52193. * Return the latest stable version of this feature
  52194. * @param featureName the name of the feature to search
  52195. * @returns the version number. if not found will return -1
  52196. */
  52197. static GetStableVersionOfFeature(featureName: string): number;
  52198. /**
  52199. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52200. * Can be used during a session to start a feature
  52201. * @param featureName the name of feature to attach
  52202. */
  52203. attachFeature(featureName: string): void;
  52204. /**
  52205. * Can be used inside a session or when the session ends to detach a specific feature
  52206. * @param featureName the name of the feature to detach
  52207. */
  52208. detachFeature(featureName: string): void;
  52209. /**
  52210. * Used to disable an already-enabled feature
  52211. * The feature will be disposed and will be recreated once enabled.
  52212. * @param featureName the feature to disable
  52213. * @returns true if disable was successful
  52214. */
  52215. disableFeature(featureName: string | {
  52216. Name: string;
  52217. }): boolean;
  52218. /**
  52219. * dispose this features manager
  52220. */
  52221. dispose(): void;
  52222. /**
  52223. * 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.
  52224. * 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.
  52225. *
  52226. * @param featureName the name of the feature to load or the class of the feature
  52227. * @param version optional version to load. if not provided the latest version will be enabled
  52228. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52229. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52230. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52231. * @returns a new constructed feature or throws an error if feature not found.
  52232. */
  52233. enableFeature(featureName: string | {
  52234. Name: string;
  52235. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52236. /**
  52237. * get the implementation of an enabled feature.
  52238. * @param featureName the name of the feature to load
  52239. * @returns the feature class, if found
  52240. */
  52241. getEnabledFeature(featureName: string): IWebXRFeature;
  52242. /**
  52243. * Get the list of enabled features
  52244. * @returns an array of enabled features
  52245. */
  52246. getEnabledFeatures(): string[];
  52247. /**
  52248. * This function will exten the session creation configuration object with enabled features.
  52249. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52250. * according to the defined "required" variable, provided during enableFeature call
  52251. * @param xrSessionInit the xr Session init object to extend
  52252. *
  52253. * @returns an extended XRSessionInit object
  52254. */
  52255. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52256. }
  52257. }
  52258. declare module "babylonjs/XR/webXRExperienceHelper" {
  52259. import { Observable } from "babylonjs/Misc/observable";
  52260. import { IDisposable, Scene } from "babylonjs/scene";
  52261. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52262. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52263. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52264. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52265. /**
  52266. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52267. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52268. */
  52269. export class WebXRExperienceHelper implements IDisposable {
  52270. private scene;
  52271. private _nonVRCamera;
  52272. private _originalSceneAutoClear;
  52273. private _supported;
  52274. /**
  52275. * Camera used to render xr content
  52276. */
  52277. camera: WebXRCamera;
  52278. /** A features manager for this xr session */
  52279. featuresManager: WebXRFeaturesManager;
  52280. /**
  52281. * Observers registered here will be triggered after the camera's initial transformation is set
  52282. * This can be used to set a different ground level or an extra rotation.
  52283. *
  52284. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52285. * to the position set after this observable is done executing.
  52286. */
  52287. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52288. /**
  52289. * Fires when the state of the experience helper has changed
  52290. */
  52291. onStateChangedObservable: Observable<WebXRState>;
  52292. /** Session manager used to keep track of xr session */
  52293. sessionManager: WebXRSessionManager;
  52294. /**
  52295. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52296. */
  52297. state: WebXRState;
  52298. /**
  52299. * Creates a WebXRExperienceHelper
  52300. * @param scene The scene the helper should be created in
  52301. */
  52302. private constructor();
  52303. /**
  52304. * Creates the experience helper
  52305. * @param scene the scene to attach the experience helper to
  52306. * @returns a promise for the experience helper
  52307. */
  52308. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52309. /**
  52310. * Disposes of the experience helper
  52311. */
  52312. dispose(): void;
  52313. /**
  52314. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52315. * @param sessionMode options for the XR session
  52316. * @param referenceSpaceType frame of reference of the XR session
  52317. * @param renderTarget the output canvas that will be used to enter XR mode
  52318. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52319. * @returns promise that resolves after xr mode has entered
  52320. */
  52321. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52322. /**
  52323. * Exits XR mode and returns the scene to its original state
  52324. * @returns promise that resolves after xr mode has exited
  52325. */
  52326. exitXRAsync(): Promise<void>;
  52327. private _nonXRToXRCamera;
  52328. private _setState;
  52329. }
  52330. }
  52331. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52332. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52333. import { Observable } from "babylonjs/Misc/observable";
  52334. import { IDisposable } from "babylonjs/scene";
  52335. /**
  52336. * X-Y values for axes in WebXR
  52337. */
  52338. export interface IWebXRMotionControllerAxesValue {
  52339. /**
  52340. * The value of the x axis
  52341. */
  52342. x: number;
  52343. /**
  52344. * The value of the y-axis
  52345. */
  52346. y: number;
  52347. }
  52348. /**
  52349. * changed / previous values for the values of this component
  52350. */
  52351. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52352. /**
  52353. * current (this frame) value
  52354. */
  52355. current: T;
  52356. /**
  52357. * previous (last change) value
  52358. */
  52359. previous: T;
  52360. }
  52361. /**
  52362. * Represents changes in the component between current frame and last values recorded
  52363. */
  52364. export interface IWebXRMotionControllerComponentChanges {
  52365. /**
  52366. * will be populated with previous and current values if axes changed
  52367. */
  52368. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52369. /**
  52370. * will be populated with previous and current values if pressed changed
  52371. */
  52372. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52373. /**
  52374. * will be populated with previous and current values if touched changed
  52375. */
  52376. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52377. /**
  52378. * will be populated with previous and current values if value changed
  52379. */
  52380. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52381. }
  52382. /**
  52383. * This class represents a single component (for example button or thumbstick) of a motion controller
  52384. */
  52385. export class WebXRControllerComponent implements IDisposable {
  52386. /**
  52387. * the id of this component
  52388. */
  52389. id: string;
  52390. /**
  52391. * the type of the component
  52392. */
  52393. type: MotionControllerComponentType;
  52394. private _buttonIndex;
  52395. private _axesIndices;
  52396. private _axes;
  52397. private _changes;
  52398. private _currentValue;
  52399. private _hasChanges;
  52400. private _pressed;
  52401. private _touched;
  52402. /**
  52403. * button component type
  52404. */
  52405. static BUTTON_TYPE: MotionControllerComponentType;
  52406. /**
  52407. * squeeze component type
  52408. */
  52409. static SQUEEZE_TYPE: MotionControllerComponentType;
  52410. /**
  52411. * Thumbstick component type
  52412. */
  52413. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52414. /**
  52415. * Touchpad component type
  52416. */
  52417. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52418. /**
  52419. * trigger component type
  52420. */
  52421. static TRIGGER_TYPE: MotionControllerComponentType;
  52422. /**
  52423. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52424. * the axes data changes
  52425. */
  52426. onAxisValueChangedObservable: Observable<{
  52427. x: number;
  52428. y: number;
  52429. }>;
  52430. /**
  52431. * Observers registered here will be triggered when the state of a button changes
  52432. * State change is either pressed / touched / value
  52433. */
  52434. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52435. /**
  52436. * Creates a new component for a motion controller.
  52437. * It is created by the motion controller itself
  52438. *
  52439. * @param id the id of this component
  52440. * @param type the type of the component
  52441. * @param _buttonIndex index in the buttons array of the gamepad
  52442. * @param _axesIndices indices of the values in the axes array of the gamepad
  52443. */
  52444. constructor(
  52445. /**
  52446. * the id of this component
  52447. */
  52448. id: string,
  52449. /**
  52450. * the type of the component
  52451. */
  52452. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52453. /**
  52454. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52455. */
  52456. get axes(): IWebXRMotionControllerAxesValue;
  52457. /**
  52458. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52459. */
  52460. get changes(): IWebXRMotionControllerComponentChanges;
  52461. /**
  52462. * Return whether or not the component changed the last frame
  52463. */
  52464. get hasChanges(): boolean;
  52465. /**
  52466. * is the button currently pressed
  52467. */
  52468. get pressed(): boolean;
  52469. /**
  52470. * is the button currently touched
  52471. */
  52472. get touched(): boolean;
  52473. /**
  52474. * Get the current value of this component
  52475. */
  52476. get value(): number;
  52477. /**
  52478. * Dispose this component
  52479. */
  52480. dispose(): void;
  52481. /**
  52482. * Are there axes correlating to this component
  52483. * @return true is axes data is available
  52484. */
  52485. isAxes(): boolean;
  52486. /**
  52487. * Is this component a button (hence - pressable)
  52488. * @returns true if can be pressed
  52489. */
  52490. isButton(): boolean;
  52491. /**
  52492. * update this component using the gamepad object it is in. Called on every frame
  52493. * @param nativeController the native gamepad controller object
  52494. */
  52495. update(nativeController: IMinimalMotionControllerObject): void;
  52496. }
  52497. }
  52498. declare module "babylonjs/Loading/sceneLoader" {
  52499. import { Observable } from "babylonjs/Misc/observable";
  52500. import { Nullable } from "babylonjs/types";
  52501. import { Scene } from "babylonjs/scene";
  52502. import { Engine } from "babylonjs/Engines/engine";
  52503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52504. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52505. import { AssetContainer } from "babylonjs/assetContainer";
  52506. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52507. import { Skeleton } from "babylonjs/Bones/skeleton";
  52508. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52509. import { WebRequest } from "babylonjs/Misc/webRequest";
  52510. /**
  52511. * Interface used to represent data loading progression
  52512. */
  52513. export interface ISceneLoaderProgressEvent {
  52514. /**
  52515. * Defines if data length to load can be evaluated
  52516. */
  52517. readonly lengthComputable: boolean;
  52518. /**
  52519. * Defines the loaded data length
  52520. */
  52521. readonly loaded: number;
  52522. /**
  52523. * Defines the data length to load
  52524. */
  52525. readonly total: number;
  52526. }
  52527. /**
  52528. * Interface used by SceneLoader plugins to define supported file extensions
  52529. */
  52530. export interface ISceneLoaderPluginExtensions {
  52531. /**
  52532. * Defines the list of supported extensions
  52533. */
  52534. [extension: string]: {
  52535. isBinary: boolean;
  52536. };
  52537. }
  52538. /**
  52539. * Interface used by SceneLoader plugin factory
  52540. */
  52541. export interface ISceneLoaderPluginFactory {
  52542. /**
  52543. * Defines the name of the factory
  52544. */
  52545. name: string;
  52546. /**
  52547. * Function called to create a new plugin
  52548. * @return the new plugin
  52549. */
  52550. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52551. /**
  52552. * The callback that returns true if the data can be directly loaded.
  52553. * @param data string containing the file data
  52554. * @returns if the data can be loaded directly
  52555. */
  52556. canDirectLoad?(data: string): boolean;
  52557. }
  52558. /**
  52559. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52560. */
  52561. export interface ISceneLoaderPluginBase {
  52562. /**
  52563. * The friendly name of this plugin.
  52564. */
  52565. name: string;
  52566. /**
  52567. * The file extensions supported by this plugin.
  52568. */
  52569. extensions: string | ISceneLoaderPluginExtensions;
  52570. /**
  52571. * The callback called when loading from a url.
  52572. * @param scene scene loading this url
  52573. * @param url url to load
  52574. * @param onSuccess callback called when the file successfully loads
  52575. * @param onProgress callback called while file is loading (if the server supports this mode)
  52576. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52577. * @param onError callback called when the file fails to load
  52578. * @returns a file request object
  52579. */
  52580. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52581. /**
  52582. * The callback called when loading from a file object.
  52583. * @param scene scene loading this file
  52584. * @param file defines the file to load
  52585. * @param onSuccess defines the callback to call when data is loaded
  52586. * @param onProgress defines the callback to call during loading process
  52587. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52588. * @param onError defines the callback to call when an error occurs
  52589. * @returns a file request object
  52590. */
  52591. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52592. /**
  52593. * The callback that returns true if the data can be directly loaded.
  52594. * @param data string containing the file data
  52595. * @returns if the data can be loaded directly
  52596. */
  52597. canDirectLoad?(data: string): boolean;
  52598. /**
  52599. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52600. * @param scene scene loading this data
  52601. * @param data string containing the data
  52602. * @returns data to pass to the plugin
  52603. */
  52604. directLoad?(scene: Scene, data: string): any;
  52605. /**
  52606. * The callback that allows custom handling of the root url based on the response url.
  52607. * @param rootUrl the original root url
  52608. * @param responseURL the response url if available
  52609. * @returns the new root url
  52610. */
  52611. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52612. }
  52613. /**
  52614. * Interface used to define a SceneLoader plugin
  52615. */
  52616. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52617. /**
  52618. * Import meshes into a scene.
  52619. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52620. * @param scene The scene to import into
  52621. * @param data The data to import
  52622. * @param rootUrl The root url for scene and resources
  52623. * @param meshes The meshes array to import into
  52624. * @param particleSystems The particle systems array to import into
  52625. * @param skeletons The skeletons array to import into
  52626. * @param onError The callback when import fails
  52627. * @returns True if successful or false otherwise
  52628. */
  52629. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52630. /**
  52631. * Load into a scene.
  52632. * @param scene The scene to load into
  52633. * @param data The data to import
  52634. * @param rootUrl The root url for scene and resources
  52635. * @param onError The callback when import fails
  52636. * @returns True if successful or false otherwise
  52637. */
  52638. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52639. /**
  52640. * Load into an asset container.
  52641. * @param scene The scene to load into
  52642. * @param data The data to import
  52643. * @param rootUrl The root url for scene and resources
  52644. * @param onError The callback when import fails
  52645. * @returns The loaded asset container
  52646. */
  52647. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52648. }
  52649. /**
  52650. * Interface used to define an async SceneLoader plugin
  52651. */
  52652. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52653. /**
  52654. * Import meshes into a scene.
  52655. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52656. * @param scene The scene to import into
  52657. * @param data The data to import
  52658. * @param rootUrl The root url for scene and resources
  52659. * @param onProgress The callback when the load progresses
  52660. * @param fileName Defines the name of the file to load
  52661. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52662. */
  52663. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52664. meshes: AbstractMesh[];
  52665. particleSystems: IParticleSystem[];
  52666. skeletons: Skeleton[];
  52667. animationGroups: AnimationGroup[];
  52668. }>;
  52669. /**
  52670. * Load into a scene.
  52671. * @param scene The scene to load into
  52672. * @param data The data to import
  52673. * @param rootUrl The root url for scene and resources
  52674. * @param onProgress The callback when the load progresses
  52675. * @param fileName Defines the name of the file to load
  52676. * @returns Nothing
  52677. */
  52678. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52679. /**
  52680. * Load into an asset container.
  52681. * @param scene The scene to load into
  52682. * @param data The data to import
  52683. * @param rootUrl The root url for scene and resources
  52684. * @param onProgress The callback when the load progresses
  52685. * @param fileName Defines the name of the file to load
  52686. * @returns The loaded asset container
  52687. */
  52688. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52689. }
  52690. /**
  52691. * Mode that determines how to handle old animation groups before loading new ones.
  52692. */
  52693. export enum SceneLoaderAnimationGroupLoadingMode {
  52694. /**
  52695. * Reset all old animations to initial state then dispose them.
  52696. */
  52697. Clean = 0,
  52698. /**
  52699. * Stop all old animations.
  52700. */
  52701. Stop = 1,
  52702. /**
  52703. * Restart old animations from first frame.
  52704. */
  52705. Sync = 2,
  52706. /**
  52707. * Old animations remains untouched.
  52708. */
  52709. NoSync = 3
  52710. }
  52711. /**
  52712. * Defines a plugin registered by the SceneLoader
  52713. */
  52714. interface IRegisteredPlugin {
  52715. /**
  52716. * Defines the plugin to use
  52717. */
  52718. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52719. /**
  52720. * Defines if the plugin supports binary data
  52721. */
  52722. isBinary: boolean;
  52723. }
  52724. /**
  52725. * Class used to load scene from various file formats using registered plugins
  52726. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52727. */
  52728. export class SceneLoader {
  52729. /**
  52730. * No logging while loading
  52731. */
  52732. static readonly NO_LOGGING: number;
  52733. /**
  52734. * Minimal logging while loading
  52735. */
  52736. static readonly MINIMAL_LOGGING: number;
  52737. /**
  52738. * Summary logging while loading
  52739. */
  52740. static readonly SUMMARY_LOGGING: number;
  52741. /**
  52742. * Detailled logging while loading
  52743. */
  52744. static readonly DETAILED_LOGGING: number;
  52745. /**
  52746. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52747. */
  52748. static get ForceFullSceneLoadingForIncremental(): boolean;
  52749. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52750. /**
  52751. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52752. */
  52753. static get ShowLoadingScreen(): boolean;
  52754. static set ShowLoadingScreen(value: boolean);
  52755. /**
  52756. * Defines the current logging level (while loading the scene)
  52757. * @ignorenaming
  52758. */
  52759. static get loggingLevel(): number;
  52760. static set loggingLevel(value: number);
  52761. /**
  52762. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52763. */
  52764. static get CleanBoneMatrixWeights(): boolean;
  52765. static set CleanBoneMatrixWeights(value: boolean);
  52766. /**
  52767. * Event raised when a plugin is used to load a scene
  52768. */
  52769. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52770. private static _registeredPlugins;
  52771. private static _showingLoadingScreen;
  52772. /**
  52773. * Gets the default plugin (used to load Babylon files)
  52774. * @returns the .babylon plugin
  52775. */
  52776. static GetDefaultPlugin(): IRegisteredPlugin;
  52777. private static _GetPluginForExtension;
  52778. private static _GetPluginForDirectLoad;
  52779. private static _GetPluginForFilename;
  52780. private static _GetDirectLoad;
  52781. private static _LoadData;
  52782. private static _GetFileInfo;
  52783. /**
  52784. * Gets a plugin that can load the given extension
  52785. * @param extension defines the extension to load
  52786. * @returns a plugin or null if none works
  52787. */
  52788. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52789. /**
  52790. * Gets a boolean indicating that the given extension can be loaded
  52791. * @param extension defines the extension to load
  52792. * @returns true if the extension is supported
  52793. */
  52794. static IsPluginForExtensionAvailable(extension: string): boolean;
  52795. /**
  52796. * Adds a new plugin to the list of registered plugins
  52797. * @param plugin defines the plugin to add
  52798. */
  52799. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52800. /**
  52801. * Import meshes into a scene
  52802. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52803. * @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)
  52804. * @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)
  52805. * @param scene the instance of BABYLON.Scene to append to
  52806. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52807. * @param onProgress a callback with a progress event for each file being loaded
  52808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52809. * @param pluginExtension the extension used to determine the plugin
  52810. * @returns The loaded plugin
  52811. */
  52812. 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>;
  52813. /**
  52814. * Import meshes into a scene
  52815. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52816. * @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)
  52817. * @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)
  52818. * @param scene the instance of BABYLON.Scene to append to
  52819. * @param onProgress a callback with a progress event for each file being loaded
  52820. * @param pluginExtension the extension used to determine the plugin
  52821. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52822. */
  52823. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52824. meshes: AbstractMesh[];
  52825. particleSystems: IParticleSystem[];
  52826. skeletons: Skeleton[];
  52827. animationGroups: AnimationGroup[];
  52828. }>;
  52829. /**
  52830. * Load a scene
  52831. * @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)
  52832. * @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)
  52833. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52834. * @param onSuccess a callback with the scene when import succeeds
  52835. * @param onProgress a callback with a progress event for each file being loaded
  52836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52837. * @param pluginExtension the extension used to determine the plugin
  52838. * @returns The loaded plugin
  52839. */
  52840. 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>;
  52841. /**
  52842. * Load a scene
  52843. * @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)
  52844. * @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)
  52845. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52846. * @param onProgress a callback with a progress event for each file being loaded
  52847. * @param pluginExtension the extension used to determine the plugin
  52848. * @returns The loaded scene
  52849. */
  52850. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52851. /**
  52852. * Append a scene
  52853. * @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)
  52854. * @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)
  52855. * @param scene is the instance of BABYLON.Scene to append to
  52856. * @param onSuccess a callback with the scene when import succeeds
  52857. * @param onProgress a callback with a progress event for each file being loaded
  52858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52859. * @param pluginExtension the extension used to determine the plugin
  52860. * @returns The loaded plugin
  52861. */
  52862. 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>;
  52863. /**
  52864. * Append a scene
  52865. * @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)
  52866. * @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)
  52867. * @param scene is the instance of BABYLON.Scene to append to
  52868. * @param onProgress a callback with a progress event for each file being loaded
  52869. * @param pluginExtension the extension used to determine the plugin
  52870. * @returns The given scene
  52871. */
  52872. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52873. /**
  52874. * Load a scene into an asset container
  52875. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  52876. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  52877. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52878. * @param onSuccess a callback with the scene when import succeeds
  52879. * @param onProgress a callback with a progress event for each file being loaded
  52880. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52881. * @param pluginExtension the extension used to determine the plugin
  52882. * @returns The loaded plugin
  52883. */
  52884. 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>;
  52885. /**
  52886. * Load a scene into an asset container
  52887. * @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)
  52888. * @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)
  52889. * @param scene is the instance of Scene to append to
  52890. * @param onProgress a callback with a progress event for each file being loaded
  52891. * @param pluginExtension the extension used to determine the plugin
  52892. * @returns The loaded asset container
  52893. */
  52894. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  52895. /**
  52896. * Import animations from a file into a scene
  52897. * @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)
  52898. * @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)
  52899. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52900. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52901. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52902. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52903. * @param onSuccess a callback with the scene when import succeeds
  52904. * @param onProgress a callback with a progress event for each file being loaded
  52905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52906. * @param pluginExtension the extension used to determine the plugin
  52907. */
  52908. 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;
  52909. /**
  52910. * Import animations from a file into a scene
  52911. * @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)
  52912. * @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)
  52913. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52914. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52915. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52916. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52917. * @param onSuccess a callback with the scene 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 updated scene with imported animations
  52922. */
  52923. 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>;
  52924. }
  52925. }
  52926. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  52927. import { IDisposable, Scene } from "babylonjs/scene";
  52928. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  52929. import { Observable } from "babylonjs/Misc/observable";
  52930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52931. import { Nullable } from "babylonjs/types";
  52932. /**
  52933. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  52934. */
  52935. export type MotionControllerHandedness = "none" | "left" | "right";
  52936. /**
  52937. * The type of components available in motion controllers.
  52938. * This is not the name of the component.
  52939. */
  52940. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  52941. /**
  52942. * The state of a controller component
  52943. */
  52944. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  52945. /**
  52946. * The schema of motion controller layout.
  52947. * No object will be initialized using this interface
  52948. * This is used just to define the profile.
  52949. */
  52950. export interface IMotionControllerLayout {
  52951. /**
  52952. * Path to load the assets. Usually relative to the base path
  52953. */
  52954. assetPath: string;
  52955. /**
  52956. * Available components (unsorted)
  52957. */
  52958. components: {
  52959. /**
  52960. * A map of component Ids
  52961. */
  52962. [componentId: string]: {
  52963. /**
  52964. * The type of input the component outputs
  52965. */
  52966. type: MotionControllerComponentType;
  52967. /**
  52968. * The indices of this component in the gamepad object
  52969. */
  52970. gamepadIndices: {
  52971. /**
  52972. * Index of button
  52973. */
  52974. button?: number;
  52975. /**
  52976. * If available, index of x-axis
  52977. */
  52978. xAxis?: number;
  52979. /**
  52980. * If available, index of y-axis
  52981. */
  52982. yAxis?: number;
  52983. };
  52984. /**
  52985. * The mesh's root node name
  52986. */
  52987. rootNodeName: string;
  52988. /**
  52989. * Animation definitions for this model
  52990. */
  52991. visualResponses: {
  52992. [stateKey: string]: {
  52993. /**
  52994. * What property will be animated
  52995. */
  52996. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  52997. /**
  52998. * What states influence this visual response
  52999. */
  53000. states: MotionControllerComponentStateType[];
  53001. /**
  53002. * Type of animation - movement or visibility
  53003. */
  53004. valueNodeProperty: "transform" | "visibility";
  53005. /**
  53006. * Base node name to move. Its position will be calculated according to the min and max nodes
  53007. */
  53008. valueNodeName?: string;
  53009. /**
  53010. * Minimum movement node
  53011. */
  53012. minNodeName?: string;
  53013. /**
  53014. * Max movement node
  53015. */
  53016. maxNodeName?: string;
  53017. };
  53018. };
  53019. /**
  53020. * If touch enabled, what is the name of node to display user feedback
  53021. */
  53022. touchPointNodeName?: string;
  53023. };
  53024. };
  53025. /**
  53026. * Is it xr standard mapping or not
  53027. */
  53028. gamepadMapping: "" | "xr-standard";
  53029. /**
  53030. * Base root node of this entire model
  53031. */
  53032. rootNodeName: string;
  53033. /**
  53034. * Defines the main button component id
  53035. */
  53036. selectComponentId: string;
  53037. }
  53038. /**
  53039. * A definition for the layout map in the input profile
  53040. */
  53041. export interface IMotionControllerLayoutMap {
  53042. /**
  53043. * Layouts with handedness type as a key
  53044. */
  53045. [handedness: string]: IMotionControllerLayout;
  53046. }
  53047. /**
  53048. * The XR Input profile schema
  53049. * Profiles can be found here:
  53050. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53051. */
  53052. export interface IMotionControllerProfile {
  53053. /**
  53054. * fallback profiles for this profileId
  53055. */
  53056. fallbackProfileIds: string[];
  53057. /**
  53058. * The layout map, with handedness as key
  53059. */
  53060. layouts: IMotionControllerLayoutMap;
  53061. /**
  53062. * The id of this profile
  53063. * correlates to the profile(s) in the xrInput.profiles array
  53064. */
  53065. profileId: string;
  53066. }
  53067. /**
  53068. * A helper-interface for the 3 meshes needed for controller button animation
  53069. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53070. */
  53071. export interface IMotionControllerButtonMeshMap {
  53072. /**
  53073. * the mesh that defines the pressed value mesh position.
  53074. * This is used to find the max-position of this button
  53075. */
  53076. pressedMesh: AbstractMesh;
  53077. /**
  53078. * the mesh that defines the unpressed value mesh position.
  53079. * This is used to find the min (or initial) position of this button
  53080. */
  53081. unpressedMesh: AbstractMesh;
  53082. /**
  53083. * The mesh that will be changed when value changes
  53084. */
  53085. valueMesh: AbstractMesh;
  53086. }
  53087. /**
  53088. * A helper-interface for the 3 meshes needed for controller axis animation.
  53089. * This will be expanded when touchpad animations are fully supported
  53090. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53091. */
  53092. export interface IMotionControllerMeshMap {
  53093. /**
  53094. * the mesh that defines the maximum value mesh position.
  53095. */
  53096. maxMesh?: AbstractMesh;
  53097. /**
  53098. * the mesh that defines the minimum value mesh position.
  53099. */
  53100. minMesh?: AbstractMesh;
  53101. /**
  53102. * The mesh that will be changed when axis value changes
  53103. */
  53104. valueMesh?: AbstractMesh;
  53105. }
  53106. /**
  53107. * The elements needed for change-detection of the gamepad objects in motion controllers
  53108. */
  53109. export interface IMinimalMotionControllerObject {
  53110. /**
  53111. * Available axes of this controller
  53112. */
  53113. axes: number[];
  53114. /**
  53115. * An array of available buttons
  53116. */
  53117. buttons: Array<{
  53118. /**
  53119. * Value of the button/trigger
  53120. */
  53121. value: number;
  53122. /**
  53123. * If the button/trigger is currently touched
  53124. */
  53125. touched: boolean;
  53126. /**
  53127. * If the button/trigger is currently pressed
  53128. */
  53129. pressed: boolean;
  53130. }>;
  53131. /**
  53132. * EXPERIMENTAL haptic support.
  53133. */
  53134. hapticActuators?: Array<{
  53135. pulse: (value: number, duration: number) => Promise<boolean>;
  53136. }>;
  53137. }
  53138. /**
  53139. * An Abstract Motion controller
  53140. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53141. * Each component has an observable to check for changes in value and state
  53142. */
  53143. export abstract class WebXRAbstractMotionController implements IDisposable {
  53144. protected scene: Scene;
  53145. protected layout: IMotionControllerLayout;
  53146. /**
  53147. * The gamepad object correlating to this controller
  53148. */
  53149. gamepadObject: IMinimalMotionControllerObject;
  53150. /**
  53151. * handedness (left/right/none) of this controller
  53152. */
  53153. handedness: MotionControllerHandedness;
  53154. private _initComponent;
  53155. private _modelReady;
  53156. /**
  53157. * A map of components (WebXRControllerComponent) in this motion controller
  53158. * Components have a ComponentType and can also have both button and axis definitions
  53159. */
  53160. readonly components: {
  53161. [id: string]: WebXRControllerComponent;
  53162. };
  53163. /**
  53164. * Disable the model's animation. Can be set at any time.
  53165. */
  53166. disableAnimation: boolean;
  53167. /**
  53168. * Observers registered here will be triggered when the model of this controller is done loading
  53169. */
  53170. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53171. /**
  53172. * The profile id of this motion controller
  53173. */
  53174. abstract profileId: string;
  53175. /**
  53176. * The root mesh of the model. It is null if the model was not yet initialized
  53177. */
  53178. rootMesh: Nullable<AbstractMesh>;
  53179. /**
  53180. * constructs a new abstract motion controller
  53181. * @param scene the scene to which the model of the controller will be added
  53182. * @param layout The profile layout to load
  53183. * @param gamepadObject The gamepad object correlating to this controller
  53184. * @param handedness handedness (left/right/none) of this controller
  53185. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53186. */
  53187. constructor(scene: Scene, layout: IMotionControllerLayout,
  53188. /**
  53189. * The gamepad object correlating to this controller
  53190. */
  53191. gamepadObject: IMinimalMotionControllerObject,
  53192. /**
  53193. * handedness (left/right/none) of this controller
  53194. */
  53195. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53196. /**
  53197. * Dispose this controller, the model mesh and all its components
  53198. */
  53199. dispose(): void;
  53200. /**
  53201. * Returns all components of specific type
  53202. * @param type the type to search for
  53203. * @return an array of components with this type
  53204. */
  53205. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53206. /**
  53207. * get a component based an its component id as defined in layout.components
  53208. * @param id the id of the component
  53209. * @returns the component correlates to the id or undefined if not found
  53210. */
  53211. getComponent(id: string): WebXRControllerComponent;
  53212. /**
  53213. * Get the list of components available in this motion controller
  53214. * @returns an array of strings correlating to available components
  53215. */
  53216. getComponentIds(): string[];
  53217. /**
  53218. * Get the first component of specific type
  53219. * @param type type of component to find
  53220. * @return a controller component or null if not found
  53221. */
  53222. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53223. /**
  53224. * Get the main (Select) component of this controller as defined in the layout
  53225. * @returns the main component of this controller
  53226. */
  53227. getMainComponent(): WebXRControllerComponent;
  53228. /**
  53229. * Loads the model correlating to this controller
  53230. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53231. * @returns A promise fulfilled with the result of the model loading
  53232. */
  53233. loadModel(): Promise<boolean>;
  53234. /**
  53235. * Update this model using the current XRFrame
  53236. * @param xrFrame the current xr frame to use and update the model
  53237. */
  53238. updateFromXRFrame(xrFrame: XRFrame): void;
  53239. /**
  53240. * Backwards compatibility due to a deeply-integrated typo
  53241. */
  53242. get handness(): XREye;
  53243. /**
  53244. * Pulse (vibrate) this controller
  53245. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53246. * Consecutive calls to this function will cancel the last pulse call
  53247. *
  53248. * @param value the strength of the pulse in 0.0...1.0 range
  53249. * @param duration Duration of the pulse in milliseconds
  53250. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53251. * @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
  53252. */
  53253. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53254. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53255. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53256. /**
  53257. * Moves the axis on the controller mesh based on its current state
  53258. * @param axis the index of the axis
  53259. * @param axisValue the value of the axis which determines the meshes new position
  53260. * @hidden
  53261. */
  53262. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53263. /**
  53264. * Update the model itself with the current frame data
  53265. * @param xrFrame the frame to use for updating the model mesh
  53266. */
  53267. protected updateModel(xrFrame: XRFrame): void;
  53268. /**
  53269. * Get the filename and path for this controller's model
  53270. * @returns a map of filename and path
  53271. */
  53272. protected abstract _getFilenameAndPath(): {
  53273. filename: string;
  53274. path: string;
  53275. };
  53276. /**
  53277. * This function is called before the mesh is loaded. It checks for loading constraints.
  53278. * For example, this function can check if the GLB loader is available
  53279. * If this function returns false, the generic controller will be loaded instead
  53280. * @returns Is the client ready to load the mesh
  53281. */
  53282. protected abstract _getModelLoadingConstraints(): boolean;
  53283. /**
  53284. * This function will be called after the model was successfully loaded and can be used
  53285. * for mesh transformations before it is available for the user
  53286. * @param meshes the loaded meshes
  53287. */
  53288. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53289. /**
  53290. * Set the root mesh for this controller. Important for the WebXR controller class
  53291. * @param meshes the loaded meshes
  53292. */
  53293. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53294. /**
  53295. * A function executed each frame that updates the mesh (if needed)
  53296. * @param xrFrame the current xrFrame
  53297. */
  53298. protected abstract _updateModel(xrFrame: XRFrame): void;
  53299. private _getGenericFilenameAndPath;
  53300. private _getGenericParentMesh;
  53301. }
  53302. }
  53303. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53304. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53306. import { Scene } from "babylonjs/scene";
  53307. /**
  53308. * A generic trigger-only motion controller for WebXR
  53309. */
  53310. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53311. /**
  53312. * Static version of the profile id of this controller
  53313. */
  53314. static ProfileId: string;
  53315. profileId: string;
  53316. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53317. protected _getFilenameAndPath(): {
  53318. filename: string;
  53319. path: string;
  53320. };
  53321. protected _getModelLoadingConstraints(): boolean;
  53322. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53323. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53324. protected _updateModel(): void;
  53325. }
  53326. }
  53327. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53328. import { Vector4 } from "babylonjs/Maths/math.vector";
  53329. import { Mesh } from "babylonjs/Meshes/mesh";
  53330. import { Scene } from "babylonjs/scene";
  53331. import { Nullable } from "babylonjs/types";
  53332. /**
  53333. * Class containing static functions to help procedurally build meshes
  53334. */
  53335. export class SphereBuilder {
  53336. /**
  53337. * Creates a sphere mesh
  53338. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53339. * * 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`)
  53340. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53341. * * 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
  53342. * * 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)
  53343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53346. * @param name defines the name of the mesh
  53347. * @param options defines the options used to create the mesh
  53348. * @param scene defines the hosting scene
  53349. * @returns the sphere mesh
  53350. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53351. */
  53352. static CreateSphere(name: string, options: {
  53353. segments?: number;
  53354. diameter?: number;
  53355. diameterX?: number;
  53356. diameterY?: number;
  53357. diameterZ?: number;
  53358. arc?: number;
  53359. slice?: number;
  53360. sideOrientation?: number;
  53361. frontUVs?: Vector4;
  53362. backUVs?: Vector4;
  53363. updatable?: boolean;
  53364. }, scene?: Nullable<Scene>): Mesh;
  53365. }
  53366. }
  53367. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53369. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53370. import { Scene } from "babylonjs/scene";
  53371. /**
  53372. * A profiled motion controller has its profile loaded from an online repository.
  53373. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53374. */
  53375. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53376. private _repositoryUrl;
  53377. private _buttonMeshMapping;
  53378. private _touchDots;
  53379. /**
  53380. * The profile ID of this controller. Will be populated when the controller initializes.
  53381. */
  53382. profileId: string;
  53383. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53384. dispose(): void;
  53385. protected _getFilenameAndPath(): {
  53386. filename: string;
  53387. path: string;
  53388. };
  53389. protected _getModelLoadingConstraints(): boolean;
  53390. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53391. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53392. protected _updateModel(_xrFrame: XRFrame): void;
  53393. }
  53394. }
  53395. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53396. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53397. import { Scene } from "babylonjs/scene";
  53398. /**
  53399. * A construction function type to create a new controller based on an xrInput object
  53400. */
  53401. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53402. /**
  53403. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53404. *
  53405. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53406. * it should be replaced with auto-loaded controllers.
  53407. *
  53408. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53409. */
  53410. export class WebXRMotionControllerManager {
  53411. private static _AvailableControllers;
  53412. private static _Fallbacks;
  53413. private static _ProfileLoadingPromises;
  53414. private static _ProfilesList;
  53415. /**
  53416. * The base URL of the online controller repository. Can be changed at any time.
  53417. */
  53418. static BaseRepositoryUrl: string;
  53419. /**
  53420. * Which repository gets priority - local or online
  53421. */
  53422. static PrioritizeOnlineRepository: boolean;
  53423. /**
  53424. * Use the online repository, or use only locally-defined controllers
  53425. */
  53426. static UseOnlineRepository: boolean;
  53427. /**
  53428. * Clear the cache used for profile loading and reload when requested again
  53429. */
  53430. static ClearProfilesCache(): void;
  53431. /**
  53432. * Register the default fallbacks.
  53433. * This function is called automatically when this file is imported.
  53434. */
  53435. static DefaultFallbacks(): void;
  53436. /**
  53437. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53438. * @param profileId the profile to which a fallback needs to be found
  53439. * @return an array with corresponding fallback profiles
  53440. */
  53441. static FindFallbackWithProfileId(profileId: string): string[];
  53442. /**
  53443. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53444. * The order of search:
  53445. *
  53446. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53447. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53448. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53449. * 4) return the generic trigger controller if none were found
  53450. *
  53451. * @param xrInput the xrInput to which a new controller is initialized
  53452. * @param scene the scene to which the model will be added
  53453. * @param forceProfile force a certain profile for this controller
  53454. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53455. */
  53456. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53457. /**
  53458. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53459. *
  53460. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53461. *
  53462. * @param type the profile type to register
  53463. * @param constructFunction the function to be called when loading this profile
  53464. */
  53465. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53466. /**
  53467. * Register a fallback to a specific profile.
  53468. * @param profileId the profileId that will receive the fallbacks
  53469. * @param fallbacks A list of fallback profiles
  53470. */
  53471. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53472. /**
  53473. * Will update the list of profiles available in the repository
  53474. * @return a promise that resolves to a map of profiles available online
  53475. */
  53476. static UpdateProfilesList(): Promise<{
  53477. [profile: string]: string;
  53478. }>;
  53479. private static _LoadProfileFromRepository;
  53480. private static _LoadProfilesFromAvailableControllers;
  53481. }
  53482. }
  53483. declare module "babylonjs/XR/webXRInputSource" {
  53484. import { Observable } from "babylonjs/Misc/observable";
  53485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53486. import { Ray } from "babylonjs/Culling/ray";
  53487. import { Scene } from "babylonjs/scene";
  53488. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53489. /**
  53490. * Configuration options for the WebXR controller creation
  53491. */
  53492. export interface IWebXRControllerOptions {
  53493. /**
  53494. * Should the controller mesh be animated when a user interacts with it
  53495. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53496. */
  53497. disableMotionControllerAnimation?: boolean;
  53498. /**
  53499. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53500. */
  53501. doNotLoadControllerMesh?: boolean;
  53502. /**
  53503. * Force a specific controller type for this controller.
  53504. * This can be used when creating your own profile or when testing different controllers
  53505. */
  53506. forceControllerProfile?: string;
  53507. /**
  53508. * Defines a rendering group ID for meshes that will be loaded.
  53509. * This is for the default controllers only.
  53510. */
  53511. renderingGroupId?: number;
  53512. }
  53513. /**
  53514. * Represents an XR controller
  53515. */
  53516. export class WebXRInputSource {
  53517. private _scene;
  53518. /** The underlying input source for the controller */
  53519. inputSource: XRInputSource;
  53520. private _options;
  53521. private _tmpVector;
  53522. private _uniqueId;
  53523. private _disposed;
  53524. /**
  53525. * 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
  53526. */
  53527. grip?: AbstractMesh;
  53528. /**
  53529. * If available, this is the gamepad object related to this controller.
  53530. * Using this object it is possible to get click events and trackpad changes of the
  53531. * webxr controller that is currently being used.
  53532. */
  53533. motionController?: WebXRAbstractMotionController;
  53534. /**
  53535. * Event that fires when the controller is removed/disposed.
  53536. * The object provided as event data is this controller, after associated assets were disposed.
  53537. * uniqueId is still available.
  53538. */
  53539. onDisposeObservable: Observable<WebXRInputSource>;
  53540. /**
  53541. * Will be triggered when the mesh associated with the motion controller is done loading.
  53542. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53543. * A shortened version of controller -> motion controller -> on mesh loaded.
  53544. */
  53545. onMeshLoadedObservable: Observable<AbstractMesh>;
  53546. /**
  53547. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53548. */
  53549. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53550. /**
  53551. * Pointer which can be used to select objects or attach a visible laser to
  53552. */
  53553. pointer: AbstractMesh;
  53554. /**
  53555. * Creates the input source object
  53556. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53557. * @param _scene the scene which the controller should be associated to
  53558. * @param inputSource the underlying input source for the controller
  53559. * @param _options options for this controller creation
  53560. */
  53561. constructor(_scene: Scene,
  53562. /** The underlying input source for the controller */
  53563. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53564. /**
  53565. * Get this controllers unique id
  53566. */
  53567. get uniqueId(): string;
  53568. /**
  53569. * Disposes of the object
  53570. */
  53571. dispose(): void;
  53572. /**
  53573. * Gets a world space ray coming from the pointer or grip
  53574. * @param result the resulting ray
  53575. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53576. */
  53577. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53578. /**
  53579. * Updates the controller pose based on the given XRFrame
  53580. * @param xrFrame xr frame to update the pose with
  53581. * @param referenceSpace reference space to use
  53582. */
  53583. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53584. }
  53585. }
  53586. declare module "babylonjs/XR/webXRInput" {
  53587. import { Observable } from "babylonjs/Misc/observable";
  53588. import { IDisposable } from "babylonjs/scene";
  53589. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53590. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53591. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53592. /**
  53593. * The schema for initialization options of the XR Input class
  53594. */
  53595. export interface IWebXRInputOptions {
  53596. /**
  53597. * If set to true no model will be automatically loaded
  53598. */
  53599. doNotLoadControllerMeshes?: boolean;
  53600. /**
  53601. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53602. * If not found, the xr input profile data will be used.
  53603. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53604. */
  53605. forceInputProfile?: string;
  53606. /**
  53607. * Do not send a request to the controller repository to load the profile.
  53608. *
  53609. * Instead, use the controllers available in babylon itself.
  53610. */
  53611. disableOnlineControllerRepository?: boolean;
  53612. /**
  53613. * A custom URL for the controllers repository
  53614. */
  53615. customControllersRepositoryURL?: string;
  53616. /**
  53617. * Should the controller model's components not move according to the user input
  53618. */
  53619. disableControllerAnimation?: boolean;
  53620. /**
  53621. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53622. */
  53623. controllerOptions?: IWebXRControllerOptions;
  53624. }
  53625. /**
  53626. * XR input used to track XR inputs such as controllers/rays
  53627. */
  53628. export class WebXRInput implements IDisposable {
  53629. /**
  53630. * the xr session manager for this session
  53631. */
  53632. xrSessionManager: WebXRSessionManager;
  53633. /**
  53634. * the WebXR camera for this session. Mainly used for teleportation
  53635. */
  53636. xrCamera: WebXRCamera;
  53637. private readonly options;
  53638. /**
  53639. * XR controllers being tracked
  53640. */
  53641. controllers: Array<WebXRInputSource>;
  53642. private _frameObserver;
  53643. private _sessionEndedObserver;
  53644. private _sessionInitObserver;
  53645. /**
  53646. * Event when a controller has been connected/added
  53647. */
  53648. onControllerAddedObservable: Observable<WebXRInputSource>;
  53649. /**
  53650. * Event when a controller has been removed/disconnected
  53651. */
  53652. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53653. /**
  53654. * Initializes the WebXRInput
  53655. * @param xrSessionManager the xr session manager for this session
  53656. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53657. * @param options = initialization options for this xr input
  53658. */
  53659. constructor(
  53660. /**
  53661. * the xr session manager for this session
  53662. */
  53663. xrSessionManager: WebXRSessionManager,
  53664. /**
  53665. * the WebXR camera for this session. Mainly used for teleportation
  53666. */
  53667. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53668. private _onInputSourcesChange;
  53669. private _addAndRemoveControllers;
  53670. /**
  53671. * Disposes of the object
  53672. */
  53673. dispose(): void;
  53674. }
  53675. }
  53676. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53677. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53678. import { Observable, EventState } from "babylonjs/Misc/observable";
  53679. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53680. /**
  53681. * This is the base class for all WebXR features.
  53682. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53683. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53684. */
  53685. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53686. protected _xrSessionManager: WebXRSessionManager;
  53687. private _attached;
  53688. private _removeOnDetach;
  53689. /**
  53690. * Is this feature disposed?
  53691. */
  53692. isDisposed: boolean;
  53693. /**
  53694. * Should auto-attach be disabled?
  53695. */
  53696. disableAutoAttach: boolean;
  53697. /**
  53698. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53699. */
  53700. xrNativeFeatureName: string;
  53701. /**
  53702. * Construct a new (abstract) WebXR feature
  53703. * @param _xrSessionManager the xr session manager for this feature
  53704. */
  53705. constructor(_xrSessionManager: WebXRSessionManager);
  53706. /**
  53707. * Is this feature attached
  53708. */
  53709. get attached(): boolean;
  53710. /**
  53711. * attach this feature
  53712. *
  53713. * @param force should attachment be forced (even when already attached)
  53714. * @returns true if successful, false is failed or already attached
  53715. */
  53716. attach(force?: boolean): boolean;
  53717. /**
  53718. * detach this feature.
  53719. *
  53720. * @returns true if successful, false if failed or already detached
  53721. */
  53722. detach(): boolean;
  53723. /**
  53724. * Dispose this feature and all of the resources attached
  53725. */
  53726. dispose(): void;
  53727. /**
  53728. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53729. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53730. *
  53731. * @returns whether or not the feature is compatible in this environment
  53732. */
  53733. isCompatible(): boolean;
  53734. /**
  53735. * This is used to register callbacks that will automatically be removed when detach is called.
  53736. * @param observable the observable to which the observer will be attached
  53737. * @param callback the callback to register
  53738. */
  53739. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53740. /**
  53741. * Code in this function will be executed on each xrFrame received from the browser.
  53742. * This function will not execute after the feature is detached.
  53743. * @param _xrFrame the current frame
  53744. */
  53745. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53746. }
  53747. }
  53748. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53749. import { IDisposable, Scene } from "babylonjs/scene";
  53750. import { Nullable } from "babylonjs/types";
  53751. import { Observable } from "babylonjs/Misc/observable";
  53752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53753. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53754. import { Camera } from "babylonjs/Cameras/camera";
  53755. /**
  53756. * Renders a layer on top of an existing scene
  53757. */
  53758. export class UtilityLayerRenderer implements IDisposable {
  53759. /** the original scene that will be rendered on top of */
  53760. originalScene: Scene;
  53761. private _pointerCaptures;
  53762. private _lastPointerEvents;
  53763. private static _DefaultUtilityLayer;
  53764. private static _DefaultKeepDepthUtilityLayer;
  53765. private _sharedGizmoLight;
  53766. private _renderCamera;
  53767. /**
  53768. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53769. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53770. * @returns the camera that is used when rendering the utility layer
  53771. */
  53772. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53773. /**
  53774. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53775. * @param cam the camera that should be used when rendering the utility layer
  53776. */
  53777. setRenderCamera(cam: Nullable<Camera>): void;
  53778. /**
  53779. * @hidden
  53780. * Light which used by gizmos to get light shading
  53781. */
  53782. _getSharedGizmoLight(): HemisphericLight;
  53783. /**
  53784. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53785. */
  53786. pickUtilitySceneFirst: boolean;
  53787. /**
  53788. * 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)
  53789. */
  53790. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53791. /**
  53792. * 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)
  53793. */
  53794. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53795. /**
  53796. * The scene that is rendered on top of the original scene
  53797. */
  53798. utilityLayerScene: Scene;
  53799. /**
  53800. * If the utility layer should automatically be rendered on top of existing scene
  53801. */
  53802. shouldRender: boolean;
  53803. /**
  53804. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53805. */
  53806. onlyCheckPointerDownEvents: boolean;
  53807. /**
  53808. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53809. */
  53810. processAllEvents: boolean;
  53811. /**
  53812. * Observable raised when the pointer move from the utility layer scene to the main scene
  53813. */
  53814. onPointerOutObservable: Observable<number>;
  53815. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53816. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53817. private _afterRenderObserver;
  53818. private _sceneDisposeObserver;
  53819. private _originalPointerObserver;
  53820. /**
  53821. * Instantiates a UtilityLayerRenderer
  53822. * @param originalScene the original scene that will be rendered on top of
  53823. * @param handleEvents boolean indicating if the utility layer should handle events
  53824. */
  53825. constructor(
  53826. /** the original scene that will be rendered on top of */
  53827. originalScene: Scene, handleEvents?: boolean);
  53828. private _notifyObservers;
  53829. /**
  53830. * Renders the utility layers scene on top of the original scene
  53831. */
  53832. render(): void;
  53833. /**
  53834. * Disposes of the renderer
  53835. */
  53836. dispose(): void;
  53837. private _updateCamera;
  53838. }
  53839. }
  53840. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53841. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53843. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53844. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53845. import { Scene } from "babylonjs/scene";
  53846. import { Nullable } from "babylonjs/types";
  53847. import { Color3 } from "babylonjs/Maths/math.color";
  53848. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53849. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53850. /**
  53851. * Options interface for the pointer selection module
  53852. */
  53853. export interface IWebXRControllerPointerSelectionOptions {
  53854. /**
  53855. * if provided, this scene will be used to render meshes.
  53856. */
  53857. customUtilityLayerScene?: Scene;
  53858. /**
  53859. * 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)
  53860. * If not disabled, the last picked point will be used to execute a pointer up event
  53861. * If disabled, pointer up event will be triggered right after the pointer down event.
  53862. * Used in screen and gaze target ray mode only
  53863. */
  53864. disablePointerUpOnTouchOut: boolean;
  53865. /**
  53866. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53867. */
  53868. forceGazeMode: boolean;
  53869. /**
  53870. * 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
  53871. * to start a new countdown to the pointer down event.
  53872. * Defaults to 1.
  53873. */
  53874. gazeModePointerMovedFactor?: number;
  53875. /**
  53876. * Different button type to use instead of the main component
  53877. */
  53878. overrideButtonId?: string;
  53879. /**
  53880. * use this rendering group id for the meshes (optional)
  53881. */
  53882. renderingGroupId?: number;
  53883. /**
  53884. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53885. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53886. * 3000 means 3 seconds between pointing at something and selecting it
  53887. */
  53888. timeToSelect?: number;
  53889. /**
  53890. * Should meshes created here be added to a utility layer or the main scene
  53891. */
  53892. useUtilityLayer?: boolean;
  53893. /**
  53894. * Optional WebXR camera to be used for gaze selection
  53895. */
  53896. gazeCamera?: WebXRCamera;
  53897. /**
  53898. * the xr input to use with this pointer selection
  53899. */
  53900. xrInput: WebXRInput;
  53901. }
  53902. /**
  53903. * A module that will enable pointer selection for motion controllers of XR Input Sources
  53904. */
  53905. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  53906. private readonly _options;
  53907. private static _idCounter;
  53908. private _attachController;
  53909. private _controllers;
  53910. private _scene;
  53911. private _tmpVectorForPickCompare;
  53912. /**
  53913. * The module's name
  53914. */
  53915. static readonly Name: string;
  53916. /**
  53917. * The (Babylon) version of this module.
  53918. * This is an integer representing the implementation version.
  53919. * This number does not correspond to the WebXR specs version
  53920. */
  53921. static readonly Version: number;
  53922. /**
  53923. * Disable lighting on the laser pointer (so it will always be visible)
  53924. */
  53925. disablePointerLighting: boolean;
  53926. /**
  53927. * Disable lighting on the selection mesh (so it will always be visible)
  53928. */
  53929. disableSelectionMeshLighting: boolean;
  53930. /**
  53931. * Should the laser pointer be displayed
  53932. */
  53933. displayLaserPointer: boolean;
  53934. /**
  53935. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  53936. */
  53937. displaySelectionMesh: boolean;
  53938. /**
  53939. * This color will be set to the laser pointer when selection is triggered
  53940. */
  53941. laserPointerPickedColor: Color3;
  53942. /**
  53943. * Default color of the laser pointer
  53944. */
  53945. laserPointerDefaultColor: Color3;
  53946. /**
  53947. * default color of the selection ring
  53948. */
  53949. selectionMeshDefaultColor: Color3;
  53950. /**
  53951. * This color will be applied to the selection ring when selection is triggered
  53952. */
  53953. selectionMeshPickedColor: Color3;
  53954. /**
  53955. * Optional filter to be used for ray selection. This predicate shares behavior with
  53956. * scene.pointerMovePredicate which takes priority if it is also assigned.
  53957. */
  53958. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53959. /**
  53960. * constructs a new background remover module
  53961. * @param _xrSessionManager the session manager for this module
  53962. * @param _options read-only options to be used in this module
  53963. */
  53964. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  53965. /**
  53966. * attach this feature
  53967. * Will usually be called by the features manager
  53968. *
  53969. * @returns true if successful.
  53970. */
  53971. attach(): boolean;
  53972. /**
  53973. * detach this feature.
  53974. * Will usually be called by the features manager
  53975. *
  53976. * @returns true if successful.
  53977. */
  53978. detach(): boolean;
  53979. /**
  53980. * Will get the mesh under a specific pointer.
  53981. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  53982. * @param controllerId the controllerId to check
  53983. * @returns The mesh under pointer or null if no mesh is under the pointer
  53984. */
  53985. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  53986. /**
  53987. * Get the xr controller that correlates to the pointer id in the pointer event
  53988. *
  53989. * @param id the pointer id to search for
  53990. * @returns the controller that correlates to this id or null if not found
  53991. */
  53992. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  53993. protected _onXRFrame(_xrFrame: XRFrame): void;
  53994. private _attachGazeMode;
  53995. private _attachScreenRayMode;
  53996. private _attachTrackedPointerRayMode;
  53997. private _convertNormalToDirectionOfRay;
  53998. private _detachController;
  53999. private _generateNewMeshPair;
  54000. private _pickingMoved;
  54001. private _updatePointerDistance;
  54002. /** @hidden */
  54003. get lasterPointerDefaultColor(): Color3;
  54004. }
  54005. }
  54006. declare module "babylonjs/XR/webXREnterExitUI" {
  54007. import { Nullable } from "babylonjs/types";
  54008. import { Observable } from "babylonjs/Misc/observable";
  54009. import { IDisposable, Scene } from "babylonjs/scene";
  54010. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54011. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54012. /**
  54013. * Button which can be used to enter a different mode of XR
  54014. */
  54015. export class WebXREnterExitUIButton {
  54016. /** button element */
  54017. element: HTMLElement;
  54018. /** XR initialization options for the button */
  54019. sessionMode: XRSessionMode;
  54020. /** Reference space type */
  54021. referenceSpaceType: XRReferenceSpaceType;
  54022. /**
  54023. * Creates a WebXREnterExitUIButton
  54024. * @param element button element
  54025. * @param sessionMode XR initialization session mode
  54026. * @param referenceSpaceType the type of reference space to be used
  54027. */
  54028. constructor(
  54029. /** button element */
  54030. element: HTMLElement,
  54031. /** XR initialization options for the button */
  54032. sessionMode: XRSessionMode,
  54033. /** Reference space type */
  54034. referenceSpaceType: XRReferenceSpaceType);
  54035. /**
  54036. * Extendable function which can be used to update the button's visuals when the state changes
  54037. * @param activeButton the current active button in the UI
  54038. */
  54039. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54040. }
  54041. /**
  54042. * Options to create the webXR UI
  54043. */
  54044. export class WebXREnterExitUIOptions {
  54045. /**
  54046. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54047. */
  54048. customButtons?: Array<WebXREnterExitUIButton>;
  54049. /**
  54050. * A reference space type to use when creating the default button.
  54051. * Default is local-floor
  54052. */
  54053. referenceSpaceType?: XRReferenceSpaceType;
  54054. /**
  54055. * Context to enter xr with
  54056. */
  54057. renderTarget?: Nullable<WebXRRenderTarget>;
  54058. /**
  54059. * A session mode to use when creating the default button.
  54060. * Default is immersive-vr
  54061. */
  54062. sessionMode?: XRSessionMode;
  54063. /**
  54064. * A list of optional features to init the session with
  54065. */
  54066. optionalFeatures?: string[];
  54067. /**
  54068. * A list of optional features to init the session with
  54069. */
  54070. requiredFeatures?: string[];
  54071. }
  54072. /**
  54073. * UI to allow the user to enter/exit XR mode
  54074. */
  54075. export class WebXREnterExitUI implements IDisposable {
  54076. private scene;
  54077. /** version of the options passed to this UI */
  54078. options: WebXREnterExitUIOptions;
  54079. private _activeButton;
  54080. private _buttons;
  54081. /**
  54082. * The HTML Div Element to which buttons are added.
  54083. */
  54084. readonly overlay: HTMLDivElement;
  54085. /**
  54086. * Fired every time the active button is changed.
  54087. *
  54088. * When xr is entered via a button that launches xr that button will be the callback parameter
  54089. *
  54090. * When exiting xr the callback parameter will be null)
  54091. */
  54092. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54093. /**
  54094. *
  54095. * @param scene babylon scene object to use
  54096. * @param options (read-only) version of the options passed to this UI
  54097. */
  54098. private constructor();
  54099. /**
  54100. * Creates UI to allow the user to enter/exit XR mode
  54101. * @param scene the scene to add the ui to
  54102. * @param helper the xr experience helper to enter/exit xr with
  54103. * @param options options to configure the UI
  54104. * @returns the created ui
  54105. */
  54106. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54107. /**
  54108. * Disposes of the XR UI component
  54109. */
  54110. dispose(): void;
  54111. private _updateButtons;
  54112. }
  54113. }
  54114. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54115. import { Vector3 } from "babylonjs/Maths/math.vector";
  54116. import { Color4 } from "babylonjs/Maths/math.color";
  54117. import { Nullable } from "babylonjs/types";
  54118. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54119. import { Scene } from "babylonjs/scene";
  54120. /**
  54121. * Class containing static functions to help procedurally build meshes
  54122. */
  54123. export class LinesBuilder {
  54124. /**
  54125. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54126. * * 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
  54127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54128. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54129. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54130. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54132. * * 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
  54133. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54136. * @param name defines the name of the new line system
  54137. * @param options defines the options used to create the line system
  54138. * @param scene defines the hosting scene
  54139. * @returns a new line system mesh
  54140. */
  54141. static CreateLineSystem(name: string, options: {
  54142. lines: Vector3[][];
  54143. updatable?: boolean;
  54144. instance?: Nullable<LinesMesh>;
  54145. colors?: Nullable<Color4[][]>;
  54146. useVertexAlpha?: boolean;
  54147. }, scene: Nullable<Scene>): LinesMesh;
  54148. /**
  54149. * Creates a line mesh
  54150. * 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
  54151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54152. * * The parameter `points` is an array successive Vector3
  54153. * * 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
  54154. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54156. * * When updating an instance, remember that only point positions can change, not the number of points
  54157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54159. * @param name defines the name of the new line system
  54160. * @param options defines the options used to create the line system
  54161. * @param scene defines the hosting scene
  54162. * @returns a new line mesh
  54163. */
  54164. static CreateLines(name: string, options: {
  54165. points: Vector3[];
  54166. updatable?: boolean;
  54167. instance?: Nullable<LinesMesh>;
  54168. colors?: Color4[];
  54169. useVertexAlpha?: boolean;
  54170. }, scene?: Nullable<Scene>): LinesMesh;
  54171. /**
  54172. * Creates a dashed line mesh
  54173. * * 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
  54174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54175. * * The parameter `points` is an array successive Vector3
  54176. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54177. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54178. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54179. * * 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
  54180. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54181. * * When updating an instance, remember that only point positions can change, not the number of points
  54182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54183. * @param name defines the name of the mesh
  54184. * @param options defines the options used to create the mesh
  54185. * @param scene defines the hosting scene
  54186. * @returns the dashed line mesh
  54187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54188. */
  54189. static CreateDashedLines(name: string, options: {
  54190. points: Vector3[];
  54191. dashSize?: number;
  54192. gapSize?: number;
  54193. dashNb?: number;
  54194. updatable?: boolean;
  54195. instance?: LinesMesh;
  54196. useVertexAlpha?: boolean;
  54197. }, scene?: Nullable<Scene>): LinesMesh;
  54198. }
  54199. }
  54200. declare module "babylonjs/Misc/timer" {
  54201. import { Observable, Observer } from "babylonjs/Misc/observable";
  54202. import { Nullable } from "babylonjs/types";
  54203. import { IDisposable } from "babylonjs/scene";
  54204. /**
  54205. * Construction options for a timer
  54206. */
  54207. export interface ITimerOptions<T> {
  54208. /**
  54209. * Time-to-end
  54210. */
  54211. timeout: number;
  54212. /**
  54213. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54214. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54215. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54216. */
  54217. contextObservable: Observable<T>;
  54218. /**
  54219. * Optional parameters when adding an observer to the observable
  54220. */
  54221. observableParameters?: {
  54222. mask?: number;
  54223. insertFirst?: boolean;
  54224. scope?: any;
  54225. };
  54226. /**
  54227. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54228. */
  54229. breakCondition?: (data?: ITimerData<T>) => boolean;
  54230. /**
  54231. * Will be triggered when the time condition has met
  54232. */
  54233. onEnded?: (data: ITimerData<any>) => void;
  54234. /**
  54235. * Will be triggered when the break condition has met (prematurely ended)
  54236. */
  54237. onAborted?: (data: ITimerData<any>) => void;
  54238. /**
  54239. * Optional function to execute on each tick (or count)
  54240. */
  54241. onTick?: (data: ITimerData<any>) => void;
  54242. }
  54243. /**
  54244. * An interface defining the data sent by the timer
  54245. */
  54246. export interface ITimerData<T> {
  54247. /**
  54248. * When did it start
  54249. */
  54250. startTime: number;
  54251. /**
  54252. * Time now
  54253. */
  54254. currentTime: number;
  54255. /**
  54256. * Time passed since started
  54257. */
  54258. deltaTime: number;
  54259. /**
  54260. * How much is completed, in [0.0...1.0].
  54261. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54262. */
  54263. completeRate: number;
  54264. /**
  54265. * What the registered observable sent in the last count
  54266. */
  54267. payload: T;
  54268. }
  54269. /**
  54270. * The current state of the timer
  54271. */
  54272. export enum TimerState {
  54273. /**
  54274. * Timer initialized, not yet started
  54275. */
  54276. INIT = 0,
  54277. /**
  54278. * Timer started and counting
  54279. */
  54280. STARTED = 1,
  54281. /**
  54282. * Timer ended (whether aborted or time reached)
  54283. */
  54284. ENDED = 2
  54285. }
  54286. /**
  54287. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54288. *
  54289. * @param options options with which to initialize this timer
  54290. */
  54291. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54292. /**
  54293. * An advanced implementation of a timer class
  54294. */
  54295. export class AdvancedTimer<T = any> implements IDisposable {
  54296. /**
  54297. * Will notify each time the timer calculates the remaining time
  54298. */
  54299. onEachCountObservable: Observable<ITimerData<T>>;
  54300. /**
  54301. * Will trigger when the timer was aborted due to the break condition
  54302. */
  54303. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54304. /**
  54305. * Will trigger when the timer ended successfully
  54306. */
  54307. onTimerEndedObservable: Observable<ITimerData<T>>;
  54308. /**
  54309. * Will trigger when the timer state has changed
  54310. */
  54311. onStateChangedObservable: Observable<TimerState>;
  54312. private _observer;
  54313. private _contextObservable;
  54314. private _observableParameters;
  54315. private _startTime;
  54316. private _timer;
  54317. private _state;
  54318. private _breakCondition;
  54319. private _timeToEnd;
  54320. private _breakOnNextTick;
  54321. /**
  54322. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54323. * @param options construction options for this advanced timer
  54324. */
  54325. constructor(options: ITimerOptions<T>);
  54326. /**
  54327. * set a breaking condition for this timer. Default is to never break during count
  54328. * @param predicate the new break condition. Returns true to break, false otherwise
  54329. */
  54330. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54331. /**
  54332. * Reset ALL associated observables in this advanced timer
  54333. */
  54334. clearObservables(): void;
  54335. /**
  54336. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54337. *
  54338. * @param timeToEnd how much time to measure until timer ended
  54339. */
  54340. start(timeToEnd?: number): void;
  54341. /**
  54342. * Will force a stop on the next tick.
  54343. */
  54344. stop(): void;
  54345. /**
  54346. * Dispose this timer, clearing all resources
  54347. */
  54348. dispose(): void;
  54349. private _setState;
  54350. private _tick;
  54351. private _stop;
  54352. }
  54353. }
  54354. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54355. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54356. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54357. import { Nullable } from "babylonjs/types";
  54358. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54360. import { Vector3 } from "babylonjs/Maths/math.vector";
  54361. import { Material } from "babylonjs/Materials/material";
  54362. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54363. import { Scene } from "babylonjs/scene";
  54364. /**
  54365. * The options container for the teleportation module
  54366. */
  54367. export interface IWebXRTeleportationOptions {
  54368. /**
  54369. * if provided, this scene will be used to render meshes.
  54370. */
  54371. customUtilityLayerScene?: Scene;
  54372. /**
  54373. * Values to configure the default target mesh
  54374. */
  54375. defaultTargetMeshOptions?: {
  54376. /**
  54377. * Fill color of the teleportation area
  54378. */
  54379. teleportationFillColor?: string;
  54380. /**
  54381. * Border color for the teleportation area
  54382. */
  54383. teleportationBorderColor?: string;
  54384. /**
  54385. * Disable the mesh's animation sequence
  54386. */
  54387. disableAnimation?: boolean;
  54388. /**
  54389. * Disable lighting on the material or the ring and arrow
  54390. */
  54391. disableLighting?: boolean;
  54392. /**
  54393. * Override the default material of the torus and arrow
  54394. */
  54395. torusArrowMaterial?: Material;
  54396. };
  54397. /**
  54398. * A list of meshes to use as floor meshes.
  54399. * Meshes can be added and removed after initializing the feature using the
  54400. * addFloorMesh and removeFloorMesh functions
  54401. * If empty, rotation will still work
  54402. */
  54403. floorMeshes?: AbstractMesh[];
  54404. /**
  54405. * use this rendering group id for the meshes (optional)
  54406. */
  54407. renderingGroupId?: number;
  54408. /**
  54409. * Should teleportation move only to snap points
  54410. */
  54411. snapPointsOnly?: boolean;
  54412. /**
  54413. * An array of points to which the teleportation will snap to.
  54414. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54415. */
  54416. snapPositions?: Vector3[];
  54417. /**
  54418. * How close should the teleportation ray be in order to snap to position.
  54419. * Default to 0.8 units (meters)
  54420. */
  54421. snapToPositionRadius?: number;
  54422. /**
  54423. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54424. * If you want to support rotation, make sure your mesh has a direction indicator.
  54425. *
  54426. * When left untouched, the default mesh will be initialized.
  54427. */
  54428. teleportationTargetMesh?: AbstractMesh;
  54429. /**
  54430. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54431. */
  54432. timeToTeleport?: number;
  54433. /**
  54434. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54435. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54436. */
  54437. useMainComponentOnly?: boolean;
  54438. /**
  54439. * Should meshes created here be added to a utility layer or the main scene
  54440. */
  54441. useUtilityLayer?: boolean;
  54442. /**
  54443. * Babylon XR Input class for controller
  54444. */
  54445. xrInput: WebXRInput;
  54446. /**
  54447. * Meshes that the teleportation ray cannot go through
  54448. */
  54449. pickBlockerMeshes?: AbstractMesh[];
  54450. }
  54451. /**
  54452. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54453. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54454. * the input of the attached controllers.
  54455. */
  54456. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54457. private _options;
  54458. private _controllers;
  54459. private _currentTeleportationControllerId;
  54460. private _floorMeshes;
  54461. private _quadraticBezierCurve;
  54462. private _selectionFeature;
  54463. private _snapToPositions;
  54464. private _snappedToPoint;
  54465. private _teleportationRingMaterial?;
  54466. private _tmpRay;
  54467. private _tmpVector;
  54468. private _tmpQuaternion;
  54469. /**
  54470. * The module's name
  54471. */
  54472. static readonly Name: string;
  54473. /**
  54474. * The (Babylon) version of this module.
  54475. * This is an integer representing the implementation version.
  54476. * This number does not correspond to the webxr specs version
  54477. */
  54478. static readonly Version: number;
  54479. /**
  54480. * Is movement backwards enabled
  54481. */
  54482. backwardsMovementEnabled: boolean;
  54483. /**
  54484. * Distance to travel when moving backwards
  54485. */
  54486. backwardsTeleportationDistance: number;
  54487. /**
  54488. * The distance from the user to the inspection point in the direction of the controller
  54489. * A higher number will allow the user to move further
  54490. * defaults to 5 (meters, in xr units)
  54491. */
  54492. parabolicCheckRadius: number;
  54493. /**
  54494. * Should the module support parabolic ray on top of direct ray
  54495. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54496. * Very helpful when moving between floors / different heights
  54497. */
  54498. parabolicRayEnabled: boolean;
  54499. /**
  54500. * How much rotation should be applied when rotating right and left
  54501. */
  54502. rotationAngle: number;
  54503. /**
  54504. * Is rotation enabled when moving forward?
  54505. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54506. */
  54507. rotationEnabled: boolean;
  54508. /**
  54509. * constructs a new anchor system
  54510. * @param _xrSessionManager an instance of WebXRSessionManager
  54511. * @param _options configuration object for this feature
  54512. */
  54513. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54514. /**
  54515. * Get the snapPointsOnly flag
  54516. */
  54517. get snapPointsOnly(): boolean;
  54518. /**
  54519. * Sets the snapPointsOnly flag
  54520. * @param snapToPoints should teleportation be exclusively to snap points
  54521. */
  54522. set snapPointsOnly(snapToPoints: boolean);
  54523. /**
  54524. * Add a new mesh to the floor meshes array
  54525. * @param mesh the mesh to use as floor mesh
  54526. */
  54527. addFloorMesh(mesh: AbstractMesh): void;
  54528. /**
  54529. * Add a new snap-to point to fix teleportation to this position
  54530. * @param newSnapPoint The new Snap-To point
  54531. */
  54532. addSnapPoint(newSnapPoint: Vector3): void;
  54533. attach(): boolean;
  54534. detach(): boolean;
  54535. dispose(): void;
  54536. /**
  54537. * Remove a mesh from the floor meshes array
  54538. * @param mesh the mesh to remove
  54539. */
  54540. removeFloorMesh(mesh: AbstractMesh): void;
  54541. /**
  54542. * Remove a mesh from the floor meshes array using its name
  54543. * @param name the mesh name to remove
  54544. */
  54545. removeFloorMeshByName(name: string): void;
  54546. /**
  54547. * 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
  54548. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54549. * @returns was the point found and removed or not
  54550. */
  54551. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54552. /**
  54553. * This function sets a selection feature that will be disabled when
  54554. * the forward ray is shown and will be reattached when hidden.
  54555. * This is used to remove the selection rays when moving.
  54556. * @param selectionFeature the feature to disable when forward movement is enabled
  54557. */
  54558. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54559. protected _onXRFrame(_xrFrame: XRFrame): void;
  54560. private _attachController;
  54561. private _createDefaultTargetMesh;
  54562. private _detachController;
  54563. private _findClosestSnapPointWithRadius;
  54564. private _setTargetMeshPosition;
  54565. private _setTargetMeshVisibility;
  54566. private _showParabolicPath;
  54567. private _teleportForward;
  54568. }
  54569. }
  54570. declare module "babylonjs/XR/webXRDefaultExperience" {
  54571. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54572. import { Scene } from "babylonjs/scene";
  54573. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54574. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54575. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54576. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54578. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54579. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54580. /**
  54581. * Options for the default xr helper
  54582. */
  54583. export class WebXRDefaultExperienceOptions {
  54584. /**
  54585. * Enable or disable default UI to enter XR
  54586. */
  54587. disableDefaultUI?: boolean;
  54588. /**
  54589. * Should teleportation not initialize. defaults to false.
  54590. */
  54591. disableTeleportation?: boolean;
  54592. /**
  54593. * Floor meshes that will be used for teleport
  54594. */
  54595. floorMeshes?: Array<AbstractMesh>;
  54596. /**
  54597. * If set to true, the first frame will not be used to reset position
  54598. * The first frame is mainly used when copying transformation from the old camera
  54599. * Mainly used in AR
  54600. */
  54601. ignoreNativeCameraTransformation?: boolean;
  54602. /**
  54603. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54604. */
  54605. inputOptions?: IWebXRInputOptions;
  54606. /**
  54607. * optional configuration for the output canvas
  54608. */
  54609. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54610. /**
  54611. * optional UI options. This can be used among other to change session mode and reference space type
  54612. */
  54613. uiOptions?: WebXREnterExitUIOptions;
  54614. /**
  54615. * When loading teleportation and pointer select, use stable versions instead of latest.
  54616. */
  54617. useStablePlugins?: boolean;
  54618. /**
  54619. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54620. */
  54621. renderingGroupId?: number;
  54622. /**
  54623. * A list of optional features to init the session with
  54624. * If set to true, all features we support will be added
  54625. */
  54626. optionalFeatures?: boolean | string[];
  54627. }
  54628. /**
  54629. * Default experience which provides a similar setup to the previous webVRExperience
  54630. */
  54631. export class WebXRDefaultExperience {
  54632. /**
  54633. * Base experience
  54634. */
  54635. baseExperience: WebXRExperienceHelper;
  54636. /**
  54637. * Enables ui for entering/exiting xr
  54638. */
  54639. enterExitUI: WebXREnterExitUI;
  54640. /**
  54641. * Input experience extension
  54642. */
  54643. input: WebXRInput;
  54644. /**
  54645. * Enables laser pointer and selection
  54646. */
  54647. pointerSelection: WebXRControllerPointerSelection;
  54648. /**
  54649. * Default target xr should render to
  54650. */
  54651. renderTarget: WebXRRenderTarget;
  54652. /**
  54653. * Enables teleportation
  54654. */
  54655. teleportation: WebXRMotionControllerTeleportation;
  54656. private constructor();
  54657. /**
  54658. * Creates the default xr experience
  54659. * @param scene scene
  54660. * @param options options for basic configuration
  54661. * @returns resulting WebXRDefaultExperience
  54662. */
  54663. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54664. /**
  54665. * DIsposes of the experience helper
  54666. */
  54667. dispose(): void;
  54668. }
  54669. }
  54670. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54671. import { Observable } from "babylonjs/Misc/observable";
  54672. import { Nullable } from "babylonjs/types";
  54673. import { Camera } from "babylonjs/Cameras/camera";
  54674. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54675. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54676. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54677. import { Scene } from "babylonjs/scene";
  54678. import { Vector3 } from "babylonjs/Maths/math.vector";
  54679. import { Color3 } from "babylonjs/Maths/math.color";
  54680. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54682. import { Mesh } from "babylonjs/Meshes/mesh";
  54683. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54684. import { EasingFunction } from "babylonjs/Animations/easing";
  54685. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54686. import "babylonjs/Meshes/Builders/groundBuilder";
  54687. import "babylonjs/Meshes/Builders/torusBuilder";
  54688. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54689. import "babylonjs/Gamepads/gamepadSceneComponent";
  54690. import "babylonjs/Animations/animatable";
  54691. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54692. /**
  54693. * Options to modify the vr teleportation behavior.
  54694. */
  54695. export interface VRTeleportationOptions {
  54696. /**
  54697. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54698. */
  54699. floorMeshName?: string;
  54700. /**
  54701. * A list of meshes to be used as the teleportation floor. (default: empty)
  54702. */
  54703. floorMeshes?: Mesh[];
  54704. /**
  54705. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54706. */
  54707. teleportationMode?: number;
  54708. /**
  54709. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54710. */
  54711. teleportationTime?: number;
  54712. /**
  54713. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54714. */
  54715. teleportationSpeed?: number;
  54716. /**
  54717. * The easing function used in the animation or null for Linear. (default CircleEase)
  54718. */
  54719. easingFunction?: EasingFunction;
  54720. }
  54721. /**
  54722. * Options to modify the vr experience helper's behavior.
  54723. */
  54724. export interface VRExperienceHelperOptions extends WebVROptions {
  54725. /**
  54726. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54727. */
  54728. createDeviceOrientationCamera?: boolean;
  54729. /**
  54730. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54731. */
  54732. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54733. /**
  54734. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54735. */
  54736. laserToggle?: boolean;
  54737. /**
  54738. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54739. */
  54740. floorMeshes?: Mesh[];
  54741. /**
  54742. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54743. */
  54744. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54745. /**
  54746. * Defines if WebXR should be used instead of WebVR (if available)
  54747. */
  54748. useXR?: boolean;
  54749. }
  54750. /**
  54751. * Event containing information after VR has been entered
  54752. */
  54753. export class OnAfterEnteringVRObservableEvent {
  54754. /**
  54755. * If entering vr was successful
  54756. */
  54757. success: boolean;
  54758. }
  54759. /**
  54760. * Helps to quickly add VR support to an existing scene.
  54761. * See https://doc.babylonjs.com/how_to/webvr_helper
  54762. */
  54763. export class VRExperienceHelper {
  54764. /** Options to modify the vr experience helper's behavior. */
  54765. webVROptions: VRExperienceHelperOptions;
  54766. private _scene;
  54767. private _position;
  54768. private _btnVR;
  54769. private _btnVRDisplayed;
  54770. private _webVRsupported;
  54771. private _webVRready;
  54772. private _webVRrequesting;
  54773. private _webVRpresenting;
  54774. private _hasEnteredVR;
  54775. private _fullscreenVRpresenting;
  54776. private _inputElement;
  54777. private _webVRCamera;
  54778. private _vrDeviceOrientationCamera;
  54779. private _deviceOrientationCamera;
  54780. private _existingCamera;
  54781. private _onKeyDown;
  54782. private _onVrDisplayPresentChange;
  54783. private _onVRDisplayChanged;
  54784. private _onVRRequestPresentStart;
  54785. private _onVRRequestPresentComplete;
  54786. /**
  54787. * 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)
  54788. */
  54789. enableGazeEvenWhenNoPointerLock: boolean;
  54790. /**
  54791. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54792. */
  54793. exitVROnDoubleTap: boolean;
  54794. /**
  54795. * Observable raised right before entering VR.
  54796. */
  54797. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54798. /**
  54799. * Observable raised when entering VR has completed.
  54800. */
  54801. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54802. /**
  54803. * Observable raised when exiting VR.
  54804. */
  54805. onExitingVRObservable: Observable<VRExperienceHelper>;
  54806. /**
  54807. * Observable raised when controller mesh is loaded.
  54808. */
  54809. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54810. /** Return this.onEnteringVRObservable
  54811. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54812. */
  54813. get onEnteringVR(): Observable<VRExperienceHelper>;
  54814. /** Return this.onExitingVRObservable
  54815. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54816. */
  54817. get onExitingVR(): Observable<VRExperienceHelper>;
  54818. /** Return this.onControllerMeshLoadedObservable
  54819. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54820. */
  54821. get onControllerMeshLoaded(): Observable<WebVRController>;
  54822. private _rayLength;
  54823. private _useCustomVRButton;
  54824. private _teleportationRequested;
  54825. private _teleportActive;
  54826. private _floorMeshName;
  54827. private _floorMeshesCollection;
  54828. private _teleportationMode;
  54829. private _teleportationTime;
  54830. private _teleportationSpeed;
  54831. private _teleportationEasing;
  54832. private _rotationAllowed;
  54833. private _teleportBackwardsVector;
  54834. private _teleportationTarget;
  54835. private _isDefaultTeleportationTarget;
  54836. private _postProcessMove;
  54837. private _teleportationFillColor;
  54838. private _teleportationBorderColor;
  54839. private _rotationAngle;
  54840. private _haloCenter;
  54841. private _cameraGazer;
  54842. private _padSensibilityUp;
  54843. private _padSensibilityDown;
  54844. private _leftController;
  54845. private _rightController;
  54846. private _gazeColor;
  54847. private _laserColor;
  54848. private _pickedLaserColor;
  54849. private _pickedGazeColor;
  54850. /**
  54851. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54852. */
  54853. onNewMeshSelected: Observable<AbstractMesh>;
  54854. /**
  54855. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54856. * This observable will provide the mesh and the controller used to select the mesh
  54857. */
  54858. onMeshSelectedWithController: Observable<{
  54859. mesh: AbstractMesh;
  54860. controller: WebVRController;
  54861. }>;
  54862. /**
  54863. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54864. */
  54865. onNewMeshPicked: Observable<PickingInfo>;
  54866. private _circleEase;
  54867. /**
  54868. * Observable raised before camera teleportation
  54869. */
  54870. onBeforeCameraTeleport: Observable<Vector3>;
  54871. /**
  54872. * Observable raised after camera teleportation
  54873. */
  54874. onAfterCameraTeleport: Observable<Vector3>;
  54875. /**
  54876. * Observable raised when current selected mesh gets unselected
  54877. */
  54878. onSelectedMeshUnselected: Observable<AbstractMesh>;
  54879. private _raySelectionPredicate;
  54880. /**
  54881. * To be optionaly changed by user to define custom ray selection
  54882. */
  54883. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54884. /**
  54885. * To be optionaly changed by user to define custom selection logic (after ray selection)
  54886. */
  54887. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54888. /**
  54889. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  54890. */
  54891. teleportationEnabled: boolean;
  54892. private _defaultHeight;
  54893. private _teleportationInitialized;
  54894. private _interactionsEnabled;
  54895. private _interactionsRequested;
  54896. private _displayGaze;
  54897. private _displayLaserPointer;
  54898. /**
  54899. * The mesh used to display where the user is going to teleport.
  54900. */
  54901. get teleportationTarget(): Mesh;
  54902. /**
  54903. * Sets the mesh to be used to display where the user is going to teleport.
  54904. */
  54905. set teleportationTarget(value: Mesh);
  54906. /**
  54907. * 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
  54908. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  54909. * See https://doc.babylonjs.com/resources/baking_transformations
  54910. */
  54911. get gazeTrackerMesh(): Mesh;
  54912. set gazeTrackerMesh(value: Mesh);
  54913. /**
  54914. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  54915. */
  54916. updateGazeTrackerScale: boolean;
  54917. /**
  54918. * If the gaze trackers color should be updated when selecting meshes
  54919. */
  54920. updateGazeTrackerColor: boolean;
  54921. /**
  54922. * If the controller laser color should be updated when selecting meshes
  54923. */
  54924. updateControllerLaserColor: boolean;
  54925. /**
  54926. * The gaze tracking mesh corresponding to the left controller
  54927. */
  54928. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  54929. /**
  54930. * The gaze tracking mesh corresponding to the right controller
  54931. */
  54932. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  54933. /**
  54934. * If the ray of the gaze should be displayed.
  54935. */
  54936. get displayGaze(): boolean;
  54937. /**
  54938. * Sets if the ray of the gaze should be displayed.
  54939. */
  54940. set displayGaze(value: boolean);
  54941. /**
  54942. * If the ray of the LaserPointer should be displayed.
  54943. */
  54944. get displayLaserPointer(): boolean;
  54945. /**
  54946. * Sets if the ray of the LaserPointer should be displayed.
  54947. */
  54948. set displayLaserPointer(value: boolean);
  54949. /**
  54950. * The deviceOrientationCamera used as the camera when not in VR.
  54951. */
  54952. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  54953. /**
  54954. * Based on the current WebVR support, returns the current VR camera used.
  54955. */
  54956. get currentVRCamera(): Nullable<Camera>;
  54957. /**
  54958. * The webVRCamera which is used when in VR.
  54959. */
  54960. get webVRCamera(): WebVRFreeCamera;
  54961. /**
  54962. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  54963. */
  54964. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  54965. /**
  54966. * The html button that is used to trigger entering into VR.
  54967. */
  54968. get vrButton(): Nullable<HTMLButtonElement>;
  54969. private get _teleportationRequestInitiated();
  54970. /**
  54971. * Defines whether or not Pointer lock should be requested when switching to
  54972. * full screen.
  54973. */
  54974. requestPointerLockOnFullScreen: boolean;
  54975. /**
  54976. * If asking to force XR, this will be populated with the default xr experience
  54977. */
  54978. xr: WebXRDefaultExperience;
  54979. /**
  54980. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  54981. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  54982. */
  54983. xrTestDone: boolean;
  54984. /**
  54985. * Instantiates a VRExperienceHelper.
  54986. * Helps to quickly add VR support to an existing scene.
  54987. * @param scene The scene the VRExperienceHelper belongs to.
  54988. * @param webVROptions Options to modify the vr experience helper's behavior.
  54989. */
  54990. constructor(scene: Scene,
  54991. /** Options to modify the vr experience helper's behavior. */
  54992. webVROptions?: VRExperienceHelperOptions);
  54993. private completeVRInit;
  54994. private _onDefaultMeshLoaded;
  54995. private _onResize;
  54996. private _onFullscreenChange;
  54997. /**
  54998. * Gets a value indicating if we are currently in VR mode.
  54999. */
  55000. get isInVRMode(): boolean;
  55001. private onVrDisplayPresentChange;
  55002. private onVRDisplayChanged;
  55003. private moveButtonToBottomRight;
  55004. private displayVRButton;
  55005. private updateButtonVisibility;
  55006. private _cachedAngularSensibility;
  55007. /**
  55008. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55009. * Otherwise, will use the fullscreen API.
  55010. */
  55011. enterVR(): void;
  55012. /**
  55013. * Attempt to exit VR, or fullscreen.
  55014. */
  55015. exitVR(): void;
  55016. /**
  55017. * The position of the vr experience helper.
  55018. */
  55019. get position(): Vector3;
  55020. /**
  55021. * Sets the position of the vr experience helper.
  55022. */
  55023. set position(value: Vector3);
  55024. /**
  55025. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55026. */
  55027. enableInteractions(): void;
  55028. private get _noControllerIsActive();
  55029. private beforeRender;
  55030. private _isTeleportationFloor;
  55031. /**
  55032. * Adds a floor mesh to be used for teleportation.
  55033. * @param floorMesh the mesh to be used for teleportation.
  55034. */
  55035. addFloorMesh(floorMesh: Mesh): void;
  55036. /**
  55037. * Removes a floor mesh from being used for teleportation.
  55038. * @param floorMesh the mesh to be removed.
  55039. */
  55040. removeFloorMesh(floorMesh: Mesh): void;
  55041. /**
  55042. * Enables interactions and teleportation using the VR controllers and gaze.
  55043. * @param vrTeleportationOptions options to modify teleportation behavior.
  55044. */
  55045. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55046. private _onNewGamepadConnected;
  55047. private _tryEnableInteractionOnController;
  55048. private _onNewGamepadDisconnected;
  55049. private _enableInteractionOnController;
  55050. private _checkTeleportWithRay;
  55051. private _checkRotate;
  55052. private _checkTeleportBackwards;
  55053. private _enableTeleportationOnController;
  55054. private _createTeleportationCircles;
  55055. private _displayTeleportationTarget;
  55056. private _hideTeleportationTarget;
  55057. private _rotateCamera;
  55058. private _moveTeleportationSelectorTo;
  55059. private _workingVector;
  55060. private _workingQuaternion;
  55061. private _workingMatrix;
  55062. /**
  55063. * Time Constant Teleportation Mode
  55064. */
  55065. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55066. /**
  55067. * Speed Constant Teleportation Mode
  55068. */
  55069. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55070. /**
  55071. * Teleports the users feet to the desired location
  55072. * @param location The location where the user's feet should be placed
  55073. */
  55074. teleportCamera(location: Vector3): void;
  55075. private _convertNormalToDirectionOfRay;
  55076. private _castRayAndSelectObject;
  55077. private _notifySelectedMeshUnselected;
  55078. /**
  55079. * Permanently set new colors for the laser pointer
  55080. * @param color the new laser color
  55081. * @param pickedColor the new laser color when picked mesh detected
  55082. */
  55083. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55084. /**
  55085. * Set lighting enabled / disabled on the laser pointer of both controllers
  55086. * @param enabled should the lighting be enabled on the laser pointer
  55087. */
  55088. setLaserLightingState(enabled?: boolean): void;
  55089. /**
  55090. * Permanently set new colors for the gaze pointer
  55091. * @param color the new gaze color
  55092. * @param pickedColor the new gaze color when picked mesh detected
  55093. */
  55094. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55095. /**
  55096. * Sets the color of the laser ray from the vr controllers.
  55097. * @param color new color for the ray.
  55098. */
  55099. changeLaserColor(color: Color3): void;
  55100. /**
  55101. * Sets the color of the ray from the vr headsets gaze.
  55102. * @param color new color for the ray.
  55103. */
  55104. changeGazeColor(color: Color3): void;
  55105. /**
  55106. * Exits VR and disposes of the vr experience helper
  55107. */
  55108. dispose(): void;
  55109. /**
  55110. * Gets the name of the VRExperienceHelper class
  55111. * @returns "VRExperienceHelper"
  55112. */
  55113. getClassName(): string;
  55114. }
  55115. }
  55116. declare module "babylonjs/Cameras/VR/index" {
  55117. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55118. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55119. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55120. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55121. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55122. export * from "babylonjs/Cameras/VR/webVRCamera";
  55123. }
  55124. declare module "babylonjs/Cameras/RigModes/index" {
  55125. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55126. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55127. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55128. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55129. }
  55130. declare module "babylonjs/Cameras/index" {
  55131. export * from "babylonjs/Cameras/Inputs/index";
  55132. export * from "babylonjs/Cameras/cameraInputsManager";
  55133. export * from "babylonjs/Cameras/camera";
  55134. export * from "babylonjs/Cameras/targetCamera";
  55135. export * from "babylonjs/Cameras/freeCamera";
  55136. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55137. export * from "babylonjs/Cameras/touchCamera";
  55138. export * from "babylonjs/Cameras/arcRotateCamera";
  55139. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55140. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55141. export * from "babylonjs/Cameras/flyCamera";
  55142. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55143. export * from "babylonjs/Cameras/followCamera";
  55144. export * from "babylonjs/Cameras/followCameraInputsManager";
  55145. export * from "babylonjs/Cameras/gamepadCamera";
  55146. export * from "babylonjs/Cameras/Stereoscopic/index";
  55147. export * from "babylonjs/Cameras/universalCamera";
  55148. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55149. export * from "babylonjs/Cameras/VR/index";
  55150. export * from "babylonjs/Cameras/RigModes/index";
  55151. }
  55152. declare module "babylonjs/Collisions/index" {
  55153. export * from "babylonjs/Collisions/collider";
  55154. export * from "babylonjs/Collisions/collisionCoordinator";
  55155. export * from "babylonjs/Collisions/pickingInfo";
  55156. export * from "babylonjs/Collisions/intersectionInfo";
  55157. export * from "babylonjs/Collisions/meshCollisionData";
  55158. }
  55159. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55160. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55161. import { Vector3 } from "babylonjs/Maths/math.vector";
  55162. import { Ray } from "babylonjs/Culling/ray";
  55163. import { Plane } from "babylonjs/Maths/math.plane";
  55164. /**
  55165. * Contains an array of blocks representing the octree
  55166. */
  55167. export interface IOctreeContainer<T> {
  55168. /**
  55169. * Blocks within the octree
  55170. */
  55171. blocks: Array<OctreeBlock<T>>;
  55172. }
  55173. /**
  55174. * Class used to store a cell in an octree
  55175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55176. */
  55177. export class OctreeBlock<T> {
  55178. /**
  55179. * Gets the content of the current block
  55180. */
  55181. entries: T[];
  55182. /**
  55183. * Gets the list of block children
  55184. */
  55185. blocks: Array<OctreeBlock<T>>;
  55186. private _depth;
  55187. private _maxDepth;
  55188. private _capacity;
  55189. private _minPoint;
  55190. private _maxPoint;
  55191. private _boundingVectors;
  55192. private _creationFunc;
  55193. /**
  55194. * Creates a new block
  55195. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55196. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55197. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55198. * @param depth defines the current depth of this block in the octree
  55199. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55200. * @param creationFunc defines a callback to call when an element is added to the block
  55201. */
  55202. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55203. /**
  55204. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55205. */
  55206. get capacity(): number;
  55207. /**
  55208. * Gets the minimum vector (in world space) of the block's bounding box
  55209. */
  55210. get minPoint(): Vector3;
  55211. /**
  55212. * Gets the maximum vector (in world space) of the block's bounding box
  55213. */
  55214. get maxPoint(): Vector3;
  55215. /**
  55216. * Add a new element to this block
  55217. * @param entry defines the element to add
  55218. */
  55219. addEntry(entry: T): void;
  55220. /**
  55221. * Remove an element from this block
  55222. * @param entry defines the element to remove
  55223. */
  55224. removeEntry(entry: T): void;
  55225. /**
  55226. * Add an array of elements to this block
  55227. * @param entries defines the array of elements to add
  55228. */
  55229. addEntries(entries: T[]): void;
  55230. /**
  55231. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55232. * @param frustumPlanes defines the frustum planes to test
  55233. * @param selection defines the array to store current content if selection is positive
  55234. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55235. */
  55236. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55237. /**
  55238. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55239. * @param sphereCenter defines the bounding sphere center
  55240. * @param sphereRadius defines the bounding sphere radius
  55241. * @param selection defines the array to store current content if selection is positive
  55242. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55243. */
  55244. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55245. /**
  55246. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55247. * @param ray defines the ray to test with
  55248. * @param selection defines the array to store current content if selection is positive
  55249. */
  55250. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55251. /**
  55252. * Subdivide the content into child blocks (this block will then be empty)
  55253. */
  55254. createInnerBlocks(): void;
  55255. /**
  55256. * @hidden
  55257. */
  55258. 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;
  55259. }
  55260. }
  55261. declare module "babylonjs/Culling/Octrees/octree" {
  55262. import { SmartArray } from "babylonjs/Misc/smartArray";
  55263. import { Vector3 } from "babylonjs/Maths/math.vector";
  55264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55266. import { Ray } from "babylonjs/Culling/ray";
  55267. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55268. import { Plane } from "babylonjs/Maths/math.plane";
  55269. /**
  55270. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55271. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55272. */
  55273. export class Octree<T> {
  55274. /** 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.) */
  55275. maxDepth: number;
  55276. /**
  55277. * Blocks within the octree containing objects
  55278. */
  55279. blocks: Array<OctreeBlock<T>>;
  55280. /**
  55281. * Content stored in the octree
  55282. */
  55283. dynamicContent: T[];
  55284. private _maxBlockCapacity;
  55285. private _selectionContent;
  55286. private _creationFunc;
  55287. /**
  55288. * Creates a octree
  55289. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55290. * @param creationFunc function to be used to instatiate the octree
  55291. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55292. * @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.)
  55293. */
  55294. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55295. /** 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.) */
  55296. maxDepth?: number);
  55297. /**
  55298. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55299. * @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);
  55300. * @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);
  55301. * @param entries meshes to be added to the octree blocks
  55302. */
  55303. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55304. /**
  55305. * Adds a mesh to the octree
  55306. * @param entry Mesh to add to the octree
  55307. */
  55308. addMesh(entry: T): void;
  55309. /**
  55310. * Remove an element from the octree
  55311. * @param entry defines the element to remove
  55312. */
  55313. removeMesh(entry: T): void;
  55314. /**
  55315. * Selects an array of meshes within the frustum
  55316. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55317. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55318. * @returns array of meshes within the frustum
  55319. */
  55320. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55321. /**
  55322. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55323. * @param sphereCenter defines the bounding sphere center
  55324. * @param sphereRadius defines the bounding sphere radius
  55325. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55326. * @returns an array of objects that intersect the sphere
  55327. */
  55328. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55329. /**
  55330. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55331. * @param ray defines the ray to test with
  55332. * @returns array of intersected objects
  55333. */
  55334. intersectsRay(ray: Ray): SmartArray<T>;
  55335. /**
  55336. * Adds a mesh into the octree block if it intersects the block
  55337. */
  55338. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55339. /**
  55340. * Adds a submesh into the octree block if it intersects the block
  55341. */
  55342. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55343. }
  55344. }
  55345. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55346. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55347. import { Scene } from "babylonjs/scene";
  55348. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55350. import { Ray } from "babylonjs/Culling/ray";
  55351. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55352. import { Collider } from "babylonjs/Collisions/collider";
  55353. module "babylonjs/scene" {
  55354. interface Scene {
  55355. /**
  55356. * @hidden
  55357. * Backing Filed
  55358. */
  55359. _selectionOctree: Octree<AbstractMesh>;
  55360. /**
  55361. * Gets the octree used to boost mesh selection (picking)
  55362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55363. */
  55364. selectionOctree: Octree<AbstractMesh>;
  55365. /**
  55366. * Creates or updates the octree used to boost selection (picking)
  55367. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55368. * @param maxCapacity defines the maximum capacity per leaf
  55369. * @param maxDepth defines the maximum depth of the octree
  55370. * @returns an octree of AbstractMesh
  55371. */
  55372. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55373. }
  55374. }
  55375. module "babylonjs/Meshes/abstractMesh" {
  55376. interface AbstractMesh {
  55377. /**
  55378. * @hidden
  55379. * Backing Field
  55380. */
  55381. _submeshesOctree: Octree<SubMesh>;
  55382. /**
  55383. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55384. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55385. * @param maxCapacity defines the maximum size of each block (64 by default)
  55386. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55387. * @returns the new octree
  55388. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55390. */
  55391. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55392. }
  55393. }
  55394. /**
  55395. * Defines the octree scene component responsible to manage any octrees
  55396. * in a given scene.
  55397. */
  55398. export class OctreeSceneComponent {
  55399. /**
  55400. * The component name help to identify the component in the list of scene components.
  55401. */
  55402. readonly name: string;
  55403. /**
  55404. * The scene the component belongs to.
  55405. */
  55406. scene: Scene;
  55407. /**
  55408. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55409. */
  55410. readonly checksIsEnabled: boolean;
  55411. /**
  55412. * Creates a new instance of the component for the given scene
  55413. * @param scene Defines the scene to register the component in
  55414. */
  55415. constructor(scene: Scene);
  55416. /**
  55417. * Registers the component in a given scene
  55418. */
  55419. register(): void;
  55420. /**
  55421. * Return the list of active meshes
  55422. * @returns the list of active meshes
  55423. */
  55424. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55425. /**
  55426. * Return the list of active sub meshes
  55427. * @param mesh The mesh to get the candidates sub meshes from
  55428. * @returns the list of active sub meshes
  55429. */
  55430. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55431. private _tempRay;
  55432. /**
  55433. * Return the list of sub meshes intersecting with a given local ray
  55434. * @param mesh defines the mesh to find the submesh for
  55435. * @param localRay defines the ray in local space
  55436. * @returns the list of intersecting sub meshes
  55437. */
  55438. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55439. /**
  55440. * Return the list of sub meshes colliding with a collider
  55441. * @param mesh defines the mesh to find the submesh for
  55442. * @param collider defines the collider to evaluate the collision against
  55443. * @returns the list of colliding sub meshes
  55444. */
  55445. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55446. /**
  55447. * Rebuilds the elements related to this component in case of
  55448. * context lost for instance.
  55449. */
  55450. rebuild(): void;
  55451. /**
  55452. * Disposes the component and the associated ressources.
  55453. */
  55454. dispose(): void;
  55455. }
  55456. }
  55457. declare module "babylonjs/Culling/Octrees/index" {
  55458. export * from "babylonjs/Culling/Octrees/octree";
  55459. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55460. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55461. }
  55462. declare module "babylonjs/Culling/index" {
  55463. export * from "babylonjs/Culling/boundingBox";
  55464. export * from "babylonjs/Culling/boundingInfo";
  55465. export * from "babylonjs/Culling/boundingSphere";
  55466. export * from "babylonjs/Culling/Octrees/index";
  55467. export * from "babylonjs/Culling/ray";
  55468. }
  55469. declare module "babylonjs/Gizmos/gizmo" {
  55470. import { Nullable } from "babylonjs/types";
  55471. import { IDisposable } from "babylonjs/scene";
  55472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55473. import { Mesh } from "babylonjs/Meshes/mesh";
  55474. import { Node } from "babylonjs/node";
  55475. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55476. /**
  55477. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55478. */
  55479. export class Gizmo implements IDisposable {
  55480. /** The utility layer the gizmo will be added to */
  55481. gizmoLayer: UtilityLayerRenderer;
  55482. /**
  55483. * The root mesh of the gizmo
  55484. */
  55485. _rootMesh: Mesh;
  55486. private _attachedMesh;
  55487. private _attachedNode;
  55488. /**
  55489. * Ratio for the scale of the gizmo (Default: 1)
  55490. */
  55491. protected _scaleRatio: number;
  55492. /**
  55493. * boolean updated by pointermove when a gizmo mesh is hovered
  55494. */
  55495. protected _isHovered: boolean;
  55496. /**
  55497. * Ratio for the scale of the gizmo (Default: 1)
  55498. */
  55499. set scaleRatio(value: number);
  55500. get scaleRatio(): number;
  55501. /**
  55502. * True when the mouse pointer is hovered a gizmo mesh
  55503. */
  55504. get isHovered(): boolean;
  55505. /**
  55506. * If a custom mesh has been set (Default: false)
  55507. */
  55508. protected _customMeshSet: boolean;
  55509. /**
  55510. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55511. * * When set, interactions will be enabled
  55512. */
  55513. get attachedMesh(): Nullable<AbstractMesh>;
  55514. set attachedMesh(value: Nullable<AbstractMesh>);
  55515. /**
  55516. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55517. * * When set, interactions will be enabled
  55518. */
  55519. get attachedNode(): Nullable<Node>;
  55520. set attachedNode(value: Nullable<Node>);
  55521. /**
  55522. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55523. * @param mesh The mesh to replace the default mesh of the gizmo
  55524. */
  55525. setCustomMesh(mesh: Mesh): void;
  55526. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55527. /**
  55528. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55529. */
  55530. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55531. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55532. /**
  55533. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55534. */
  55535. updateGizmoPositionToMatchAttachedMesh: boolean;
  55536. /**
  55537. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55538. */
  55539. updateScale: boolean;
  55540. protected _interactionsEnabled: boolean;
  55541. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55542. private _beforeRenderObserver;
  55543. private _tempQuaternion;
  55544. private _tempVector;
  55545. private _tempVector2;
  55546. private _tempMatrix1;
  55547. private _tempMatrix2;
  55548. private _rightHandtoLeftHandMatrix;
  55549. /**
  55550. * Creates a gizmo
  55551. * @param gizmoLayer The utility layer the gizmo will be added to
  55552. */
  55553. constructor(
  55554. /** The utility layer the gizmo will be added to */
  55555. gizmoLayer?: UtilityLayerRenderer);
  55556. /**
  55557. * Updates the gizmo to match the attached mesh's position/rotation
  55558. */
  55559. protected _update(): void;
  55560. /**
  55561. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55562. * @param value Node, TransformNode or mesh
  55563. */
  55564. protected _matrixChanged(): void;
  55565. /**
  55566. * Disposes of the gizmo
  55567. */
  55568. dispose(): void;
  55569. }
  55570. }
  55571. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55572. import { Observable } from "babylonjs/Misc/observable";
  55573. import { Nullable } from "babylonjs/types";
  55574. import { Vector3 } from "babylonjs/Maths/math.vector";
  55575. import { Color3 } from "babylonjs/Maths/math.color";
  55576. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55577. import { Node } from "babylonjs/node";
  55578. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55579. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55580. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55581. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55582. import { Scene } from "babylonjs/scene";
  55583. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55584. /**
  55585. * Single plane drag gizmo
  55586. */
  55587. export class PlaneDragGizmo extends Gizmo {
  55588. /**
  55589. * Drag behavior responsible for the gizmos dragging interactions
  55590. */
  55591. dragBehavior: PointerDragBehavior;
  55592. private _pointerObserver;
  55593. /**
  55594. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55595. */
  55596. snapDistance: number;
  55597. /**
  55598. * Event that fires each time the gizmo snaps to a new location.
  55599. * * snapDistance is the the change in distance
  55600. */
  55601. onSnapObservable: Observable<{
  55602. snapDistance: number;
  55603. }>;
  55604. private _plane;
  55605. private _coloredMaterial;
  55606. private _hoverMaterial;
  55607. private _isEnabled;
  55608. private _parent;
  55609. /** @hidden */
  55610. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55611. /** @hidden */
  55612. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55613. /**
  55614. * Creates a PlaneDragGizmo
  55615. * @param gizmoLayer The utility layer the gizmo will be added to
  55616. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55617. * @param color The color of the gizmo
  55618. */
  55619. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55620. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55621. /**
  55622. * If the gizmo is enabled
  55623. */
  55624. set isEnabled(value: boolean);
  55625. get isEnabled(): boolean;
  55626. /**
  55627. * Disposes of the gizmo
  55628. */
  55629. dispose(): void;
  55630. }
  55631. }
  55632. declare module "babylonjs/Gizmos/positionGizmo" {
  55633. import { Observable } from "babylonjs/Misc/observable";
  55634. import { Nullable } from "babylonjs/types";
  55635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55636. import { Node } from "babylonjs/node";
  55637. import { Mesh } from "babylonjs/Meshes/mesh";
  55638. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55639. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55640. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55642. /**
  55643. * Gizmo that enables dragging a mesh along 3 axis
  55644. */
  55645. export class PositionGizmo extends Gizmo {
  55646. /**
  55647. * Internal gizmo used for interactions on the x axis
  55648. */
  55649. xGizmo: AxisDragGizmo;
  55650. /**
  55651. * Internal gizmo used for interactions on the y axis
  55652. */
  55653. yGizmo: AxisDragGizmo;
  55654. /**
  55655. * Internal gizmo used for interactions on the z axis
  55656. */
  55657. zGizmo: AxisDragGizmo;
  55658. /**
  55659. * Internal gizmo used for interactions on the yz plane
  55660. */
  55661. xPlaneGizmo: PlaneDragGizmo;
  55662. /**
  55663. * Internal gizmo used for interactions on the xz plane
  55664. */
  55665. yPlaneGizmo: PlaneDragGizmo;
  55666. /**
  55667. * Internal gizmo used for interactions on the xy plane
  55668. */
  55669. zPlaneGizmo: PlaneDragGizmo;
  55670. /**
  55671. * private variables
  55672. */
  55673. private _meshAttached;
  55674. private _nodeAttached;
  55675. private _snapDistance;
  55676. /** Fires an event when any of it's sub gizmos are dragged */
  55677. onDragStartObservable: Observable<unknown>;
  55678. /** Fires an event when any of it's sub gizmos are released from dragging */
  55679. onDragEndObservable: Observable<unknown>;
  55680. /**
  55681. * If set to true, planar drag is enabled
  55682. */
  55683. private _planarGizmoEnabled;
  55684. get attachedMesh(): Nullable<AbstractMesh>;
  55685. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55686. get attachedNode(): Nullable<Node>;
  55687. set attachedNode(node: Nullable<Node>);
  55688. /**
  55689. * True when the mouse pointer is hovering a gizmo mesh
  55690. */
  55691. get isHovered(): boolean;
  55692. /**
  55693. * Creates a PositionGizmo
  55694. * @param gizmoLayer The utility layer the gizmo will be added to
  55695. @param thickness display gizmo axis thickness
  55696. */
  55697. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55698. /**
  55699. * If the planar drag gizmo is enabled
  55700. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55701. */
  55702. set planarGizmoEnabled(value: boolean);
  55703. get planarGizmoEnabled(): boolean;
  55704. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55705. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55706. /**
  55707. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55708. */
  55709. set snapDistance(value: number);
  55710. get snapDistance(): number;
  55711. /**
  55712. * Ratio for the scale of the gizmo (Default: 1)
  55713. */
  55714. set scaleRatio(value: number);
  55715. get scaleRatio(): number;
  55716. /**
  55717. * Disposes of the gizmo
  55718. */
  55719. dispose(): void;
  55720. /**
  55721. * CustomMeshes are not supported by this gizmo
  55722. * @param mesh The mesh to replace the default mesh of the gizmo
  55723. */
  55724. setCustomMesh(mesh: Mesh): void;
  55725. }
  55726. }
  55727. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55728. import { Observable } from "babylonjs/Misc/observable";
  55729. import { Nullable } from "babylonjs/types";
  55730. import { Vector3 } from "babylonjs/Maths/math.vector";
  55731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55732. import { Node } from "babylonjs/node";
  55733. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55734. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55735. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55736. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55737. import { Scene } from "babylonjs/scene";
  55738. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55739. import { Color3 } from "babylonjs/Maths/math.color";
  55740. /**
  55741. * Single axis drag gizmo
  55742. */
  55743. export class AxisDragGizmo extends Gizmo {
  55744. /**
  55745. * Drag behavior responsible for the gizmos dragging interactions
  55746. */
  55747. dragBehavior: PointerDragBehavior;
  55748. private _pointerObserver;
  55749. /**
  55750. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55751. */
  55752. snapDistance: number;
  55753. /**
  55754. * Event that fires each time the gizmo snaps to a new location.
  55755. * * snapDistance is the the change in distance
  55756. */
  55757. onSnapObservable: Observable<{
  55758. snapDistance: number;
  55759. }>;
  55760. private _isEnabled;
  55761. private _parent;
  55762. private _arrow;
  55763. private _coloredMaterial;
  55764. private _hoverMaterial;
  55765. /** @hidden */
  55766. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55767. /** @hidden */
  55768. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55769. /**
  55770. * Creates an AxisDragGizmo
  55771. * @param gizmoLayer The utility layer the gizmo will be added to
  55772. * @param dragAxis The axis which the gizmo will be able to drag on
  55773. * @param color The color of the gizmo
  55774. * @param thickness display gizmo axis thickness
  55775. */
  55776. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55777. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55778. /**
  55779. * If the gizmo is enabled
  55780. */
  55781. set isEnabled(value: boolean);
  55782. get isEnabled(): boolean;
  55783. /**
  55784. * Disposes of the gizmo
  55785. */
  55786. dispose(): void;
  55787. }
  55788. }
  55789. declare module "babylonjs/Debug/axesViewer" {
  55790. import { Vector3 } from "babylonjs/Maths/math.vector";
  55791. import { Nullable } from "babylonjs/types";
  55792. import { Scene } from "babylonjs/scene";
  55793. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55794. /**
  55795. * The Axes viewer will show 3 axes in a specific point in space
  55796. */
  55797. export class AxesViewer {
  55798. private _xAxis;
  55799. private _yAxis;
  55800. private _zAxis;
  55801. private _scaleLinesFactor;
  55802. private _instanced;
  55803. /**
  55804. * Gets the hosting scene
  55805. */
  55806. scene: Nullable<Scene>;
  55807. /**
  55808. * Gets or sets a number used to scale line length
  55809. */
  55810. scaleLines: number;
  55811. /** Gets the node hierarchy used to render x-axis */
  55812. get xAxis(): TransformNode;
  55813. /** Gets the node hierarchy used to render y-axis */
  55814. get yAxis(): TransformNode;
  55815. /** Gets the node hierarchy used to render z-axis */
  55816. get zAxis(): TransformNode;
  55817. /**
  55818. * Creates a new AxesViewer
  55819. * @param scene defines the hosting scene
  55820. * @param scaleLines defines a number used to scale line length (1 by default)
  55821. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55822. * @param xAxis defines the node hierarchy used to render the x-axis
  55823. * @param yAxis defines the node hierarchy used to render the y-axis
  55824. * @param zAxis defines the node hierarchy used to render the z-axis
  55825. */
  55826. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55827. /**
  55828. * Force the viewer to update
  55829. * @param position defines the position of the viewer
  55830. * @param xaxis defines the x axis of the viewer
  55831. * @param yaxis defines the y axis of the viewer
  55832. * @param zaxis defines the z axis of the viewer
  55833. */
  55834. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55835. /**
  55836. * Creates an instance of this axes viewer.
  55837. * @returns a new axes viewer with instanced meshes
  55838. */
  55839. createInstance(): AxesViewer;
  55840. /** Releases resources */
  55841. dispose(): void;
  55842. private static _SetRenderingGroupId;
  55843. }
  55844. }
  55845. declare module "babylonjs/Debug/boneAxesViewer" {
  55846. import { Nullable } from "babylonjs/types";
  55847. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55848. import { Vector3 } from "babylonjs/Maths/math.vector";
  55849. import { Mesh } from "babylonjs/Meshes/mesh";
  55850. import { Bone } from "babylonjs/Bones/bone";
  55851. import { Scene } from "babylonjs/scene";
  55852. /**
  55853. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55854. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55855. */
  55856. export class BoneAxesViewer extends AxesViewer {
  55857. /**
  55858. * Gets or sets the target mesh where to display the axes viewer
  55859. */
  55860. mesh: Nullable<Mesh>;
  55861. /**
  55862. * Gets or sets the target bone where to display the axes viewer
  55863. */
  55864. bone: Nullable<Bone>;
  55865. /** Gets current position */
  55866. pos: Vector3;
  55867. /** Gets direction of X axis */
  55868. xaxis: Vector3;
  55869. /** Gets direction of Y axis */
  55870. yaxis: Vector3;
  55871. /** Gets direction of Z axis */
  55872. zaxis: Vector3;
  55873. /**
  55874. * Creates a new BoneAxesViewer
  55875. * @param scene defines the hosting scene
  55876. * @param bone defines the target bone
  55877. * @param mesh defines the target mesh
  55878. * @param scaleLines defines a scaling factor for line length (1 by default)
  55879. */
  55880. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55881. /**
  55882. * Force the viewer to update
  55883. */
  55884. update(): void;
  55885. /** Releases resources */
  55886. dispose(): void;
  55887. }
  55888. }
  55889. declare module "babylonjs/Debug/debugLayer" {
  55890. import { Scene } from "babylonjs/scene";
  55891. /**
  55892. * Interface used to define scene explorer extensibility option
  55893. */
  55894. export interface IExplorerExtensibilityOption {
  55895. /**
  55896. * Define the option label
  55897. */
  55898. label: string;
  55899. /**
  55900. * Defines the action to execute on click
  55901. */
  55902. action: (entity: any) => void;
  55903. }
  55904. /**
  55905. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55906. */
  55907. export interface IExplorerExtensibilityGroup {
  55908. /**
  55909. * Defines a predicate to test if a given type mut be extended
  55910. */
  55911. predicate: (entity: any) => boolean;
  55912. /**
  55913. * Gets the list of options added to a type
  55914. */
  55915. entries: IExplorerExtensibilityOption[];
  55916. }
  55917. /**
  55918. * Interface used to define the options to use to create the Inspector
  55919. */
  55920. export interface IInspectorOptions {
  55921. /**
  55922. * Display in overlay mode (default: false)
  55923. */
  55924. overlay?: boolean;
  55925. /**
  55926. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55927. */
  55928. globalRoot?: HTMLElement;
  55929. /**
  55930. * Display the Scene explorer
  55931. */
  55932. showExplorer?: boolean;
  55933. /**
  55934. * Display the property inspector
  55935. */
  55936. showInspector?: boolean;
  55937. /**
  55938. * Display in embed mode (both panes on the right)
  55939. */
  55940. embedMode?: boolean;
  55941. /**
  55942. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55943. */
  55944. handleResize?: boolean;
  55945. /**
  55946. * Allow the panes to popup (default: true)
  55947. */
  55948. enablePopup?: boolean;
  55949. /**
  55950. * Allow the panes to be closed by users (default: true)
  55951. */
  55952. enableClose?: boolean;
  55953. /**
  55954. * Optional list of extensibility entries
  55955. */
  55956. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55957. /**
  55958. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55959. */
  55960. inspectorURL?: string;
  55961. /**
  55962. * Optional initial tab (default to DebugLayerTab.Properties)
  55963. */
  55964. initialTab?: DebugLayerTab;
  55965. }
  55966. module "babylonjs/scene" {
  55967. interface Scene {
  55968. /**
  55969. * @hidden
  55970. * Backing field
  55971. */
  55972. _debugLayer: DebugLayer;
  55973. /**
  55974. * Gets the debug layer (aka Inspector) associated with the scene
  55975. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55976. */
  55977. debugLayer: DebugLayer;
  55978. }
  55979. }
  55980. /**
  55981. * Enum of inspector action tab
  55982. */
  55983. export enum DebugLayerTab {
  55984. /**
  55985. * Properties tag (default)
  55986. */
  55987. Properties = 0,
  55988. /**
  55989. * Debug tab
  55990. */
  55991. Debug = 1,
  55992. /**
  55993. * Statistics tab
  55994. */
  55995. Statistics = 2,
  55996. /**
  55997. * Tools tab
  55998. */
  55999. Tools = 3,
  56000. /**
  56001. * Settings tab
  56002. */
  56003. Settings = 4
  56004. }
  56005. /**
  56006. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56007. * what is happening in your scene
  56008. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56009. */
  56010. export class DebugLayer {
  56011. /**
  56012. * Define the url to get the inspector script from.
  56013. * By default it uses the babylonjs CDN.
  56014. * @ignoreNaming
  56015. */
  56016. static InspectorURL: string;
  56017. private _scene;
  56018. private BJSINSPECTOR;
  56019. private _onPropertyChangedObservable?;
  56020. /**
  56021. * Observable triggered when a property is changed through the inspector.
  56022. */
  56023. get onPropertyChangedObservable(): any;
  56024. /**
  56025. * Instantiates a new debug layer.
  56026. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56027. * what is happening in your scene
  56028. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56029. * @param scene Defines the scene to inspect
  56030. */
  56031. constructor(scene: Scene);
  56032. /** Creates the inspector window. */
  56033. private _createInspector;
  56034. /**
  56035. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56036. * @param entity defines the entity to select
  56037. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56038. */
  56039. select(entity: any, lineContainerTitles?: string | string[]): void;
  56040. /** Get the inspector from bundle or global */
  56041. private _getGlobalInspector;
  56042. /**
  56043. * Get if the inspector is visible or not.
  56044. * @returns true if visible otherwise, false
  56045. */
  56046. isVisible(): boolean;
  56047. /**
  56048. * Hide the inspector and close its window.
  56049. */
  56050. hide(): void;
  56051. /**
  56052. * Update the scene in the inspector
  56053. */
  56054. setAsActiveScene(): void;
  56055. /**
  56056. * Launch the debugLayer.
  56057. * @param config Define the configuration of the inspector
  56058. * @return a promise fulfilled when the debug layer is visible
  56059. */
  56060. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56061. }
  56062. }
  56063. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56064. import { Nullable } from "babylonjs/types";
  56065. import { Scene } from "babylonjs/scene";
  56066. import { Vector4 } from "babylonjs/Maths/math.vector";
  56067. import { Color4 } from "babylonjs/Maths/math.color";
  56068. import { Mesh } from "babylonjs/Meshes/mesh";
  56069. /**
  56070. * Class containing static functions to help procedurally build meshes
  56071. */
  56072. export class BoxBuilder {
  56073. /**
  56074. * Creates a box mesh
  56075. * * The parameter `size` sets the size (float) of each box side (default 1)
  56076. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56077. * * 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)
  56078. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56082. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56083. * @param name defines the name of the mesh
  56084. * @param options defines the options used to create the mesh
  56085. * @param scene defines the hosting scene
  56086. * @returns the box mesh
  56087. */
  56088. static CreateBox(name: string, options: {
  56089. size?: number;
  56090. width?: number;
  56091. height?: number;
  56092. depth?: number;
  56093. faceUV?: Vector4[];
  56094. faceColors?: Color4[];
  56095. sideOrientation?: number;
  56096. frontUVs?: Vector4;
  56097. backUVs?: Vector4;
  56098. wrap?: boolean;
  56099. topBaseAt?: number;
  56100. bottomBaseAt?: number;
  56101. updatable?: boolean;
  56102. }, scene?: Nullable<Scene>): Mesh;
  56103. }
  56104. }
  56105. declare module "babylonjs/Debug/physicsViewer" {
  56106. import { Nullable } from "babylonjs/types";
  56107. import { Scene } from "babylonjs/scene";
  56108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56109. import { Mesh } from "babylonjs/Meshes/mesh";
  56110. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56111. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56112. /**
  56113. * Used to show the physics impostor around the specific mesh
  56114. */
  56115. export class PhysicsViewer {
  56116. /** @hidden */
  56117. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56118. /** @hidden */
  56119. protected _meshes: Array<Nullable<AbstractMesh>>;
  56120. /** @hidden */
  56121. protected _scene: Nullable<Scene>;
  56122. /** @hidden */
  56123. protected _numMeshes: number;
  56124. /** @hidden */
  56125. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56126. private _renderFunction;
  56127. private _utilityLayer;
  56128. private _debugBoxMesh;
  56129. private _debugSphereMesh;
  56130. private _debugCylinderMesh;
  56131. private _debugMaterial;
  56132. private _debugMeshMeshes;
  56133. /**
  56134. * Creates a new PhysicsViewer
  56135. * @param scene defines the hosting scene
  56136. */
  56137. constructor(scene: Scene);
  56138. /** @hidden */
  56139. protected _updateDebugMeshes(): void;
  56140. /**
  56141. * Renders a specified physic impostor
  56142. * @param impostor defines the impostor to render
  56143. * @param targetMesh defines the mesh represented by the impostor
  56144. * @returns the new debug mesh used to render the impostor
  56145. */
  56146. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56147. /**
  56148. * Hides a specified physic impostor
  56149. * @param impostor defines the impostor to hide
  56150. */
  56151. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56152. private _getDebugMaterial;
  56153. private _getDebugBoxMesh;
  56154. private _getDebugSphereMesh;
  56155. private _getDebugCylinderMesh;
  56156. private _getDebugMeshMesh;
  56157. private _getDebugMesh;
  56158. /** Releases all resources */
  56159. dispose(): void;
  56160. }
  56161. }
  56162. declare module "babylonjs/Debug/rayHelper" {
  56163. import { Nullable } from "babylonjs/types";
  56164. import { Ray } from "babylonjs/Culling/ray";
  56165. import { Vector3 } from "babylonjs/Maths/math.vector";
  56166. import { Color3 } from "babylonjs/Maths/math.color";
  56167. import { Scene } from "babylonjs/scene";
  56168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56169. import "babylonjs/Meshes/Builders/linesBuilder";
  56170. /**
  56171. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56172. * in order to better appreciate the issue one might have.
  56173. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56174. */
  56175. export class RayHelper {
  56176. /**
  56177. * Defines the ray we are currently tryin to visualize.
  56178. */
  56179. ray: Nullable<Ray>;
  56180. private _renderPoints;
  56181. private _renderLine;
  56182. private _renderFunction;
  56183. private _scene;
  56184. private _onAfterRenderObserver;
  56185. private _onAfterStepObserver;
  56186. private _attachedToMesh;
  56187. private _meshSpaceDirection;
  56188. private _meshSpaceOrigin;
  56189. /**
  56190. * Helper function to create a colored helper in a scene in one line.
  56191. * @param ray Defines the ray we are currently tryin to visualize
  56192. * @param scene Defines the scene the ray is used in
  56193. * @param color Defines the color we want to see the ray in
  56194. * @returns The newly created ray helper.
  56195. */
  56196. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56197. /**
  56198. * Instantiate a new ray helper.
  56199. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56200. * in order to better appreciate the issue one might have.
  56201. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56202. * @param ray Defines the ray we are currently tryin to visualize
  56203. */
  56204. constructor(ray: Ray);
  56205. /**
  56206. * Shows the ray we are willing to debug.
  56207. * @param scene Defines the scene the ray needs to be rendered in
  56208. * @param color Defines the color the ray needs to be rendered in
  56209. */
  56210. show(scene: Scene, color?: Color3): void;
  56211. /**
  56212. * Hides the ray we are debugging.
  56213. */
  56214. hide(): void;
  56215. private _render;
  56216. /**
  56217. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56218. * @param mesh Defines the mesh we want the helper attached to
  56219. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56220. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56221. * @param length Defines the length of the ray
  56222. */
  56223. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56224. /**
  56225. * Detach the ray helper from the mesh it has previously been attached to.
  56226. */
  56227. detachFromMesh(): void;
  56228. private _updateToMesh;
  56229. /**
  56230. * Dispose the helper and release its associated resources.
  56231. */
  56232. dispose(): void;
  56233. }
  56234. }
  56235. declare module "babylonjs/Debug/ISkeletonViewer" {
  56236. import { Skeleton } from "babylonjs/Bones/skeleton";
  56237. import { Color3 } from "babylonjs/Maths/math.color";
  56238. /**
  56239. * Defines the options associated with the creation of a SkeletonViewer.
  56240. */
  56241. export interface ISkeletonViewerOptions {
  56242. /** Should the system pause animations before building the Viewer? */
  56243. pauseAnimations: boolean;
  56244. /** Should the system return the skeleton to rest before building? */
  56245. returnToRest: boolean;
  56246. /** public Display Mode of the Viewer */
  56247. displayMode: number;
  56248. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56249. displayOptions: ISkeletonViewerDisplayOptions;
  56250. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56251. computeBonesUsingShaders: boolean;
  56252. /** Flag ignore non weighted bones */
  56253. useAllBones: boolean;
  56254. }
  56255. /**
  56256. * Defines how to display the various bone meshes for the viewer.
  56257. */
  56258. export interface ISkeletonViewerDisplayOptions {
  56259. /** How far down to start tapering the bone spurs */
  56260. midStep?: number;
  56261. /** How big is the midStep? */
  56262. midStepFactor?: number;
  56263. /** Base for the Sphere Size */
  56264. sphereBaseSize?: number;
  56265. /** The ratio of the sphere to the longest bone in units */
  56266. sphereScaleUnit?: number;
  56267. /** Ratio for the Sphere Size */
  56268. sphereFactor?: number;
  56269. /** Whether a spur should attach its far end to the child bone position */
  56270. spurFollowsChild?: boolean;
  56271. /** Whether to show local axes or not */
  56272. showLocalAxes?: boolean;
  56273. /** Length of each local axis */
  56274. localAxesSize?: number;
  56275. }
  56276. /**
  56277. * Defines the constructor options for the BoneWeight Shader.
  56278. */
  56279. export interface IBoneWeightShaderOptions {
  56280. /** Skeleton to Map */
  56281. skeleton: Skeleton;
  56282. /** Colors for Uninfluenced bones */
  56283. colorBase?: Color3;
  56284. /** Colors for 0.0-0.25 Weight bones */
  56285. colorZero?: Color3;
  56286. /** Color for 0.25-0.5 Weight Influence */
  56287. colorQuarter?: Color3;
  56288. /** Color for 0.5-0.75 Weight Influence */
  56289. colorHalf?: Color3;
  56290. /** Color for 0.75-1 Weight Influence */
  56291. colorFull?: Color3;
  56292. /** Color for Zero Weight Influence */
  56293. targetBoneIndex?: number;
  56294. }
  56295. /**
  56296. * Simple structure of the gradient steps for the Color Map.
  56297. */
  56298. export interface ISkeletonMapShaderColorMapKnot {
  56299. /** Color of the Knot */
  56300. color: Color3;
  56301. /** Location of the Knot */
  56302. location: number;
  56303. }
  56304. /**
  56305. * Defines the constructor options for the SkeletonMap Shader.
  56306. */
  56307. export interface ISkeletonMapShaderOptions {
  56308. /** Skeleton to Map */
  56309. skeleton: Skeleton;
  56310. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56311. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56312. }
  56313. }
  56314. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56315. import { Nullable } from "babylonjs/types";
  56316. import { Scene } from "babylonjs/scene";
  56317. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56318. import { Color4 } from "babylonjs/Maths/math.color";
  56319. import { Mesh } from "babylonjs/Meshes/mesh";
  56320. /**
  56321. * Class containing static functions to help procedurally build meshes
  56322. */
  56323. export class RibbonBuilder {
  56324. /**
  56325. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56326. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56327. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56328. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56329. * * 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
  56330. * * 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
  56331. * * 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
  56332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56335. * * 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
  56336. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56337. * * 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
  56338. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56340. * @param name defines the name of the mesh
  56341. * @param options defines the options used to create the mesh
  56342. * @param scene defines the hosting scene
  56343. * @returns the ribbon mesh
  56344. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56346. */
  56347. static CreateRibbon(name: string, options: {
  56348. pathArray: Vector3[][];
  56349. closeArray?: boolean;
  56350. closePath?: boolean;
  56351. offset?: number;
  56352. updatable?: boolean;
  56353. sideOrientation?: number;
  56354. frontUVs?: Vector4;
  56355. backUVs?: Vector4;
  56356. instance?: Mesh;
  56357. invertUV?: boolean;
  56358. uvs?: Vector2[];
  56359. colors?: Color4[];
  56360. }, scene?: Nullable<Scene>): Mesh;
  56361. }
  56362. }
  56363. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56364. import { Nullable } from "babylonjs/types";
  56365. import { Scene } from "babylonjs/scene";
  56366. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56367. import { Mesh } from "babylonjs/Meshes/mesh";
  56368. /**
  56369. * Class containing static functions to help procedurally build meshes
  56370. */
  56371. export class ShapeBuilder {
  56372. /**
  56373. * 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.
  56374. * * 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.
  56375. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56376. * * 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.
  56377. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56378. * * 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
  56379. * * 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
  56380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56385. * @param name defines the name of the mesh
  56386. * @param options defines the options used to create the mesh
  56387. * @param scene defines the hosting scene
  56388. * @returns the extruded shape mesh
  56389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56391. */
  56392. static ExtrudeShape(name: string, options: {
  56393. shape: Vector3[];
  56394. path: Vector3[];
  56395. scale?: number;
  56396. rotation?: number;
  56397. cap?: number;
  56398. updatable?: boolean;
  56399. sideOrientation?: number;
  56400. frontUVs?: Vector4;
  56401. backUVs?: Vector4;
  56402. instance?: Mesh;
  56403. invertUV?: boolean;
  56404. }, scene?: Nullable<Scene>): Mesh;
  56405. /**
  56406. * Creates an custom extruded shape mesh.
  56407. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56408. * * 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.
  56409. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56410. * * 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
  56411. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56412. * * 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
  56413. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56414. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56415. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56416. * * 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
  56417. * * 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
  56418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56423. * @param name defines the name of the mesh
  56424. * @param options defines the options used to create the mesh
  56425. * @param scene defines the hosting scene
  56426. * @returns the custom extruded shape mesh
  56427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56430. */
  56431. static ExtrudeShapeCustom(name: string, options: {
  56432. shape: Vector3[];
  56433. path: Vector3[];
  56434. scaleFunction?: any;
  56435. rotationFunction?: any;
  56436. ribbonCloseArray?: boolean;
  56437. ribbonClosePath?: boolean;
  56438. cap?: number;
  56439. updatable?: boolean;
  56440. sideOrientation?: number;
  56441. frontUVs?: Vector4;
  56442. backUVs?: Vector4;
  56443. instance?: Mesh;
  56444. invertUV?: boolean;
  56445. }, scene?: Nullable<Scene>): Mesh;
  56446. private static _ExtrudeShapeGeneric;
  56447. }
  56448. }
  56449. declare module "babylonjs/Debug/skeletonViewer" {
  56450. import { Color3 } from "babylonjs/Maths/math.color";
  56451. import { Scene } from "babylonjs/scene";
  56452. import { Nullable } from "babylonjs/types";
  56453. import { Skeleton } from "babylonjs/Bones/skeleton";
  56454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56455. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56456. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56457. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56458. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56459. /**
  56460. * Class used to render a debug view of a given skeleton
  56461. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56462. */
  56463. export class SkeletonViewer {
  56464. /** defines the skeleton to render */
  56465. skeleton: Skeleton;
  56466. /** defines the mesh attached to the skeleton */
  56467. mesh: AbstractMesh;
  56468. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56469. autoUpdateBonesMatrices: boolean;
  56470. /** defines the rendering group id to use with the viewer */
  56471. renderingGroupId: number;
  56472. /** is the options for the viewer */
  56473. options: Partial<ISkeletonViewerOptions>;
  56474. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56475. static readonly DISPLAY_LINES: number;
  56476. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56477. static readonly DISPLAY_SPHERES: number;
  56478. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56479. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56480. /** public static method to create a BoneWeight Shader
  56481. * @param options The constructor options
  56482. * @param scene The scene that the shader is scoped to
  56483. * @returns The created ShaderMaterial
  56484. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56485. */
  56486. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56487. /** public static method to create a BoneWeight Shader
  56488. * @param options The constructor options
  56489. * @param scene The scene that the shader is scoped to
  56490. * @returns The created ShaderMaterial
  56491. */
  56492. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56493. /** private static method to create a BoneWeight Shader
  56494. * @param size The size of the buffer to create (usually the bone count)
  56495. * @param colorMap The gradient data to generate
  56496. * @param scene The scene that the shader is scoped to
  56497. * @returns an Array of floats from the color gradient values
  56498. */
  56499. private static _CreateBoneMapColorBuffer;
  56500. /** If SkeletonViewer scene scope. */
  56501. private _scene;
  56502. /** Gets or sets the color used to render the skeleton */
  56503. color: Color3;
  56504. /** Array of the points of the skeleton fo the line view. */
  56505. private _debugLines;
  56506. /** The SkeletonViewers Mesh. */
  56507. private _debugMesh;
  56508. /** The local axes Meshes. */
  56509. private _localAxes;
  56510. /** If SkeletonViewer is enabled. */
  56511. private _isEnabled;
  56512. /** If SkeletonViewer is ready. */
  56513. private _ready;
  56514. /** SkeletonViewer render observable. */
  56515. private _obs;
  56516. /** The Utility Layer to render the gizmos in. */
  56517. private _utilityLayer;
  56518. private _boneIndices;
  56519. /** Gets the Scene. */
  56520. get scene(): Scene;
  56521. /** Gets the utilityLayer. */
  56522. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56523. /** Checks Ready Status. */
  56524. get isReady(): Boolean;
  56525. /** Sets Ready Status. */
  56526. set ready(value: boolean);
  56527. /** Gets the debugMesh */
  56528. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56529. /** Sets the debugMesh */
  56530. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56531. /** Gets the displayMode */
  56532. get displayMode(): number;
  56533. /** Sets the displayMode */
  56534. set displayMode(value: number);
  56535. /**
  56536. * Creates a new SkeletonViewer
  56537. * @param skeleton defines the skeleton to render
  56538. * @param mesh defines the mesh attached to the skeleton
  56539. * @param scene defines the hosting scene
  56540. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56541. * @param renderingGroupId defines the rendering group id to use with the viewer
  56542. * @param options All of the extra constructor options for the SkeletonViewer
  56543. */
  56544. constructor(
  56545. /** defines the skeleton to render */
  56546. skeleton: Skeleton,
  56547. /** defines the mesh attached to the skeleton */
  56548. mesh: AbstractMesh,
  56549. /** The Scene scope*/
  56550. scene: Scene,
  56551. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56552. autoUpdateBonesMatrices?: boolean,
  56553. /** defines the rendering group id to use with the viewer */
  56554. renderingGroupId?: number,
  56555. /** is the options for the viewer */
  56556. options?: Partial<ISkeletonViewerOptions>);
  56557. /** The Dynamic bindings for the update functions */
  56558. private _bindObs;
  56559. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56560. update(): void;
  56561. /** Gets or sets a boolean indicating if the viewer is enabled */
  56562. set isEnabled(value: boolean);
  56563. get isEnabled(): boolean;
  56564. private _getBonePosition;
  56565. private _getLinesForBonesWithLength;
  56566. private _getLinesForBonesNoLength;
  56567. /** function to revert the mesh and scene back to the initial state. */
  56568. private _revert;
  56569. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56570. private _getAbsoluteBindPoseToRef;
  56571. /** function to build and bind sphere joint points and spur bone representations. */
  56572. private _buildSpheresAndSpurs;
  56573. private _buildLocalAxes;
  56574. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56575. private _displayLinesUpdate;
  56576. /** Changes the displayMode of the skeleton viewer
  56577. * @param mode The displayMode numerical value
  56578. */
  56579. changeDisplayMode(mode: number): void;
  56580. /** Sets a display option of the skeleton viewer
  56581. *
  56582. * | Option | Type | Default | Description |
  56583. * | ---------------- | ------- | ------- | ----------- |
  56584. * | 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`. |
  56585. * | 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`. |
  56586. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56587. * | 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`. |
  56588. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56589. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56590. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56591. *
  56592. * @param option String of the option name
  56593. * @param value The numerical option value
  56594. */
  56595. changeDisplayOptions(option: string, value: number): void;
  56596. /** Release associated resources */
  56597. dispose(): void;
  56598. }
  56599. }
  56600. declare module "babylonjs/Debug/index" {
  56601. export * from "babylonjs/Debug/axesViewer";
  56602. export * from "babylonjs/Debug/boneAxesViewer";
  56603. export * from "babylonjs/Debug/debugLayer";
  56604. export * from "babylonjs/Debug/physicsViewer";
  56605. export * from "babylonjs/Debug/rayHelper";
  56606. export * from "babylonjs/Debug/skeletonViewer";
  56607. export * from "babylonjs/Debug/ISkeletonViewer";
  56608. }
  56609. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56610. /**
  56611. * Enum for Device Types
  56612. */
  56613. export enum DeviceType {
  56614. /** Generic */
  56615. Generic = 0,
  56616. /** Keyboard */
  56617. Keyboard = 1,
  56618. /** Mouse */
  56619. Mouse = 2,
  56620. /** Touch Pointers */
  56621. Touch = 3,
  56622. /** PS4 Dual Shock */
  56623. DualShock = 4,
  56624. /** Xbox */
  56625. Xbox = 5,
  56626. /** Switch Controller */
  56627. Switch = 6
  56628. }
  56629. /**
  56630. * Enum for All Pointers (Touch/Mouse)
  56631. */
  56632. export enum PointerInput {
  56633. /** Horizontal Axis */
  56634. Horizontal = 0,
  56635. /** Vertical Axis */
  56636. Vertical = 1,
  56637. /** Left Click or Touch */
  56638. LeftClick = 2,
  56639. /** Middle Click */
  56640. MiddleClick = 3,
  56641. /** Right Click */
  56642. RightClick = 4,
  56643. /** Browser Back */
  56644. BrowserBack = 5,
  56645. /** Browser Forward */
  56646. BrowserForward = 6
  56647. }
  56648. /**
  56649. * Enum for Dual Shock Gamepad
  56650. */
  56651. export enum DualShockInput {
  56652. /** Cross */
  56653. Cross = 0,
  56654. /** Circle */
  56655. Circle = 1,
  56656. /** Square */
  56657. Square = 2,
  56658. /** Triangle */
  56659. Triangle = 3,
  56660. /** L1 */
  56661. L1 = 4,
  56662. /** R1 */
  56663. R1 = 5,
  56664. /** L2 */
  56665. L2 = 6,
  56666. /** R2 */
  56667. R2 = 7,
  56668. /** Share */
  56669. Share = 8,
  56670. /** Options */
  56671. Options = 9,
  56672. /** L3 */
  56673. L3 = 10,
  56674. /** R3 */
  56675. R3 = 11,
  56676. /** DPadUp */
  56677. DPadUp = 12,
  56678. /** DPadDown */
  56679. DPadDown = 13,
  56680. /** DPadLeft */
  56681. DPadLeft = 14,
  56682. /** DRight */
  56683. DPadRight = 15,
  56684. /** Home */
  56685. Home = 16,
  56686. /** TouchPad */
  56687. TouchPad = 17,
  56688. /** LStickXAxis */
  56689. LStickXAxis = 18,
  56690. /** LStickYAxis */
  56691. LStickYAxis = 19,
  56692. /** RStickXAxis */
  56693. RStickXAxis = 20,
  56694. /** RStickYAxis */
  56695. RStickYAxis = 21
  56696. }
  56697. /**
  56698. * Enum for Xbox Gamepad
  56699. */
  56700. export enum XboxInput {
  56701. /** A */
  56702. A = 0,
  56703. /** B */
  56704. B = 1,
  56705. /** X */
  56706. X = 2,
  56707. /** Y */
  56708. Y = 3,
  56709. /** LB */
  56710. LB = 4,
  56711. /** RB */
  56712. RB = 5,
  56713. /** LT */
  56714. LT = 6,
  56715. /** RT */
  56716. RT = 7,
  56717. /** Back */
  56718. Back = 8,
  56719. /** Start */
  56720. Start = 9,
  56721. /** LS */
  56722. LS = 10,
  56723. /** RS */
  56724. RS = 11,
  56725. /** DPadUp */
  56726. DPadUp = 12,
  56727. /** DPadDown */
  56728. DPadDown = 13,
  56729. /** DPadLeft */
  56730. DPadLeft = 14,
  56731. /** DRight */
  56732. DPadRight = 15,
  56733. /** Home */
  56734. Home = 16,
  56735. /** LStickXAxis */
  56736. LStickXAxis = 17,
  56737. /** LStickYAxis */
  56738. LStickYAxis = 18,
  56739. /** RStickXAxis */
  56740. RStickXAxis = 19,
  56741. /** RStickYAxis */
  56742. RStickYAxis = 20
  56743. }
  56744. /**
  56745. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56746. */
  56747. export enum SwitchInput {
  56748. /** B */
  56749. B = 0,
  56750. /** A */
  56751. A = 1,
  56752. /** Y */
  56753. Y = 2,
  56754. /** X */
  56755. X = 3,
  56756. /** L */
  56757. L = 4,
  56758. /** R */
  56759. R = 5,
  56760. /** ZL */
  56761. ZL = 6,
  56762. /** ZR */
  56763. ZR = 7,
  56764. /** Minus */
  56765. Minus = 8,
  56766. /** Plus */
  56767. Plus = 9,
  56768. /** LS */
  56769. LS = 10,
  56770. /** RS */
  56771. RS = 11,
  56772. /** DPadUp */
  56773. DPadUp = 12,
  56774. /** DPadDown */
  56775. DPadDown = 13,
  56776. /** DPadLeft */
  56777. DPadLeft = 14,
  56778. /** DRight */
  56779. DPadRight = 15,
  56780. /** Home */
  56781. Home = 16,
  56782. /** Capture */
  56783. Capture = 17,
  56784. /** LStickXAxis */
  56785. LStickXAxis = 18,
  56786. /** LStickYAxis */
  56787. LStickYAxis = 19,
  56788. /** RStickXAxis */
  56789. RStickXAxis = 20,
  56790. /** RStickYAxis */
  56791. RStickYAxis = 21
  56792. }
  56793. }
  56794. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56795. import { Engine } from "babylonjs/Engines/engine";
  56796. import { IDisposable } from "babylonjs/scene";
  56797. import { Nullable } from "babylonjs/types";
  56798. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56799. /**
  56800. * This class will take all inputs from Keyboard, Pointer, and
  56801. * any Gamepads and provide a polling system that all devices
  56802. * will use. This class assumes that there will only be one
  56803. * pointer device and one keyboard.
  56804. */
  56805. export class DeviceInputSystem implements IDisposable {
  56806. /**
  56807. * Callback to be triggered when a device is connected
  56808. */
  56809. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56810. /**
  56811. * Callback to be triggered when a device is disconnected
  56812. */
  56813. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56814. /**
  56815. * Callback to be triggered when event driven input is updated
  56816. */
  56817. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56818. private _inputs;
  56819. private _gamepads;
  56820. private _keyboardActive;
  56821. private _pointerActive;
  56822. private _elementToAttachTo;
  56823. private _keyboardDownEvent;
  56824. private _keyboardUpEvent;
  56825. private _pointerMoveEvent;
  56826. private _pointerDownEvent;
  56827. private _pointerUpEvent;
  56828. private _gamepadConnectedEvent;
  56829. private _gamepadDisconnectedEvent;
  56830. private static _MAX_KEYCODES;
  56831. private static _MAX_POINTER_INPUTS;
  56832. private constructor();
  56833. /**
  56834. * Creates a new DeviceInputSystem instance
  56835. * @param engine Engine to pull input element from
  56836. * @returns The new instance
  56837. */
  56838. static Create(engine: Engine): DeviceInputSystem;
  56839. /**
  56840. * Checks for current device input value, given an id and input index
  56841. * @param deviceName Id of connected device
  56842. * @param inputIndex Index of device input
  56843. * @returns Current value of input
  56844. */
  56845. /**
  56846. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56847. * @param deviceType Enum specifiying device type
  56848. * @param deviceSlot "Slot" or index that device is referenced in
  56849. * @param inputIndex Id of input to be checked
  56850. * @returns Current value of input
  56851. */
  56852. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56853. /**
  56854. * Dispose of all the eventlisteners
  56855. */
  56856. dispose(): void;
  56857. /**
  56858. * Add device and inputs to device array
  56859. * @param deviceType Enum specifiying device type
  56860. * @param deviceSlot "Slot" or index that device is referenced in
  56861. * @param numberOfInputs Number of input entries to create for given device
  56862. */
  56863. private _registerDevice;
  56864. /**
  56865. * Given a specific device name, remove that device from the device map
  56866. * @param deviceType Enum specifiying device type
  56867. * @param deviceSlot "Slot" or index that device is referenced in
  56868. */
  56869. private _unregisterDevice;
  56870. /**
  56871. * Handle all actions that come from keyboard interaction
  56872. */
  56873. private _handleKeyActions;
  56874. /**
  56875. * Handle all actions that come from pointer interaction
  56876. */
  56877. private _handlePointerActions;
  56878. /**
  56879. * Handle all actions that come from gamepad interaction
  56880. */
  56881. private _handleGamepadActions;
  56882. /**
  56883. * Update all non-event based devices with each frame
  56884. * @param deviceType Enum specifiying device type
  56885. * @param deviceSlot "Slot" or index that device is referenced in
  56886. * @param inputIndex Id of input to be checked
  56887. */
  56888. private _updateDevice;
  56889. /**
  56890. * Gets DeviceType from the device name
  56891. * @param deviceName Name of Device from DeviceInputSystem
  56892. * @returns DeviceType enum value
  56893. */
  56894. private _getGamepadDeviceType;
  56895. }
  56896. }
  56897. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  56898. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56899. /**
  56900. * Type to handle enforcement of inputs
  56901. */
  56902. 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;
  56903. }
  56904. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  56905. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  56906. import { Engine } from "babylonjs/Engines/engine";
  56907. import { IDisposable } from "babylonjs/scene";
  56908. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56909. import { Nullable } from "babylonjs/types";
  56910. import { Observable } from "babylonjs/Misc/observable";
  56911. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  56912. /**
  56913. * Class that handles all input for a specific device
  56914. */
  56915. export class DeviceSource<T extends DeviceType> {
  56916. /** Type of device */
  56917. readonly deviceType: DeviceType;
  56918. /** "Slot" or index that device is referenced in */
  56919. readonly deviceSlot: number;
  56920. /**
  56921. * Observable to handle device input changes per device
  56922. */
  56923. readonly onInputChangedObservable: Observable<{
  56924. inputIndex: DeviceInput<T>;
  56925. previousState: Nullable<number>;
  56926. currentState: Nullable<number>;
  56927. }>;
  56928. private readonly _deviceInputSystem;
  56929. /**
  56930. * Default Constructor
  56931. * @param deviceInputSystem Reference to DeviceInputSystem
  56932. * @param deviceType Type of device
  56933. * @param deviceSlot "Slot" or index that device is referenced in
  56934. */
  56935. constructor(deviceInputSystem: DeviceInputSystem,
  56936. /** Type of device */
  56937. deviceType: DeviceType,
  56938. /** "Slot" or index that device is referenced in */
  56939. deviceSlot?: number);
  56940. /**
  56941. * Get input for specific input
  56942. * @param inputIndex index of specific input on device
  56943. * @returns Input value from DeviceInputSystem
  56944. */
  56945. getInput(inputIndex: DeviceInput<T>): number;
  56946. }
  56947. /**
  56948. * Class to keep track of devices
  56949. */
  56950. export class DeviceSourceManager implements IDisposable {
  56951. /**
  56952. * Observable to be triggered when before a device is connected
  56953. */
  56954. readonly onBeforeDeviceConnectedObservable: Observable<{
  56955. deviceType: DeviceType;
  56956. deviceSlot: number;
  56957. }>;
  56958. /**
  56959. * Observable to be triggered when before a device is disconnected
  56960. */
  56961. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  56962. deviceType: DeviceType;
  56963. deviceSlot: number;
  56964. }>;
  56965. /**
  56966. * Observable to be triggered when after a device is connected
  56967. */
  56968. readonly onAfterDeviceConnectedObservable: Observable<{
  56969. deviceType: DeviceType;
  56970. deviceSlot: number;
  56971. }>;
  56972. /**
  56973. * Observable to be triggered when after a device is disconnected
  56974. */
  56975. readonly onAfterDeviceDisconnectedObservable: Observable<{
  56976. deviceType: DeviceType;
  56977. deviceSlot: number;
  56978. }>;
  56979. private readonly _devices;
  56980. private readonly _firstDevice;
  56981. private readonly _deviceInputSystem;
  56982. /**
  56983. * Default Constructor
  56984. * @param engine engine to pull input element from
  56985. */
  56986. constructor(engine: Engine);
  56987. /**
  56988. * Gets a DeviceSource, given a type and slot
  56989. * @param deviceType Enum specifying device type
  56990. * @param deviceSlot "Slot" or index that device is referenced in
  56991. * @returns DeviceSource object
  56992. */
  56993. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56994. /**
  56995. * Gets an array of DeviceSource objects for a given device type
  56996. * @param deviceType Enum specifying device type
  56997. * @returns Array of DeviceSource objects
  56998. */
  56999. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57000. /**
  57001. * Dispose of DeviceInputSystem and other parts
  57002. */
  57003. dispose(): void;
  57004. /**
  57005. * Function to add device name to device list
  57006. * @param deviceType Enum specifying device type
  57007. * @param deviceSlot "Slot" or index that device is referenced in
  57008. */
  57009. private _addDevice;
  57010. /**
  57011. * Function to remove device name to device list
  57012. * @param deviceType Enum specifying device type
  57013. * @param deviceSlot "Slot" or index that device is referenced in
  57014. */
  57015. private _removeDevice;
  57016. /**
  57017. * Updates array storing first connected device of each type
  57018. * @param type Type of Device
  57019. */
  57020. private _updateFirstDevices;
  57021. }
  57022. }
  57023. declare module "babylonjs/DeviceInput/index" {
  57024. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57025. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57026. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57027. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57028. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57029. }
  57030. declare module "babylonjs/Engines/nullEngine" {
  57031. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57032. import { Engine } from "babylonjs/Engines/engine";
  57033. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57034. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57036. import { Effect } from "babylonjs/Materials/effect";
  57037. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57038. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57039. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57040. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57041. /**
  57042. * Options to create the null engine
  57043. */
  57044. export class NullEngineOptions {
  57045. /**
  57046. * Render width (Default: 512)
  57047. */
  57048. renderWidth: number;
  57049. /**
  57050. * Render height (Default: 256)
  57051. */
  57052. renderHeight: number;
  57053. /**
  57054. * Texture size (Default: 512)
  57055. */
  57056. textureSize: number;
  57057. /**
  57058. * If delta time between frames should be constant
  57059. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57060. */
  57061. deterministicLockstep: boolean;
  57062. /**
  57063. * Maximum about of steps between frames (Default: 4)
  57064. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57065. */
  57066. lockstepMaxSteps: number;
  57067. /**
  57068. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57069. */
  57070. useHighPrecisionMatrix?: boolean;
  57071. }
  57072. /**
  57073. * The null engine class provides support for headless version of babylon.js.
  57074. * This can be used in server side scenario or for testing purposes
  57075. */
  57076. export class NullEngine extends Engine {
  57077. private _options;
  57078. /**
  57079. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57081. * @returns true if engine is in deterministic lock step mode
  57082. */
  57083. isDeterministicLockStep(): boolean;
  57084. /**
  57085. * Gets the max steps when engine is running in deterministic lock step
  57086. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57087. * @returns the max steps
  57088. */
  57089. getLockstepMaxSteps(): number;
  57090. /**
  57091. * Gets the current hardware scaling level.
  57092. * By default the hardware scaling level is computed from the window device ratio.
  57093. * 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.
  57094. * @returns a number indicating the current hardware scaling level
  57095. */
  57096. getHardwareScalingLevel(): number;
  57097. constructor(options?: NullEngineOptions);
  57098. /**
  57099. * Creates a vertex buffer
  57100. * @param vertices the data for the vertex buffer
  57101. * @returns the new WebGL static buffer
  57102. */
  57103. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57104. /**
  57105. * Creates a new index buffer
  57106. * @param indices defines the content of the index buffer
  57107. * @param updatable defines if the index buffer must be updatable
  57108. * @returns a new webGL buffer
  57109. */
  57110. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57111. /**
  57112. * Clear the current render buffer or the current render target (if any is set up)
  57113. * @param color defines the color to use
  57114. * @param backBuffer defines if the back buffer must be cleared
  57115. * @param depth defines if the depth buffer must be cleared
  57116. * @param stencil defines if the stencil buffer must be cleared
  57117. */
  57118. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57119. /**
  57120. * Gets the current render width
  57121. * @param useScreen defines if screen size must be used (or the current render target if any)
  57122. * @returns a number defining the current render width
  57123. */
  57124. getRenderWidth(useScreen?: boolean): number;
  57125. /**
  57126. * Gets the current render height
  57127. * @param useScreen defines if screen size must be used (or the current render target if any)
  57128. * @returns a number defining the current render height
  57129. */
  57130. getRenderHeight(useScreen?: boolean): number;
  57131. /**
  57132. * Set the WebGL's viewport
  57133. * @param viewport defines the viewport element to be used
  57134. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57135. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57136. */
  57137. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57138. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57139. /**
  57140. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57141. * @param pipelineContext defines the pipeline context to use
  57142. * @param uniformsNames defines the list of uniform names
  57143. * @returns an array of webGL uniform locations
  57144. */
  57145. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57146. /**
  57147. * Gets the lsit of active attributes for a given webGL program
  57148. * @param pipelineContext defines the pipeline context to use
  57149. * @param attributesNames defines the list of attribute names to get
  57150. * @returns an array of indices indicating the offset of each attribute
  57151. */
  57152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57153. /**
  57154. * Binds an effect to the webGL context
  57155. * @param effect defines the effect to bind
  57156. */
  57157. bindSamplers(effect: Effect): void;
  57158. /**
  57159. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57160. * @param effect defines the effect to activate
  57161. */
  57162. enableEffect(effect: Effect): void;
  57163. /**
  57164. * Set various states to the webGL context
  57165. * @param culling defines backface culling state
  57166. * @param zOffset defines the value to apply to zOffset (0 by default)
  57167. * @param force defines if states must be applied even if cache is up to date
  57168. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57169. */
  57170. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57171. /**
  57172. * Set the value of an uniform to an array of int32
  57173. * @param uniform defines the webGL uniform location where to store the value
  57174. * @param array defines the array of int32 to store
  57175. * @returns true if value was set
  57176. */
  57177. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57178. /**
  57179. * Set the value of an uniform to an array of int32 (stored as vec2)
  57180. * @param uniform defines the webGL uniform location where to store the value
  57181. * @param array defines the array of int32 to store
  57182. * @returns true if value was set
  57183. */
  57184. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57185. /**
  57186. * Set the value of an uniform to an array of int32 (stored as vec3)
  57187. * @param uniform defines the webGL uniform location where to store the value
  57188. * @param array defines the array of int32 to store
  57189. * @returns true if value was set
  57190. */
  57191. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57192. /**
  57193. * Set the value of an uniform to an array of int32 (stored as vec4)
  57194. * @param uniform defines the webGL uniform location where to store the value
  57195. * @param array defines the array of int32 to store
  57196. * @returns true if value was set
  57197. */
  57198. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57199. /**
  57200. * Set the value of an uniform to an array of float32
  57201. * @param uniform defines the webGL uniform location where to store the value
  57202. * @param array defines the array of float32 to store
  57203. * @returns true if value was set
  57204. */
  57205. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57206. /**
  57207. * Set the value of an uniform to an array of float32 (stored as vec2)
  57208. * @param uniform defines the webGL uniform location where to store the value
  57209. * @param array defines the array of float32 to store
  57210. * @returns true if value was set
  57211. */
  57212. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57213. /**
  57214. * Set the value of an uniform to an array of float32 (stored as vec3)
  57215. * @param uniform defines the webGL uniform location where to store the value
  57216. * @param array defines the array of float32 to store
  57217. * @returns true if value was set
  57218. */
  57219. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57220. /**
  57221. * Set the value of an uniform to an array of float32 (stored as vec4)
  57222. * @param uniform defines the webGL uniform location where to store the value
  57223. * @param array defines the array of float32 to store
  57224. * @returns true if value was set
  57225. */
  57226. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57227. /**
  57228. * Set the value of an uniform to an array of number
  57229. * @param uniform defines the webGL uniform location where to store the value
  57230. * @param array defines the array of number to store
  57231. * @returns true if value was set
  57232. */
  57233. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57234. /**
  57235. * Set the value of an uniform to an array of number (stored as vec2)
  57236. * @param uniform defines the webGL uniform location where to store the value
  57237. * @param array defines the array of number to store
  57238. * @returns true if value was set
  57239. */
  57240. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57241. /**
  57242. * Set the value of an uniform to an array of number (stored as vec3)
  57243. * @param uniform defines the webGL uniform location where to store the value
  57244. * @param array defines the array of number to store
  57245. * @returns true if value was set
  57246. */
  57247. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57248. /**
  57249. * Set the value of an uniform to an array of number (stored as vec4)
  57250. * @param uniform defines the webGL uniform location where to store the value
  57251. * @param array defines the array of number to store
  57252. * @returns true if value was set
  57253. */
  57254. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57255. /**
  57256. * Set the value of an uniform to an array of float32 (stored as matrices)
  57257. * @param uniform defines the webGL uniform location where to store the value
  57258. * @param matrices defines the array of float32 to store
  57259. * @returns true if value was set
  57260. */
  57261. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57262. /**
  57263. * Set the value of an uniform to a matrix (3x3)
  57264. * @param uniform defines the webGL uniform location where to store the value
  57265. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57266. * @returns true if value was set
  57267. */
  57268. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57269. /**
  57270. * Set the value of an uniform to a matrix (2x2)
  57271. * @param uniform defines the webGL uniform location where to store the value
  57272. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57273. * @returns true if value was set
  57274. */
  57275. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57276. /**
  57277. * Set the value of an uniform to a number (float)
  57278. * @param uniform defines the webGL uniform location where to store the value
  57279. * @param value defines the float number to store
  57280. * @returns true if value was set
  57281. */
  57282. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57283. /**
  57284. * Set the value of an uniform to a vec2
  57285. * @param uniform defines the webGL uniform location where to store the value
  57286. * @param x defines the 1st component of the value
  57287. * @param y defines the 2nd component of the value
  57288. * @returns true if value was set
  57289. */
  57290. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57291. /**
  57292. * Set the value of an uniform to a vec3
  57293. * @param uniform defines the webGL uniform location where to store the value
  57294. * @param x defines the 1st component of the value
  57295. * @param y defines the 2nd component of the value
  57296. * @param z defines the 3rd component of the value
  57297. * @returns true if value was set
  57298. */
  57299. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57300. /**
  57301. * Set the value of an uniform to a boolean
  57302. * @param uniform defines the webGL uniform location where to store the value
  57303. * @param bool defines the boolean to store
  57304. * @returns true if value was set
  57305. */
  57306. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57307. /**
  57308. * Set the value of an uniform to a vec4
  57309. * @param uniform defines the webGL uniform location where to store the value
  57310. * @param x defines the 1st component of the value
  57311. * @param y defines the 2nd component of the value
  57312. * @param z defines the 3rd component of the value
  57313. * @param w defines the 4th component of the value
  57314. * @returns true if value was set
  57315. */
  57316. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57317. /**
  57318. * Sets the current alpha mode
  57319. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57320. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57321. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57322. */
  57323. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57324. /**
  57325. * Bind webGl buffers directly to the webGL context
  57326. * @param vertexBuffers defines the vertex buffer to bind
  57327. * @param indexBuffer defines the index buffer to bind
  57328. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57329. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57330. * @param effect defines the effect associated with the vertex buffer
  57331. */
  57332. bindBuffers(vertexBuffers: {
  57333. [key: string]: VertexBuffer;
  57334. }, indexBuffer: DataBuffer, effect: Effect): void;
  57335. /**
  57336. * Force the entire cache to be cleared
  57337. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57338. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57339. */
  57340. wipeCaches(bruteForce?: boolean): void;
  57341. /**
  57342. * Send a draw order
  57343. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57344. * @param indexStart defines the starting index
  57345. * @param indexCount defines the number of index to draw
  57346. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57347. */
  57348. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57349. /**
  57350. * Draw a list of indexed primitives
  57351. * @param fillMode defines the primitive to use
  57352. * @param indexStart defines the starting index
  57353. * @param indexCount defines the number of index to draw
  57354. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57355. */
  57356. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57357. /**
  57358. * Draw a list of unindexed primitives
  57359. * @param fillMode defines the primitive to use
  57360. * @param verticesStart defines the index of first vertex to draw
  57361. * @param verticesCount defines the count of vertices to draw
  57362. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57363. */
  57364. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57365. /** @hidden */
  57366. _createTexture(): WebGLTexture;
  57367. /** @hidden */
  57368. _releaseTexture(texture: InternalTexture): void;
  57369. /**
  57370. * Usually called from Texture.ts.
  57371. * Passed information to create a WebGLTexture
  57372. * @param urlArg defines a value which contains one of the following:
  57373. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57374. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57375. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57376. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57377. * @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)
  57378. * @param scene needed for loading to the correct scene
  57379. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57380. * @param onLoad optional callback to be called upon successful completion
  57381. * @param onError optional callback to be called upon failure
  57382. * @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
  57383. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57384. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57385. * @param forcedExtension defines the extension to use to pick the right loader
  57386. * @param mimeType defines an optional mime type
  57387. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57388. */
  57389. 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;
  57390. /**
  57391. * Creates a new render target texture
  57392. * @param size defines the size of the texture
  57393. * @param options defines the options used to create the texture
  57394. * @returns a new render target texture stored in an InternalTexture
  57395. */
  57396. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57397. /**
  57398. * Update the sampling mode of a given texture
  57399. * @param samplingMode defines the required sampling mode
  57400. * @param texture defines the texture to update
  57401. */
  57402. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57403. /**
  57404. * Binds the frame buffer to the specified texture.
  57405. * @param texture The texture to render to or null for the default canvas
  57406. * @param faceIndex The face of the texture to render to in case of cube texture
  57407. * @param requiredWidth The width of the target to render to
  57408. * @param requiredHeight The height of the target to render to
  57409. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57410. * @param lodLevel defines le lod level to bind to the frame buffer
  57411. */
  57412. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57413. /**
  57414. * Unbind the current render target texture from the webGL context
  57415. * @param texture defines the render target texture to unbind
  57416. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57417. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57418. */
  57419. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57420. /**
  57421. * Creates a dynamic vertex buffer
  57422. * @param vertices the data for the dynamic vertex buffer
  57423. * @returns the new WebGL dynamic buffer
  57424. */
  57425. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57426. /**
  57427. * Update the content of a dynamic texture
  57428. * @param texture defines the texture to update
  57429. * @param canvas defines the canvas containing the source
  57430. * @param invertY defines if data must be stored with Y axis inverted
  57431. * @param premulAlpha defines if alpha is stored as premultiplied
  57432. * @param format defines the format of the data
  57433. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57434. */
  57435. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57436. /**
  57437. * Gets a boolean indicating if all created effects are ready
  57438. * @returns true if all effects are ready
  57439. */
  57440. areAllEffectsReady(): boolean;
  57441. /**
  57442. * @hidden
  57443. * Get the current error code of the webGL context
  57444. * @returns the error code
  57445. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57446. */
  57447. getError(): number;
  57448. /** @hidden */
  57449. _getUnpackAlignement(): number;
  57450. /** @hidden */
  57451. _unpackFlipY(value: boolean): void;
  57452. /**
  57453. * Update a dynamic index buffer
  57454. * @param indexBuffer defines the target index buffer
  57455. * @param indices defines the data to update
  57456. * @param offset defines the offset in the target index buffer where update should start
  57457. */
  57458. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57459. /**
  57460. * Updates a dynamic vertex buffer.
  57461. * @param vertexBuffer the vertex buffer to update
  57462. * @param vertices the data used to update the vertex buffer
  57463. * @param byteOffset the byte offset of the data (optional)
  57464. * @param byteLength the byte length of the data (optional)
  57465. */
  57466. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57467. /** @hidden */
  57468. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57469. /** @hidden */
  57470. _bindTexture(channel: number, texture: InternalTexture): void;
  57471. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57472. /**
  57473. * 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
  57474. */
  57475. releaseEffects(): void;
  57476. displayLoadingUI(): void;
  57477. hideLoadingUI(): void;
  57478. /** @hidden */
  57479. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57480. /** @hidden */
  57481. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57482. /** @hidden */
  57483. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57484. /** @hidden */
  57485. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57486. }
  57487. }
  57488. declare module "babylonjs/Instrumentation/timeToken" {
  57489. import { Nullable } from "babylonjs/types";
  57490. /**
  57491. * @hidden
  57492. **/
  57493. export class _TimeToken {
  57494. _startTimeQuery: Nullable<WebGLQuery>;
  57495. _endTimeQuery: Nullable<WebGLQuery>;
  57496. _timeElapsedQuery: Nullable<WebGLQuery>;
  57497. _timeElapsedQueryEnded: boolean;
  57498. }
  57499. }
  57500. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57501. import { Nullable, int } from "babylonjs/types";
  57502. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57503. /** @hidden */
  57504. export class _OcclusionDataStorage {
  57505. /** @hidden */
  57506. occlusionInternalRetryCounter: number;
  57507. /** @hidden */
  57508. isOcclusionQueryInProgress: boolean;
  57509. /** @hidden */
  57510. isOccluded: boolean;
  57511. /** @hidden */
  57512. occlusionRetryCount: number;
  57513. /** @hidden */
  57514. occlusionType: number;
  57515. /** @hidden */
  57516. occlusionQueryAlgorithmType: number;
  57517. }
  57518. module "babylonjs/Engines/engine" {
  57519. interface Engine {
  57520. /**
  57521. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57522. * @return the new query
  57523. */
  57524. createQuery(): WebGLQuery;
  57525. /**
  57526. * Delete and release a webGL query
  57527. * @param query defines the query to delete
  57528. * @return the current engine
  57529. */
  57530. deleteQuery(query: WebGLQuery): Engine;
  57531. /**
  57532. * Check if a given query has resolved and got its value
  57533. * @param query defines the query to check
  57534. * @returns true if the query got its value
  57535. */
  57536. isQueryResultAvailable(query: WebGLQuery): boolean;
  57537. /**
  57538. * Gets the value of a given query
  57539. * @param query defines the query to check
  57540. * @returns the value of the query
  57541. */
  57542. getQueryResult(query: WebGLQuery): number;
  57543. /**
  57544. * Initiates an occlusion query
  57545. * @param algorithmType defines the algorithm to use
  57546. * @param query defines the query to use
  57547. * @returns the current engine
  57548. * @see https://doc.babylonjs.com/features/occlusionquery
  57549. */
  57550. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57551. /**
  57552. * Ends an occlusion query
  57553. * @see https://doc.babylonjs.com/features/occlusionquery
  57554. * @param algorithmType defines the algorithm to use
  57555. * @returns the current engine
  57556. */
  57557. endOcclusionQuery(algorithmType: number): Engine;
  57558. /**
  57559. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57560. * Please note that only one query can be issued at a time
  57561. * @returns a time token used to track the time span
  57562. */
  57563. startTimeQuery(): Nullable<_TimeToken>;
  57564. /**
  57565. * Ends a time query
  57566. * @param token defines the token used to measure the time span
  57567. * @returns the time spent (in ns)
  57568. */
  57569. endTimeQuery(token: _TimeToken): int;
  57570. /** @hidden */
  57571. _currentNonTimestampToken: Nullable<_TimeToken>;
  57572. /** @hidden */
  57573. _createTimeQuery(): WebGLQuery;
  57574. /** @hidden */
  57575. _deleteTimeQuery(query: WebGLQuery): void;
  57576. /** @hidden */
  57577. _getGlAlgorithmType(algorithmType: number): number;
  57578. /** @hidden */
  57579. _getTimeQueryResult(query: WebGLQuery): any;
  57580. /** @hidden */
  57581. _getTimeQueryAvailability(query: WebGLQuery): any;
  57582. }
  57583. }
  57584. module "babylonjs/Meshes/abstractMesh" {
  57585. interface AbstractMesh {
  57586. /**
  57587. * Backing filed
  57588. * @hidden
  57589. */
  57590. __occlusionDataStorage: _OcclusionDataStorage;
  57591. /**
  57592. * Access property
  57593. * @hidden
  57594. */
  57595. _occlusionDataStorage: _OcclusionDataStorage;
  57596. /**
  57597. * 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.
  57598. * The default value is -1 which means don't break the query and wait till the result
  57599. * @see https://doc.babylonjs.com/features/occlusionquery
  57600. */
  57601. occlusionRetryCount: number;
  57602. /**
  57603. * 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:
  57604. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57605. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57606. * * 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.
  57607. * @see https://doc.babylonjs.com/features/occlusionquery
  57608. */
  57609. occlusionType: number;
  57610. /**
  57611. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57612. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57613. * * 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.
  57614. * @see https://doc.babylonjs.com/features/occlusionquery
  57615. */
  57616. occlusionQueryAlgorithmType: number;
  57617. /**
  57618. * 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
  57619. * @see https://doc.babylonjs.com/features/occlusionquery
  57620. */
  57621. isOccluded: boolean;
  57622. /**
  57623. * Flag to check the progress status of the query
  57624. * @see https://doc.babylonjs.com/features/occlusionquery
  57625. */
  57626. isOcclusionQueryInProgress: boolean;
  57627. }
  57628. }
  57629. }
  57630. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57631. import { Nullable } from "babylonjs/types";
  57632. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57633. /** @hidden */
  57634. export var _forceTransformFeedbackToBundle: boolean;
  57635. module "babylonjs/Engines/engine" {
  57636. interface Engine {
  57637. /**
  57638. * Creates a webGL transform feedback object
  57639. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57640. * @returns the webGL transform feedback object
  57641. */
  57642. createTransformFeedback(): WebGLTransformFeedback;
  57643. /**
  57644. * Delete a webGL transform feedback object
  57645. * @param value defines the webGL transform feedback object to delete
  57646. */
  57647. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57648. /**
  57649. * Bind a webGL transform feedback object to the webgl context
  57650. * @param value defines the webGL transform feedback object to bind
  57651. */
  57652. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57653. /**
  57654. * Begins a transform feedback operation
  57655. * @param usePoints defines if points or triangles must be used
  57656. */
  57657. beginTransformFeedback(usePoints: boolean): void;
  57658. /**
  57659. * Ends a transform feedback operation
  57660. */
  57661. endTransformFeedback(): void;
  57662. /**
  57663. * Specify the varyings to use with transform feedback
  57664. * @param program defines the associated webGL program
  57665. * @param value defines the list of strings representing the varying names
  57666. */
  57667. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57668. /**
  57669. * Bind a webGL buffer for a transform feedback operation
  57670. * @param value defines the webGL buffer to bind
  57671. */
  57672. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57673. }
  57674. }
  57675. }
  57676. declare module "babylonjs/Engines/Extensions/engine.views" {
  57677. import { Camera } from "babylonjs/Cameras/camera";
  57678. import { Nullable } from "babylonjs/types";
  57679. /**
  57680. * Class used to define an additional view for the engine
  57681. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57682. */
  57683. export class EngineView {
  57684. /** Defines the canvas where to render the view */
  57685. target: HTMLCanvasElement;
  57686. /** Defines an optional camera used to render the view (will use active camera else) */
  57687. camera?: Camera;
  57688. }
  57689. module "babylonjs/Engines/engine" {
  57690. interface Engine {
  57691. /**
  57692. * Gets or sets the HTML element to use for attaching events
  57693. */
  57694. inputElement: Nullable<HTMLElement>;
  57695. /**
  57696. * Gets the current engine view
  57697. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57698. */
  57699. activeView: Nullable<EngineView>;
  57700. /** Gets or sets the list of views */
  57701. views: EngineView[];
  57702. /**
  57703. * Register a new child canvas
  57704. * @param canvas defines the canvas to register
  57705. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57706. * @returns the associated view
  57707. */
  57708. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57709. /**
  57710. * Remove a registered child canvas
  57711. * @param canvas defines the canvas to remove
  57712. * @returns the current engine
  57713. */
  57714. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57715. }
  57716. }
  57717. }
  57718. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57719. import { Nullable } from "babylonjs/types";
  57720. module "babylonjs/Engines/engine" {
  57721. interface Engine {
  57722. /** @hidden */
  57723. _excludedCompressedTextures: string[];
  57724. /** @hidden */
  57725. _textureFormatInUse: string;
  57726. /**
  57727. * Gets the list of texture formats supported
  57728. */
  57729. readonly texturesSupported: Array<string>;
  57730. /**
  57731. * Gets the texture format in use
  57732. */
  57733. readonly textureFormatInUse: Nullable<string>;
  57734. /**
  57735. * Set the compressed texture extensions or file names to skip.
  57736. *
  57737. * @param skippedFiles defines the list of those texture files you want to skip
  57738. * Example: [".dds", ".env", "myfile.png"]
  57739. */
  57740. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57741. /**
  57742. * Set the compressed texture format to use, based on the formats you have, and the formats
  57743. * supported by the hardware / browser.
  57744. *
  57745. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57746. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57747. * to API arguments needed to compressed textures. This puts the burden on the container
  57748. * generator to house the arcane code for determining these for current & future formats.
  57749. *
  57750. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57751. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57752. *
  57753. * Note: The result of this call is not taken into account when a texture is base64.
  57754. *
  57755. * @param formatsAvailable defines the list of those format families you have created
  57756. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57757. *
  57758. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57759. * @returns The extension selected.
  57760. */
  57761. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57762. }
  57763. }
  57764. }
  57765. declare module "babylonjs/Engines/Extensions/index" {
  57766. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57767. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57768. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57769. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57770. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57771. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57772. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57773. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57774. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57775. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57776. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57777. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57778. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57779. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57780. export * from "babylonjs/Engines/Extensions/engine.views";
  57781. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57782. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57783. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57784. }
  57785. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57787. /** @hidden */
  57788. export var rgbdEncodePixelShader: {
  57789. name: string;
  57790. shader: string;
  57791. };
  57792. }
  57793. declare module "babylonjs/Misc/environmentTextureTools" {
  57794. import { Nullable } from "babylonjs/types";
  57795. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57798. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57799. import "babylonjs/Engines/Extensions/engine.readTexture";
  57800. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57801. import "babylonjs/Shaders/rgbdEncode.fragment";
  57802. import "babylonjs/Shaders/rgbdDecode.fragment";
  57803. /**
  57804. * Raw texture data and descriptor sufficient for WebGL texture upload
  57805. */
  57806. export interface EnvironmentTextureInfo {
  57807. /**
  57808. * Version of the environment map
  57809. */
  57810. version: number;
  57811. /**
  57812. * Width of image
  57813. */
  57814. width: number;
  57815. /**
  57816. * Irradiance information stored in the file.
  57817. */
  57818. irradiance: any;
  57819. /**
  57820. * Specular information stored in the file.
  57821. */
  57822. specular: any;
  57823. }
  57824. /**
  57825. * Defines One Image in the file. It requires only the position in the file
  57826. * as well as the length.
  57827. */
  57828. interface BufferImageData {
  57829. /**
  57830. * Length of the image data.
  57831. */
  57832. length: number;
  57833. /**
  57834. * Position of the data from the null terminator delimiting the end of the JSON.
  57835. */
  57836. position: number;
  57837. }
  57838. /**
  57839. * Defines the specular data enclosed in the file.
  57840. * This corresponds to the version 1 of the data.
  57841. */
  57842. export interface EnvironmentTextureSpecularInfoV1 {
  57843. /**
  57844. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57845. */
  57846. specularDataPosition?: number;
  57847. /**
  57848. * This contains all the images data needed to reconstruct the cubemap.
  57849. */
  57850. mipmaps: Array<BufferImageData>;
  57851. /**
  57852. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57853. */
  57854. lodGenerationScale: number;
  57855. }
  57856. /**
  57857. * Sets of helpers addressing the serialization and deserialization of environment texture
  57858. * stored in a BabylonJS env file.
  57859. * Those files are usually stored as .env files.
  57860. */
  57861. export class EnvironmentTextureTools {
  57862. /**
  57863. * Magic number identifying the env file.
  57864. */
  57865. private static _MagicBytes;
  57866. /**
  57867. * Gets the environment info from an env file.
  57868. * @param data The array buffer containing the .env bytes.
  57869. * @returns the environment file info (the json header) if successfully parsed.
  57870. */
  57871. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57872. /**
  57873. * Creates an environment texture from a loaded cube texture.
  57874. * @param texture defines the cube texture to convert in env file
  57875. * @return a promise containing the environment data if succesfull.
  57876. */
  57877. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57878. /**
  57879. * Creates a JSON representation of the spherical data.
  57880. * @param texture defines the texture containing the polynomials
  57881. * @return the JSON representation of the spherical info
  57882. */
  57883. private static _CreateEnvTextureIrradiance;
  57884. /**
  57885. * Creates the ArrayBufferViews used for initializing environment texture image data.
  57886. * @param data the image data
  57887. * @param info parameters that determine what views will be created for accessing the underlying buffer
  57888. * @return the views described by info providing access to the underlying buffer
  57889. */
  57890. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57891. /**
  57892. * Uploads the texture info contained in the env file to the GPU.
  57893. * @param texture defines the internal texture to upload to
  57894. * @param data defines the data to load
  57895. * @param info defines the texture info retrieved through the GetEnvInfo method
  57896. * @returns a promise
  57897. */
  57898. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57899. private static _OnImageReadyAsync;
  57900. /**
  57901. * Uploads the levels of image data to the GPU.
  57902. * @param texture defines the internal texture to upload to
  57903. * @param imageData defines the array buffer views of image data [mipmap][face]
  57904. * @returns a promise
  57905. */
  57906. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57907. /**
  57908. * Uploads spherical polynomials information to the texture.
  57909. * @param texture defines the texture we are trying to upload the information to
  57910. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57911. */
  57912. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57913. /** @hidden */
  57914. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57915. }
  57916. }
  57917. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  57918. /**
  57919. * Class used to inline functions in shader code
  57920. */
  57921. export class ShaderCodeInliner {
  57922. private static readonly _RegexpFindFunctionNameAndType;
  57923. private _sourceCode;
  57924. private _functionDescr;
  57925. private _numMaxIterations;
  57926. /** Gets or sets the token used to mark the functions to inline */
  57927. inlineToken: string;
  57928. /** Gets or sets the debug mode */
  57929. debug: boolean;
  57930. /** Gets the code after the inlining process */
  57931. get code(): string;
  57932. /**
  57933. * Initializes the inliner
  57934. * @param sourceCode shader code source to inline
  57935. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57936. */
  57937. constructor(sourceCode: string, numMaxIterations?: number);
  57938. /**
  57939. * Start the processing of the shader code
  57940. */
  57941. processCode(): void;
  57942. private _collectFunctions;
  57943. private _processInlining;
  57944. private _extractBetweenMarkers;
  57945. private _skipWhitespaces;
  57946. private _removeComments;
  57947. private _replaceFunctionCallsByCode;
  57948. private _findBackward;
  57949. private _escapeRegExp;
  57950. private _replaceNames;
  57951. }
  57952. }
  57953. declare module "babylonjs/Engines/nativeEngine" {
  57954. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  57955. import { Engine } from "babylonjs/Engines/engine";
  57956. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57959. import { Effect } from "babylonjs/Materials/effect";
  57960. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57961. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  57962. import { IColor4Like } from "babylonjs/Maths/math.like";
  57963. import { Scene } from "babylonjs/scene";
  57964. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57965. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57966. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57967. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  57968. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  57969. /**
  57970. * Container for accessors for natively-stored mesh data buffers.
  57971. */
  57972. class NativeDataBuffer extends DataBuffer {
  57973. /**
  57974. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57975. */
  57976. nativeIndexBuffer?: any;
  57977. /**
  57978. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57979. */
  57980. nativeVertexBuffer?: any;
  57981. }
  57982. /** @hidden */
  57983. class NativeTexture extends InternalTexture {
  57984. getInternalTexture(): InternalTexture;
  57985. getViewCount(): number;
  57986. }
  57987. /** @hidden */
  57988. export class NativeEngine extends Engine {
  57989. private readonly _native;
  57990. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57991. private readonly INVALID_HANDLE;
  57992. private _boundBuffersVertexArray;
  57993. private _currentDepthTest;
  57994. getHardwareScalingLevel(): number;
  57995. constructor();
  57996. dispose(): void;
  57997. /**
  57998. * Can be used to override the current requestAnimationFrame requester.
  57999. * @hidden
  58000. */
  58001. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58002. /**
  58003. * Override default engine behavior.
  58004. * @param color
  58005. * @param backBuffer
  58006. * @param depth
  58007. * @param stencil
  58008. */
  58009. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58010. /**
  58011. * Gets host document
  58012. * @returns the host document object
  58013. */
  58014. getHostDocument(): Nullable<Document>;
  58015. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58016. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58017. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58018. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58019. [key: string]: VertexBuffer;
  58020. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58021. bindBuffers(vertexBuffers: {
  58022. [key: string]: VertexBuffer;
  58023. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58024. recordVertexArrayObject(vertexBuffers: {
  58025. [key: string]: VertexBuffer;
  58026. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58027. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58028. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58029. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58030. /**
  58031. * Draw a list of indexed primitives
  58032. * @param fillMode defines the primitive to use
  58033. * @param indexStart defines the starting index
  58034. * @param indexCount defines the number of index to draw
  58035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58036. */
  58037. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58038. /**
  58039. * Draw a list of unindexed primitives
  58040. * @param fillMode defines the primitive to use
  58041. * @param verticesStart defines the index of first vertex to draw
  58042. * @param verticesCount defines the count of vertices to draw
  58043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58044. */
  58045. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58046. createPipelineContext(): IPipelineContext;
  58047. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58048. /** @hidden */
  58049. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58050. /** @hidden */
  58051. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58052. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58053. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58054. protected _setProgram(program: WebGLProgram): void;
  58055. _releaseEffect(effect: Effect): void;
  58056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58057. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58058. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58059. bindSamplers(effect: Effect): void;
  58060. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58061. getRenderWidth(useScreen?: boolean): number;
  58062. getRenderHeight(useScreen?: boolean): number;
  58063. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58064. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58065. /**
  58066. * Set the z offset to apply to current rendering
  58067. * @param value defines the offset to apply
  58068. */
  58069. setZOffset(value: number): void;
  58070. /**
  58071. * Gets the current value of the zOffset
  58072. * @returns the current zOffset state
  58073. */
  58074. getZOffset(): number;
  58075. /**
  58076. * Enable or disable depth buffering
  58077. * @param enable defines the state to set
  58078. */
  58079. setDepthBuffer(enable: boolean): void;
  58080. /**
  58081. * Gets a boolean indicating if depth writing is enabled
  58082. * @returns the current depth writing state
  58083. */
  58084. getDepthWrite(): boolean;
  58085. setDepthFunctionToGreater(): void;
  58086. setDepthFunctionToGreaterOrEqual(): void;
  58087. setDepthFunctionToLess(): void;
  58088. setDepthFunctionToLessOrEqual(): void;
  58089. /**
  58090. * Enable or disable depth writing
  58091. * @param enable defines the state to set
  58092. */
  58093. setDepthWrite(enable: boolean): void;
  58094. /**
  58095. * Enable or disable color writing
  58096. * @param enable defines the state to set
  58097. */
  58098. setColorWrite(enable: boolean): void;
  58099. /**
  58100. * Gets a boolean indicating if color writing is enabled
  58101. * @returns the current color writing state
  58102. */
  58103. getColorWrite(): boolean;
  58104. /**
  58105. * Sets alpha constants used by some alpha blending modes
  58106. * @param r defines the red component
  58107. * @param g defines the green component
  58108. * @param b defines the blue component
  58109. * @param a defines the alpha component
  58110. */
  58111. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58112. /**
  58113. * Sets the current alpha mode
  58114. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58115. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58116. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58117. */
  58118. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58119. /**
  58120. * Gets the current alpha mode
  58121. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58122. * @returns the current alpha mode
  58123. */
  58124. getAlphaMode(): number;
  58125. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58126. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58127. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58128. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58129. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58130. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58131. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58132. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58133. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58134. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58135. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58136. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58137. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58138. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58139. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58140. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58141. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58142. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58143. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58144. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58145. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58146. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58147. wipeCaches(bruteForce?: boolean): void;
  58148. _createTexture(): WebGLTexture;
  58149. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58150. /**
  58151. * Update the content of a dynamic texture
  58152. * @param texture defines the texture to update
  58153. * @param canvas defines the canvas containing the source
  58154. * @param invertY defines if data must be stored with Y axis inverted
  58155. * @param premulAlpha defines if alpha is stored as premultiplied
  58156. * @param format defines the format of the data
  58157. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58158. */
  58159. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58160. /**
  58161. * Usually called from Texture.ts.
  58162. * Passed information to create a WebGLTexture
  58163. * @param url defines a value which contains one of the following:
  58164. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58165. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58166. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58167. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58168. * @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)
  58169. * @param scene needed for loading to the correct scene
  58170. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58171. * @param onLoad optional callback to be called upon successful completion
  58172. * @param onError optional callback to be called upon failure
  58173. * @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
  58174. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58175. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58176. * @param forcedExtension defines the extension to use to pick the right loader
  58177. * @param mimeType defines an optional mime type
  58178. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58179. */
  58180. 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;
  58181. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58182. _releaseFramebufferObjects(texture: InternalTexture): void;
  58183. /**
  58184. * Creates a cube texture
  58185. * @param rootUrl defines the url where the files to load is located
  58186. * @param scene defines the current scene
  58187. * @param files defines the list of files to load (1 per face)
  58188. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58189. * @param onLoad defines an optional callback raised when the texture is loaded
  58190. * @param onError defines an optional callback raised if there is an issue to load the texture
  58191. * @param format defines the format of the data
  58192. * @param forcedExtension defines the extension to use to pick the right loader
  58193. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58194. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58195. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58196. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58197. * @returns the cube texture as an InternalTexture
  58198. */
  58199. 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;
  58200. createRenderTargetTexture(size: number | {
  58201. width: number;
  58202. height: number;
  58203. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58204. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58205. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58206. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58207. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58208. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58209. /**
  58210. * Updates a dynamic vertex buffer.
  58211. * @param vertexBuffer the vertex buffer to update
  58212. * @param data the data used to update the vertex buffer
  58213. * @param byteOffset the byte offset of the data (optional)
  58214. * @param byteLength the byte length of the data (optional)
  58215. */
  58216. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58217. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58218. private _updateAnisotropicLevel;
  58219. private _getAddressMode;
  58220. /** @hidden */
  58221. _bindTexture(channel: number, texture: InternalTexture): void;
  58222. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58223. releaseEffects(): void;
  58224. /** @hidden */
  58225. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58226. /** @hidden */
  58227. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58228. /** @hidden */
  58229. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58230. /** @hidden */
  58231. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58232. private _getNativeSamplingMode;
  58233. private _getNativeTextureFormat;
  58234. private _getNativeAlphaMode;
  58235. private _getNativeAttribType;
  58236. }
  58237. }
  58238. declare module "babylonjs/Engines/index" {
  58239. export * from "babylonjs/Engines/constants";
  58240. export * from "babylonjs/Engines/engineCapabilities";
  58241. export * from "babylonjs/Engines/instancingAttributeInfo";
  58242. export * from "babylonjs/Engines/thinEngine";
  58243. export * from "babylonjs/Engines/engine";
  58244. export * from "babylonjs/Engines/engineStore";
  58245. export * from "babylonjs/Engines/nullEngine";
  58246. export * from "babylonjs/Engines/Extensions/index";
  58247. export * from "babylonjs/Engines/IPipelineContext";
  58248. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58249. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58250. export * from "babylonjs/Engines/nativeEngine";
  58251. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58252. export * from "babylonjs/Engines/performanceConfigurator";
  58253. }
  58254. declare module "babylonjs/Events/clipboardEvents" {
  58255. /**
  58256. * Gather the list of clipboard event types as constants.
  58257. */
  58258. export class ClipboardEventTypes {
  58259. /**
  58260. * The clipboard event is fired when a copy command is active (pressed).
  58261. */
  58262. static readonly COPY: number;
  58263. /**
  58264. * The clipboard event is fired when a cut command is active (pressed).
  58265. */
  58266. static readonly CUT: number;
  58267. /**
  58268. * The clipboard event is fired when a paste command is active (pressed).
  58269. */
  58270. static readonly PASTE: number;
  58271. }
  58272. /**
  58273. * This class is used to store clipboard related info for the onClipboardObservable event.
  58274. */
  58275. export class ClipboardInfo {
  58276. /**
  58277. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58278. */
  58279. type: number;
  58280. /**
  58281. * Defines the related dom event
  58282. */
  58283. event: ClipboardEvent;
  58284. /**
  58285. *Creates an instance of ClipboardInfo.
  58286. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58287. * @param event Defines the related dom event
  58288. */
  58289. constructor(
  58290. /**
  58291. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58292. */
  58293. type: number,
  58294. /**
  58295. * Defines the related dom event
  58296. */
  58297. event: ClipboardEvent);
  58298. /**
  58299. * Get the clipboard event's type from the keycode.
  58300. * @param keyCode Defines the keyCode for the current keyboard event.
  58301. * @return {number}
  58302. */
  58303. static GetTypeFromCharacter(keyCode: number): number;
  58304. }
  58305. }
  58306. declare module "babylonjs/Events/index" {
  58307. export * from "babylonjs/Events/keyboardEvents";
  58308. export * from "babylonjs/Events/pointerEvents";
  58309. export * from "babylonjs/Events/clipboardEvents";
  58310. }
  58311. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58312. import { Scene } from "babylonjs/scene";
  58313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58314. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58315. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58316. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58317. /**
  58318. * Google Daydream controller
  58319. */
  58320. export class DaydreamController extends WebVRController {
  58321. /**
  58322. * Base Url for the controller model.
  58323. */
  58324. static MODEL_BASE_URL: string;
  58325. /**
  58326. * File name for the controller model.
  58327. */
  58328. static MODEL_FILENAME: string;
  58329. /**
  58330. * Gamepad Id prefix used to identify Daydream Controller.
  58331. */
  58332. static readonly GAMEPAD_ID_PREFIX: string;
  58333. /**
  58334. * Creates a new DaydreamController from a gamepad
  58335. * @param vrGamepad the gamepad that the controller should be created from
  58336. */
  58337. constructor(vrGamepad: any);
  58338. /**
  58339. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58340. * @param scene scene in which to add meshes
  58341. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58342. */
  58343. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58344. /**
  58345. * Called once for each button that changed state since the last frame
  58346. * @param buttonIdx Which button index changed
  58347. * @param state New state of the button
  58348. * @param changes Which properties on the state changed since last frame
  58349. */
  58350. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58351. }
  58352. }
  58353. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58354. import { Scene } from "babylonjs/scene";
  58355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58356. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58357. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58358. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58359. /**
  58360. * Gear VR Controller
  58361. */
  58362. export class GearVRController extends WebVRController {
  58363. /**
  58364. * Base Url for the controller model.
  58365. */
  58366. static MODEL_BASE_URL: string;
  58367. /**
  58368. * File name for the controller model.
  58369. */
  58370. static MODEL_FILENAME: string;
  58371. /**
  58372. * Gamepad Id prefix used to identify this controller.
  58373. */
  58374. static readonly GAMEPAD_ID_PREFIX: string;
  58375. private readonly _buttonIndexToObservableNameMap;
  58376. /**
  58377. * Creates a new GearVRController from a gamepad
  58378. * @param vrGamepad the gamepad that the controller should be created from
  58379. */
  58380. constructor(vrGamepad: any);
  58381. /**
  58382. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58383. * @param scene scene in which to add meshes
  58384. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58385. */
  58386. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58387. /**
  58388. * Called once for each button that changed state since the last frame
  58389. * @param buttonIdx Which button index changed
  58390. * @param state New state of the button
  58391. * @param changes Which properties on the state changed since last frame
  58392. */
  58393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58394. }
  58395. }
  58396. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58397. import { Scene } from "babylonjs/scene";
  58398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58399. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58400. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58401. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58402. /**
  58403. * Generic Controller
  58404. */
  58405. export class GenericController extends WebVRController {
  58406. /**
  58407. * Base Url for the controller model.
  58408. */
  58409. static readonly MODEL_BASE_URL: string;
  58410. /**
  58411. * File name for the controller model.
  58412. */
  58413. static readonly MODEL_FILENAME: string;
  58414. /**
  58415. * Creates a new GenericController from a gamepad
  58416. * @param vrGamepad the gamepad that the controller should be created from
  58417. */
  58418. constructor(vrGamepad: any);
  58419. /**
  58420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58421. * @param scene scene in which to add meshes
  58422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58423. */
  58424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58425. /**
  58426. * Called once for each button that changed state since the last frame
  58427. * @param buttonIdx Which button index changed
  58428. * @param state New state of the button
  58429. * @param changes Which properties on the state changed since last frame
  58430. */
  58431. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58432. }
  58433. }
  58434. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58435. import { Observable } from "babylonjs/Misc/observable";
  58436. import { Scene } from "babylonjs/scene";
  58437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58438. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58439. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58440. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58441. /**
  58442. * Oculus Touch Controller
  58443. */
  58444. export class OculusTouchController extends WebVRController {
  58445. /**
  58446. * Base Url for the controller model.
  58447. */
  58448. static MODEL_BASE_URL: string;
  58449. /**
  58450. * File name for the left controller model.
  58451. */
  58452. static MODEL_LEFT_FILENAME: string;
  58453. /**
  58454. * File name for the right controller model.
  58455. */
  58456. static MODEL_RIGHT_FILENAME: string;
  58457. /**
  58458. * Base Url for the Quest controller model.
  58459. */
  58460. static QUEST_MODEL_BASE_URL: string;
  58461. /**
  58462. * @hidden
  58463. * If the controllers are running on a device that needs the updated Quest controller models
  58464. */
  58465. static _IsQuest: boolean;
  58466. /**
  58467. * Fired when the secondary trigger on this controller is modified
  58468. */
  58469. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58470. /**
  58471. * Fired when the thumb rest on this controller is modified
  58472. */
  58473. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58474. /**
  58475. * Creates a new OculusTouchController from a gamepad
  58476. * @param vrGamepad the gamepad that the controller should be created from
  58477. */
  58478. constructor(vrGamepad: any);
  58479. /**
  58480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58481. * @param scene scene in which to add meshes
  58482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58483. */
  58484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58485. /**
  58486. * Fired when the A button on this controller is modified
  58487. */
  58488. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58489. /**
  58490. * Fired when the B button on this controller is modified
  58491. */
  58492. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58493. /**
  58494. * Fired when the X button on this controller is modified
  58495. */
  58496. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58497. /**
  58498. * Fired when the Y button on this controller is modified
  58499. */
  58500. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58501. /**
  58502. * Called once for each button that changed state since the last frame
  58503. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58504. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58505. * 2) secondary trigger (same)
  58506. * 3) A (right) X (left), touch, pressed = value
  58507. * 4) B / Y
  58508. * 5) thumb rest
  58509. * @param buttonIdx Which button index changed
  58510. * @param state New state of the button
  58511. * @param changes Which properties on the state changed since last frame
  58512. */
  58513. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58514. }
  58515. }
  58516. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58517. import { Scene } from "babylonjs/scene";
  58518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58519. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58520. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58521. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58522. import { Observable } from "babylonjs/Misc/observable";
  58523. /**
  58524. * Vive Controller
  58525. */
  58526. export class ViveController extends WebVRController {
  58527. /**
  58528. * Base Url for the controller model.
  58529. */
  58530. static MODEL_BASE_URL: string;
  58531. /**
  58532. * File name for the controller model.
  58533. */
  58534. static MODEL_FILENAME: string;
  58535. /**
  58536. * Creates a new ViveController 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. * Fired when the left button on this controller is modified
  58548. */
  58549. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58550. /**
  58551. * Fired when the right button on this controller is modified
  58552. */
  58553. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58554. /**
  58555. * Fired when the menu button on this controller is modified
  58556. */
  58557. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58558. /**
  58559. * Called once for each button that changed state since the last frame
  58560. * Vive mapping:
  58561. * 0: touchpad
  58562. * 1: trigger
  58563. * 2: left AND right buttons
  58564. * 3: menu button
  58565. * @param buttonIdx Which button index changed
  58566. * @param state New state of the button
  58567. * @param changes Which properties on the state changed since last frame
  58568. */
  58569. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58570. }
  58571. }
  58572. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58573. import { Observable } from "babylonjs/Misc/observable";
  58574. import { Scene } from "babylonjs/scene";
  58575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58576. import { Ray } from "babylonjs/Culling/ray";
  58577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58578. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58579. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58580. /**
  58581. * Defines the WindowsMotionController object that the state of the windows motion controller
  58582. */
  58583. export class WindowsMotionController extends WebVRController {
  58584. /**
  58585. * The base url used to load the left and right controller models
  58586. */
  58587. static MODEL_BASE_URL: string;
  58588. /**
  58589. * The name of the left controller model file
  58590. */
  58591. static MODEL_LEFT_FILENAME: string;
  58592. /**
  58593. * The name of the right controller model file
  58594. */
  58595. static MODEL_RIGHT_FILENAME: string;
  58596. /**
  58597. * The controller name prefix for this controller type
  58598. */
  58599. static readonly GAMEPAD_ID_PREFIX: string;
  58600. /**
  58601. * The controller id pattern for this controller type
  58602. */
  58603. private static readonly GAMEPAD_ID_PATTERN;
  58604. private _loadedMeshInfo;
  58605. protected readonly _mapping: {
  58606. buttons: string[];
  58607. buttonMeshNames: {
  58608. trigger: string;
  58609. menu: string;
  58610. grip: string;
  58611. thumbstick: string;
  58612. trackpad: string;
  58613. };
  58614. buttonObservableNames: {
  58615. trigger: string;
  58616. menu: string;
  58617. grip: string;
  58618. thumbstick: string;
  58619. trackpad: string;
  58620. };
  58621. axisMeshNames: string[];
  58622. pointingPoseMeshName: string;
  58623. };
  58624. /**
  58625. * Fired when the trackpad on this controller is clicked
  58626. */
  58627. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58628. /**
  58629. * Fired when the trackpad on this controller is modified
  58630. */
  58631. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58632. /**
  58633. * The current x and y values of this controller's trackpad
  58634. */
  58635. trackpad: StickValues;
  58636. /**
  58637. * Creates a new WindowsMotionController from a gamepad
  58638. * @param vrGamepad the gamepad that the controller should be created from
  58639. */
  58640. constructor(vrGamepad: any);
  58641. /**
  58642. * Fired when the trigger on this controller is modified
  58643. */
  58644. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58645. /**
  58646. * Fired when the menu button on this controller is modified
  58647. */
  58648. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58649. /**
  58650. * Fired when the grip button on this controller is modified
  58651. */
  58652. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58653. /**
  58654. * Fired when the thumbstick button on this controller is modified
  58655. */
  58656. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58657. /**
  58658. * Fired when the touchpad button on this controller is modified
  58659. */
  58660. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58661. /**
  58662. * Fired when the touchpad values on this controller are modified
  58663. */
  58664. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58665. protected _updateTrackpad(): void;
  58666. /**
  58667. * Called once per frame by the engine.
  58668. */
  58669. update(): void;
  58670. /**
  58671. * Called once for each button that changed state since the last frame
  58672. * @param buttonIdx Which button index changed
  58673. * @param state New state of the button
  58674. * @param changes Which properties on the state changed since last frame
  58675. */
  58676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58677. /**
  58678. * Moves the buttons on the controller mesh based on their current state
  58679. * @param buttonName the name of the button to move
  58680. * @param buttonValue the value of the button which determines the buttons new position
  58681. */
  58682. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58683. /**
  58684. * Moves the axis on the controller mesh based on its current state
  58685. * @param axis the index of the axis
  58686. * @param axisValue the value of the axis which determines the meshes new position
  58687. * @hidden
  58688. */
  58689. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58690. /**
  58691. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58692. * @param scene scene in which to add meshes
  58693. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58694. */
  58695. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58696. /**
  58697. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58698. * can be transformed by button presses and axes values, based on this._mapping.
  58699. *
  58700. * @param scene scene in which the meshes exist
  58701. * @param meshes list of meshes that make up the controller model to process
  58702. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58703. */
  58704. private processModel;
  58705. private createMeshInfo;
  58706. /**
  58707. * Gets the ray of the controller in the direction the controller is pointing
  58708. * @param length the length the resulting ray should be
  58709. * @returns a ray in the direction the controller is pointing
  58710. */
  58711. getForwardRay(length?: number): Ray;
  58712. /**
  58713. * Disposes of the controller
  58714. */
  58715. dispose(): void;
  58716. }
  58717. /**
  58718. * This class represents a new windows motion controller in XR.
  58719. */
  58720. export class XRWindowsMotionController extends WindowsMotionController {
  58721. /**
  58722. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58723. */
  58724. protected readonly _mapping: {
  58725. buttons: string[];
  58726. buttonMeshNames: {
  58727. trigger: string;
  58728. menu: string;
  58729. grip: string;
  58730. thumbstick: string;
  58731. trackpad: string;
  58732. };
  58733. buttonObservableNames: {
  58734. trigger: string;
  58735. menu: string;
  58736. grip: string;
  58737. thumbstick: string;
  58738. trackpad: string;
  58739. };
  58740. axisMeshNames: string[];
  58741. pointingPoseMeshName: string;
  58742. };
  58743. /**
  58744. * Construct a new XR-Based windows motion controller
  58745. *
  58746. * @param gamepadInfo the gamepad object from the browser
  58747. */
  58748. constructor(gamepadInfo: any);
  58749. /**
  58750. * holds the thumbstick values (X,Y)
  58751. */
  58752. thumbstickValues: StickValues;
  58753. /**
  58754. * Fired when the thumbstick on this controller is clicked
  58755. */
  58756. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58757. /**
  58758. * Fired when the thumbstick on this controller is modified
  58759. */
  58760. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58761. /**
  58762. * Fired when the touchpad button on this controller is modified
  58763. */
  58764. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58765. /**
  58766. * Fired when the touchpad values on this controller are modified
  58767. */
  58768. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58769. /**
  58770. * Fired when the thumbstick button on this controller is modified
  58771. * here to prevent breaking changes
  58772. */
  58773. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58774. /**
  58775. * updating the thumbstick(!) and not the trackpad.
  58776. * This is named this way due to the difference between WebVR and XR and to avoid
  58777. * changing the parent class.
  58778. */
  58779. protected _updateTrackpad(): void;
  58780. /**
  58781. * Disposes the class with joy
  58782. */
  58783. dispose(): void;
  58784. }
  58785. }
  58786. declare module "babylonjs/Gamepads/Controllers/index" {
  58787. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58788. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58789. export * from "babylonjs/Gamepads/Controllers/genericController";
  58790. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58791. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58792. export * from "babylonjs/Gamepads/Controllers/viveController";
  58793. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58794. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58795. }
  58796. declare module "babylonjs/Gamepads/index" {
  58797. export * from "babylonjs/Gamepads/Controllers/index";
  58798. export * from "babylonjs/Gamepads/gamepad";
  58799. export * from "babylonjs/Gamepads/gamepadManager";
  58800. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58801. export * from "babylonjs/Gamepads/xboxGamepad";
  58802. export * from "babylonjs/Gamepads/dualShockGamepad";
  58803. }
  58804. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58805. import { Scene } from "babylonjs/scene";
  58806. import { Vector4 } from "babylonjs/Maths/math.vector";
  58807. import { Color4 } from "babylonjs/Maths/math.color";
  58808. import { Mesh } from "babylonjs/Meshes/mesh";
  58809. import { Nullable } from "babylonjs/types";
  58810. /**
  58811. * Class containing static functions to help procedurally build meshes
  58812. */
  58813. export class PolyhedronBuilder {
  58814. /**
  58815. * Creates a polyhedron mesh
  58816. * * 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
  58817. * * The parameter `size` (positive float, default 1) sets the polygon size
  58818. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58819. * * 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`
  58820. * * 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
  58821. * * 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)`)
  58822. * * 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
  58823. * * 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
  58824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58827. * @param name defines the name of the mesh
  58828. * @param options defines the options used to create the mesh
  58829. * @param scene defines the hosting scene
  58830. * @returns the polyhedron mesh
  58831. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58832. */
  58833. static CreatePolyhedron(name: string, options: {
  58834. type?: number;
  58835. size?: number;
  58836. sizeX?: number;
  58837. sizeY?: number;
  58838. sizeZ?: number;
  58839. custom?: any;
  58840. faceUV?: Vector4[];
  58841. faceColors?: Color4[];
  58842. flat?: boolean;
  58843. updatable?: boolean;
  58844. sideOrientation?: number;
  58845. frontUVs?: Vector4;
  58846. backUVs?: Vector4;
  58847. }, scene?: Nullable<Scene>): Mesh;
  58848. }
  58849. }
  58850. declare module "babylonjs/Gizmos/scaleGizmo" {
  58851. import { Observable } from "babylonjs/Misc/observable";
  58852. import { Nullable } from "babylonjs/types";
  58853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58854. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58855. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58856. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58857. import { Node } from "babylonjs/node";
  58858. /**
  58859. * Gizmo that enables scaling a mesh along 3 axis
  58860. */
  58861. export class ScaleGizmo extends Gizmo {
  58862. /**
  58863. * Internal gizmo used for interactions on the x axis
  58864. */
  58865. xGizmo: AxisScaleGizmo;
  58866. /**
  58867. * Internal gizmo used for interactions on the y axis
  58868. */
  58869. yGizmo: AxisScaleGizmo;
  58870. /**
  58871. * Internal gizmo used for interactions on the z axis
  58872. */
  58873. zGizmo: AxisScaleGizmo;
  58874. /**
  58875. * Internal gizmo used to scale all axis equally
  58876. */
  58877. uniformScaleGizmo: AxisScaleGizmo;
  58878. private _meshAttached;
  58879. private _nodeAttached;
  58880. private _snapDistance;
  58881. private _uniformScalingMesh;
  58882. private _octahedron;
  58883. private _sensitivity;
  58884. /** Fires an event when any of it's sub gizmos are dragged */
  58885. onDragStartObservable: Observable<unknown>;
  58886. /** Fires an event when any of it's sub gizmos are released from dragging */
  58887. onDragEndObservable: Observable<unknown>;
  58888. get attachedMesh(): Nullable<AbstractMesh>;
  58889. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58890. get attachedNode(): Nullable<Node>;
  58891. set attachedNode(node: Nullable<Node>);
  58892. /**
  58893. * True when the mouse pointer is hovering a gizmo mesh
  58894. */
  58895. get isHovered(): boolean;
  58896. /**
  58897. * Creates a ScaleGizmo
  58898. * @param gizmoLayer The utility layer the gizmo will be added to
  58899. * @param thickness display gizmo axis thickness
  58900. */
  58901. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  58902. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58903. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58904. /**
  58905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58906. */
  58907. set snapDistance(value: number);
  58908. get snapDistance(): number;
  58909. /**
  58910. * Ratio for the scale of the gizmo (Default: 1)
  58911. */
  58912. set scaleRatio(value: number);
  58913. get scaleRatio(): number;
  58914. /**
  58915. * Sensitivity factor for dragging (Default: 1)
  58916. */
  58917. set sensitivity(value: number);
  58918. get sensitivity(): number;
  58919. /**
  58920. * Disposes of the gizmo
  58921. */
  58922. dispose(): void;
  58923. }
  58924. }
  58925. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  58926. import { Observable } from "babylonjs/Misc/observable";
  58927. import { Nullable } from "babylonjs/types";
  58928. import { Vector3 } from "babylonjs/Maths/math.vector";
  58929. import { Node } from "babylonjs/node";
  58930. import { Mesh } from "babylonjs/Meshes/mesh";
  58931. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  58932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58933. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58934. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  58935. import { Color3 } from "babylonjs/Maths/math.color";
  58936. /**
  58937. * Single axis scale gizmo
  58938. */
  58939. export class AxisScaleGizmo extends Gizmo {
  58940. /**
  58941. * Drag behavior responsible for the gizmos dragging interactions
  58942. */
  58943. dragBehavior: PointerDragBehavior;
  58944. private _pointerObserver;
  58945. /**
  58946. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58947. */
  58948. snapDistance: number;
  58949. /**
  58950. * Event that fires each time the gizmo snaps to a new location.
  58951. * * snapDistance is the the change in distance
  58952. */
  58953. onSnapObservable: Observable<{
  58954. snapDistance: number;
  58955. }>;
  58956. /**
  58957. * If the scaling operation should be done on all axis (default: false)
  58958. */
  58959. uniformScaling: boolean;
  58960. /**
  58961. * Custom sensitivity value for the drag strength
  58962. */
  58963. sensitivity: number;
  58964. private _isEnabled;
  58965. private _parent;
  58966. private _arrow;
  58967. private _coloredMaterial;
  58968. private _hoverMaterial;
  58969. /**
  58970. * Creates an AxisScaleGizmo
  58971. * @param gizmoLayer The utility layer the gizmo will be added to
  58972. * @param dragAxis The axis which the gizmo will be able to scale on
  58973. * @param color The color of the gizmo
  58974. * @param thickness display gizmo axis thickness
  58975. */
  58976. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  58977. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58978. /**
  58979. * If the gizmo is enabled
  58980. */
  58981. set isEnabled(value: boolean);
  58982. get isEnabled(): boolean;
  58983. /**
  58984. * Disposes of the gizmo
  58985. */
  58986. dispose(): void;
  58987. /**
  58988. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58989. * @param mesh The mesh to replace the default mesh of the gizmo
  58990. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58991. */
  58992. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58993. }
  58994. }
  58995. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  58996. import { Observable } from "babylonjs/Misc/observable";
  58997. import { Nullable } from "babylonjs/types";
  58998. import { Vector3 } from "babylonjs/Maths/math.vector";
  58999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59000. import { Mesh } from "babylonjs/Meshes/mesh";
  59001. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59002. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59003. import { Color3 } from "babylonjs/Maths/math.color";
  59004. import "babylonjs/Meshes/Builders/boxBuilder";
  59005. /**
  59006. * Bounding box gizmo
  59007. */
  59008. export class BoundingBoxGizmo extends Gizmo {
  59009. private _lineBoundingBox;
  59010. private _rotateSpheresParent;
  59011. private _scaleBoxesParent;
  59012. private _boundingDimensions;
  59013. private _renderObserver;
  59014. private _pointerObserver;
  59015. private _scaleDragSpeed;
  59016. private _tmpQuaternion;
  59017. private _tmpVector;
  59018. private _tmpRotationMatrix;
  59019. /**
  59020. * 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)
  59021. */
  59022. ignoreChildren: boolean;
  59023. /**
  59024. * 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)
  59025. */
  59026. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59027. /**
  59028. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59029. */
  59030. rotationSphereSize: number;
  59031. /**
  59032. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59033. */
  59034. scaleBoxSize: number;
  59035. /**
  59036. * 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)
  59037. */
  59038. fixedDragMeshScreenSize: boolean;
  59039. /**
  59040. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59041. */
  59042. fixedDragMeshScreenSizeDistanceFactor: number;
  59043. /**
  59044. * Fired when a rotation sphere or scale box is dragged
  59045. */
  59046. onDragStartObservable: Observable<{}>;
  59047. /**
  59048. * Fired when a scale box is dragged
  59049. */
  59050. onScaleBoxDragObservable: Observable<{}>;
  59051. /**
  59052. * Fired when a scale box drag is ended
  59053. */
  59054. onScaleBoxDragEndObservable: Observable<{}>;
  59055. /**
  59056. * Fired when a rotation sphere is dragged
  59057. */
  59058. onRotationSphereDragObservable: Observable<{}>;
  59059. /**
  59060. * Fired when a rotation sphere drag is ended
  59061. */
  59062. onRotationSphereDragEndObservable: Observable<{}>;
  59063. /**
  59064. * 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)
  59065. */
  59066. scalePivot: Nullable<Vector3>;
  59067. /**
  59068. * Mesh used as a pivot to rotate the attached node
  59069. */
  59070. private _anchorMesh;
  59071. private _existingMeshScale;
  59072. private _dragMesh;
  59073. private pointerDragBehavior;
  59074. private coloredMaterial;
  59075. private hoverColoredMaterial;
  59076. /**
  59077. * Sets the color of the bounding box gizmo
  59078. * @param color the color to set
  59079. */
  59080. setColor(color: Color3): void;
  59081. /**
  59082. * Creates an BoundingBoxGizmo
  59083. * @param gizmoLayer The utility layer the gizmo will be added to
  59084. * @param color The color of the gizmo
  59085. */
  59086. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59087. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59088. private _selectNode;
  59089. /**
  59090. * Updates the bounding box information for the Gizmo
  59091. */
  59092. updateBoundingBox(): void;
  59093. private _updateRotationSpheres;
  59094. private _updateScaleBoxes;
  59095. /**
  59096. * Enables rotation on the specified axis and disables rotation on the others
  59097. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59098. */
  59099. setEnabledRotationAxis(axis: string): void;
  59100. /**
  59101. * Enables/disables scaling
  59102. * @param enable if scaling should be enabled
  59103. * @param homogeneousScaling defines if scaling should only be homogeneous
  59104. */
  59105. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59106. private _updateDummy;
  59107. /**
  59108. * Enables a pointer drag behavior on the bounding box of the gizmo
  59109. */
  59110. enableDragBehavior(): void;
  59111. /**
  59112. * Disposes of the gizmo
  59113. */
  59114. dispose(): void;
  59115. /**
  59116. * 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)
  59117. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59118. * @returns the bounding box mesh with the passed in mesh as a child
  59119. */
  59120. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59121. /**
  59122. * CustomMeshes are not supported by this gizmo
  59123. * @param mesh The mesh to replace the default mesh of the gizmo
  59124. */
  59125. setCustomMesh(mesh: Mesh): void;
  59126. }
  59127. }
  59128. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59129. import { Observable } from "babylonjs/Misc/observable";
  59130. import { Nullable } from "babylonjs/types";
  59131. import { Vector3 } from "babylonjs/Maths/math.vector";
  59132. import { Color3 } from "babylonjs/Maths/math.color";
  59133. import { Node } from "babylonjs/node";
  59134. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59135. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59136. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59137. import "babylonjs/Meshes/Builders/linesBuilder";
  59138. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59139. /**
  59140. * Single plane rotation gizmo
  59141. */
  59142. export class PlaneRotationGizmo extends Gizmo {
  59143. /**
  59144. * Drag behavior responsible for the gizmos dragging interactions
  59145. */
  59146. dragBehavior: PointerDragBehavior;
  59147. private _pointerObserver;
  59148. /**
  59149. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59150. */
  59151. snapDistance: number;
  59152. /**
  59153. * Event that fires each time the gizmo snaps to a new location.
  59154. * * snapDistance is the the change in distance
  59155. */
  59156. onSnapObservable: Observable<{
  59157. snapDistance: number;
  59158. }>;
  59159. private _isEnabled;
  59160. private _parent;
  59161. /**
  59162. * Creates a PlaneRotationGizmo
  59163. * @param gizmoLayer The utility layer the gizmo will be added to
  59164. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59165. * @param color The color of the gizmo
  59166. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59167. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59168. * @param thickness display gizmo axis thickness
  59169. */
  59170. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59171. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59172. /**
  59173. * If the gizmo is enabled
  59174. */
  59175. set isEnabled(value: boolean);
  59176. get isEnabled(): boolean;
  59177. /**
  59178. * Disposes of the gizmo
  59179. */
  59180. dispose(): void;
  59181. }
  59182. }
  59183. declare module "babylonjs/Gizmos/rotationGizmo" {
  59184. import { Observable } from "babylonjs/Misc/observable";
  59185. import { Nullable } from "babylonjs/types";
  59186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59187. import { Mesh } from "babylonjs/Meshes/mesh";
  59188. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59189. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59191. import { Node } from "babylonjs/node";
  59192. /**
  59193. * Gizmo that enables rotating a mesh along 3 axis
  59194. */
  59195. export class RotationGizmo extends Gizmo {
  59196. /**
  59197. * Internal gizmo used for interactions on the x axis
  59198. */
  59199. xGizmo: PlaneRotationGizmo;
  59200. /**
  59201. * Internal gizmo used for interactions on the y axis
  59202. */
  59203. yGizmo: PlaneRotationGizmo;
  59204. /**
  59205. * Internal gizmo used for interactions on the z axis
  59206. */
  59207. zGizmo: PlaneRotationGizmo;
  59208. /** Fires an event when any of it's sub gizmos are dragged */
  59209. onDragStartObservable: Observable<unknown>;
  59210. /** Fires an event when any of it's sub gizmos are released from dragging */
  59211. onDragEndObservable: Observable<unknown>;
  59212. private _meshAttached;
  59213. private _nodeAttached;
  59214. get attachedMesh(): Nullable<AbstractMesh>;
  59215. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59216. get attachedNode(): Nullable<Node>;
  59217. set attachedNode(node: Nullable<Node>);
  59218. /**
  59219. * True when the mouse pointer is hovering a gizmo mesh
  59220. */
  59221. get isHovered(): boolean;
  59222. /**
  59223. * Creates a RotationGizmo
  59224. * @param gizmoLayer The utility layer the gizmo will be added to
  59225. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59226. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59227. * @param thickness display gizmo axis thickness
  59228. */
  59229. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59230. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59231. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59232. /**
  59233. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59234. */
  59235. set snapDistance(value: number);
  59236. get snapDistance(): number;
  59237. /**
  59238. * Ratio for the scale of the gizmo (Default: 1)
  59239. */
  59240. set scaleRatio(value: number);
  59241. get scaleRatio(): number;
  59242. /**
  59243. * Disposes of the gizmo
  59244. */
  59245. dispose(): void;
  59246. /**
  59247. * CustomMeshes are not supported by this gizmo
  59248. * @param mesh The mesh to replace the default mesh of the gizmo
  59249. */
  59250. setCustomMesh(mesh: Mesh): void;
  59251. }
  59252. }
  59253. declare module "babylonjs/Gizmos/gizmoManager" {
  59254. import { Observable } from "babylonjs/Misc/observable";
  59255. import { Nullable } from "babylonjs/types";
  59256. import { Scene, IDisposable } from "babylonjs/scene";
  59257. import { Node } from "babylonjs/node";
  59258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59259. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59260. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59261. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59262. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59263. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59264. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59265. /**
  59266. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59267. */
  59268. export class GizmoManager implements IDisposable {
  59269. private scene;
  59270. /**
  59271. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59272. */
  59273. gizmos: {
  59274. positionGizmo: Nullable<PositionGizmo>;
  59275. rotationGizmo: Nullable<RotationGizmo>;
  59276. scaleGizmo: Nullable<ScaleGizmo>;
  59277. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59278. };
  59279. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59280. clearGizmoOnEmptyPointerEvent: boolean;
  59281. /** Fires an event when the manager is attached to a mesh */
  59282. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59283. /** Fires an event when the manager is attached to a node */
  59284. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59285. private _gizmosEnabled;
  59286. private _pointerObserver;
  59287. private _attachedMesh;
  59288. private _attachedNode;
  59289. private _boundingBoxColor;
  59290. private _defaultUtilityLayer;
  59291. private _defaultKeepDepthUtilityLayer;
  59292. private _thickness;
  59293. /**
  59294. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59295. */
  59296. boundingBoxDragBehavior: SixDofDragBehavior;
  59297. /**
  59298. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59299. */
  59300. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59301. /**
  59302. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59303. */
  59304. attachableNodes: Nullable<Array<Node>>;
  59305. /**
  59306. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59307. */
  59308. usePointerToAttachGizmos: boolean;
  59309. /**
  59310. * Utility layer that the bounding box gizmo belongs to
  59311. */
  59312. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59313. /**
  59314. * Utility layer that all gizmos besides bounding box belong to
  59315. */
  59316. get utilityLayer(): UtilityLayerRenderer;
  59317. /**
  59318. * True when the mouse pointer is hovering a gizmo mesh
  59319. */
  59320. get isHovered(): boolean;
  59321. /**
  59322. * Instatiates a gizmo manager
  59323. * @param scene the scene to overlay the gizmos on top of
  59324. * @param thickness display gizmo axis thickness
  59325. */
  59326. constructor(scene: Scene, thickness?: number);
  59327. /**
  59328. * Attaches a set of gizmos to the specified mesh
  59329. * @param mesh The mesh the gizmo's should be attached to
  59330. */
  59331. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59332. /**
  59333. * Attaches a set of gizmos to the specified node
  59334. * @param node The node the gizmo's should be attached to
  59335. */
  59336. attachToNode(node: Nullable<Node>): void;
  59337. /**
  59338. * If the position gizmo is enabled
  59339. */
  59340. set positionGizmoEnabled(value: boolean);
  59341. get positionGizmoEnabled(): boolean;
  59342. /**
  59343. * If the rotation gizmo is enabled
  59344. */
  59345. set rotationGizmoEnabled(value: boolean);
  59346. get rotationGizmoEnabled(): boolean;
  59347. /**
  59348. * If the scale gizmo is enabled
  59349. */
  59350. set scaleGizmoEnabled(value: boolean);
  59351. get scaleGizmoEnabled(): boolean;
  59352. /**
  59353. * If the boundingBox gizmo is enabled
  59354. */
  59355. set boundingBoxGizmoEnabled(value: boolean);
  59356. get boundingBoxGizmoEnabled(): boolean;
  59357. /**
  59358. * Disposes of the gizmo manager
  59359. */
  59360. dispose(): void;
  59361. }
  59362. }
  59363. declare module "babylonjs/Lights/directionalLight" {
  59364. import { Camera } from "babylonjs/Cameras/camera";
  59365. import { Scene } from "babylonjs/scene";
  59366. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59368. import { Light } from "babylonjs/Lights/light";
  59369. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59370. import { Effect } from "babylonjs/Materials/effect";
  59371. /**
  59372. * A directional light is defined by a direction (what a surprise!).
  59373. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59374. * 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.
  59375. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59376. */
  59377. export class DirectionalLight extends ShadowLight {
  59378. private _shadowFrustumSize;
  59379. /**
  59380. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59381. */
  59382. get shadowFrustumSize(): number;
  59383. /**
  59384. * Specifies a fix frustum size for the shadow generation.
  59385. */
  59386. set shadowFrustumSize(value: number);
  59387. private _shadowOrthoScale;
  59388. /**
  59389. * Gets the shadow projection scale against the optimal computed one.
  59390. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59391. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59392. */
  59393. get shadowOrthoScale(): number;
  59394. /**
  59395. * Sets the shadow projection scale against the optimal computed one.
  59396. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59397. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59398. */
  59399. set shadowOrthoScale(value: number);
  59400. /**
  59401. * Automatically compute the projection matrix to best fit (including all the casters)
  59402. * on each frame.
  59403. */
  59404. autoUpdateExtends: boolean;
  59405. /**
  59406. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59407. * on each frame. autoUpdateExtends must be set to true for this to work
  59408. */
  59409. autoCalcShadowZBounds: boolean;
  59410. private _orthoLeft;
  59411. private _orthoRight;
  59412. private _orthoTop;
  59413. private _orthoBottom;
  59414. /**
  59415. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59416. * The directional light is emitted from everywhere in the given direction.
  59417. * It can cast shadows.
  59418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59419. * @param name The friendly name of the light
  59420. * @param direction The direction of the light
  59421. * @param scene The scene the light belongs to
  59422. */
  59423. constructor(name: string, direction: Vector3, scene: Scene);
  59424. /**
  59425. * Returns the string "DirectionalLight".
  59426. * @return The class name
  59427. */
  59428. getClassName(): string;
  59429. /**
  59430. * Returns the integer 1.
  59431. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59432. */
  59433. getTypeID(): number;
  59434. /**
  59435. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59436. * Returns the DirectionalLight Shadow projection matrix.
  59437. */
  59438. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59439. /**
  59440. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59441. * Returns the DirectionalLight Shadow projection matrix.
  59442. */
  59443. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59444. /**
  59445. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59446. * Returns the DirectionalLight Shadow projection matrix.
  59447. */
  59448. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59449. protected _buildUniformLayout(): void;
  59450. /**
  59451. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59452. * @param effect The effect to update
  59453. * @param lightIndex The index of the light in the effect to update
  59454. * @returns The directional light
  59455. */
  59456. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59457. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59458. /**
  59459. * Gets the minZ used for shadow according to both the scene and the light.
  59460. *
  59461. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59462. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59463. * @param activeCamera The camera we are returning the min for
  59464. * @returns the depth min z
  59465. */
  59466. getDepthMinZ(activeCamera: Camera): number;
  59467. /**
  59468. * Gets the maxZ used for shadow according to both the scene and the light.
  59469. *
  59470. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59471. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59472. * @param activeCamera The camera we are returning the max for
  59473. * @returns the depth max z
  59474. */
  59475. getDepthMaxZ(activeCamera: Camera): number;
  59476. /**
  59477. * Prepares the list of defines specific to the light type.
  59478. * @param defines the list of defines
  59479. * @param lightIndex defines the index of the light for the effect
  59480. */
  59481. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59482. }
  59483. }
  59484. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59485. import { Mesh } from "babylonjs/Meshes/mesh";
  59486. /**
  59487. * Class containing static functions to help procedurally build meshes
  59488. */
  59489. export class HemisphereBuilder {
  59490. /**
  59491. * Creates a hemisphere mesh
  59492. * @param name defines the name of the mesh
  59493. * @param options defines the options used to create the mesh
  59494. * @param scene defines the hosting scene
  59495. * @returns the hemisphere mesh
  59496. */
  59497. static CreateHemisphere(name: string, options: {
  59498. segments?: number;
  59499. diameter?: number;
  59500. sideOrientation?: number;
  59501. }, scene: any): Mesh;
  59502. }
  59503. }
  59504. declare module "babylonjs/Lights/spotLight" {
  59505. import { Nullable } from "babylonjs/types";
  59506. import { Scene } from "babylonjs/scene";
  59507. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59509. import { Effect } from "babylonjs/Materials/effect";
  59510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59511. import { Light } from "babylonjs/Lights/light";
  59512. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59513. /**
  59514. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59515. * These values define a cone of light starting from the position, emitting toward the direction.
  59516. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59517. * and the exponent defines the speed of the decay of the light with distance (reach).
  59518. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59519. */
  59520. export class SpotLight extends ShadowLight {
  59521. private _angle;
  59522. private _innerAngle;
  59523. private _cosHalfAngle;
  59524. private _lightAngleScale;
  59525. private _lightAngleOffset;
  59526. /**
  59527. * Gets the cone angle of the spot light in Radians.
  59528. */
  59529. get angle(): number;
  59530. /**
  59531. * Sets the cone angle of the spot light in Radians.
  59532. */
  59533. set angle(value: number);
  59534. /**
  59535. * Only used in gltf falloff mode, this defines the angle where
  59536. * the directional falloff will start before cutting at angle which could be seen
  59537. * as outer angle.
  59538. */
  59539. get innerAngle(): number;
  59540. /**
  59541. * Only used in gltf falloff mode, this defines the angle where
  59542. * the directional falloff will start before cutting at angle which could be seen
  59543. * as outer angle.
  59544. */
  59545. set innerAngle(value: number);
  59546. private _shadowAngleScale;
  59547. /**
  59548. * Allows scaling the angle of the light for shadow generation only.
  59549. */
  59550. get shadowAngleScale(): number;
  59551. /**
  59552. * Allows scaling the angle of the light for shadow generation only.
  59553. */
  59554. set shadowAngleScale(value: number);
  59555. /**
  59556. * The light decay speed with the distance from the emission spot.
  59557. */
  59558. exponent: number;
  59559. private _projectionTextureMatrix;
  59560. /**
  59561. * Allows reading the projecton texture
  59562. */
  59563. get projectionTextureMatrix(): Matrix;
  59564. protected _projectionTextureLightNear: number;
  59565. /**
  59566. * Gets the near clip of the Spotlight for texture projection.
  59567. */
  59568. get projectionTextureLightNear(): number;
  59569. /**
  59570. * Sets the near clip of the Spotlight for texture projection.
  59571. */
  59572. set projectionTextureLightNear(value: number);
  59573. protected _projectionTextureLightFar: number;
  59574. /**
  59575. * Gets the far clip of the Spotlight for texture projection.
  59576. */
  59577. get projectionTextureLightFar(): number;
  59578. /**
  59579. * Sets the far clip of the Spotlight for texture projection.
  59580. */
  59581. set projectionTextureLightFar(value: number);
  59582. protected _projectionTextureUpDirection: Vector3;
  59583. /**
  59584. * Gets the Up vector of the Spotlight for texture projection.
  59585. */
  59586. get projectionTextureUpDirection(): Vector3;
  59587. /**
  59588. * Sets the Up vector of the Spotlight for texture projection.
  59589. */
  59590. set projectionTextureUpDirection(value: Vector3);
  59591. private _projectionTexture;
  59592. /**
  59593. * Gets the projection texture of the light.
  59594. */
  59595. get projectionTexture(): Nullable<BaseTexture>;
  59596. /**
  59597. * Sets the projection texture of the light.
  59598. */
  59599. set projectionTexture(value: Nullable<BaseTexture>);
  59600. private _projectionTextureViewLightDirty;
  59601. private _projectionTextureProjectionLightDirty;
  59602. private _projectionTextureDirty;
  59603. private _projectionTextureViewTargetVector;
  59604. private _projectionTextureViewLightMatrix;
  59605. private _projectionTextureProjectionLightMatrix;
  59606. private _projectionTextureScalingMatrix;
  59607. /**
  59608. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59609. * It can cast shadows.
  59610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59611. * @param name The light friendly name
  59612. * @param position The position of the spot light in the scene
  59613. * @param direction The direction of the light in the scene
  59614. * @param angle The cone angle of the light in Radians
  59615. * @param exponent The light decay speed with the distance from the emission spot
  59616. * @param scene The scene the lights belongs to
  59617. */
  59618. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59619. /**
  59620. * Returns the string "SpotLight".
  59621. * @returns the class name
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Returns the integer 2.
  59626. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59627. */
  59628. getTypeID(): number;
  59629. /**
  59630. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59631. */
  59632. protected _setDirection(value: Vector3): void;
  59633. /**
  59634. * Overrides the position setter to recompute the projection texture view light Matrix.
  59635. */
  59636. protected _setPosition(value: Vector3): void;
  59637. /**
  59638. * 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.
  59639. * Returns the SpotLight.
  59640. */
  59641. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59642. protected _computeProjectionTextureViewLightMatrix(): void;
  59643. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59644. /**
  59645. * Main function for light texture projection matrix computing.
  59646. */
  59647. protected _computeProjectionTextureMatrix(): void;
  59648. protected _buildUniformLayout(): void;
  59649. private _computeAngleValues;
  59650. /**
  59651. * Sets the passed Effect "effect" with the Light textures.
  59652. * @param effect The effect to update
  59653. * @param lightIndex The index of the light in the effect to update
  59654. * @returns The light
  59655. */
  59656. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59657. /**
  59658. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59659. * @param effect The effect to update
  59660. * @param lightIndex The index of the light in the effect to update
  59661. * @returns The spot light
  59662. */
  59663. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59664. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59665. /**
  59666. * Disposes the light and the associated resources.
  59667. */
  59668. dispose(): void;
  59669. /**
  59670. * Prepares the list of defines specific to the light type.
  59671. * @param defines the list of defines
  59672. * @param lightIndex defines the index of the light for the effect
  59673. */
  59674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59675. }
  59676. }
  59677. declare module "babylonjs/Gizmos/lightGizmo" {
  59678. import { Nullable } from "babylonjs/types";
  59679. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59680. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59681. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59682. import { Light } from "babylonjs/Lights/light";
  59683. import { Observable } from "babylonjs/Misc/observable";
  59684. /**
  59685. * Gizmo that enables viewing a light
  59686. */
  59687. export class LightGizmo extends Gizmo {
  59688. private _lightMesh;
  59689. private _material;
  59690. private _cachedPosition;
  59691. private _cachedForward;
  59692. private _attachedMeshParent;
  59693. private _pointerObserver;
  59694. /**
  59695. * Event that fires each time the gizmo is clicked
  59696. */
  59697. onClickedObservable: Observable<Light>;
  59698. /**
  59699. * Creates a LightGizmo
  59700. * @param gizmoLayer The utility layer the gizmo will be added to
  59701. */
  59702. constructor(gizmoLayer?: UtilityLayerRenderer);
  59703. private _light;
  59704. /**
  59705. * The light that the gizmo is attached to
  59706. */
  59707. set light(light: Nullable<Light>);
  59708. get light(): Nullable<Light>;
  59709. /**
  59710. * Gets the material used to render the light gizmo
  59711. */
  59712. get material(): StandardMaterial;
  59713. /**
  59714. * @hidden
  59715. * Updates the gizmo to match the attached mesh's position/rotation
  59716. */
  59717. protected _update(): void;
  59718. private static _Scale;
  59719. /**
  59720. * Creates the lines for a light mesh
  59721. */
  59722. private static _CreateLightLines;
  59723. /**
  59724. * Disposes of the light gizmo
  59725. */
  59726. dispose(): void;
  59727. private static _CreateHemisphericLightMesh;
  59728. private static _CreatePointLightMesh;
  59729. private static _CreateSpotLightMesh;
  59730. private static _CreateDirectionalLightMesh;
  59731. }
  59732. }
  59733. declare module "babylonjs/Gizmos/cameraGizmo" {
  59734. import { Nullable } from "babylonjs/types";
  59735. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59736. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59737. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59738. import { Camera } from "babylonjs/Cameras/camera";
  59739. import { Observable } from "babylonjs/Misc/observable";
  59740. /**
  59741. * Gizmo that enables viewing a camera
  59742. */
  59743. export class CameraGizmo extends Gizmo {
  59744. private _cameraMesh;
  59745. private _cameraLinesMesh;
  59746. private _material;
  59747. private _pointerObserver;
  59748. /**
  59749. * Event that fires each time the gizmo is clicked
  59750. */
  59751. onClickedObservable: Observable<Camera>;
  59752. /**
  59753. * Creates a CameraGizmo
  59754. * @param gizmoLayer The utility layer the gizmo will be added to
  59755. */
  59756. constructor(gizmoLayer?: UtilityLayerRenderer);
  59757. private _camera;
  59758. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59759. get displayFrustum(): boolean;
  59760. set displayFrustum(value: boolean);
  59761. /**
  59762. * The camera that the gizmo is attached to
  59763. */
  59764. set camera(camera: Nullable<Camera>);
  59765. get camera(): Nullable<Camera>;
  59766. /**
  59767. * Gets the material used to render the camera gizmo
  59768. */
  59769. get material(): StandardMaterial;
  59770. /**
  59771. * @hidden
  59772. * Updates the gizmo to match the attached mesh's position/rotation
  59773. */
  59774. protected _update(): void;
  59775. private static _Scale;
  59776. private _invProjection;
  59777. /**
  59778. * Disposes of the camera gizmo
  59779. */
  59780. dispose(): void;
  59781. private static _CreateCameraMesh;
  59782. private static _CreateCameraFrustum;
  59783. }
  59784. }
  59785. declare module "babylonjs/Gizmos/index" {
  59786. export * from "babylonjs/Gizmos/axisDragGizmo";
  59787. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59788. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59789. export * from "babylonjs/Gizmos/gizmo";
  59790. export * from "babylonjs/Gizmos/gizmoManager";
  59791. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59792. export * from "babylonjs/Gizmos/positionGizmo";
  59793. export * from "babylonjs/Gizmos/rotationGizmo";
  59794. export * from "babylonjs/Gizmos/scaleGizmo";
  59795. export * from "babylonjs/Gizmos/lightGizmo";
  59796. export * from "babylonjs/Gizmos/cameraGizmo";
  59797. export * from "babylonjs/Gizmos/planeDragGizmo";
  59798. }
  59799. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59800. /** @hidden */
  59801. export var backgroundFragmentDeclaration: {
  59802. name: string;
  59803. shader: string;
  59804. };
  59805. }
  59806. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59807. /** @hidden */
  59808. export var backgroundUboDeclaration: {
  59809. name: string;
  59810. shader: string;
  59811. };
  59812. }
  59813. declare module "babylonjs/Shaders/background.fragment" {
  59814. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59815. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59816. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59817. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59818. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59819. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59821. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59822. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59823. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59824. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59825. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59826. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59827. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59828. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59829. /** @hidden */
  59830. export var backgroundPixelShader: {
  59831. name: string;
  59832. shader: string;
  59833. };
  59834. }
  59835. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59836. /** @hidden */
  59837. export var backgroundVertexDeclaration: {
  59838. name: string;
  59839. shader: string;
  59840. };
  59841. }
  59842. declare module "babylonjs/Shaders/background.vertex" {
  59843. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59844. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59846. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59849. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59850. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59851. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59852. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59853. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59854. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59855. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59856. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59857. /** @hidden */
  59858. export var backgroundVertexShader: {
  59859. name: string;
  59860. shader: string;
  59861. };
  59862. }
  59863. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59864. import { Nullable, int, float } from "babylonjs/types";
  59865. import { Scene } from "babylonjs/scene";
  59866. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59869. import { Mesh } from "babylonjs/Meshes/mesh";
  59870. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59872. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59874. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59875. import { Color3 } from "babylonjs/Maths/math.color";
  59876. import "babylonjs/Shaders/background.fragment";
  59877. import "babylonjs/Shaders/background.vertex";
  59878. /**
  59879. * Background material used to create an efficient environement around your scene.
  59880. */
  59881. export class BackgroundMaterial extends PushMaterial {
  59882. /**
  59883. * Standard reflectance value at parallel view angle.
  59884. */
  59885. static StandardReflectance0: number;
  59886. /**
  59887. * Standard reflectance value at grazing angle.
  59888. */
  59889. static StandardReflectance90: number;
  59890. protected _primaryColor: Color3;
  59891. /**
  59892. * Key light Color (multiply against the environement texture)
  59893. */
  59894. primaryColor: Color3;
  59895. protected __perceptualColor: Nullable<Color3>;
  59896. /**
  59897. * Experimental Internal Use Only.
  59898. *
  59899. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  59900. * This acts as a helper to set the primary color to a more "human friendly" value.
  59901. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  59902. * output color as close as possible from the chosen value.
  59903. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  59904. * part of lighting setup.)
  59905. */
  59906. get _perceptualColor(): Nullable<Color3>;
  59907. set _perceptualColor(value: Nullable<Color3>);
  59908. protected _primaryColorShadowLevel: float;
  59909. /**
  59910. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  59911. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  59912. */
  59913. get primaryColorShadowLevel(): float;
  59914. set primaryColorShadowLevel(value: float);
  59915. protected _primaryColorHighlightLevel: float;
  59916. /**
  59917. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  59918. * The primary color is used at the level chosen to define what the white area would look.
  59919. */
  59920. get primaryColorHighlightLevel(): float;
  59921. set primaryColorHighlightLevel(value: float);
  59922. protected _reflectionTexture: Nullable<BaseTexture>;
  59923. /**
  59924. * Reflection Texture used in the material.
  59925. * Should be author in a specific way for the best result (refer to the documentation).
  59926. */
  59927. reflectionTexture: Nullable<BaseTexture>;
  59928. protected _reflectionBlur: float;
  59929. /**
  59930. * Reflection Texture level of blur.
  59931. *
  59932. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  59933. * texture twice.
  59934. */
  59935. reflectionBlur: float;
  59936. protected _diffuseTexture: Nullable<BaseTexture>;
  59937. /**
  59938. * Diffuse Texture used in the material.
  59939. * Should be author in a specific way for the best result (refer to the documentation).
  59940. */
  59941. diffuseTexture: Nullable<BaseTexture>;
  59942. protected _shadowLights: Nullable<IShadowLight[]>;
  59943. /**
  59944. * Specify the list of lights casting shadow on the material.
  59945. * All scene shadow lights will be included if null.
  59946. */
  59947. shadowLights: Nullable<IShadowLight[]>;
  59948. protected _shadowLevel: float;
  59949. /**
  59950. * Helps adjusting the shadow to a softer level if required.
  59951. * 0 means black shadows and 1 means no shadows.
  59952. */
  59953. shadowLevel: float;
  59954. protected _sceneCenter: Vector3;
  59955. /**
  59956. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  59957. * It is usually zero but might be interesting to modify according to your setup.
  59958. */
  59959. sceneCenter: Vector3;
  59960. protected _opacityFresnel: boolean;
  59961. /**
  59962. * This helps specifying that the material is falling off to the sky box at grazing angle.
  59963. * This helps ensuring a nice transition when the camera goes under the ground.
  59964. */
  59965. opacityFresnel: boolean;
  59966. protected _reflectionFresnel: boolean;
  59967. /**
  59968. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  59969. * This helps adding a mirror texture on the ground.
  59970. */
  59971. reflectionFresnel: boolean;
  59972. protected _reflectionFalloffDistance: number;
  59973. /**
  59974. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  59975. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  59976. */
  59977. reflectionFalloffDistance: number;
  59978. protected _reflectionAmount: number;
  59979. /**
  59980. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  59981. */
  59982. reflectionAmount: number;
  59983. protected _reflectionReflectance0: number;
  59984. /**
  59985. * This specifies the weight of the reflection at grazing angle.
  59986. */
  59987. reflectionReflectance0: number;
  59988. protected _reflectionReflectance90: number;
  59989. /**
  59990. * This specifies the weight of the reflection at a perpendicular point of view.
  59991. */
  59992. reflectionReflectance90: number;
  59993. /**
  59994. * Sets the reflection reflectance fresnel values according to the default standard
  59995. * empirically know to work well :-)
  59996. */
  59997. set reflectionStandardFresnelWeight(value: number);
  59998. protected _useRGBColor: boolean;
  59999. /**
  60000. * Helps to directly use the maps channels instead of their level.
  60001. */
  60002. useRGBColor: boolean;
  60003. protected _enableNoise: boolean;
  60004. /**
  60005. * This helps reducing the banding effect that could occur on the background.
  60006. */
  60007. enableNoise: boolean;
  60008. /**
  60009. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60010. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60011. * Recommended to be keep at 1.0 except for special cases.
  60012. */
  60013. get fovMultiplier(): number;
  60014. set fovMultiplier(value: number);
  60015. private _fovMultiplier;
  60016. /**
  60017. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60018. */
  60019. useEquirectangularFOV: boolean;
  60020. private _maxSimultaneousLights;
  60021. /**
  60022. * Number of Simultaneous lights allowed on the material.
  60023. */
  60024. maxSimultaneousLights: int;
  60025. private _shadowOnly;
  60026. /**
  60027. * Make the material only render shadows
  60028. */
  60029. shadowOnly: boolean;
  60030. /**
  60031. * Default configuration related to image processing available in the Background Material.
  60032. */
  60033. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60034. /**
  60035. * Keep track of the image processing observer to allow dispose and replace.
  60036. */
  60037. private _imageProcessingObserver;
  60038. /**
  60039. * Attaches a new image processing configuration to the PBR Material.
  60040. * @param configuration (if null the scene configuration will be use)
  60041. */
  60042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60043. /**
  60044. * Gets the image processing configuration used either in this material.
  60045. */
  60046. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60047. /**
  60048. * Sets the Default image processing configuration used either in the this material.
  60049. *
  60050. * If sets to null, the scene one is in use.
  60051. */
  60052. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60053. /**
  60054. * Gets wether the color curves effect is enabled.
  60055. */
  60056. get cameraColorCurvesEnabled(): boolean;
  60057. /**
  60058. * Sets wether the color curves effect is enabled.
  60059. */
  60060. set cameraColorCurvesEnabled(value: boolean);
  60061. /**
  60062. * Gets wether the color grading effect is enabled.
  60063. */
  60064. get cameraColorGradingEnabled(): boolean;
  60065. /**
  60066. * Gets wether the color grading effect is enabled.
  60067. */
  60068. set cameraColorGradingEnabled(value: boolean);
  60069. /**
  60070. * Gets wether tonemapping is enabled or not.
  60071. */
  60072. get cameraToneMappingEnabled(): boolean;
  60073. /**
  60074. * Sets wether tonemapping is enabled or not
  60075. */
  60076. set cameraToneMappingEnabled(value: boolean);
  60077. /**
  60078. * The camera exposure used on this material.
  60079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60080. * This corresponds to a photographic exposure.
  60081. */
  60082. get cameraExposure(): float;
  60083. /**
  60084. * The camera exposure used on this material.
  60085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60086. * This corresponds to a photographic exposure.
  60087. */
  60088. set cameraExposure(value: float);
  60089. /**
  60090. * Gets The camera contrast used on this material.
  60091. */
  60092. get cameraContrast(): float;
  60093. /**
  60094. * Sets The camera contrast used on this material.
  60095. */
  60096. set cameraContrast(value: float);
  60097. /**
  60098. * Gets the Color Grading 2D Lookup Texture.
  60099. */
  60100. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60101. /**
  60102. * Sets the Color Grading 2D Lookup Texture.
  60103. */
  60104. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60105. /**
  60106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60108. * 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;
  60109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60110. */
  60111. get cameraColorCurves(): Nullable<ColorCurves>;
  60112. /**
  60113. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60114. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60115. * 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;
  60116. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60117. */
  60118. set cameraColorCurves(value: Nullable<ColorCurves>);
  60119. /**
  60120. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60121. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60122. */
  60123. switchToBGR: boolean;
  60124. private _renderTargets;
  60125. private _reflectionControls;
  60126. private _white;
  60127. private _primaryShadowColor;
  60128. private _primaryHighlightColor;
  60129. /**
  60130. * Instantiates a Background Material in the given scene
  60131. * @param name The friendly name of the material
  60132. * @param scene The scene to add the material to
  60133. */
  60134. constructor(name: string, scene: Scene);
  60135. /**
  60136. * Gets a boolean indicating that current material needs to register RTT
  60137. */
  60138. get hasRenderTargetTextures(): boolean;
  60139. /**
  60140. * The entire material has been created in order to prevent overdraw.
  60141. * @returns false
  60142. */
  60143. needAlphaTesting(): boolean;
  60144. /**
  60145. * The entire material has been created in order to prevent overdraw.
  60146. * @returns true if blending is enable
  60147. */
  60148. needAlphaBlending(): boolean;
  60149. /**
  60150. * Checks wether the material is ready to be rendered for a given mesh.
  60151. * @param mesh The mesh to render
  60152. * @param subMesh The submesh to check against
  60153. * @param useInstances Specify wether or not the material is used with instances
  60154. * @returns true if all the dependencies are ready (Textures, Effects...)
  60155. */
  60156. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60157. /**
  60158. * Compute the primary color according to the chosen perceptual color.
  60159. */
  60160. private _computePrimaryColorFromPerceptualColor;
  60161. /**
  60162. * Compute the highlights and shadow colors according to their chosen levels.
  60163. */
  60164. private _computePrimaryColors;
  60165. /**
  60166. * Build the uniform buffer used in the material.
  60167. */
  60168. buildUniformLayout(): void;
  60169. /**
  60170. * Unbind the material.
  60171. */
  60172. unbind(): void;
  60173. /**
  60174. * Bind only the world matrix to the material.
  60175. * @param world The world matrix to bind.
  60176. */
  60177. bindOnlyWorldMatrix(world: Matrix): void;
  60178. /**
  60179. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60180. * @param world The world matrix to bind.
  60181. * @param subMesh The submesh to bind for.
  60182. */
  60183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60184. /**
  60185. * Checks to see if a texture is used in the material.
  60186. * @param texture - Base texture to use.
  60187. * @returns - Boolean specifying if a texture is used in the material.
  60188. */
  60189. hasTexture(texture: BaseTexture): boolean;
  60190. /**
  60191. * Dispose the material.
  60192. * @param forceDisposeEffect Force disposal of the associated effect.
  60193. * @param forceDisposeTextures Force disposal of the associated textures.
  60194. */
  60195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60196. /**
  60197. * Clones the material.
  60198. * @param name The cloned name.
  60199. * @returns The cloned material.
  60200. */
  60201. clone(name: string): BackgroundMaterial;
  60202. /**
  60203. * Serializes the current material to its JSON representation.
  60204. * @returns The JSON representation.
  60205. */
  60206. serialize(): any;
  60207. /**
  60208. * Gets the class name of the material
  60209. * @returns "BackgroundMaterial"
  60210. */
  60211. getClassName(): string;
  60212. /**
  60213. * Parse a JSON input to create back a background material.
  60214. * @param source The JSON data to parse
  60215. * @param scene The scene to create the parsed material in
  60216. * @param rootUrl The root url of the assets the material depends upon
  60217. * @returns the instantiated BackgroundMaterial.
  60218. */
  60219. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60220. }
  60221. }
  60222. declare module "babylonjs/Helpers/environmentHelper" {
  60223. import { Observable } from "babylonjs/Misc/observable";
  60224. import { Nullable } from "babylonjs/types";
  60225. import { Scene } from "babylonjs/scene";
  60226. import { Vector3 } from "babylonjs/Maths/math.vector";
  60227. import { Color3 } from "babylonjs/Maths/math.color";
  60228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60229. import { Mesh } from "babylonjs/Meshes/mesh";
  60230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60231. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60232. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60233. import "babylonjs/Meshes/Builders/planeBuilder";
  60234. import "babylonjs/Meshes/Builders/boxBuilder";
  60235. /**
  60236. * Represents the different options available during the creation of
  60237. * a Environment helper.
  60238. *
  60239. * This can control the default ground, skybox and image processing setup of your scene.
  60240. */
  60241. export interface IEnvironmentHelperOptions {
  60242. /**
  60243. * Specifies whether or not to create a ground.
  60244. * True by default.
  60245. */
  60246. createGround: boolean;
  60247. /**
  60248. * Specifies the ground size.
  60249. * 15 by default.
  60250. */
  60251. groundSize: number;
  60252. /**
  60253. * The texture used on the ground for the main color.
  60254. * Comes from the BabylonJS CDN by default.
  60255. *
  60256. * Remarks: Can be either a texture or a url.
  60257. */
  60258. groundTexture: string | BaseTexture;
  60259. /**
  60260. * The color mixed in the ground texture by default.
  60261. * BabylonJS clearColor by default.
  60262. */
  60263. groundColor: Color3;
  60264. /**
  60265. * Specifies the ground opacity.
  60266. * 1 by default.
  60267. */
  60268. groundOpacity: number;
  60269. /**
  60270. * Enables the ground to receive shadows.
  60271. * True by default.
  60272. */
  60273. enableGroundShadow: boolean;
  60274. /**
  60275. * Helps preventing the shadow to be fully black on the ground.
  60276. * 0.5 by default.
  60277. */
  60278. groundShadowLevel: number;
  60279. /**
  60280. * Creates a mirror texture attach to the ground.
  60281. * false by default.
  60282. */
  60283. enableGroundMirror: boolean;
  60284. /**
  60285. * Specifies the ground mirror size ratio.
  60286. * 0.3 by default as the default kernel is 64.
  60287. */
  60288. groundMirrorSizeRatio: number;
  60289. /**
  60290. * Specifies the ground mirror blur kernel size.
  60291. * 64 by default.
  60292. */
  60293. groundMirrorBlurKernel: number;
  60294. /**
  60295. * Specifies the ground mirror visibility amount.
  60296. * 1 by default
  60297. */
  60298. groundMirrorAmount: number;
  60299. /**
  60300. * Specifies the ground mirror reflectance weight.
  60301. * This uses the standard weight of the background material to setup the fresnel effect
  60302. * of the mirror.
  60303. * 1 by default.
  60304. */
  60305. groundMirrorFresnelWeight: number;
  60306. /**
  60307. * Specifies the ground mirror Falloff distance.
  60308. * This can helps reducing the size of the reflection.
  60309. * 0 by Default.
  60310. */
  60311. groundMirrorFallOffDistance: number;
  60312. /**
  60313. * Specifies the ground mirror texture type.
  60314. * Unsigned Int by Default.
  60315. */
  60316. groundMirrorTextureType: number;
  60317. /**
  60318. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60319. * the shown objects.
  60320. */
  60321. groundYBias: number;
  60322. /**
  60323. * Specifies whether or not to create a skybox.
  60324. * True by default.
  60325. */
  60326. createSkybox: boolean;
  60327. /**
  60328. * Specifies the skybox size.
  60329. * 20 by default.
  60330. */
  60331. skyboxSize: number;
  60332. /**
  60333. * The texture used on the skybox for the main color.
  60334. * Comes from the BabylonJS CDN by default.
  60335. *
  60336. * Remarks: Can be either a texture or a url.
  60337. */
  60338. skyboxTexture: string | BaseTexture;
  60339. /**
  60340. * The color mixed in the skybox texture by default.
  60341. * BabylonJS clearColor by default.
  60342. */
  60343. skyboxColor: Color3;
  60344. /**
  60345. * The background rotation around the Y axis of the scene.
  60346. * This helps aligning the key lights of your scene with the background.
  60347. * 0 by default.
  60348. */
  60349. backgroundYRotation: number;
  60350. /**
  60351. * Compute automatically the size of the elements to best fit with the scene.
  60352. */
  60353. sizeAuto: boolean;
  60354. /**
  60355. * Default position of the rootMesh if autoSize is not true.
  60356. */
  60357. rootPosition: Vector3;
  60358. /**
  60359. * Sets up the image processing in the scene.
  60360. * true by default.
  60361. */
  60362. setupImageProcessing: boolean;
  60363. /**
  60364. * The texture used as your environment texture in the scene.
  60365. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60366. *
  60367. * Remarks: Can be either a texture or a url.
  60368. */
  60369. environmentTexture: string | BaseTexture;
  60370. /**
  60371. * The value of the exposure to apply to the scene.
  60372. * 0.6 by default if setupImageProcessing is true.
  60373. */
  60374. cameraExposure: number;
  60375. /**
  60376. * The value of the contrast to apply to the scene.
  60377. * 1.6 by default if setupImageProcessing is true.
  60378. */
  60379. cameraContrast: number;
  60380. /**
  60381. * Specifies whether or not tonemapping should be enabled in the scene.
  60382. * true by default if setupImageProcessing is true.
  60383. */
  60384. toneMappingEnabled: boolean;
  60385. }
  60386. /**
  60387. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60388. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60389. * It also helps with the default setup of your imageProcessing configuration.
  60390. */
  60391. export class EnvironmentHelper {
  60392. /**
  60393. * Default ground texture URL.
  60394. */
  60395. private static _groundTextureCDNUrl;
  60396. /**
  60397. * Default skybox texture URL.
  60398. */
  60399. private static _skyboxTextureCDNUrl;
  60400. /**
  60401. * Default environment texture URL.
  60402. */
  60403. private static _environmentTextureCDNUrl;
  60404. /**
  60405. * Creates the default options for the helper.
  60406. */
  60407. private static _getDefaultOptions;
  60408. private _rootMesh;
  60409. /**
  60410. * Gets the root mesh created by the helper.
  60411. */
  60412. get rootMesh(): Mesh;
  60413. private _skybox;
  60414. /**
  60415. * Gets the skybox created by the helper.
  60416. */
  60417. get skybox(): Nullable<Mesh>;
  60418. private _skyboxTexture;
  60419. /**
  60420. * Gets the skybox texture created by the helper.
  60421. */
  60422. get skyboxTexture(): Nullable<BaseTexture>;
  60423. private _skyboxMaterial;
  60424. /**
  60425. * Gets the skybox material created by the helper.
  60426. */
  60427. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60428. private _ground;
  60429. /**
  60430. * Gets the ground mesh created by the helper.
  60431. */
  60432. get ground(): Nullable<Mesh>;
  60433. private _groundTexture;
  60434. /**
  60435. * Gets the ground texture created by the helper.
  60436. */
  60437. get groundTexture(): Nullable<BaseTexture>;
  60438. private _groundMirror;
  60439. /**
  60440. * Gets the ground mirror created by the helper.
  60441. */
  60442. get groundMirror(): Nullable<MirrorTexture>;
  60443. /**
  60444. * Gets the ground mirror render list to helps pushing the meshes
  60445. * you wish in the ground reflection.
  60446. */
  60447. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60448. private _groundMaterial;
  60449. /**
  60450. * Gets the ground material created by the helper.
  60451. */
  60452. get groundMaterial(): Nullable<BackgroundMaterial>;
  60453. /**
  60454. * Stores the creation options.
  60455. */
  60456. private readonly _scene;
  60457. private _options;
  60458. /**
  60459. * This observable will be notified with any error during the creation of the environment,
  60460. * mainly texture creation errors.
  60461. */
  60462. onErrorObservable: Observable<{
  60463. message?: string;
  60464. exception?: any;
  60465. }>;
  60466. /**
  60467. * constructor
  60468. * @param options Defines the options we want to customize the helper
  60469. * @param scene The scene to add the material to
  60470. */
  60471. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60472. /**
  60473. * Updates the background according to the new options
  60474. * @param options
  60475. */
  60476. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60477. /**
  60478. * Sets the primary color of all the available elements.
  60479. * @param color the main color to affect to the ground and the background
  60480. */
  60481. setMainColor(color: Color3): void;
  60482. /**
  60483. * Setup the image processing according to the specified options.
  60484. */
  60485. private _setupImageProcessing;
  60486. /**
  60487. * Setup the environment texture according to the specified options.
  60488. */
  60489. private _setupEnvironmentTexture;
  60490. /**
  60491. * Setup the background according to the specified options.
  60492. */
  60493. private _setupBackground;
  60494. /**
  60495. * Get the scene sizes according to the setup.
  60496. */
  60497. private _getSceneSize;
  60498. /**
  60499. * Setup the ground according to the specified options.
  60500. */
  60501. private _setupGround;
  60502. /**
  60503. * Setup the ground material according to the specified options.
  60504. */
  60505. private _setupGroundMaterial;
  60506. /**
  60507. * Setup the ground diffuse texture according to the specified options.
  60508. */
  60509. private _setupGroundDiffuseTexture;
  60510. /**
  60511. * Setup the ground mirror texture according to the specified options.
  60512. */
  60513. private _setupGroundMirrorTexture;
  60514. /**
  60515. * Setup the ground to receive the mirror texture.
  60516. */
  60517. private _setupMirrorInGroundMaterial;
  60518. /**
  60519. * Setup the skybox according to the specified options.
  60520. */
  60521. private _setupSkybox;
  60522. /**
  60523. * Setup the skybox material according to the specified options.
  60524. */
  60525. private _setupSkyboxMaterial;
  60526. /**
  60527. * Setup the skybox reflection texture according to the specified options.
  60528. */
  60529. private _setupSkyboxReflectionTexture;
  60530. private _errorHandler;
  60531. /**
  60532. * Dispose all the elements created by the Helper.
  60533. */
  60534. dispose(): void;
  60535. }
  60536. }
  60537. declare module "babylonjs/Helpers/textureDome" {
  60538. import { Scene } from "babylonjs/scene";
  60539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60540. import { Mesh } from "babylonjs/Meshes/mesh";
  60541. import { Texture } from "babylonjs/Materials/Textures/texture";
  60542. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60543. import "babylonjs/Meshes/Builders/sphereBuilder";
  60544. import { Nullable } from "babylonjs/types";
  60545. import { Observable } from "babylonjs/Misc/observable";
  60546. /**
  60547. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60548. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60549. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60550. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60551. */
  60552. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60553. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60554. /**
  60555. * Define the source as a Monoscopic panoramic 360/180.
  60556. */
  60557. static readonly MODE_MONOSCOPIC: number;
  60558. /**
  60559. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60560. */
  60561. static readonly MODE_TOPBOTTOM: number;
  60562. /**
  60563. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60564. */
  60565. static readonly MODE_SIDEBYSIDE: number;
  60566. private _halfDome;
  60567. private _crossEye;
  60568. protected _useDirectMapping: boolean;
  60569. /**
  60570. * The texture being displayed on the sphere
  60571. */
  60572. protected _texture: T;
  60573. /**
  60574. * Gets the texture being displayed on the sphere
  60575. */
  60576. get texture(): T;
  60577. /**
  60578. * Sets the texture being displayed on the sphere
  60579. */
  60580. set texture(newTexture: T);
  60581. /**
  60582. * The skybox material
  60583. */
  60584. protected _material: BackgroundMaterial;
  60585. /**
  60586. * The surface used for the dome
  60587. */
  60588. protected _mesh: Mesh;
  60589. /**
  60590. * Gets the mesh used for the dome.
  60591. */
  60592. get mesh(): Mesh;
  60593. /**
  60594. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60595. */
  60596. private _halfDomeMask;
  60597. /**
  60598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60599. * Also see the options.resolution property.
  60600. */
  60601. get fovMultiplier(): number;
  60602. set fovMultiplier(value: number);
  60603. protected _textureMode: number;
  60604. /**
  60605. * Gets or set the current texture mode for the texture. It can be:
  60606. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60607. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60608. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60609. */
  60610. get textureMode(): number;
  60611. /**
  60612. * Sets the current texture mode for the texture. It can be:
  60613. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60614. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60615. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60616. */
  60617. set textureMode(value: number);
  60618. /**
  60619. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60620. */
  60621. get halfDome(): boolean;
  60622. /**
  60623. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60624. */
  60625. set halfDome(enabled: boolean);
  60626. /**
  60627. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60628. */
  60629. set crossEye(enabled: boolean);
  60630. /**
  60631. * Is it a cross-eye texture?
  60632. */
  60633. get crossEye(): boolean;
  60634. /**
  60635. * Oberserver used in Stereoscopic VR Mode.
  60636. */
  60637. private _onBeforeCameraRenderObserver;
  60638. /**
  60639. * Observable raised when an error occured while loading the 360 image
  60640. */
  60641. onLoadErrorObservable: Observable<string>;
  60642. /**
  60643. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60644. * @param name Element's name, child elements will append suffixes for their own names.
  60645. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60646. * @param options An object containing optional or exposed sub element properties
  60647. */
  60648. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60649. resolution?: number;
  60650. clickToPlay?: boolean;
  60651. autoPlay?: boolean;
  60652. loop?: boolean;
  60653. size?: number;
  60654. poster?: string;
  60655. faceForward?: boolean;
  60656. useDirectMapping?: boolean;
  60657. halfDomeMode?: boolean;
  60658. crossEyeMode?: boolean;
  60659. generateMipMaps?: boolean;
  60660. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60661. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60662. protected _changeTextureMode(value: number): void;
  60663. /**
  60664. * Releases resources associated with this node.
  60665. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60666. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60667. */
  60668. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60669. }
  60670. }
  60671. declare module "babylonjs/Helpers/photoDome" {
  60672. import { Scene } from "babylonjs/scene";
  60673. import { Texture } from "babylonjs/Materials/Textures/texture";
  60674. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60675. /**
  60676. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60677. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60678. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60679. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60680. */
  60681. export class PhotoDome extends TextureDome<Texture> {
  60682. /**
  60683. * Define the image as a Monoscopic panoramic 360 image.
  60684. */
  60685. static readonly MODE_MONOSCOPIC: number;
  60686. /**
  60687. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60688. */
  60689. static readonly MODE_TOPBOTTOM: number;
  60690. /**
  60691. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60692. */
  60693. static readonly MODE_SIDEBYSIDE: number;
  60694. /**
  60695. * Gets or sets the texture being displayed on the sphere
  60696. */
  60697. get photoTexture(): Texture;
  60698. /**
  60699. * sets the texture being displayed on the sphere
  60700. */
  60701. set photoTexture(value: Texture);
  60702. /**
  60703. * Gets the current video mode for the video. It can be:
  60704. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60705. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60706. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60707. */
  60708. get imageMode(): number;
  60709. /**
  60710. * Sets the current video mode for the video. It can be:
  60711. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60712. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60713. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60714. */
  60715. set imageMode(value: number);
  60716. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60717. }
  60718. }
  60719. declare module "babylonjs/Misc/dds" {
  60720. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60721. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60722. import { Nullable } from "babylonjs/types";
  60723. import { Scene } from "babylonjs/scene";
  60724. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60725. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60726. /**
  60727. * Direct draw surface info
  60728. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60729. */
  60730. export interface DDSInfo {
  60731. /**
  60732. * Width of the texture
  60733. */
  60734. width: number;
  60735. /**
  60736. * Width of the texture
  60737. */
  60738. height: number;
  60739. /**
  60740. * Number of Mipmaps for the texture
  60741. * @see https://en.wikipedia.org/wiki/Mipmap
  60742. */
  60743. mipmapCount: number;
  60744. /**
  60745. * If the textures format is a known fourCC format
  60746. * @see https://www.fourcc.org/
  60747. */
  60748. isFourCC: boolean;
  60749. /**
  60750. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60751. */
  60752. isRGB: boolean;
  60753. /**
  60754. * If the texture is a lumincance format
  60755. */
  60756. isLuminance: boolean;
  60757. /**
  60758. * If this is a cube texture
  60759. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60760. */
  60761. isCube: boolean;
  60762. /**
  60763. * If the texture is a compressed format eg. FOURCC_DXT1
  60764. */
  60765. isCompressed: boolean;
  60766. /**
  60767. * The dxgiFormat of the texture
  60768. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60769. */
  60770. dxgiFormat: number;
  60771. /**
  60772. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60773. */
  60774. textureType: number;
  60775. /**
  60776. * Sphericle polynomial created for the dds texture
  60777. */
  60778. sphericalPolynomial?: SphericalPolynomial;
  60779. }
  60780. /**
  60781. * Class used to provide DDS decompression tools
  60782. */
  60783. export class DDSTools {
  60784. /**
  60785. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60786. */
  60787. static StoreLODInAlphaChannel: boolean;
  60788. /**
  60789. * Gets DDS information from an array buffer
  60790. * @param data defines the array buffer view to read data from
  60791. * @returns the DDS information
  60792. */
  60793. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60794. private static _FloatView;
  60795. private static _Int32View;
  60796. private static _ToHalfFloat;
  60797. private static _FromHalfFloat;
  60798. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60799. private static _GetHalfFloatRGBAArrayBuffer;
  60800. private static _GetFloatRGBAArrayBuffer;
  60801. private static _GetFloatAsUIntRGBAArrayBuffer;
  60802. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60803. private static _GetRGBAArrayBuffer;
  60804. private static _ExtractLongWordOrder;
  60805. private static _GetRGBArrayBuffer;
  60806. private static _GetLuminanceArrayBuffer;
  60807. /**
  60808. * Uploads DDS Levels to a Babylon Texture
  60809. * @hidden
  60810. */
  60811. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60812. }
  60813. module "babylonjs/Engines/thinEngine" {
  60814. interface ThinEngine {
  60815. /**
  60816. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60817. * @param rootUrl defines the url where the file to load is located
  60818. * @param scene defines the current scene
  60819. * @param lodScale defines scale to apply to the mip map selection
  60820. * @param lodOffset defines offset to apply to the mip map selection
  60821. * @param onLoad defines an optional callback raised when the texture is loaded
  60822. * @param onError defines an optional callback raised if there is an issue to load the texture
  60823. * @param format defines the format of the data
  60824. * @param forcedExtension defines the extension to use to pick the right loader
  60825. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60826. * @returns the cube texture as an InternalTexture
  60827. */
  60828. 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;
  60829. }
  60830. }
  60831. }
  60832. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60833. import { Nullable } from "babylonjs/types";
  60834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60835. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60836. /**
  60837. * Implementation of the DDS Texture Loader.
  60838. * @hidden
  60839. */
  60840. export class _DDSTextureLoader implements IInternalTextureLoader {
  60841. /**
  60842. * Defines wether the loader supports cascade loading the different faces.
  60843. */
  60844. readonly supportCascades: boolean;
  60845. /**
  60846. * This returns if the loader support the current file information.
  60847. * @param extension defines the file extension of the file being loaded
  60848. * @returns true if the loader can load the specified file
  60849. */
  60850. canLoad(extension: string): boolean;
  60851. /**
  60852. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60853. * @param data contains the texture data
  60854. * @param texture defines the BabylonJS internal texture
  60855. * @param createPolynomials will be true if polynomials have been requested
  60856. * @param onLoad defines the callback to trigger once the texture is ready
  60857. * @param onError defines the callback to trigger in case of error
  60858. */
  60859. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60860. /**
  60861. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60862. * @param data contains the texture data
  60863. * @param texture defines the BabylonJS internal texture
  60864. * @param callback defines the method to call once ready to upload
  60865. */
  60866. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60867. }
  60868. }
  60869. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60870. import { Nullable } from "babylonjs/types";
  60871. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60872. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60873. /**
  60874. * Implementation of the ENV Texture Loader.
  60875. * @hidden
  60876. */
  60877. export class _ENVTextureLoader implements IInternalTextureLoader {
  60878. /**
  60879. * Defines wether the loader supports cascade loading the different faces.
  60880. */
  60881. readonly supportCascades: boolean;
  60882. /**
  60883. * This returns if the loader support the current file information.
  60884. * @param extension defines the file extension of the file being loaded
  60885. * @returns true if the loader can load the specified file
  60886. */
  60887. canLoad(extension: string): boolean;
  60888. /**
  60889. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60890. * @param data contains the texture data
  60891. * @param texture defines the BabylonJS internal texture
  60892. * @param createPolynomials will be true if polynomials have been requested
  60893. * @param onLoad defines the callback to trigger once the texture is ready
  60894. * @param onError defines the callback to trigger in case of error
  60895. */
  60896. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60897. /**
  60898. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60899. * @param data contains the texture data
  60900. * @param texture defines the BabylonJS internal texture
  60901. * @param callback defines the method to call once ready to upload
  60902. */
  60903. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60904. }
  60905. }
  60906. declare module "babylonjs/Misc/khronosTextureContainer" {
  60907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60908. /**
  60909. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60910. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60911. */
  60912. export class KhronosTextureContainer {
  60913. /** contents of the KTX container file */
  60914. data: ArrayBufferView;
  60915. private static HEADER_LEN;
  60916. private static COMPRESSED_2D;
  60917. private static COMPRESSED_3D;
  60918. private static TEX_2D;
  60919. private static TEX_3D;
  60920. /**
  60921. * Gets the openGL type
  60922. */
  60923. glType: number;
  60924. /**
  60925. * Gets the openGL type size
  60926. */
  60927. glTypeSize: number;
  60928. /**
  60929. * Gets the openGL format
  60930. */
  60931. glFormat: number;
  60932. /**
  60933. * Gets the openGL internal format
  60934. */
  60935. glInternalFormat: number;
  60936. /**
  60937. * Gets the base internal format
  60938. */
  60939. glBaseInternalFormat: number;
  60940. /**
  60941. * Gets image width in pixel
  60942. */
  60943. pixelWidth: number;
  60944. /**
  60945. * Gets image height in pixel
  60946. */
  60947. pixelHeight: number;
  60948. /**
  60949. * Gets image depth in pixels
  60950. */
  60951. pixelDepth: number;
  60952. /**
  60953. * Gets the number of array elements
  60954. */
  60955. numberOfArrayElements: number;
  60956. /**
  60957. * Gets the number of faces
  60958. */
  60959. numberOfFaces: number;
  60960. /**
  60961. * Gets the number of mipmap levels
  60962. */
  60963. numberOfMipmapLevels: number;
  60964. /**
  60965. * Gets the bytes of key value data
  60966. */
  60967. bytesOfKeyValueData: number;
  60968. /**
  60969. * Gets the load type
  60970. */
  60971. loadType: number;
  60972. /**
  60973. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60974. */
  60975. isInvalid: boolean;
  60976. /**
  60977. * Creates a new KhronosTextureContainer
  60978. * @param data contents of the KTX container file
  60979. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60980. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60981. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60982. */
  60983. constructor(
  60984. /** contents of the KTX container file */
  60985. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60986. /**
  60987. * Uploads KTX content to a Babylon Texture.
  60988. * It is assumed that the texture has already been created & is currently bound
  60989. * @hidden
  60990. */
  60991. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60992. private _upload2DCompressedLevels;
  60993. /**
  60994. * Checks if the given data starts with a KTX file identifier.
  60995. * @param data the data to check
  60996. * @returns true if the data is a KTX file or false otherwise
  60997. */
  60998. static IsValid(data: ArrayBufferView): boolean;
  60999. }
  61000. }
  61001. declare module "babylonjs/Misc/workerPool" {
  61002. import { IDisposable } from "babylonjs/scene";
  61003. /**
  61004. * Helper class to push actions to a pool of workers.
  61005. */
  61006. export class WorkerPool implements IDisposable {
  61007. private _workerInfos;
  61008. private _pendingActions;
  61009. /**
  61010. * Constructor
  61011. * @param workers Array of workers to use for actions
  61012. */
  61013. constructor(workers: Array<Worker>);
  61014. /**
  61015. * Terminates all workers and clears any pending actions.
  61016. */
  61017. dispose(): void;
  61018. /**
  61019. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61020. * pended until a worker has completed its action.
  61021. * @param action The action to perform. Call onComplete when the action is complete.
  61022. */
  61023. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61024. private _execute;
  61025. }
  61026. }
  61027. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61029. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61030. /**
  61031. * Class for loading KTX2 files
  61032. */
  61033. export class KhronosTextureContainer2 {
  61034. private static _WorkerPoolPromise?;
  61035. private static _Initialized;
  61036. private static _Ktx2Decoder;
  61037. /**
  61038. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61039. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61040. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61041. * Urls you can change:
  61042. * URLConfig.jsDecoderModule
  61043. * URLConfig.wasmUASTCToASTC
  61044. * URLConfig.wasmUASTCToBC7
  61045. * URLConfig.jsMSCTranscoder
  61046. * URLConfig.wasmMSCTranscoder
  61047. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61048. */
  61049. static URLConfig: {
  61050. jsDecoderModule: string;
  61051. wasmUASTCToASTC: null;
  61052. wasmUASTCToBC7: null;
  61053. jsMSCTranscoder: null;
  61054. wasmMSCTranscoder: null;
  61055. };
  61056. /**
  61057. * Default number of workers used to handle data decoding
  61058. */
  61059. static DefaultNumWorkers: number;
  61060. private static GetDefaultNumWorkers;
  61061. private _engine;
  61062. private static _CreateWorkerPool;
  61063. /**
  61064. * Constructor
  61065. * @param engine The engine to use
  61066. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61067. */
  61068. constructor(engine: ThinEngine, numWorkers?: number);
  61069. /** @hidden */
  61070. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61071. /**
  61072. * Stop all async operations and release resources.
  61073. */
  61074. dispose(): void;
  61075. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61076. /**
  61077. * Checks if the given data starts with a KTX2 file identifier.
  61078. * @param data the data to check
  61079. * @returns true if the data is a KTX2 file or false otherwise
  61080. */
  61081. static IsValid(data: ArrayBufferView): boolean;
  61082. }
  61083. }
  61084. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61085. import { Nullable } from "babylonjs/types";
  61086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61087. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61088. /**
  61089. * Implementation of the KTX Texture Loader.
  61090. * @hidden
  61091. */
  61092. export class _KTXTextureLoader implements IInternalTextureLoader {
  61093. /**
  61094. * Defines wether the loader supports cascade loading the different faces.
  61095. */
  61096. readonly supportCascades: boolean;
  61097. /**
  61098. * This returns if the loader support the current file information.
  61099. * @param extension defines the file extension of the file being loaded
  61100. * @param mimeType defines the optional mime type of the file being loaded
  61101. * @returns true if the loader can load the specified file
  61102. */
  61103. canLoad(extension: string, mimeType?: string): boolean;
  61104. /**
  61105. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61106. * @param data contains the texture data
  61107. * @param texture defines the BabylonJS internal texture
  61108. * @param createPolynomials will be true if polynomials have been requested
  61109. * @param onLoad defines the callback to trigger once the texture is ready
  61110. * @param onError defines the callback to trigger in case of error
  61111. */
  61112. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61113. /**
  61114. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61115. * @param data contains the texture data
  61116. * @param texture defines the BabylonJS internal texture
  61117. * @param callback defines the method to call once ready to upload
  61118. */
  61119. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61120. }
  61121. }
  61122. declare module "babylonjs/Helpers/sceneHelpers" {
  61123. import { Nullable } from "babylonjs/types";
  61124. import { Mesh } from "babylonjs/Meshes/mesh";
  61125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61126. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61127. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61128. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61129. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61130. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61131. import "babylonjs/Meshes/Builders/boxBuilder";
  61132. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61133. /** @hidden */
  61134. export var _forceSceneHelpersToBundle: boolean;
  61135. module "babylonjs/scene" {
  61136. interface Scene {
  61137. /**
  61138. * Creates a default light for the scene.
  61139. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61140. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61141. */
  61142. createDefaultLight(replace?: boolean): void;
  61143. /**
  61144. * Creates a default camera for the scene.
  61145. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61146. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61147. * @param replace has default false, when true replaces the active camera in the scene
  61148. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61149. */
  61150. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61151. /**
  61152. * Creates a default camera and a default light.
  61153. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61154. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61155. * @param replace has the default false, when true replaces the active camera/light in the scene
  61156. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61157. */
  61158. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61159. /**
  61160. * Creates a new sky box
  61161. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61162. * @param environmentTexture defines the texture to use as environment texture
  61163. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61164. * @param scale defines the overall scale of the skybox
  61165. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61166. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61167. * @returns a new mesh holding the sky box
  61168. */
  61169. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61170. /**
  61171. * Creates a new environment
  61172. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61173. * @param options defines the options you can use to configure the environment
  61174. * @returns the new EnvironmentHelper
  61175. */
  61176. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61177. /**
  61178. * Creates a new VREXperienceHelper
  61179. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61180. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61181. * @returns a new VREXperienceHelper
  61182. */
  61183. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61184. /**
  61185. * Creates a new WebXRDefaultExperience
  61186. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61187. * @param options experience options
  61188. * @returns a promise for a new WebXRDefaultExperience
  61189. */
  61190. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61191. }
  61192. }
  61193. }
  61194. declare module "babylonjs/Helpers/videoDome" {
  61195. import { Scene } from "babylonjs/scene";
  61196. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61197. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61198. /**
  61199. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61200. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61201. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61202. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61203. */
  61204. export class VideoDome extends TextureDome<VideoTexture> {
  61205. /**
  61206. * Define the video source as a Monoscopic panoramic 360 video.
  61207. */
  61208. static readonly MODE_MONOSCOPIC: number;
  61209. /**
  61210. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61211. */
  61212. static readonly MODE_TOPBOTTOM: number;
  61213. /**
  61214. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61215. */
  61216. static readonly MODE_SIDEBYSIDE: number;
  61217. /**
  61218. * Get the video texture associated with this video dome
  61219. */
  61220. get videoTexture(): VideoTexture;
  61221. /**
  61222. * Get the video mode of this dome
  61223. */
  61224. get videoMode(): number;
  61225. /**
  61226. * Set the video mode of this dome.
  61227. * @see textureMode
  61228. */
  61229. set videoMode(value: number);
  61230. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61231. }
  61232. }
  61233. declare module "babylonjs/Helpers/index" {
  61234. export * from "babylonjs/Helpers/environmentHelper";
  61235. export * from "babylonjs/Helpers/photoDome";
  61236. export * from "babylonjs/Helpers/sceneHelpers";
  61237. export * from "babylonjs/Helpers/videoDome";
  61238. }
  61239. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61240. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61241. import { IDisposable } from "babylonjs/scene";
  61242. import { Engine } from "babylonjs/Engines/engine";
  61243. /**
  61244. * This class can be used to get instrumentation data from a Babylon engine
  61245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61246. */
  61247. export class EngineInstrumentation implements IDisposable {
  61248. /**
  61249. * Define the instrumented engine.
  61250. */
  61251. engine: Engine;
  61252. private _captureGPUFrameTime;
  61253. private _gpuFrameTimeToken;
  61254. private _gpuFrameTime;
  61255. private _captureShaderCompilationTime;
  61256. private _shaderCompilationTime;
  61257. private _onBeginFrameObserver;
  61258. private _onEndFrameObserver;
  61259. private _onBeforeShaderCompilationObserver;
  61260. private _onAfterShaderCompilationObserver;
  61261. /**
  61262. * Gets the perf counter used for GPU frame time
  61263. */
  61264. get gpuFrameTimeCounter(): PerfCounter;
  61265. /**
  61266. * Gets the GPU frame time capture status
  61267. */
  61268. get captureGPUFrameTime(): boolean;
  61269. /**
  61270. * Enable or disable the GPU frame time capture
  61271. */
  61272. set captureGPUFrameTime(value: boolean);
  61273. /**
  61274. * Gets the perf counter used for shader compilation time
  61275. */
  61276. get shaderCompilationTimeCounter(): PerfCounter;
  61277. /**
  61278. * Gets the shader compilation time capture status
  61279. */
  61280. get captureShaderCompilationTime(): boolean;
  61281. /**
  61282. * Enable or disable the shader compilation time capture
  61283. */
  61284. set captureShaderCompilationTime(value: boolean);
  61285. /**
  61286. * Instantiates a new engine instrumentation.
  61287. * This class can be used to get instrumentation data from a Babylon engine
  61288. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61289. * @param engine Defines the engine to instrument
  61290. */
  61291. constructor(
  61292. /**
  61293. * Define the instrumented engine.
  61294. */
  61295. engine: Engine);
  61296. /**
  61297. * Dispose and release associated resources.
  61298. */
  61299. dispose(): void;
  61300. }
  61301. }
  61302. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61303. import { Scene, IDisposable } from "babylonjs/scene";
  61304. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61305. /**
  61306. * This class can be used to get instrumentation data from a Babylon engine
  61307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61308. */
  61309. export class SceneInstrumentation implements IDisposable {
  61310. /**
  61311. * Defines the scene to instrument
  61312. */
  61313. scene: Scene;
  61314. private _captureActiveMeshesEvaluationTime;
  61315. private _activeMeshesEvaluationTime;
  61316. private _captureRenderTargetsRenderTime;
  61317. private _renderTargetsRenderTime;
  61318. private _captureFrameTime;
  61319. private _frameTime;
  61320. private _captureRenderTime;
  61321. private _renderTime;
  61322. private _captureInterFrameTime;
  61323. private _interFrameTime;
  61324. private _captureParticlesRenderTime;
  61325. private _particlesRenderTime;
  61326. private _captureSpritesRenderTime;
  61327. private _spritesRenderTime;
  61328. private _capturePhysicsTime;
  61329. private _physicsTime;
  61330. private _captureAnimationsTime;
  61331. private _animationsTime;
  61332. private _captureCameraRenderTime;
  61333. private _cameraRenderTime;
  61334. private _onBeforeActiveMeshesEvaluationObserver;
  61335. private _onAfterActiveMeshesEvaluationObserver;
  61336. private _onBeforeRenderTargetsRenderObserver;
  61337. private _onAfterRenderTargetsRenderObserver;
  61338. private _onAfterRenderObserver;
  61339. private _onBeforeDrawPhaseObserver;
  61340. private _onAfterDrawPhaseObserver;
  61341. private _onBeforeAnimationsObserver;
  61342. private _onBeforeParticlesRenderingObserver;
  61343. private _onAfterParticlesRenderingObserver;
  61344. private _onBeforeSpritesRenderingObserver;
  61345. private _onAfterSpritesRenderingObserver;
  61346. private _onBeforePhysicsObserver;
  61347. private _onAfterPhysicsObserver;
  61348. private _onAfterAnimationsObserver;
  61349. private _onBeforeCameraRenderObserver;
  61350. private _onAfterCameraRenderObserver;
  61351. /**
  61352. * Gets the perf counter used for active meshes evaluation time
  61353. */
  61354. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61355. /**
  61356. * Gets the active meshes evaluation time capture status
  61357. */
  61358. get captureActiveMeshesEvaluationTime(): boolean;
  61359. /**
  61360. * Enable or disable the active meshes evaluation time capture
  61361. */
  61362. set captureActiveMeshesEvaluationTime(value: boolean);
  61363. /**
  61364. * Gets the perf counter used for render targets render time
  61365. */
  61366. get renderTargetsRenderTimeCounter(): PerfCounter;
  61367. /**
  61368. * Gets the render targets render time capture status
  61369. */
  61370. get captureRenderTargetsRenderTime(): boolean;
  61371. /**
  61372. * Enable or disable the render targets render time capture
  61373. */
  61374. set captureRenderTargetsRenderTime(value: boolean);
  61375. /**
  61376. * Gets the perf counter used for particles render time
  61377. */
  61378. get particlesRenderTimeCounter(): PerfCounter;
  61379. /**
  61380. * Gets the particles render time capture status
  61381. */
  61382. get captureParticlesRenderTime(): boolean;
  61383. /**
  61384. * Enable or disable the particles render time capture
  61385. */
  61386. set captureParticlesRenderTime(value: boolean);
  61387. /**
  61388. * Gets the perf counter used for sprites render time
  61389. */
  61390. get spritesRenderTimeCounter(): PerfCounter;
  61391. /**
  61392. * Gets the sprites render time capture status
  61393. */
  61394. get captureSpritesRenderTime(): boolean;
  61395. /**
  61396. * Enable or disable the sprites render time capture
  61397. */
  61398. set captureSpritesRenderTime(value: boolean);
  61399. /**
  61400. * Gets the perf counter used for physics time
  61401. */
  61402. get physicsTimeCounter(): PerfCounter;
  61403. /**
  61404. * Gets the physics time capture status
  61405. */
  61406. get capturePhysicsTime(): boolean;
  61407. /**
  61408. * Enable or disable the physics time capture
  61409. */
  61410. set capturePhysicsTime(value: boolean);
  61411. /**
  61412. * Gets the perf counter used for animations time
  61413. */
  61414. get animationsTimeCounter(): PerfCounter;
  61415. /**
  61416. * Gets the animations time capture status
  61417. */
  61418. get captureAnimationsTime(): boolean;
  61419. /**
  61420. * Enable or disable the animations time capture
  61421. */
  61422. set captureAnimationsTime(value: boolean);
  61423. /**
  61424. * Gets the perf counter used for frame time capture
  61425. */
  61426. get frameTimeCounter(): PerfCounter;
  61427. /**
  61428. * Gets the frame time capture status
  61429. */
  61430. get captureFrameTime(): boolean;
  61431. /**
  61432. * Enable or disable the frame time capture
  61433. */
  61434. set captureFrameTime(value: boolean);
  61435. /**
  61436. * Gets the perf counter used for inter-frames time capture
  61437. */
  61438. get interFrameTimeCounter(): PerfCounter;
  61439. /**
  61440. * Gets the inter-frames time capture status
  61441. */
  61442. get captureInterFrameTime(): boolean;
  61443. /**
  61444. * Enable or disable the inter-frames time capture
  61445. */
  61446. set captureInterFrameTime(value: boolean);
  61447. /**
  61448. * Gets the perf counter used for render time capture
  61449. */
  61450. get renderTimeCounter(): PerfCounter;
  61451. /**
  61452. * Gets the render time capture status
  61453. */
  61454. get captureRenderTime(): boolean;
  61455. /**
  61456. * Enable or disable the render time capture
  61457. */
  61458. set captureRenderTime(value: boolean);
  61459. /**
  61460. * Gets the perf counter used for camera render time capture
  61461. */
  61462. get cameraRenderTimeCounter(): PerfCounter;
  61463. /**
  61464. * Gets the camera render time capture status
  61465. */
  61466. get captureCameraRenderTime(): boolean;
  61467. /**
  61468. * Enable or disable the camera render time capture
  61469. */
  61470. set captureCameraRenderTime(value: boolean);
  61471. /**
  61472. * Gets the perf counter used for draw calls
  61473. */
  61474. get drawCallsCounter(): PerfCounter;
  61475. /**
  61476. * Instantiates a new scene instrumentation.
  61477. * This class can be used to get instrumentation data from a Babylon engine
  61478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61479. * @param scene Defines the scene to instrument
  61480. */
  61481. constructor(
  61482. /**
  61483. * Defines the scene to instrument
  61484. */
  61485. scene: Scene);
  61486. /**
  61487. * Dispose and release associated resources.
  61488. */
  61489. dispose(): void;
  61490. }
  61491. }
  61492. declare module "babylonjs/Instrumentation/index" {
  61493. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61494. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61495. export * from "babylonjs/Instrumentation/timeToken";
  61496. }
  61497. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61498. /** @hidden */
  61499. export var glowMapGenerationPixelShader: {
  61500. name: string;
  61501. shader: string;
  61502. };
  61503. }
  61504. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61508. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61510. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61511. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61512. /** @hidden */
  61513. export var glowMapGenerationVertexShader: {
  61514. name: string;
  61515. shader: string;
  61516. };
  61517. }
  61518. declare module "babylonjs/Layers/effectLayer" {
  61519. import { Observable } from "babylonjs/Misc/observable";
  61520. import { Nullable } from "babylonjs/types";
  61521. import { Camera } from "babylonjs/Cameras/camera";
  61522. import { Scene } from "babylonjs/scene";
  61523. import { ISize } from "babylonjs/Maths/math.size";
  61524. import { Color4 } from "babylonjs/Maths/math.color";
  61525. import { Engine } from "babylonjs/Engines/engine";
  61526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61528. import { Mesh } from "babylonjs/Meshes/mesh";
  61529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61532. import { Effect } from "babylonjs/Materials/effect";
  61533. import { Material } from "babylonjs/Materials/material";
  61534. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61535. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61536. /**
  61537. * Effect layer options. This helps customizing the behaviour
  61538. * of the effect layer.
  61539. */
  61540. export interface IEffectLayerOptions {
  61541. /**
  61542. * Multiplication factor apply to the canvas size to compute the render target size
  61543. * used to generated the objects (the smaller the faster).
  61544. */
  61545. mainTextureRatio: number;
  61546. /**
  61547. * Enforces a fixed size texture to ensure effect stability across devices.
  61548. */
  61549. mainTextureFixedSize?: number;
  61550. /**
  61551. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61552. */
  61553. alphaBlendingMode: number;
  61554. /**
  61555. * The camera attached to the layer.
  61556. */
  61557. camera: Nullable<Camera>;
  61558. /**
  61559. * The rendering group to draw the layer in.
  61560. */
  61561. renderingGroupId: number;
  61562. }
  61563. /**
  61564. * The effect layer Helps adding post process effect blended with the main pass.
  61565. *
  61566. * This can be for instance use to generate glow or higlight effects on the scene.
  61567. *
  61568. * The effect layer class can not be used directly and is intented to inherited from to be
  61569. * customized per effects.
  61570. */
  61571. export abstract class EffectLayer {
  61572. private _vertexBuffers;
  61573. private _indexBuffer;
  61574. private _cachedDefines;
  61575. private _effectLayerMapGenerationEffect;
  61576. private _effectLayerOptions;
  61577. private _mergeEffect;
  61578. protected _scene: Scene;
  61579. protected _engine: Engine;
  61580. protected _maxSize: number;
  61581. protected _mainTextureDesiredSize: ISize;
  61582. protected _mainTexture: RenderTargetTexture;
  61583. protected _shouldRender: boolean;
  61584. protected _postProcesses: PostProcess[];
  61585. protected _textures: BaseTexture[];
  61586. protected _emissiveTextureAndColor: {
  61587. texture: Nullable<BaseTexture>;
  61588. color: Color4;
  61589. };
  61590. /**
  61591. * The name of the layer
  61592. */
  61593. name: string;
  61594. /**
  61595. * The clear color of the texture used to generate the glow map.
  61596. */
  61597. neutralColor: Color4;
  61598. /**
  61599. * Specifies whether the highlight layer is enabled or not.
  61600. */
  61601. isEnabled: boolean;
  61602. /**
  61603. * Gets the camera attached to the layer.
  61604. */
  61605. get camera(): Nullable<Camera>;
  61606. /**
  61607. * Gets the rendering group id the layer should render in.
  61608. */
  61609. get renderingGroupId(): number;
  61610. set renderingGroupId(renderingGroupId: number);
  61611. /**
  61612. * An event triggered when the effect layer has been disposed.
  61613. */
  61614. onDisposeObservable: Observable<EffectLayer>;
  61615. /**
  61616. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61617. */
  61618. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61619. /**
  61620. * An event triggered when the generated texture is being merged in the scene.
  61621. */
  61622. onBeforeComposeObservable: Observable<EffectLayer>;
  61623. /**
  61624. * An event triggered when the mesh is rendered into the effect render target.
  61625. */
  61626. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61627. /**
  61628. * An event triggered after the mesh has been rendered into the effect render target.
  61629. */
  61630. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61631. /**
  61632. * An event triggered when the generated texture has been merged in the scene.
  61633. */
  61634. onAfterComposeObservable: Observable<EffectLayer>;
  61635. /**
  61636. * An event triggered when the efffect layer changes its size.
  61637. */
  61638. onSizeChangedObservable: Observable<EffectLayer>;
  61639. /** @hidden */
  61640. static _SceneComponentInitialization: (scene: Scene) => void;
  61641. /**
  61642. * Instantiates a new effect Layer and references it in the scene.
  61643. * @param name The name of the layer
  61644. * @param scene The scene to use the layer in
  61645. */
  61646. constructor(
  61647. /** The Friendly of the effect in the scene */
  61648. name: string, scene: Scene);
  61649. /**
  61650. * Get the effect name of the layer.
  61651. * @return The effect name
  61652. */
  61653. abstract getEffectName(): string;
  61654. /**
  61655. * Checks for the readiness of the element composing the layer.
  61656. * @param subMesh the mesh to check for
  61657. * @param useInstances specify whether or not to use instances to render the mesh
  61658. * @return true if ready otherwise, false
  61659. */
  61660. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61661. /**
  61662. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61663. * @returns true if the effect requires stencil during the main canvas render pass.
  61664. */
  61665. abstract needStencil(): boolean;
  61666. /**
  61667. * Create the merge effect. This is the shader use to blit the information back
  61668. * to the main canvas at the end of the scene rendering.
  61669. * @returns The effect containing the shader used to merge the effect on the main canvas
  61670. */
  61671. protected abstract _createMergeEffect(): Effect;
  61672. /**
  61673. * Creates the render target textures and post processes used in the effect layer.
  61674. */
  61675. protected abstract _createTextureAndPostProcesses(): void;
  61676. /**
  61677. * Implementation specific of rendering the generating effect on the main canvas.
  61678. * @param effect The effect used to render through
  61679. */
  61680. protected abstract _internalRender(effect: Effect): void;
  61681. /**
  61682. * Sets the required values for both the emissive texture and and the main color.
  61683. */
  61684. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61685. /**
  61686. * Free any resources and references associated to a mesh.
  61687. * Internal use
  61688. * @param mesh The mesh to free.
  61689. */
  61690. abstract _disposeMesh(mesh: Mesh): void;
  61691. /**
  61692. * Serializes this layer (Glow or Highlight for example)
  61693. * @returns a serialized layer object
  61694. */
  61695. abstract serialize?(): any;
  61696. /**
  61697. * Initializes the effect layer with the required options.
  61698. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61699. */
  61700. protected _init(options: Partial<IEffectLayerOptions>): void;
  61701. /**
  61702. * Generates the index buffer of the full screen quad blending to the main canvas.
  61703. */
  61704. private _generateIndexBuffer;
  61705. /**
  61706. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61707. */
  61708. private _generateVertexBuffer;
  61709. /**
  61710. * Sets the main texture desired size which is the closest power of two
  61711. * of the engine canvas size.
  61712. */
  61713. private _setMainTextureSize;
  61714. /**
  61715. * Creates the main texture for the effect layer.
  61716. */
  61717. protected _createMainTexture(): void;
  61718. /**
  61719. * Adds specific effects defines.
  61720. * @param defines The defines to add specifics to.
  61721. */
  61722. protected _addCustomEffectDefines(defines: string[]): void;
  61723. /**
  61724. * Checks for the readiness of the element composing the layer.
  61725. * @param subMesh the mesh to check for
  61726. * @param useInstances specify whether or not to use instances to render the mesh
  61727. * @param emissiveTexture the associated emissive texture used to generate the glow
  61728. * @return true if ready otherwise, false
  61729. */
  61730. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61731. /**
  61732. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61733. */
  61734. render(): void;
  61735. /**
  61736. * Determine if a given mesh will be used in the current effect.
  61737. * @param mesh mesh to test
  61738. * @returns true if the mesh will be used
  61739. */
  61740. hasMesh(mesh: AbstractMesh): boolean;
  61741. /**
  61742. * Returns true if the layer contains information to display, otherwise false.
  61743. * @returns true if the glow layer should be rendered
  61744. */
  61745. shouldRender(): boolean;
  61746. /**
  61747. * Returns true if the mesh should render, otherwise false.
  61748. * @param mesh The mesh to render
  61749. * @returns true if it should render otherwise false
  61750. */
  61751. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61752. /**
  61753. * Returns true if the mesh can be rendered, otherwise false.
  61754. * @param mesh The mesh to render
  61755. * @param material The material used on the mesh
  61756. * @returns true if it can be rendered otherwise false
  61757. */
  61758. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61759. /**
  61760. * Returns true if the mesh should render, otherwise false.
  61761. * @param mesh The mesh to render
  61762. * @returns true if it should render otherwise false
  61763. */
  61764. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61765. /**
  61766. * Renders the submesh passed in parameter to the generation map.
  61767. */
  61768. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61769. /**
  61770. * Defines whether the current material of the mesh should be use to render the effect.
  61771. * @param mesh defines the current mesh to render
  61772. */
  61773. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61774. /**
  61775. * Rebuild the required buffers.
  61776. * @hidden Internal use only.
  61777. */
  61778. _rebuild(): void;
  61779. /**
  61780. * Dispose only the render target textures and post process.
  61781. */
  61782. private _disposeTextureAndPostProcesses;
  61783. /**
  61784. * Dispose the highlight layer and free resources.
  61785. */
  61786. dispose(): void;
  61787. /**
  61788. * Gets the class name of the effect layer
  61789. * @returns the string with the class name of the effect layer
  61790. */
  61791. getClassName(): string;
  61792. /**
  61793. * Creates an effect layer from parsed effect layer data
  61794. * @param parsedEffectLayer defines effect layer data
  61795. * @param scene defines the current scene
  61796. * @param rootUrl defines the root URL containing the effect layer information
  61797. * @returns a parsed effect Layer
  61798. */
  61799. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61800. }
  61801. }
  61802. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61803. import { Scene } from "babylonjs/scene";
  61804. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61805. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61806. import { AbstractScene } from "babylonjs/abstractScene";
  61807. module "babylonjs/abstractScene" {
  61808. interface AbstractScene {
  61809. /**
  61810. * The list of effect layers (highlights/glow) added to the scene
  61811. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61812. * @see https://doc.babylonjs.com/how_to/glow_layer
  61813. */
  61814. effectLayers: Array<EffectLayer>;
  61815. /**
  61816. * Removes the given effect layer from this scene.
  61817. * @param toRemove defines the effect layer to remove
  61818. * @returns the index of the removed effect layer
  61819. */
  61820. removeEffectLayer(toRemove: EffectLayer): number;
  61821. /**
  61822. * Adds the given effect layer to this scene
  61823. * @param newEffectLayer defines the effect layer to add
  61824. */
  61825. addEffectLayer(newEffectLayer: EffectLayer): void;
  61826. }
  61827. }
  61828. /**
  61829. * Defines the layer scene component responsible to manage any effect layers
  61830. * in a given scene.
  61831. */
  61832. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61833. /**
  61834. * The component name helpfull to identify the component in the list of scene components.
  61835. */
  61836. readonly name: string;
  61837. /**
  61838. * The scene the component belongs to.
  61839. */
  61840. scene: Scene;
  61841. private _engine;
  61842. private _renderEffects;
  61843. private _needStencil;
  61844. private _previousStencilState;
  61845. /**
  61846. * Creates a new instance of the component for the given scene
  61847. * @param scene Defines the scene to register the component in
  61848. */
  61849. constructor(scene: Scene);
  61850. /**
  61851. * Registers the component in a given scene
  61852. */
  61853. register(): void;
  61854. /**
  61855. * Rebuilds the elements related to this component in case of
  61856. * context lost for instance.
  61857. */
  61858. rebuild(): void;
  61859. /**
  61860. * Serializes the component data to the specified json object
  61861. * @param serializationObject The object to serialize to
  61862. */
  61863. serialize(serializationObject: any): void;
  61864. /**
  61865. * Adds all the elements from the container to the scene
  61866. * @param container the container holding the elements
  61867. */
  61868. addFromContainer(container: AbstractScene): void;
  61869. /**
  61870. * Removes all the elements in the container from the scene
  61871. * @param container contains the elements to remove
  61872. * @param dispose if the removed element should be disposed (default: false)
  61873. */
  61874. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61875. /**
  61876. * Disposes the component and the associated ressources.
  61877. */
  61878. dispose(): void;
  61879. private _isReadyForMesh;
  61880. private _renderMainTexture;
  61881. private _setStencil;
  61882. private _setStencilBack;
  61883. private _draw;
  61884. private _drawCamera;
  61885. private _drawRenderingGroup;
  61886. }
  61887. }
  61888. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61889. /** @hidden */
  61890. export var glowMapMergePixelShader: {
  61891. name: string;
  61892. shader: string;
  61893. };
  61894. }
  61895. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61896. /** @hidden */
  61897. export var glowMapMergeVertexShader: {
  61898. name: string;
  61899. shader: string;
  61900. };
  61901. }
  61902. declare module "babylonjs/Layers/glowLayer" {
  61903. import { Nullable } from "babylonjs/types";
  61904. import { Camera } from "babylonjs/Cameras/camera";
  61905. import { Scene } from "babylonjs/scene";
  61906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61908. import { Mesh } from "babylonjs/Meshes/mesh";
  61909. import { Texture } from "babylonjs/Materials/Textures/texture";
  61910. import { Effect } from "babylonjs/Materials/effect";
  61911. import { Material } from "babylonjs/Materials/material";
  61912. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61913. import { Color4 } from "babylonjs/Maths/math.color";
  61914. import "babylonjs/Shaders/glowMapMerge.fragment";
  61915. import "babylonjs/Shaders/glowMapMerge.vertex";
  61916. import "babylonjs/Layers/effectLayerSceneComponent";
  61917. module "babylonjs/abstractScene" {
  61918. interface AbstractScene {
  61919. /**
  61920. * Return a the first highlight layer of the scene with a given name.
  61921. * @param name The name of the highlight layer to look for.
  61922. * @return The highlight layer if found otherwise null.
  61923. */
  61924. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61925. }
  61926. }
  61927. /**
  61928. * Glow layer options. This helps customizing the behaviour
  61929. * of the glow layer.
  61930. */
  61931. export interface IGlowLayerOptions {
  61932. /**
  61933. * Multiplication factor apply to the canvas size to compute the render target size
  61934. * used to generated the glowing objects (the smaller the faster).
  61935. */
  61936. mainTextureRatio: number;
  61937. /**
  61938. * Enforces a fixed size texture to ensure resize independant blur.
  61939. */
  61940. mainTextureFixedSize?: number;
  61941. /**
  61942. * How big is the kernel of the blur texture.
  61943. */
  61944. blurKernelSize: number;
  61945. /**
  61946. * The camera attached to the layer.
  61947. */
  61948. camera: Nullable<Camera>;
  61949. /**
  61950. * Enable MSAA by chosing the number of samples.
  61951. */
  61952. mainTextureSamples?: number;
  61953. /**
  61954. * The rendering group to draw the layer in.
  61955. */
  61956. renderingGroupId: number;
  61957. }
  61958. /**
  61959. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61960. *
  61961. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61962. *
  61963. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61964. */
  61965. export class GlowLayer extends EffectLayer {
  61966. /**
  61967. * Effect Name of the layer.
  61968. */
  61969. static readonly EffectName: string;
  61970. /**
  61971. * The default blur kernel size used for the glow.
  61972. */
  61973. static DefaultBlurKernelSize: number;
  61974. /**
  61975. * The default texture size ratio used for the glow.
  61976. */
  61977. static DefaultTextureRatio: number;
  61978. /**
  61979. * Sets the kernel size of the blur.
  61980. */
  61981. set blurKernelSize(value: number);
  61982. /**
  61983. * Gets the kernel size of the blur.
  61984. */
  61985. get blurKernelSize(): number;
  61986. /**
  61987. * Sets the glow intensity.
  61988. */
  61989. set intensity(value: number);
  61990. /**
  61991. * Gets the glow intensity.
  61992. */
  61993. get intensity(): number;
  61994. private _options;
  61995. private _intensity;
  61996. private _horizontalBlurPostprocess1;
  61997. private _verticalBlurPostprocess1;
  61998. private _horizontalBlurPostprocess2;
  61999. private _verticalBlurPostprocess2;
  62000. private _blurTexture1;
  62001. private _blurTexture2;
  62002. private _postProcesses1;
  62003. private _postProcesses2;
  62004. private _includedOnlyMeshes;
  62005. private _excludedMeshes;
  62006. private _meshesUsingTheirOwnMaterials;
  62007. /**
  62008. * Callback used to let the user override the color selection on a per mesh basis
  62009. */
  62010. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62011. /**
  62012. * Callback used to let the user override the texture selection on a per mesh basis
  62013. */
  62014. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62015. /**
  62016. * Instantiates a new glow Layer and references it to the scene.
  62017. * @param name The name of the layer
  62018. * @param scene The scene to use the layer in
  62019. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62020. */
  62021. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62022. /**
  62023. * Get the effect name of the layer.
  62024. * @return The effect name
  62025. */
  62026. getEffectName(): string;
  62027. /**
  62028. * Create the merge effect. This is the shader use to blit the information back
  62029. * to the main canvas at the end of the scene rendering.
  62030. */
  62031. protected _createMergeEffect(): Effect;
  62032. /**
  62033. * Creates the render target textures and post processes used in the glow layer.
  62034. */
  62035. protected _createTextureAndPostProcesses(): void;
  62036. /**
  62037. * Checks for the readiness of the element composing the layer.
  62038. * @param subMesh the mesh to check for
  62039. * @param useInstances specify wether or not to use instances to render the mesh
  62040. * @param emissiveTexture the associated emissive texture used to generate the glow
  62041. * @return true if ready otherwise, false
  62042. */
  62043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62044. /**
  62045. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62046. */
  62047. needStencil(): boolean;
  62048. /**
  62049. * Returns true if the mesh can be rendered, otherwise false.
  62050. * @param mesh The mesh to render
  62051. * @param material The material used on the mesh
  62052. * @returns true if it can be rendered otherwise false
  62053. */
  62054. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62055. /**
  62056. * Implementation specific of rendering the generating effect on the main canvas.
  62057. * @param effect The effect used to render through
  62058. */
  62059. protected _internalRender(effect: Effect): void;
  62060. /**
  62061. * Sets the required values for both the emissive texture and and the main color.
  62062. */
  62063. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62064. /**
  62065. * Returns true if the mesh should render, otherwise false.
  62066. * @param mesh The mesh to render
  62067. * @returns true if it should render otherwise false
  62068. */
  62069. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62070. /**
  62071. * Adds specific effects defines.
  62072. * @param defines The defines to add specifics to.
  62073. */
  62074. protected _addCustomEffectDefines(defines: string[]): void;
  62075. /**
  62076. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62077. * @param mesh The mesh to exclude from the glow layer
  62078. */
  62079. addExcludedMesh(mesh: Mesh): void;
  62080. /**
  62081. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62082. * @param mesh The mesh to remove
  62083. */
  62084. removeExcludedMesh(mesh: Mesh): void;
  62085. /**
  62086. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62087. * @param mesh The mesh to include in the glow layer
  62088. */
  62089. addIncludedOnlyMesh(mesh: Mesh): void;
  62090. /**
  62091. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62092. * @param mesh The mesh to remove
  62093. */
  62094. removeIncludedOnlyMesh(mesh: Mesh): void;
  62095. /**
  62096. * Determine if a given mesh will be used in the glow layer
  62097. * @param mesh The mesh to test
  62098. * @returns true if the mesh will be highlighted by the current glow layer
  62099. */
  62100. hasMesh(mesh: AbstractMesh): boolean;
  62101. /**
  62102. * Defines whether the current material of the mesh should be use to render the effect.
  62103. * @param mesh defines the current mesh to render
  62104. */
  62105. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62106. /**
  62107. * Add a mesh to be rendered through its own material and not with emissive only.
  62108. * @param mesh The mesh for which we need to use its material
  62109. */
  62110. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62111. /**
  62112. * Remove a mesh from being rendered through its own material and not with emissive only.
  62113. * @param mesh The mesh for which we need to not use its material
  62114. */
  62115. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62116. /**
  62117. * Free any resources and references associated to a mesh.
  62118. * Internal use
  62119. * @param mesh The mesh to free.
  62120. * @hidden
  62121. */
  62122. _disposeMesh(mesh: Mesh): void;
  62123. /**
  62124. * Gets the class name of the effect layer
  62125. * @returns the string with the class name of the effect layer
  62126. */
  62127. getClassName(): string;
  62128. /**
  62129. * Serializes this glow layer
  62130. * @returns a serialized glow layer object
  62131. */
  62132. serialize(): any;
  62133. /**
  62134. * Creates a Glow Layer from parsed glow layer data
  62135. * @param parsedGlowLayer defines glow layer data
  62136. * @param scene defines the current scene
  62137. * @param rootUrl defines the root URL containing the glow layer information
  62138. * @returns a parsed Glow Layer
  62139. */
  62140. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62141. }
  62142. }
  62143. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62144. /** @hidden */
  62145. export var glowBlurPostProcessPixelShader: {
  62146. name: string;
  62147. shader: string;
  62148. };
  62149. }
  62150. declare module "babylonjs/Layers/highlightLayer" {
  62151. import { Observable } from "babylonjs/Misc/observable";
  62152. import { Nullable } from "babylonjs/types";
  62153. import { Camera } from "babylonjs/Cameras/camera";
  62154. import { Scene } from "babylonjs/scene";
  62155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62157. import { Mesh } from "babylonjs/Meshes/mesh";
  62158. import { Effect } from "babylonjs/Materials/effect";
  62159. import { Material } from "babylonjs/Materials/material";
  62160. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62161. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62162. import "babylonjs/Shaders/glowMapMerge.fragment";
  62163. import "babylonjs/Shaders/glowMapMerge.vertex";
  62164. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62165. module "babylonjs/abstractScene" {
  62166. interface AbstractScene {
  62167. /**
  62168. * Return a the first highlight layer of the scene with a given name.
  62169. * @param name The name of the highlight layer to look for.
  62170. * @return The highlight layer if found otherwise null.
  62171. */
  62172. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62173. }
  62174. }
  62175. /**
  62176. * Highlight layer options. This helps customizing the behaviour
  62177. * of the highlight layer.
  62178. */
  62179. export interface IHighlightLayerOptions {
  62180. /**
  62181. * Multiplication factor apply to the canvas size to compute the render target size
  62182. * used to generated the glowing objects (the smaller the faster).
  62183. */
  62184. mainTextureRatio: number;
  62185. /**
  62186. * Enforces a fixed size texture to ensure resize independant blur.
  62187. */
  62188. mainTextureFixedSize?: number;
  62189. /**
  62190. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62191. * of the picture to blur (the smaller the faster).
  62192. */
  62193. blurTextureSizeRatio: number;
  62194. /**
  62195. * How big in texel of the blur texture is the vertical blur.
  62196. */
  62197. blurVerticalSize: number;
  62198. /**
  62199. * How big in texel of the blur texture is the horizontal blur.
  62200. */
  62201. blurHorizontalSize: number;
  62202. /**
  62203. * Alpha blending mode used to apply the blur. Default is combine.
  62204. */
  62205. alphaBlendingMode: number;
  62206. /**
  62207. * The camera attached to the layer.
  62208. */
  62209. camera: Nullable<Camera>;
  62210. /**
  62211. * Should we display highlight as a solid stroke?
  62212. */
  62213. isStroke?: boolean;
  62214. /**
  62215. * The rendering group to draw the layer in.
  62216. */
  62217. renderingGroupId: number;
  62218. }
  62219. /**
  62220. * The highlight layer Helps adding a glow effect around a mesh.
  62221. *
  62222. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62223. * glowy meshes to your scene.
  62224. *
  62225. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62226. */
  62227. export class HighlightLayer extends EffectLayer {
  62228. name: string;
  62229. /**
  62230. * Effect Name of the highlight layer.
  62231. */
  62232. static readonly EffectName: string;
  62233. /**
  62234. * The neutral color used during the preparation of the glow effect.
  62235. * This is black by default as the blend operation is a blend operation.
  62236. */
  62237. static NeutralColor: Color4;
  62238. /**
  62239. * Stencil value used for glowing meshes.
  62240. */
  62241. static GlowingMeshStencilReference: number;
  62242. /**
  62243. * Stencil value used for the other meshes in the scene.
  62244. */
  62245. static NormalMeshStencilReference: number;
  62246. /**
  62247. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62248. */
  62249. innerGlow: boolean;
  62250. /**
  62251. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62252. */
  62253. outerGlow: boolean;
  62254. /**
  62255. * Specifies the horizontal size of the blur.
  62256. */
  62257. set blurHorizontalSize(value: number);
  62258. /**
  62259. * Specifies the vertical size of the blur.
  62260. */
  62261. set blurVerticalSize(value: number);
  62262. /**
  62263. * Gets the horizontal size of the blur.
  62264. */
  62265. get blurHorizontalSize(): number;
  62266. /**
  62267. * Gets the vertical size of the blur.
  62268. */
  62269. get blurVerticalSize(): number;
  62270. /**
  62271. * An event triggered when the highlight layer is being blurred.
  62272. */
  62273. onBeforeBlurObservable: Observable<HighlightLayer>;
  62274. /**
  62275. * An event triggered when the highlight layer has been blurred.
  62276. */
  62277. onAfterBlurObservable: Observable<HighlightLayer>;
  62278. private _instanceGlowingMeshStencilReference;
  62279. private _options;
  62280. private _downSamplePostprocess;
  62281. private _horizontalBlurPostprocess;
  62282. private _verticalBlurPostprocess;
  62283. private _blurTexture;
  62284. private _meshes;
  62285. private _excludedMeshes;
  62286. /**
  62287. * Instantiates a new highlight Layer and references it to the scene..
  62288. * @param name The name of the layer
  62289. * @param scene The scene to use the layer in
  62290. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62291. */
  62292. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62293. /**
  62294. * Get the effect name of the layer.
  62295. * @return The effect name
  62296. */
  62297. getEffectName(): string;
  62298. /**
  62299. * Create the merge effect. This is the shader use to blit the information back
  62300. * to the main canvas at the end of the scene rendering.
  62301. */
  62302. protected _createMergeEffect(): Effect;
  62303. /**
  62304. * Creates the render target textures and post processes used in the highlight layer.
  62305. */
  62306. protected _createTextureAndPostProcesses(): void;
  62307. /**
  62308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62309. */
  62310. needStencil(): boolean;
  62311. /**
  62312. * Checks for the readiness of the element composing the layer.
  62313. * @param subMesh the mesh to check for
  62314. * @param useInstances specify wether or not to use instances to render the mesh
  62315. * @param emissiveTexture the associated emissive texture used to generate the glow
  62316. * @return true if ready otherwise, false
  62317. */
  62318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62319. /**
  62320. * Implementation specific of rendering the generating effect on the main canvas.
  62321. * @param effect The effect used to render through
  62322. */
  62323. protected _internalRender(effect: Effect): void;
  62324. /**
  62325. * Returns true if the layer contains information to display, otherwise false.
  62326. */
  62327. shouldRender(): boolean;
  62328. /**
  62329. * Returns true if the mesh should render, otherwise false.
  62330. * @param mesh The mesh to render
  62331. * @returns true if it should render otherwise false
  62332. */
  62333. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62334. /**
  62335. * Returns true if the mesh can be rendered, otherwise false.
  62336. * @param mesh The mesh to render
  62337. * @param material The material used on the mesh
  62338. * @returns true if it can be rendered otherwise false
  62339. */
  62340. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62341. /**
  62342. * Adds specific effects defines.
  62343. * @param defines The defines to add specifics to.
  62344. */
  62345. protected _addCustomEffectDefines(defines: string[]): void;
  62346. /**
  62347. * Sets the required values for both the emissive texture and and the main color.
  62348. */
  62349. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62350. /**
  62351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62352. * @param mesh The mesh to exclude from the highlight layer
  62353. */
  62354. addExcludedMesh(mesh: Mesh): void;
  62355. /**
  62356. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62357. * @param mesh The mesh to highlight
  62358. */
  62359. removeExcludedMesh(mesh: Mesh): void;
  62360. /**
  62361. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62362. * @param mesh mesh to test
  62363. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62364. */
  62365. hasMesh(mesh: AbstractMesh): boolean;
  62366. /**
  62367. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62368. * @param mesh The mesh to highlight
  62369. * @param color The color of the highlight
  62370. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62371. */
  62372. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62373. /**
  62374. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62375. * @param mesh The mesh to highlight
  62376. */
  62377. removeMesh(mesh: Mesh): void;
  62378. /**
  62379. * Remove all the meshes currently referenced in the highlight layer
  62380. */
  62381. removeAllMeshes(): void;
  62382. /**
  62383. * Force the stencil to the normal expected value for none glowing parts
  62384. */
  62385. private _defaultStencilReference;
  62386. /**
  62387. * Free any resources and references associated to a mesh.
  62388. * Internal use
  62389. * @param mesh The mesh to free.
  62390. * @hidden
  62391. */
  62392. _disposeMesh(mesh: Mesh): void;
  62393. /**
  62394. * Dispose the highlight layer and free resources.
  62395. */
  62396. dispose(): void;
  62397. /**
  62398. * Gets the class name of the effect layer
  62399. * @returns the string with the class name of the effect layer
  62400. */
  62401. getClassName(): string;
  62402. /**
  62403. * Serializes this Highlight layer
  62404. * @returns a serialized Highlight layer object
  62405. */
  62406. serialize(): any;
  62407. /**
  62408. * Creates a Highlight layer from parsed Highlight layer data
  62409. * @param parsedHightlightLayer defines the Highlight layer data
  62410. * @param scene defines the current scene
  62411. * @param rootUrl defines the root URL containing the Highlight layer information
  62412. * @returns a parsed Highlight layer
  62413. */
  62414. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62415. }
  62416. }
  62417. declare module "babylonjs/Layers/layerSceneComponent" {
  62418. import { Scene } from "babylonjs/scene";
  62419. import { ISceneComponent } from "babylonjs/sceneComponent";
  62420. import { Layer } from "babylonjs/Layers/layer";
  62421. import { AbstractScene } from "babylonjs/abstractScene";
  62422. module "babylonjs/abstractScene" {
  62423. interface AbstractScene {
  62424. /**
  62425. * The list of layers (background and foreground) of the scene
  62426. */
  62427. layers: Array<Layer>;
  62428. }
  62429. }
  62430. /**
  62431. * Defines the layer scene component responsible to manage any layers
  62432. * in a given scene.
  62433. */
  62434. export class LayerSceneComponent implements ISceneComponent {
  62435. /**
  62436. * The component name helpfull to identify the component in the list of scene components.
  62437. */
  62438. readonly name: string;
  62439. /**
  62440. * The scene the component belongs to.
  62441. */
  62442. scene: Scene;
  62443. private _engine;
  62444. /**
  62445. * Creates a new instance of the component for the given scene
  62446. * @param scene Defines the scene to register the component in
  62447. */
  62448. constructor(scene: Scene);
  62449. /**
  62450. * Registers the component in a given scene
  62451. */
  62452. register(): void;
  62453. /**
  62454. * Rebuilds the elements related to this component in case of
  62455. * context lost for instance.
  62456. */
  62457. rebuild(): void;
  62458. /**
  62459. * Disposes the component and the associated ressources.
  62460. */
  62461. dispose(): void;
  62462. private _draw;
  62463. private _drawCameraPredicate;
  62464. private _drawCameraBackground;
  62465. private _drawCameraForeground;
  62466. private _drawRenderTargetPredicate;
  62467. private _drawRenderTargetBackground;
  62468. private _drawRenderTargetForeground;
  62469. /**
  62470. * Adds all the elements from the container to the scene
  62471. * @param container the container holding the elements
  62472. */
  62473. addFromContainer(container: AbstractScene): void;
  62474. /**
  62475. * Removes all the elements in the container from the scene
  62476. * @param container contains the elements to remove
  62477. * @param dispose if the removed element should be disposed (default: false)
  62478. */
  62479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62480. }
  62481. }
  62482. declare module "babylonjs/Shaders/layer.fragment" {
  62483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62484. /** @hidden */
  62485. export var layerPixelShader: {
  62486. name: string;
  62487. shader: string;
  62488. };
  62489. }
  62490. declare module "babylonjs/Shaders/layer.vertex" {
  62491. /** @hidden */
  62492. export var layerVertexShader: {
  62493. name: string;
  62494. shader: string;
  62495. };
  62496. }
  62497. declare module "babylonjs/Layers/layer" {
  62498. import { Observable } from "babylonjs/Misc/observable";
  62499. import { Nullable } from "babylonjs/types";
  62500. import { Scene } from "babylonjs/scene";
  62501. import { Vector2 } from "babylonjs/Maths/math.vector";
  62502. import { Color4 } from "babylonjs/Maths/math.color";
  62503. import { Texture } from "babylonjs/Materials/Textures/texture";
  62504. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62505. import "babylonjs/Shaders/layer.fragment";
  62506. import "babylonjs/Shaders/layer.vertex";
  62507. /**
  62508. * This represents a full screen 2d layer.
  62509. * This can be useful to display a picture in the background of your scene for instance.
  62510. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62511. */
  62512. export class Layer {
  62513. /**
  62514. * Define the name of the layer.
  62515. */
  62516. name: string;
  62517. /**
  62518. * Define the texture the layer should display.
  62519. */
  62520. texture: Nullable<Texture>;
  62521. /**
  62522. * Is the layer in background or foreground.
  62523. */
  62524. isBackground: boolean;
  62525. /**
  62526. * Define the color of the layer (instead of texture).
  62527. */
  62528. color: Color4;
  62529. /**
  62530. * Define the scale of the layer in order to zoom in out of the texture.
  62531. */
  62532. scale: Vector2;
  62533. /**
  62534. * Define an offset for the layer in order to shift the texture.
  62535. */
  62536. offset: Vector2;
  62537. /**
  62538. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62539. */
  62540. alphaBlendingMode: number;
  62541. /**
  62542. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62543. * Alpha test will not mix with the background color in case of transparency.
  62544. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62545. */
  62546. alphaTest: boolean;
  62547. /**
  62548. * Define a mask to restrict the layer to only some of the scene cameras.
  62549. */
  62550. layerMask: number;
  62551. /**
  62552. * Define the list of render target the layer is visible into.
  62553. */
  62554. renderTargetTextures: RenderTargetTexture[];
  62555. /**
  62556. * Define if the layer is only used in renderTarget or if it also
  62557. * renders in the main frame buffer of the canvas.
  62558. */
  62559. renderOnlyInRenderTargetTextures: boolean;
  62560. private _scene;
  62561. private _vertexBuffers;
  62562. private _indexBuffer;
  62563. private _effect;
  62564. private _previousDefines;
  62565. /**
  62566. * An event triggered when the layer is disposed.
  62567. */
  62568. onDisposeObservable: Observable<Layer>;
  62569. private _onDisposeObserver;
  62570. /**
  62571. * Back compatibility with callback before the onDisposeObservable existed.
  62572. * The set callback will be triggered when the layer has been disposed.
  62573. */
  62574. set onDispose(callback: () => void);
  62575. /**
  62576. * An event triggered before rendering the scene
  62577. */
  62578. onBeforeRenderObservable: Observable<Layer>;
  62579. private _onBeforeRenderObserver;
  62580. /**
  62581. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62582. * The set callback will be triggered just before rendering the layer.
  62583. */
  62584. set onBeforeRender(callback: () => void);
  62585. /**
  62586. * An event triggered after rendering the scene
  62587. */
  62588. onAfterRenderObservable: Observable<Layer>;
  62589. private _onAfterRenderObserver;
  62590. /**
  62591. * Back compatibility with callback before the onAfterRenderObservable existed.
  62592. * The set callback will be triggered just after rendering the layer.
  62593. */
  62594. set onAfterRender(callback: () => void);
  62595. /**
  62596. * Instantiates a new layer.
  62597. * This represents a full screen 2d layer.
  62598. * This can be useful to display a picture in the background of your scene for instance.
  62599. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62600. * @param name Define the name of the layer in the scene
  62601. * @param imgUrl Define the url of the texture to display in the layer
  62602. * @param scene Define the scene the layer belongs to
  62603. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62604. * @param color Defines a color for the layer
  62605. */
  62606. constructor(
  62607. /**
  62608. * Define the name of the layer.
  62609. */
  62610. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62611. private _createIndexBuffer;
  62612. /** @hidden */
  62613. _rebuild(): void;
  62614. /**
  62615. * Renders the layer in the scene.
  62616. */
  62617. render(): void;
  62618. /**
  62619. * Disposes and releases the associated ressources.
  62620. */
  62621. dispose(): void;
  62622. }
  62623. }
  62624. declare module "babylonjs/Layers/index" {
  62625. export * from "babylonjs/Layers/effectLayer";
  62626. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62627. export * from "babylonjs/Layers/glowLayer";
  62628. export * from "babylonjs/Layers/highlightLayer";
  62629. export * from "babylonjs/Layers/layer";
  62630. export * from "babylonjs/Layers/layerSceneComponent";
  62631. }
  62632. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62633. /** @hidden */
  62634. export var lensFlarePixelShader: {
  62635. name: string;
  62636. shader: string;
  62637. };
  62638. }
  62639. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62640. /** @hidden */
  62641. export var lensFlareVertexShader: {
  62642. name: string;
  62643. shader: string;
  62644. };
  62645. }
  62646. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62647. import { Scene } from "babylonjs/scene";
  62648. import { Vector3 } from "babylonjs/Maths/math.vector";
  62649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62650. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62651. import "babylonjs/Shaders/lensFlare.fragment";
  62652. import "babylonjs/Shaders/lensFlare.vertex";
  62653. import { Viewport } from "babylonjs/Maths/math.viewport";
  62654. /**
  62655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62656. * It is usually composed of several `lensFlare`.
  62657. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62658. */
  62659. export class LensFlareSystem {
  62660. /**
  62661. * Define the name of the lens flare system
  62662. */
  62663. name: string;
  62664. /**
  62665. * List of lens flares used in this system.
  62666. */
  62667. lensFlares: LensFlare[];
  62668. /**
  62669. * Define a limit from the border the lens flare can be visible.
  62670. */
  62671. borderLimit: number;
  62672. /**
  62673. * Define a viewport border we do not want to see the lens flare in.
  62674. */
  62675. viewportBorder: number;
  62676. /**
  62677. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62678. */
  62679. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62680. /**
  62681. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62682. */
  62683. layerMask: number;
  62684. /**
  62685. * Define the id of the lens flare system in the scene.
  62686. * (equal to name by default)
  62687. */
  62688. id: string;
  62689. private _scene;
  62690. private _emitter;
  62691. private _vertexBuffers;
  62692. private _indexBuffer;
  62693. private _effect;
  62694. private _positionX;
  62695. private _positionY;
  62696. private _isEnabled;
  62697. /** @hidden */
  62698. static _SceneComponentInitialization: (scene: Scene) => void;
  62699. /**
  62700. * Instantiates a lens flare system.
  62701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62702. * It is usually composed of several `lensFlare`.
  62703. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62704. * @param name Define the name of the lens flare system in the scene
  62705. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62706. * @param scene Define the scene the lens flare system belongs to
  62707. */
  62708. constructor(
  62709. /**
  62710. * Define the name of the lens flare system
  62711. */
  62712. name: string, emitter: any, scene: Scene);
  62713. /**
  62714. * Define if the lens flare system is enabled.
  62715. */
  62716. get isEnabled(): boolean;
  62717. set isEnabled(value: boolean);
  62718. /**
  62719. * Get the scene the effects belongs to.
  62720. * @returns the scene holding the lens flare system
  62721. */
  62722. getScene(): Scene;
  62723. /**
  62724. * Get the emitter of the lens flare system.
  62725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62726. * @returns the emitter of the lens flare system
  62727. */
  62728. getEmitter(): any;
  62729. /**
  62730. * Set the emitter of the lens flare system.
  62731. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62732. * @param newEmitter Define the new emitter of the system
  62733. */
  62734. setEmitter(newEmitter: any): void;
  62735. /**
  62736. * Get the lens flare system emitter position.
  62737. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62738. * @returns the position
  62739. */
  62740. getEmitterPosition(): Vector3;
  62741. /**
  62742. * @hidden
  62743. */
  62744. computeEffectivePosition(globalViewport: Viewport): boolean;
  62745. /** @hidden */
  62746. _isVisible(): boolean;
  62747. /**
  62748. * @hidden
  62749. */
  62750. render(): boolean;
  62751. /**
  62752. * Dispose and release the lens flare with its associated resources.
  62753. */
  62754. dispose(): void;
  62755. /**
  62756. * Parse a lens flare system from a JSON repressentation
  62757. * @param parsedLensFlareSystem Define the JSON to parse
  62758. * @param scene Define the scene the parsed system should be instantiated in
  62759. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62760. * @returns the parsed system
  62761. */
  62762. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62763. /**
  62764. * Serialize the current Lens Flare System into a JSON representation.
  62765. * @returns the serialized JSON
  62766. */
  62767. serialize(): any;
  62768. }
  62769. }
  62770. declare module "babylonjs/LensFlares/lensFlare" {
  62771. import { Nullable } from "babylonjs/types";
  62772. import { Color3 } from "babylonjs/Maths/math.color";
  62773. import { Texture } from "babylonjs/Materials/Textures/texture";
  62774. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62775. /**
  62776. * This represents one of the lens effect in a `lensFlareSystem`.
  62777. * It controls one of the indiviual texture used in the effect.
  62778. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62779. */
  62780. export class LensFlare {
  62781. /**
  62782. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62783. */
  62784. size: number;
  62785. /**
  62786. * 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.
  62787. */
  62788. position: number;
  62789. /**
  62790. * Define the lens color.
  62791. */
  62792. color: Color3;
  62793. /**
  62794. * Define the lens texture.
  62795. */
  62796. texture: Nullable<Texture>;
  62797. /**
  62798. * Define the alpha mode to render this particular lens.
  62799. */
  62800. alphaMode: number;
  62801. private _system;
  62802. /**
  62803. * Creates a new Lens Flare.
  62804. * This represents one of the lens effect in a `lensFlareSystem`.
  62805. * It controls one of the indiviual texture used in the effect.
  62806. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62807. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62808. * @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.
  62809. * @param color Define the lens color
  62810. * @param imgUrl Define the lens texture url
  62811. * @param system Define the `lensFlareSystem` this flare is part of
  62812. * @returns The newly created Lens Flare
  62813. */
  62814. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62815. /**
  62816. * Instantiates a new Lens Flare.
  62817. * This represents one of the lens effect in a `lensFlareSystem`.
  62818. * It controls one of the indiviual texture used in the effect.
  62819. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62820. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62821. * @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.
  62822. * @param color Define the lens color
  62823. * @param imgUrl Define the lens texture url
  62824. * @param system Define the `lensFlareSystem` this flare is part of
  62825. */
  62826. constructor(
  62827. /**
  62828. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62829. */
  62830. size: number,
  62831. /**
  62832. * 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.
  62833. */
  62834. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62835. /**
  62836. * Dispose and release the lens flare with its associated resources.
  62837. */
  62838. dispose(): void;
  62839. }
  62840. }
  62841. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62842. import { Nullable } from "babylonjs/types";
  62843. import { Scene } from "babylonjs/scene";
  62844. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62845. import { AbstractScene } from "babylonjs/abstractScene";
  62846. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62847. module "babylonjs/abstractScene" {
  62848. interface AbstractScene {
  62849. /**
  62850. * The list of lens flare system added to the scene
  62851. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62852. */
  62853. lensFlareSystems: Array<LensFlareSystem>;
  62854. /**
  62855. * Removes the given lens flare system from this scene.
  62856. * @param toRemove The lens flare system to remove
  62857. * @returns The index of the removed lens flare system
  62858. */
  62859. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62860. /**
  62861. * Adds the given lens flare system to this scene
  62862. * @param newLensFlareSystem The lens flare system to add
  62863. */
  62864. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62865. /**
  62866. * Gets a lens flare system using its name
  62867. * @param name defines the name to look for
  62868. * @returns the lens flare system or null if not found
  62869. */
  62870. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62871. /**
  62872. * Gets a lens flare system using its id
  62873. * @param id defines the id to look for
  62874. * @returns the lens flare system or null if not found
  62875. */
  62876. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62877. }
  62878. }
  62879. /**
  62880. * Defines the lens flare scene component responsible to manage any lens flares
  62881. * in a given scene.
  62882. */
  62883. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62884. /**
  62885. * The component name helpfull to identify the component in the list of scene components.
  62886. */
  62887. readonly name: string;
  62888. /**
  62889. * The scene the component belongs to.
  62890. */
  62891. scene: Scene;
  62892. /**
  62893. * Creates a new instance of the component for the given scene
  62894. * @param scene Defines the scene to register the component in
  62895. */
  62896. constructor(scene: Scene);
  62897. /**
  62898. * Registers the component in a given scene
  62899. */
  62900. register(): void;
  62901. /**
  62902. * Rebuilds the elements related to this component in case of
  62903. * context lost for instance.
  62904. */
  62905. rebuild(): void;
  62906. /**
  62907. * Adds all the elements from the container to the scene
  62908. * @param container the container holding the elements
  62909. */
  62910. addFromContainer(container: AbstractScene): void;
  62911. /**
  62912. * Removes all the elements in the container from the scene
  62913. * @param container contains the elements to remove
  62914. * @param dispose if the removed element should be disposed (default: false)
  62915. */
  62916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62917. /**
  62918. * Serializes the component data to the specified json object
  62919. * @param serializationObject The object to serialize to
  62920. */
  62921. serialize(serializationObject: any): void;
  62922. /**
  62923. * Disposes the component and the associated ressources.
  62924. */
  62925. dispose(): void;
  62926. private _draw;
  62927. }
  62928. }
  62929. declare module "babylonjs/LensFlares/index" {
  62930. export * from "babylonjs/LensFlares/lensFlare";
  62931. export * from "babylonjs/LensFlares/lensFlareSystem";
  62932. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62933. }
  62934. declare module "babylonjs/Shaders/depth.fragment" {
  62935. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62936. /** @hidden */
  62937. export var depthPixelShader: {
  62938. name: string;
  62939. shader: string;
  62940. };
  62941. }
  62942. declare module "babylonjs/Shaders/depth.vertex" {
  62943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62946. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62950. /** @hidden */
  62951. export var depthVertexShader: {
  62952. name: string;
  62953. shader: string;
  62954. };
  62955. }
  62956. declare module "babylonjs/Rendering/depthRenderer" {
  62957. import { Nullable } from "babylonjs/types";
  62958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62959. import { Scene } from "babylonjs/scene";
  62960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62961. import { Camera } from "babylonjs/Cameras/camera";
  62962. import "babylonjs/Shaders/depth.fragment";
  62963. import "babylonjs/Shaders/depth.vertex";
  62964. /**
  62965. * This represents a depth renderer in Babylon.
  62966. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62967. */
  62968. export class DepthRenderer {
  62969. private _scene;
  62970. private _depthMap;
  62971. private _effect;
  62972. private readonly _storeNonLinearDepth;
  62973. private readonly _clearColor;
  62974. /** Get if the depth renderer is using packed depth or not */
  62975. readonly isPacked: boolean;
  62976. private _cachedDefines;
  62977. private _camera;
  62978. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62979. enabled: boolean;
  62980. /**
  62981. * Specifiess that the depth renderer will only be used within
  62982. * the camera it is created for.
  62983. * This can help forcing its rendering during the camera processing.
  62984. */
  62985. useOnlyInActiveCamera: boolean;
  62986. /** @hidden */
  62987. static _SceneComponentInitialization: (scene: Scene) => void;
  62988. /**
  62989. * Instantiates a depth renderer
  62990. * @param scene The scene the renderer belongs to
  62991. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62992. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62994. */
  62995. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62996. /**
  62997. * Creates the depth rendering effect and checks if the effect is ready.
  62998. * @param subMesh The submesh to be used to render the depth map of
  62999. * @param useInstances If multiple world instances should be used
  63000. * @returns if the depth renderer is ready to render the depth map
  63001. */
  63002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63003. /**
  63004. * Gets the texture which the depth map will be written to.
  63005. * @returns The depth map texture
  63006. */
  63007. getDepthMap(): RenderTargetTexture;
  63008. /**
  63009. * Disposes of the depth renderer.
  63010. */
  63011. dispose(): void;
  63012. }
  63013. }
  63014. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63015. /** @hidden */
  63016. export var minmaxReduxPixelShader: {
  63017. name: string;
  63018. shader: string;
  63019. };
  63020. }
  63021. declare module "babylonjs/Misc/minMaxReducer" {
  63022. import { Nullable } from "babylonjs/types";
  63023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63024. import { Camera } from "babylonjs/Cameras/camera";
  63025. import { Observer } from "babylonjs/Misc/observable";
  63026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63027. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63028. import { Observable } from "babylonjs/Misc/observable";
  63029. import "babylonjs/Shaders/minmaxRedux.fragment";
  63030. /**
  63031. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63032. * and maximum values from all values of the texture.
  63033. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63034. * The source values are read from the red channel of the texture.
  63035. */
  63036. export class MinMaxReducer {
  63037. /**
  63038. * Observable triggered when the computation has been performed
  63039. */
  63040. onAfterReductionPerformed: Observable<{
  63041. min: number;
  63042. max: number;
  63043. }>;
  63044. protected _camera: Camera;
  63045. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63046. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63047. protected _postProcessManager: PostProcessManager;
  63048. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63049. protected _forceFullscreenViewport: boolean;
  63050. /**
  63051. * Creates a min/max reducer
  63052. * @param camera The camera to use for the post processes
  63053. */
  63054. constructor(camera: Camera);
  63055. /**
  63056. * Gets the texture used to read the values from.
  63057. */
  63058. get sourceTexture(): Nullable<RenderTargetTexture>;
  63059. /**
  63060. * Sets the source texture to read the values from.
  63061. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63062. * because in such textures '1' value must not be taken into account to compute the maximum
  63063. * as this value is used to clear the texture.
  63064. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63065. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63066. * @param depthRedux Indicates if the texture is a depth texture or not
  63067. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63068. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63069. */
  63070. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63071. /**
  63072. * Defines the refresh rate of the computation.
  63073. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63074. */
  63075. get refreshRate(): number;
  63076. set refreshRate(value: number);
  63077. protected _activated: boolean;
  63078. /**
  63079. * Gets the activation status of the reducer
  63080. */
  63081. get activated(): boolean;
  63082. /**
  63083. * Activates the reduction computation.
  63084. * When activated, the observers registered in onAfterReductionPerformed are
  63085. * called after the compuation is performed
  63086. */
  63087. activate(): void;
  63088. /**
  63089. * Deactivates the reduction computation.
  63090. */
  63091. deactivate(): void;
  63092. /**
  63093. * Disposes the min/max reducer
  63094. * @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.
  63095. */
  63096. dispose(disposeAll?: boolean): void;
  63097. }
  63098. }
  63099. declare module "babylonjs/Misc/depthReducer" {
  63100. import { Nullable } from "babylonjs/types";
  63101. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63102. import { Camera } from "babylonjs/Cameras/camera";
  63103. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63104. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63105. /**
  63106. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63107. */
  63108. export class DepthReducer extends MinMaxReducer {
  63109. private _depthRenderer;
  63110. private _depthRendererId;
  63111. /**
  63112. * Gets the depth renderer used for the computation.
  63113. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63114. */
  63115. get depthRenderer(): Nullable<DepthRenderer>;
  63116. /**
  63117. * Creates a depth reducer
  63118. * @param camera The camera used to render the depth texture
  63119. */
  63120. constructor(camera: Camera);
  63121. /**
  63122. * Sets the depth renderer to use to generate the depth map
  63123. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63124. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63125. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63126. */
  63127. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63128. /** @hidden */
  63129. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63130. /**
  63131. * Activates the reduction computation.
  63132. * When activated, the observers registered in onAfterReductionPerformed are
  63133. * called after the compuation is performed
  63134. */
  63135. activate(): void;
  63136. /**
  63137. * Deactivates the reduction computation.
  63138. */
  63139. deactivate(): void;
  63140. /**
  63141. * Disposes the depth reducer
  63142. * @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.
  63143. */
  63144. dispose(disposeAll?: boolean): void;
  63145. }
  63146. }
  63147. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63148. import { Nullable } from "babylonjs/types";
  63149. import { Scene } from "babylonjs/scene";
  63150. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63153. import { Effect } from "babylonjs/Materials/effect";
  63154. import "babylonjs/Shaders/shadowMap.fragment";
  63155. import "babylonjs/Shaders/shadowMap.vertex";
  63156. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63157. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63158. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63159. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63160. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63161. /**
  63162. * A CSM implementation allowing casting shadows on large scenes.
  63163. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63164. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63165. */
  63166. export class CascadedShadowGenerator extends ShadowGenerator {
  63167. private static readonly frustumCornersNDCSpace;
  63168. /**
  63169. * Name of the CSM class
  63170. */
  63171. static CLASSNAME: string;
  63172. /**
  63173. * Defines the default number of cascades used by the CSM.
  63174. */
  63175. static readonly DEFAULT_CASCADES_COUNT: number;
  63176. /**
  63177. * Defines the minimum number of cascades used by the CSM.
  63178. */
  63179. static readonly MIN_CASCADES_COUNT: number;
  63180. /**
  63181. * Defines the maximum number of cascades used by the CSM.
  63182. */
  63183. static readonly MAX_CASCADES_COUNT: number;
  63184. protected _validateFilter(filter: number): number;
  63185. /**
  63186. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63187. */
  63188. penumbraDarkness: number;
  63189. private _numCascades;
  63190. /**
  63191. * Gets or set the number of cascades used by the CSM.
  63192. */
  63193. get numCascades(): number;
  63194. set numCascades(value: number);
  63195. /**
  63196. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63197. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63198. */
  63199. stabilizeCascades: boolean;
  63200. private _freezeShadowCastersBoundingInfo;
  63201. private _freezeShadowCastersBoundingInfoObservable;
  63202. /**
  63203. * Enables or disables the shadow casters bounding info computation.
  63204. * If your shadow casters don't move, you can disable this feature.
  63205. * If it is enabled, the bounding box computation is done every frame.
  63206. */
  63207. get freezeShadowCastersBoundingInfo(): boolean;
  63208. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63209. private _scbiMin;
  63210. private _scbiMax;
  63211. protected _computeShadowCastersBoundingInfo(): void;
  63212. protected _shadowCastersBoundingInfo: BoundingInfo;
  63213. /**
  63214. * Gets or sets the shadow casters bounding info.
  63215. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63216. * so that the system won't overwrite the bounds you provide
  63217. */
  63218. get shadowCastersBoundingInfo(): BoundingInfo;
  63219. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63220. protected _breaksAreDirty: boolean;
  63221. protected _minDistance: number;
  63222. protected _maxDistance: number;
  63223. /**
  63224. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63225. *
  63226. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63227. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63228. * @param min minimal distance for the breaks (default to 0.)
  63229. * @param max maximal distance for the breaks (default to 1.)
  63230. */
  63231. setMinMaxDistance(min: number, max: number): void;
  63232. /** Gets the minimal distance used in the cascade break computation */
  63233. get minDistance(): number;
  63234. /** Gets the maximal distance used in the cascade break computation */
  63235. get maxDistance(): number;
  63236. /**
  63237. * Gets the class name of that object
  63238. * @returns "CascadedShadowGenerator"
  63239. */
  63240. getClassName(): string;
  63241. private _cascadeMinExtents;
  63242. private _cascadeMaxExtents;
  63243. /**
  63244. * Gets a cascade minimum extents
  63245. * @param cascadeIndex index of the cascade
  63246. * @returns the minimum cascade extents
  63247. */
  63248. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63249. /**
  63250. * Gets a cascade maximum extents
  63251. * @param cascadeIndex index of the cascade
  63252. * @returns the maximum cascade extents
  63253. */
  63254. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63255. private _cascades;
  63256. private _currentLayer;
  63257. private _viewSpaceFrustumsZ;
  63258. private _viewMatrices;
  63259. private _projectionMatrices;
  63260. private _transformMatrices;
  63261. private _transformMatricesAsArray;
  63262. private _frustumLengths;
  63263. private _lightSizeUVCorrection;
  63264. private _depthCorrection;
  63265. private _frustumCornersWorldSpace;
  63266. private _frustumCenter;
  63267. private _shadowCameraPos;
  63268. private _shadowMaxZ;
  63269. /**
  63270. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63271. * It defaults to camera.maxZ
  63272. */
  63273. get shadowMaxZ(): number;
  63274. /**
  63275. * Sets the shadow max z distance.
  63276. */
  63277. set shadowMaxZ(value: number);
  63278. protected _debug: boolean;
  63279. /**
  63280. * Gets or sets the debug flag.
  63281. * When enabled, the cascades are materialized by different colors on the screen.
  63282. */
  63283. get debug(): boolean;
  63284. set debug(dbg: boolean);
  63285. private _depthClamp;
  63286. /**
  63287. * Gets or sets the depth clamping value.
  63288. *
  63289. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63290. * to account for the shadow casters far away.
  63291. *
  63292. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63293. */
  63294. get depthClamp(): boolean;
  63295. set depthClamp(value: boolean);
  63296. private _cascadeBlendPercentage;
  63297. /**
  63298. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63299. * It defaults to 0.1 (10% blending).
  63300. */
  63301. get cascadeBlendPercentage(): number;
  63302. set cascadeBlendPercentage(value: number);
  63303. private _lambda;
  63304. /**
  63305. * Gets or set the lambda parameter.
  63306. * This parameter is used to split the camera frustum and create the cascades.
  63307. * 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.
  63308. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63309. */
  63310. get lambda(): number;
  63311. set lambda(value: number);
  63312. /**
  63313. * Gets the view matrix corresponding to a given cascade
  63314. * @param cascadeNum cascade to retrieve the view matrix from
  63315. * @returns the cascade view matrix
  63316. */
  63317. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63318. /**
  63319. * Gets the projection matrix corresponding to a given cascade
  63320. * @param cascadeNum cascade to retrieve the projection matrix from
  63321. * @returns the cascade projection matrix
  63322. */
  63323. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63324. /**
  63325. * Gets the transformation matrix corresponding to a given cascade
  63326. * @param cascadeNum cascade to retrieve the transformation matrix from
  63327. * @returns the cascade transformation matrix
  63328. */
  63329. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63330. private _depthRenderer;
  63331. /**
  63332. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63333. *
  63334. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63335. *
  63336. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63337. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63338. * @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
  63339. */
  63340. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63341. private _depthReducer;
  63342. private _autoCalcDepthBounds;
  63343. /**
  63344. * Gets or sets the autoCalcDepthBounds property.
  63345. *
  63346. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63347. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63348. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63349. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63350. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63351. */
  63352. get autoCalcDepthBounds(): boolean;
  63353. set autoCalcDepthBounds(value: boolean);
  63354. /**
  63355. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63356. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63357. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63358. * for setting the refresh rate on the renderer yourself!
  63359. */
  63360. get autoCalcDepthBoundsRefreshRate(): number;
  63361. set autoCalcDepthBoundsRefreshRate(value: number);
  63362. /**
  63363. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63364. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63365. * you change the camera near/far planes!
  63366. */
  63367. splitFrustum(): void;
  63368. private _splitFrustum;
  63369. private _computeMatrices;
  63370. private _computeFrustumInWorldSpace;
  63371. private _computeCascadeFrustum;
  63372. /**
  63373. * Support test.
  63374. */
  63375. static get IsSupported(): boolean;
  63376. /** @hidden */
  63377. static _SceneComponentInitialization: (scene: Scene) => void;
  63378. /**
  63379. * Creates a Cascaded Shadow Generator object.
  63380. * A ShadowGenerator is the required tool to use the shadows.
  63381. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63382. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63383. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63384. * @param light The directional light object generating the shadows.
  63385. * @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.
  63386. */
  63387. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63388. protected _initializeGenerator(): void;
  63389. protected _createTargetRenderTexture(): void;
  63390. protected _initializeShadowMap(): void;
  63391. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63392. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63393. /**
  63394. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63395. * @param defines Defines of the material we want to update
  63396. * @param lightIndex Index of the light in the enabled light list of the material
  63397. */
  63398. prepareDefines(defines: any, lightIndex: number): void;
  63399. /**
  63400. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63401. * defined in the generator but impacting the effect).
  63402. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63403. * @param effect The effect we are binfing the information for
  63404. */
  63405. bindShadowLight(lightIndex: string, effect: Effect): void;
  63406. /**
  63407. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63408. * (eq to view projection * shadow projection matrices)
  63409. * @returns The transform matrix used to create the shadow map
  63410. */
  63411. getTransformMatrix(): Matrix;
  63412. /**
  63413. * Disposes the ShadowGenerator.
  63414. * Returns nothing.
  63415. */
  63416. dispose(): void;
  63417. /**
  63418. * Serializes the shadow generator setup to a json object.
  63419. * @returns The serialized JSON object
  63420. */
  63421. serialize(): any;
  63422. /**
  63423. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63424. * @param parsedShadowGenerator The JSON object to parse
  63425. * @param scene The scene to create the shadow map for
  63426. * @returns The parsed shadow generator
  63427. */
  63428. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63429. }
  63430. }
  63431. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63432. import { Scene } from "babylonjs/scene";
  63433. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63434. import { AbstractScene } from "babylonjs/abstractScene";
  63435. /**
  63436. * Defines the shadow generator component responsible to manage any shadow generators
  63437. * in a given scene.
  63438. */
  63439. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63440. /**
  63441. * The component name helpfull to identify the component in the list of scene components.
  63442. */
  63443. readonly name: string;
  63444. /**
  63445. * The scene the component belongs to.
  63446. */
  63447. scene: Scene;
  63448. /**
  63449. * Creates a new instance of the component for the given scene
  63450. * @param scene Defines the scene to register the component in
  63451. */
  63452. constructor(scene: Scene);
  63453. /**
  63454. * Registers the component in a given scene
  63455. */
  63456. register(): void;
  63457. /**
  63458. * Rebuilds the elements related to this component in case of
  63459. * context lost for instance.
  63460. */
  63461. rebuild(): void;
  63462. /**
  63463. * Serializes the component data to the specified json object
  63464. * @param serializationObject The object to serialize to
  63465. */
  63466. serialize(serializationObject: any): void;
  63467. /**
  63468. * Adds all the elements from the container to the scene
  63469. * @param container the container holding the elements
  63470. */
  63471. addFromContainer(container: AbstractScene): void;
  63472. /**
  63473. * Removes all the elements in the container from the scene
  63474. * @param container contains the elements to remove
  63475. * @param dispose if the removed element should be disposed (default: false)
  63476. */
  63477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63478. /**
  63479. * Rebuilds the elements related to this component in case of
  63480. * context lost for instance.
  63481. */
  63482. dispose(): void;
  63483. private _gatherRenderTargets;
  63484. }
  63485. }
  63486. declare module "babylonjs/Lights/Shadows/index" {
  63487. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63488. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63489. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63490. }
  63491. declare module "babylonjs/Lights/pointLight" {
  63492. import { Scene } from "babylonjs/scene";
  63493. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63495. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63496. import { Effect } from "babylonjs/Materials/effect";
  63497. /**
  63498. * A point light is a light defined by an unique point in world space.
  63499. * The light is emitted in every direction from this point.
  63500. * A good example of a point light is a standard light bulb.
  63501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63502. */
  63503. export class PointLight extends ShadowLight {
  63504. private _shadowAngle;
  63505. /**
  63506. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63507. * This specifies what angle the shadow will use to be created.
  63508. *
  63509. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63510. */
  63511. get shadowAngle(): number;
  63512. /**
  63513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63514. * This specifies what angle the shadow will use to be created.
  63515. *
  63516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63517. */
  63518. set shadowAngle(value: number);
  63519. /**
  63520. * Gets the direction if it has been set.
  63521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63522. */
  63523. get direction(): Vector3;
  63524. /**
  63525. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63526. */
  63527. set direction(value: Vector3);
  63528. /**
  63529. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63530. * A PointLight emits the light in every direction.
  63531. * It can cast shadows.
  63532. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63533. * ```javascript
  63534. * var pointLight = new PointLight("pl", camera.position, scene);
  63535. * ```
  63536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63537. * @param name The light friendly name
  63538. * @param position The position of the point light in the scene
  63539. * @param scene The scene the lights belongs to
  63540. */
  63541. constructor(name: string, position: Vector3, scene: Scene);
  63542. /**
  63543. * Returns the string "PointLight"
  63544. * @returns the class name
  63545. */
  63546. getClassName(): string;
  63547. /**
  63548. * Returns the integer 0.
  63549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63550. */
  63551. getTypeID(): number;
  63552. /**
  63553. * Specifies wether or not the shadowmap should be a cube texture.
  63554. * @returns true if the shadowmap needs to be a cube texture.
  63555. */
  63556. needCube(): boolean;
  63557. /**
  63558. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63559. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63560. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63561. */
  63562. getShadowDirection(faceIndex?: number): Vector3;
  63563. /**
  63564. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63565. * - fov = PI / 2
  63566. * - aspect ratio : 1.0
  63567. * - z-near and far equal to the active camera minZ and maxZ.
  63568. * Returns the PointLight.
  63569. */
  63570. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63571. protected _buildUniformLayout(): void;
  63572. /**
  63573. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63574. * @param effect The effect to update
  63575. * @param lightIndex The index of the light in the effect to update
  63576. * @returns The point light
  63577. */
  63578. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63580. /**
  63581. * Prepares the list of defines specific to the light type.
  63582. * @param defines the list of defines
  63583. * @param lightIndex defines the index of the light for the effect
  63584. */
  63585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63586. }
  63587. }
  63588. declare module "babylonjs/Lights/index" {
  63589. export * from "babylonjs/Lights/light";
  63590. export * from "babylonjs/Lights/shadowLight";
  63591. export * from "babylonjs/Lights/Shadows/index";
  63592. export * from "babylonjs/Lights/directionalLight";
  63593. export * from "babylonjs/Lights/hemisphericLight";
  63594. export * from "babylonjs/Lights/pointLight";
  63595. export * from "babylonjs/Lights/spotLight";
  63596. }
  63597. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63598. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63599. /**
  63600. * Header information of HDR texture files.
  63601. */
  63602. export interface HDRInfo {
  63603. /**
  63604. * The height of the texture in pixels.
  63605. */
  63606. height: number;
  63607. /**
  63608. * The width of the texture in pixels.
  63609. */
  63610. width: number;
  63611. /**
  63612. * The index of the beginning of the data in the binary file.
  63613. */
  63614. dataPosition: number;
  63615. }
  63616. /**
  63617. * This groups tools to convert HDR texture to native colors array.
  63618. */
  63619. export class HDRTools {
  63620. private static Ldexp;
  63621. private static Rgbe2float;
  63622. private static readStringLine;
  63623. /**
  63624. * Reads header information from an RGBE texture stored in a native array.
  63625. * More information on this format are available here:
  63626. * https://en.wikipedia.org/wiki/RGBE_image_format
  63627. *
  63628. * @param uint8array The binary file stored in native array.
  63629. * @return The header information.
  63630. */
  63631. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63632. /**
  63633. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63634. * This RGBE texture needs to store the information as a panorama.
  63635. *
  63636. * More information on this format are available here:
  63637. * https://en.wikipedia.org/wiki/RGBE_image_format
  63638. *
  63639. * @param buffer The binary file stored in an array buffer.
  63640. * @param size The expected size of the extracted cubemap.
  63641. * @return The Cube Map information.
  63642. */
  63643. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63644. /**
  63645. * Returns the pixels data extracted from an RGBE texture.
  63646. * This pixels will be stored left to right up to down in the R G B order in one array.
  63647. *
  63648. * More information on this format are available here:
  63649. * https://en.wikipedia.org/wiki/RGBE_image_format
  63650. *
  63651. * @param uint8array The binary file stored in an array buffer.
  63652. * @param hdrInfo The header information of the file.
  63653. * @return The pixels data in RGB right to left up to down order.
  63654. */
  63655. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63656. private static RGBE_ReadPixels_RLE;
  63657. private static RGBE_ReadPixels_NOT_RLE;
  63658. }
  63659. }
  63660. declare module "babylonjs/Materials/effectRenderer" {
  63661. import { Nullable } from "babylonjs/types";
  63662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63664. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63665. import { Viewport } from "babylonjs/Maths/math.viewport";
  63666. import { Observable } from "babylonjs/Misc/observable";
  63667. import { Effect } from "babylonjs/Materials/effect";
  63668. import "babylonjs/Shaders/postprocess.vertex";
  63669. /**
  63670. * Effect Render Options
  63671. */
  63672. export interface IEffectRendererOptions {
  63673. /**
  63674. * Defines the vertices positions.
  63675. */
  63676. positions?: number[];
  63677. /**
  63678. * Defines the indices.
  63679. */
  63680. indices?: number[];
  63681. }
  63682. /**
  63683. * Helper class to render one or more effects.
  63684. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63685. */
  63686. export class EffectRenderer {
  63687. private engine;
  63688. private static _DefaultOptions;
  63689. private _vertexBuffers;
  63690. private _indexBuffer;
  63691. private _fullscreenViewport;
  63692. /**
  63693. * Creates an effect renderer
  63694. * @param engine the engine to use for rendering
  63695. * @param options defines the options of the effect renderer
  63696. */
  63697. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63698. /**
  63699. * Sets the current viewport in normalized coordinates 0-1
  63700. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63701. */
  63702. setViewport(viewport?: Viewport): void;
  63703. /**
  63704. * Binds the embedded attributes buffer to the effect.
  63705. * @param effect Defines the effect to bind the attributes for
  63706. */
  63707. bindBuffers(effect: Effect): void;
  63708. /**
  63709. * Sets the current effect wrapper to use during draw.
  63710. * The effect needs to be ready before calling this api.
  63711. * This also sets the default full screen position attribute.
  63712. * @param effectWrapper Defines the effect to draw with
  63713. */
  63714. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63715. /**
  63716. * Restores engine states
  63717. */
  63718. restoreStates(): void;
  63719. /**
  63720. * Draws a full screen quad.
  63721. */
  63722. draw(): void;
  63723. private isRenderTargetTexture;
  63724. /**
  63725. * renders one or more effects to a specified texture
  63726. * @param effectWrapper the effect to renderer
  63727. * @param outputTexture texture to draw to, if null it will render to the screen.
  63728. */
  63729. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63730. /**
  63731. * Disposes of the effect renderer
  63732. */
  63733. dispose(): void;
  63734. }
  63735. /**
  63736. * Options to create an EffectWrapper
  63737. */
  63738. interface EffectWrapperCreationOptions {
  63739. /**
  63740. * Engine to use to create the effect
  63741. */
  63742. engine: ThinEngine;
  63743. /**
  63744. * Fragment shader for the effect
  63745. */
  63746. fragmentShader: string;
  63747. /**
  63748. * Use the shader store instead of direct source code
  63749. */
  63750. useShaderStore?: boolean;
  63751. /**
  63752. * Vertex shader for the effect
  63753. */
  63754. vertexShader?: string;
  63755. /**
  63756. * Attributes to use in the shader
  63757. */
  63758. attributeNames?: Array<string>;
  63759. /**
  63760. * Uniforms to use in the shader
  63761. */
  63762. uniformNames?: Array<string>;
  63763. /**
  63764. * Texture sampler names to use in the shader
  63765. */
  63766. samplerNames?: Array<string>;
  63767. /**
  63768. * Defines to use in the shader
  63769. */
  63770. defines?: Array<string>;
  63771. /**
  63772. * Callback when effect is compiled
  63773. */
  63774. onCompiled?: Nullable<(effect: Effect) => void>;
  63775. /**
  63776. * The friendly name of the effect displayed in Spector.
  63777. */
  63778. name?: string;
  63779. }
  63780. /**
  63781. * Wraps an effect to be used for rendering
  63782. */
  63783. export class EffectWrapper {
  63784. /**
  63785. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63786. */
  63787. onApplyObservable: Observable<{}>;
  63788. /**
  63789. * The underlying effect
  63790. */
  63791. effect: Effect;
  63792. /**
  63793. * Creates an effect to be renderer
  63794. * @param creationOptions options to create the effect
  63795. */
  63796. constructor(creationOptions: EffectWrapperCreationOptions);
  63797. /**
  63798. * Disposes of the effect wrapper
  63799. */
  63800. dispose(): void;
  63801. }
  63802. }
  63803. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63804. /** @hidden */
  63805. export var hdrFilteringVertexShader: {
  63806. name: string;
  63807. shader: string;
  63808. };
  63809. }
  63810. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63811. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63812. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63813. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63814. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63815. /** @hidden */
  63816. export var hdrFilteringPixelShader: {
  63817. name: string;
  63818. shader: string;
  63819. };
  63820. }
  63821. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63823. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63824. import { Nullable } from "babylonjs/types";
  63825. import "babylonjs/Shaders/hdrFiltering.vertex";
  63826. import "babylonjs/Shaders/hdrFiltering.fragment";
  63827. /**
  63828. * Options for texture filtering
  63829. */
  63830. interface IHDRFilteringOptions {
  63831. /**
  63832. * Scales pixel intensity for the input HDR map.
  63833. */
  63834. hdrScale?: number;
  63835. /**
  63836. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63837. */
  63838. quality?: number;
  63839. }
  63840. /**
  63841. * Filters HDR maps to get correct renderings of PBR reflections
  63842. */
  63843. export class HDRFiltering {
  63844. private _engine;
  63845. private _effectRenderer;
  63846. private _effectWrapper;
  63847. private _lodGenerationOffset;
  63848. private _lodGenerationScale;
  63849. /**
  63850. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63851. * you care about baking speed.
  63852. */
  63853. quality: number;
  63854. /**
  63855. * Scales pixel intensity for the input HDR map.
  63856. */
  63857. hdrScale: number;
  63858. /**
  63859. * Instantiates HDR filter for reflection maps
  63860. *
  63861. * @param engine Thin engine
  63862. * @param options Options
  63863. */
  63864. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63865. private _createRenderTarget;
  63866. private _prefilterInternal;
  63867. private _createEffect;
  63868. /**
  63869. * Get a value indicating if the filter is ready to be used
  63870. * @param texture Texture to filter
  63871. * @returns true if the filter is ready
  63872. */
  63873. isReady(texture: BaseTexture): boolean;
  63874. /**
  63875. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63876. * Prefiltering will be invoked at the end of next rendering pass.
  63877. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63878. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63879. * @param texture Texture to filter
  63880. * @param onFinished Callback when filtering is done
  63881. * @return Promise called when prefiltering is done
  63882. */
  63883. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63884. }
  63885. }
  63886. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63887. import { Nullable } from "babylonjs/types";
  63888. import { Scene } from "babylonjs/scene";
  63889. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63892. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63893. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63894. /**
  63895. * This represents a texture coming from an HDR input.
  63896. *
  63897. * The only supported format is currently panorama picture stored in RGBE format.
  63898. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63899. */
  63900. export class HDRCubeTexture extends BaseTexture {
  63901. private static _facesMapping;
  63902. private _generateHarmonics;
  63903. private _noMipmap;
  63904. private _prefilterOnLoad;
  63905. private _textureMatrix;
  63906. private _size;
  63907. private _onLoad;
  63908. private _onError;
  63909. /**
  63910. * The texture URL.
  63911. */
  63912. url: string;
  63913. protected _isBlocking: boolean;
  63914. /**
  63915. * Sets wether or not the texture is blocking during loading.
  63916. */
  63917. set isBlocking(value: boolean);
  63918. /**
  63919. * Gets wether or not the texture is blocking during loading.
  63920. */
  63921. get isBlocking(): boolean;
  63922. protected _rotationY: number;
  63923. /**
  63924. * Sets texture matrix rotation angle around Y axis in radians.
  63925. */
  63926. set rotationY(value: number);
  63927. /**
  63928. * Gets texture matrix rotation angle around Y axis radians.
  63929. */
  63930. get rotationY(): number;
  63931. /**
  63932. * Gets or sets the center of the bounding box associated with the cube texture
  63933. * It must define where the camera used to render the texture was set
  63934. */
  63935. boundingBoxPosition: Vector3;
  63936. private _boundingBoxSize;
  63937. /**
  63938. * Gets or sets the size of the bounding box associated with the cube texture
  63939. * When defined, the cubemap will switch to local mode
  63940. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63941. * @example https://www.babylonjs-playground.com/#RNASML
  63942. */
  63943. set boundingBoxSize(value: Vector3);
  63944. get boundingBoxSize(): Vector3;
  63945. /**
  63946. * Instantiates an HDRTexture from the following parameters.
  63947. *
  63948. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63949. * @param sceneOrEngine The scene or engine the texture will be used in
  63950. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63951. * @param noMipmap Forces to not generate the mipmap if true
  63952. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63953. * @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)
  63954. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63955. */
  63956. 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>);
  63957. /**
  63958. * Get the current class name of the texture useful for serialization or dynamic coding.
  63959. * @returns "HDRCubeTexture"
  63960. */
  63961. getClassName(): string;
  63962. /**
  63963. * Occurs when the file is raw .hdr file.
  63964. */
  63965. private loadTexture;
  63966. clone(): HDRCubeTexture;
  63967. delayLoad(): void;
  63968. /**
  63969. * Get the texture reflection matrix used to rotate/transform the reflection.
  63970. * @returns the reflection matrix
  63971. */
  63972. getReflectionTextureMatrix(): Matrix;
  63973. /**
  63974. * Set the texture reflection matrix used to rotate/transform the reflection.
  63975. * @param value Define the reflection matrix to set
  63976. */
  63977. setReflectionTextureMatrix(value: Matrix): void;
  63978. /**
  63979. * Parses a JSON representation of an HDR Texture in order to create the texture
  63980. * @param parsedTexture Define the JSON representation
  63981. * @param scene Define the scene the texture should be created in
  63982. * @param rootUrl Define the root url in case we need to load relative dependencies
  63983. * @returns the newly created texture after parsing
  63984. */
  63985. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63986. serialize(): any;
  63987. }
  63988. }
  63989. declare module "babylonjs/Physics/physicsEngine" {
  63990. import { Nullable } from "babylonjs/types";
  63991. import { Vector3 } from "babylonjs/Maths/math.vector";
  63992. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63993. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63994. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63995. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63996. /**
  63997. * Class used to control physics engine
  63998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63999. */
  64000. export class PhysicsEngine implements IPhysicsEngine {
  64001. private _physicsPlugin;
  64002. /**
  64003. * Global value used to control the smallest number supported by the simulation
  64004. */
  64005. static Epsilon: number;
  64006. private _impostors;
  64007. private _joints;
  64008. private _subTimeStep;
  64009. /**
  64010. * Gets the gravity vector used by the simulation
  64011. */
  64012. gravity: Vector3;
  64013. /**
  64014. * Factory used to create the default physics plugin.
  64015. * @returns The default physics plugin
  64016. */
  64017. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64018. /**
  64019. * Creates a new Physics Engine
  64020. * @param gravity defines the gravity vector used by the simulation
  64021. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64022. */
  64023. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64024. /**
  64025. * Sets the gravity vector used by the simulation
  64026. * @param gravity defines the gravity vector to use
  64027. */
  64028. setGravity(gravity: Vector3): void;
  64029. /**
  64030. * Set the time step of the physics engine.
  64031. * Default is 1/60.
  64032. * To slow it down, enter 1/600 for example.
  64033. * To speed it up, 1/30
  64034. * @param newTimeStep defines the new timestep to apply to this world.
  64035. */
  64036. setTimeStep(newTimeStep?: number): void;
  64037. /**
  64038. * Get the time step of the physics engine.
  64039. * @returns the current time step
  64040. */
  64041. getTimeStep(): number;
  64042. /**
  64043. * Set the sub time step of the physics engine.
  64044. * Default is 0 meaning there is no sub steps
  64045. * To increase physics resolution precision, set a small value (like 1 ms)
  64046. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64047. */
  64048. setSubTimeStep(subTimeStep?: number): void;
  64049. /**
  64050. * Get the sub time step of the physics engine.
  64051. * @returns the current sub time step
  64052. */
  64053. getSubTimeStep(): number;
  64054. /**
  64055. * Release all resources
  64056. */
  64057. dispose(): void;
  64058. /**
  64059. * Gets the name of the current physics plugin
  64060. * @returns the name of the plugin
  64061. */
  64062. getPhysicsPluginName(): string;
  64063. /**
  64064. * Adding a new impostor for the impostor tracking.
  64065. * This will be done by the impostor itself.
  64066. * @param impostor the impostor to add
  64067. */
  64068. addImpostor(impostor: PhysicsImpostor): void;
  64069. /**
  64070. * Remove an impostor from the engine.
  64071. * This impostor and its mesh will not longer be updated by the physics engine.
  64072. * @param impostor the impostor to remove
  64073. */
  64074. removeImpostor(impostor: PhysicsImpostor): void;
  64075. /**
  64076. * Add a joint to the physics engine
  64077. * @param mainImpostor defines the main impostor to which the joint is added.
  64078. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64079. * @param joint defines the joint that will connect both impostors.
  64080. */
  64081. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64082. /**
  64083. * Removes a joint from the simulation
  64084. * @param mainImpostor defines the impostor used with the joint
  64085. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64086. * @param joint defines the joint to remove
  64087. */
  64088. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64089. /**
  64090. * Called by the scene. No need to call it.
  64091. * @param delta defines the timespam between frames
  64092. */
  64093. _step(delta: number): void;
  64094. /**
  64095. * Gets the current plugin used to run the simulation
  64096. * @returns current plugin
  64097. */
  64098. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64099. /**
  64100. * Gets the list of physic impostors
  64101. * @returns an array of PhysicsImpostor
  64102. */
  64103. getImpostors(): Array<PhysicsImpostor>;
  64104. /**
  64105. * Gets the impostor for a physics enabled object
  64106. * @param object defines the object impersonated by the impostor
  64107. * @returns the PhysicsImpostor or null if not found
  64108. */
  64109. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64110. /**
  64111. * Gets the impostor for a physics body object
  64112. * @param body defines physics body used by the impostor
  64113. * @returns the PhysicsImpostor or null if not found
  64114. */
  64115. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64116. /**
  64117. * Does a raycast in the physics world
  64118. * @param from when should the ray start?
  64119. * @param to when should the ray end?
  64120. * @returns PhysicsRaycastResult
  64121. */
  64122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64123. }
  64124. }
  64125. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64126. import { Nullable } from "babylonjs/types";
  64127. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64129. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64130. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64131. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64132. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64133. /** @hidden */
  64134. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64135. private _useDeltaForWorldStep;
  64136. world: any;
  64137. name: string;
  64138. private _physicsMaterials;
  64139. private _fixedTimeStep;
  64140. private _cannonRaycastResult;
  64141. private _raycastResult;
  64142. private _physicsBodysToRemoveAfterStep;
  64143. private _firstFrame;
  64144. BJSCANNON: any;
  64145. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64146. setGravity(gravity: Vector3): void;
  64147. setTimeStep(timeStep: number): void;
  64148. getTimeStep(): number;
  64149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64150. private _removeMarkedPhysicsBodiesFromWorld;
  64151. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64154. private _processChildMeshes;
  64155. removePhysicsBody(impostor: PhysicsImpostor): void;
  64156. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64157. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64158. private _addMaterial;
  64159. private _checkWithEpsilon;
  64160. private _createShape;
  64161. private _createHeightmap;
  64162. private _minus90X;
  64163. private _plus90X;
  64164. private _tmpPosition;
  64165. private _tmpDeltaPosition;
  64166. private _tmpUnityRotation;
  64167. private _updatePhysicsBodyTransformation;
  64168. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64169. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64170. isSupported(): boolean;
  64171. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64172. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64173. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64174. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64175. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64176. getBodyMass(impostor: PhysicsImpostor): number;
  64177. getBodyFriction(impostor: PhysicsImpostor): number;
  64178. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64179. getBodyRestitution(impostor: PhysicsImpostor): number;
  64180. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64181. sleepBody(impostor: PhysicsImpostor): void;
  64182. wakeUpBody(impostor: PhysicsImpostor): void;
  64183. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64184. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64185. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64186. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64187. getRadius(impostor: PhysicsImpostor): number;
  64188. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64189. dispose(): void;
  64190. private _extendNamespace;
  64191. /**
  64192. * Does a raycast in the physics world
  64193. * @param from when should the ray start?
  64194. * @param to when should the ray end?
  64195. * @returns PhysicsRaycastResult
  64196. */
  64197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64198. }
  64199. }
  64200. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64201. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64202. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64203. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64205. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64206. import { Nullable } from "babylonjs/types";
  64207. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64208. /** @hidden */
  64209. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64210. private _useDeltaForWorldStep;
  64211. world: any;
  64212. name: string;
  64213. BJSOIMO: any;
  64214. private _raycastResult;
  64215. private _fixedTimeStep;
  64216. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64217. setGravity(gravity: Vector3): void;
  64218. setTimeStep(timeStep: number): void;
  64219. getTimeStep(): number;
  64220. private _tmpImpostorsArray;
  64221. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64222. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64223. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64224. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64225. private _tmpPositionVector;
  64226. removePhysicsBody(impostor: PhysicsImpostor): void;
  64227. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64228. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64229. isSupported(): boolean;
  64230. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64231. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64232. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64233. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64234. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64235. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64236. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64237. getBodyMass(impostor: PhysicsImpostor): number;
  64238. getBodyFriction(impostor: PhysicsImpostor): number;
  64239. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64240. getBodyRestitution(impostor: PhysicsImpostor): number;
  64241. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64242. sleepBody(impostor: PhysicsImpostor): void;
  64243. wakeUpBody(impostor: PhysicsImpostor): void;
  64244. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64245. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64246. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64247. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64248. getRadius(impostor: PhysicsImpostor): number;
  64249. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64250. dispose(): void;
  64251. /**
  64252. * Does a raycast in the physics world
  64253. * @param from when should the ray start?
  64254. * @param to when should the ray end?
  64255. * @returns PhysicsRaycastResult
  64256. */
  64257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64258. }
  64259. }
  64260. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64261. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64262. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64263. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64264. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64265. import { Nullable } from "babylonjs/types";
  64266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64267. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64268. /**
  64269. * AmmoJS Physics plugin
  64270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64271. * @see https://github.com/kripken/ammo.js/
  64272. */
  64273. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64274. private _useDeltaForWorldStep;
  64275. /**
  64276. * Reference to the Ammo library
  64277. */
  64278. bjsAMMO: any;
  64279. /**
  64280. * Created ammoJS world which physics bodies are added to
  64281. */
  64282. world: any;
  64283. /**
  64284. * Name of the plugin
  64285. */
  64286. name: string;
  64287. private _timeStep;
  64288. private _fixedTimeStep;
  64289. private _maxSteps;
  64290. private _tmpQuaternion;
  64291. private _tmpAmmoTransform;
  64292. private _tmpAmmoQuaternion;
  64293. private _tmpAmmoConcreteContactResultCallback;
  64294. private _collisionConfiguration;
  64295. private _dispatcher;
  64296. private _overlappingPairCache;
  64297. private _solver;
  64298. private _softBodySolver;
  64299. private _tmpAmmoVectorA;
  64300. private _tmpAmmoVectorB;
  64301. private _tmpAmmoVectorC;
  64302. private _tmpAmmoVectorD;
  64303. private _tmpContactCallbackResult;
  64304. private _tmpAmmoVectorRCA;
  64305. private _tmpAmmoVectorRCB;
  64306. private _raycastResult;
  64307. private static readonly DISABLE_COLLISION_FLAG;
  64308. private static readonly KINEMATIC_FLAG;
  64309. private static readonly DISABLE_DEACTIVATION_FLAG;
  64310. /**
  64311. * Initializes the ammoJS plugin
  64312. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64313. * @param ammoInjection can be used to inject your own ammo reference
  64314. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64315. */
  64316. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64317. /**
  64318. * Sets the gravity of the physics world (m/(s^2))
  64319. * @param gravity Gravity to set
  64320. */
  64321. setGravity(gravity: Vector3): void;
  64322. /**
  64323. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64324. * @param timeStep timestep to use in seconds
  64325. */
  64326. setTimeStep(timeStep: number): void;
  64327. /**
  64328. * 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)
  64329. * @param fixedTimeStep fixedTimeStep to use in seconds
  64330. */
  64331. setFixedTimeStep(fixedTimeStep: number): void;
  64332. /**
  64333. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64334. * @param maxSteps the maximum number of steps by the physics engine per frame
  64335. */
  64336. setMaxSteps(maxSteps: number): void;
  64337. /**
  64338. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64339. * @returns the current timestep in seconds
  64340. */
  64341. getTimeStep(): number;
  64342. /**
  64343. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64344. */
  64345. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64346. private _isImpostorInContact;
  64347. private _isImpostorPairInContact;
  64348. private _stepSimulation;
  64349. /**
  64350. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64351. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64352. * After the step the babylon meshes are set to the position of the physics imposters
  64353. * @param delta amount of time to step forward
  64354. * @param impostors array of imposters to update before/after the step
  64355. */
  64356. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64357. /**
  64358. * Update babylon mesh to match physics world object
  64359. * @param impostor imposter to match
  64360. */
  64361. private _afterSoftStep;
  64362. /**
  64363. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64364. * @param impostor imposter to match
  64365. */
  64366. private _ropeStep;
  64367. /**
  64368. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64369. * @param impostor imposter to match
  64370. */
  64371. private _softbodyOrClothStep;
  64372. private _tmpMatrix;
  64373. /**
  64374. * Applies an impulse on the imposter
  64375. * @param impostor imposter to apply impulse to
  64376. * @param force amount of force to be applied to the imposter
  64377. * @param contactPoint the location to apply the impulse on the imposter
  64378. */
  64379. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64380. /**
  64381. * Applies a force on the imposter
  64382. * @param impostor imposter to apply force
  64383. * @param force amount of force to be applied to the imposter
  64384. * @param contactPoint the location to apply the force on the imposter
  64385. */
  64386. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64387. /**
  64388. * Creates a physics body using the plugin
  64389. * @param impostor the imposter to create the physics body on
  64390. */
  64391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64392. /**
  64393. * Removes the physics body from the imposter and disposes of the body's memory
  64394. * @param impostor imposter to remove the physics body from
  64395. */
  64396. removePhysicsBody(impostor: PhysicsImpostor): void;
  64397. /**
  64398. * Generates a joint
  64399. * @param impostorJoint the imposter joint to create the joint with
  64400. */
  64401. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64402. /**
  64403. * Removes a joint
  64404. * @param impostorJoint the imposter joint to remove the joint from
  64405. */
  64406. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64407. private _addMeshVerts;
  64408. /**
  64409. * Initialise the soft body vertices to match its object's (mesh) vertices
  64410. * Softbody vertices (nodes) are in world space and to match this
  64411. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64412. * @param impostor to create the softbody for
  64413. */
  64414. private _softVertexData;
  64415. /**
  64416. * Create an impostor's soft body
  64417. * @param impostor to create the softbody for
  64418. */
  64419. private _createSoftbody;
  64420. /**
  64421. * Create cloth for an impostor
  64422. * @param impostor to create the softbody for
  64423. */
  64424. private _createCloth;
  64425. /**
  64426. * Create rope for an impostor
  64427. * @param impostor to create the softbody for
  64428. */
  64429. private _createRope;
  64430. /**
  64431. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64432. * @param impostor to create the custom physics shape for
  64433. */
  64434. private _createCustom;
  64435. private _addHullVerts;
  64436. private _createShape;
  64437. /**
  64438. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64439. * @param impostor imposter containing the physics body and babylon object
  64440. */
  64441. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64442. /**
  64443. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64444. * @param impostor imposter containing the physics body and babylon object
  64445. * @param newPosition new position
  64446. * @param newRotation new rotation
  64447. */
  64448. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64449. /**
  64450. * If this plugin is supported
  64451. * @returns true if its supported
  64452. */
  64453. isSupported(): boolean;
  64454. /**
  64455. * Sets the linear velocity of the physics body
  64456. * @param impostor imposter to set the velocity on
  64457. * @param velocity velocity to set
  64458. */
  64459. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64460. /**
  64461. * Sets the angular velocity of the physics body
  64462. * @param impostor imposter to set the velocity on
  64463. * @param velocity velocity to set
  64464. */
  64465. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64466. /**
  64467. * gets the linear velocity
  64468. * @param impostor imposter to get linear velocity from
  64469. * @returns linear velocity
  64470. */
  64471. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64472. /**
  64473. * gets the angular velocity
  64474. * @param impostor imposter to get angular velocity from
  64475. * @returns angular velocity
  64476. */
  64477. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64478. /**
  64479. * Sets the mass of physics body
  64480. * @param impostor imposter to set the mass on
  64481. * @param mass mass to set
  64482. */
  64483. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64484. /**
  64485. * Gets the mass of the physics body
  64486. * @param impostor imposter to get the mass from
  64487. * @returns mass
  64488. */
  64489. getBodyMass(impostor: PhysicsImpostor): number;
  64490. /**
  64491. * Gets friction of the impostor
  64492. * @param impostor impostor to get friction from
  64493. * @returns friction value
  64494. */
  64495. getBodyFriction(impostor: PhysicsImpostor): number;
  64496. /**
  64497. * Sets friction of the impostor
  64498. * @param impostor impostor to set friction on
  64499. * @param friction friction value
  64500. */
  64501. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64502. /**
  64503. * Gets restitution of the impostor
  64504. * @param impostor impostor to get restitution from
  64505. * @returns restitution value
  64506. */
  64507. getBodyRestitution(impostor: PhysicsImpostor): number;
  64508. /**
  64509. * Sets resitution of the impostor
  64510. * @param impostor impostor to set resitution on
  64511. * @param restitution resitution value
  64512. */
  64513. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64514. /**
  64515. * Gets pressure inside the impostor
  64516. * @param impostor impostor to get pressure from
  64517. * @returns pressure value
  64518. */
  64519. getBodyPressure(impostor: PhysicsImpostor): number;
  64520. /**
  64521. * Sets pressure inside a soft body impostor
  64522. * Cloth and rope must remain 0 pressure
  64523. * @param impostor impostor to set pressure on
  64524. * @param pressure pressure value
  64525. */
  64526. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64527. /**
  64528. * Gets stiffness of the impostor
  64529. * @param impostor impostor to get stiffness from
  64530. * @returns pressure value
  64531. */
  64532. getBodyStiffness(impostor: PhysicsImpostor): number;
  64533. /**
  64534. * Sets stiffness of the impostor
  64535. * @param impostor impostor to set stiffness on
  64536. * @param stiffness stiffness value from 0 to 1
  64537. */
  64538. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64539. /**
  64540. * Gets velocityIterations of the impostor
  64541. * @param impostor impostor to get velocity iterations from
  64542. * @returns velocityIterations value
  64543. */
  64544. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64545. /**
  64546. * Sets velocityIterations of the impostor
  64547. * @param impostor impostor to set velocity iterations on
  64548. * @param velocityIterations velocityIterations value
  64549. */
  64550. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64551. /**
  64552. * Gets positionIterations of the impostor
  64553. * @param impostor impostor to get position iterations from
  64554. * @returns positionIterations value
  64555. */
  64556. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64557. /**
  64558. * Sets positionIterations of the impostor
  64559. * @param impostor impostor to set position on
  64560. * @param positionIterations positionIterations value
  64561. */
  64562. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64563. /**
  64564. * Append an anchor to a cloth object
  64565. * @param impostor is the cloth impostor to add anchor to
  64566. * @param otherImpostor is the rigid impostor to anchor to
  64567. * @param width ratio across width from 0 to 1
  64568. * @param height ratio up height from 0 to 1
  64569. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64570. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64571. */
  64572. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64573. /**
  64574. * Append an hook to a rope object
  64575. * @param impostor is the rope impostor to add hook to
  64576. * @param otherImpostor is the rigid impostor to hook to
  64577. * @param length ratio along the rope from 0 to 1
  64578. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64579. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64580. */
  64581. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64582. /**
  64583. * Sleeps the physics body and stops it from being active
  64584. * @param impostor impostor to sleep
  64585. */
  64586. sleepBody(impostor: PhysicsImpostor): void;
  64587. /**
  64588. * Activates the physics body
  64589. * @param impostor impostor to activate
  64590. */
  64591. wakeUpBody(impostor: PhysicsImpostor): void;
  64592. /**
  64593. * Updates the distance parameters of the joint
  64594. * @param joint joint to update
  64595. * @param maxDistance maximum distance of the joint
  64596. * @param minDistance minimum distance of the joint
  64597. */
  64598. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64599. /**
  64600. * Sets a motor on the joint
  64601. * @param joint joint to set motor on
  64602. * @param speed speed of the motor
  64603. * @param maxForce maximum force of the motor
  64604. * @param motorIndex index of the motor
  64605. */
  64606. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64607. /**
  64608. * Sets the motors limit
  64609. * @param joint joint to set limit on
  64610. * @param upperLimit upper limit
  64611. * @param lowerLimit lower limit
  64612. */
  64613. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64614. /**
  64615. * Syncs the position and rotation of a mesh with the impostor
  64616. * @param mesh mesh to sync
  64617. * @param impostor impostor to update the mesh with
  64618. */
  64619. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64620. /**
  64621. * Gets the radius of the impostor
  64622. * @param impostor impostor to get radius from
  64623. * @returns the radius
  64624. */
  64625. getRadius(impostor: PhysicsImpostor): number;
  64626. /**
  64627. * Gets the box size of the impostor
  64628. * @param impostor impostor to get box size from
  64629. * @param result the resulting box size
  64630. */
  64631. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64632. /**
  64633. * Disposes of the impostor
  64634. */
  64635. dispose(): void;
  64636. /**
  64637. * Does a raycast in the physics world
  64638. * @param from when should the ray start?
  64639. * @param to when should the ray end?
  64640. * @returns PhysicsRaycastResult
  64641. */
  64642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64643. }
  64644. }
  64645. declare module "babylonjs/Probes/reflectionProbe" {
  64646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64647. import { Vector3 } from "babylonjs/Maths/math.vector";
  64648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64649. import { Nullable } from "babylonjs/types";
  64650. import { Scene } from "babylonjs/scene";
  64651. module "babylonjs/abstractScene" {
  64652. interface AbstractScene {
  64653. /**
  64654. * The list of reflection probes added to the scene
  64655. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64656. */
  64657. reflectionProbes: Array<ReflectionProbe>;
  64658. /**
  64659. * Removes the given reflection probe from this scene.
  64660. * @param toRemove The reflection probe to remove
  64661. * @returns The index of the removed reflection probe
  64662. */
  64663. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64664. /**
  64665. * Adds the given reflection probe to this scene.
  64666. * @param newReflectionProbe The reflection probe to add
  64667. */
  64668. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64669. }
  64670. }
  64671. /**
  64672. * Class used to generate realtime reflection / refraction cube textures
  64673. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64674. */
  64675. export class ReflectionProbe {
  64676. /** defines the name of the probe */
  64677. name: string;
  64678. private _scene;
  64679. private _renderTargetTexture;
  64680. private _projectionMatrix;
  64681. private _viewMatrix;
  64682. private _target;
  64683. private _add;
  64684. private _attachedMesh;
  64685. private _invertYAxis;
  64686. /** Gets or sets probe position (center of the cube map) */
  64687. position: Vector3;
  64688. /**
  64689. * Creates a new reflection probe
  64690. * @param name defines the name of the probe
  64691. * @param size defines the texture resolution (for each face)
  64692. * @param scene defines the hosting scene
  64693. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64694. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64695. */
  64696. constructor(
  64697. /** defines the name of the probe */
  64698. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64699. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64700. get samples(): number;
  64701. set samples(value: number);
  64702. /** Gets or sets the refresh rate to use (on every frame by default) */
  64703. get refreshRate(): number;
  64704. set refreshRate(value: number);
  64705. /**
  64706. * Gets the hosting scene
  64707. * @returns a Scene
  64708. */
  64709. getScene(): Scene;
  64710. /** Gets the internal CubeTexture used to render to */
  64711. get cubeTexture(): RenderTargetTexture;
  64712. /** Gets the list of meshes to render */
  64713. get renderList(): Nullable<AbstractMesh[]>;
  64714. /**
  64715. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64716. * @param mesh defines the mesh to attach to
  64717. */
  64718. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64719. /**
  64720. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64721. * @param renderingGroupId The rendering group id corresponding to its index
  64722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64723. */
  64724. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64725. /**
  64726. * Clean all associated resources
  64727. */
  64728. dispose(): void;
  64729. /**
  64730. * Converts the reflection probe information to a readable string for debug purpose.
  64731. * @param fullDetails Supports for multiple levels of logging within scene loading
  64732. * @returns the human readable reflection probe info
  64733. */
  64734. toString(fullDetails?: boolean): string;
  64735. /**
  64736. * Get the class name of the relfection probe.
  64737. * @returns "ReflectionProbe"
  64738. */
  64739. getClassName(): string;
  64740. /**
  64741. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64742. * @returns The JSON representation of the texture
  64743. */
  64744. serialize(): any;
  64745. /**
  64746. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64747. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64748. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64749. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64750. * @returns The parsed reflection probe if successful
  64751. */
  64752. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64753. }
  64754. }
  64755. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64756. /** @hidden */
  64757. export var _BabylonLoaderRegistered: boolean;
  64758. /**
  64759. * Helps setting up some configuration for the babylon file loader.
  64760. */
  64761. export class BabylonFileLoaderConfiguration {
  64762. /**
  64763. * The loader does not allow injecting custom physix engine into the plugins.
  64764. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64765. * So you could set this variable to your engine import to make it work.
  64766. */
  64767. static LoaderInjectedPhysicsEngine: any;
  64768. }
  64769. }
  64770. declare module "babylonjs/Loading/Plugins/index" {
  64771. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64772. }
  64773. declare module "babylonjs/Loading/index" {
  64774. export * from "babylonjs/Loading/loadingScreen";
  64775. export * from "babylonjs/Loading/Plugins/index";
  64776. export * from "babylonjs/Loading/sceneLoader";
  64777. export * from "babylonjs/Loading/sceneLoaderFlags";
  64778. }
  64779. declare module "babylonjs/Materials/Background/index" {
  64780. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64781. }
  64782. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64783. import { Scene } from "babylonjs/scene";
  64784. import { Color3 } from "babylonjs/Maths/math.color";
  64785. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64787. /**
  64788. * The Physically based simple base material of BJS.
  64789. *
  64790. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64791. * It is used as the base class for both the specGloss and metalRough conventions.
  64792. */
  64793. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64794. /**
  64795. * Number of Simultaneous lights allowed on the material.
  64796. */
  64797. maxSimultaneousLights: number;
  64798. /**
  64799. * If sets to true, disables all the lights affecting the material.
  64800. */
  64801. disableLighting: boolean;
  64802. /**
  64803. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64804. */
  64805. environmentTexture: BaseTexture;
  64806. /**
  64807. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64808. */
  64809. invertNormalMapX: boolean;
  64810. /**
  64811. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64812. */
  64813. invertNormalMapY: boolean;
  64814. /**
  64815. * Normal map used in the model.
  64816. */
  64817. normalTexture: BaseTexture;
  64818. /**
  64819. * Emissivie color used to self-illuminate the model.
  64820. */
  64821. emissiveColor: Color3;
  64822. /**
  64823. * Emissivie texture used to self-illuminate the model.
  64824. */
  64825. emissiveTexture: BaseTexture;
  64826. /**
  64827. * Occlusion Channel Strenght.
  64828. */
  64829. occlusionStrength: number;
  64830. /**
  64831. * Occlusion Texture of the material (adding extra occlusion effects).
  64832. */
  64833. occlusionTexture: BaseTexture;
  64834. /**
  64835. * Defines the alpha limits in alpha test mode.
  64836. */
  64837. alphaCutOff: number;
  64838. /**
  64839. * Gets the current double sided mode.
  64840. */
  64841. get doubleSided(): boolean;
  64842. /**
  64843. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64844. */
  64845. set doubleSided(value: boolean);
  64846. /**
  64847. * Stores the pre-calculated light information of a mesh in a texture.
  64848. */
  64849. lightmapTexture: BaseTexture;
  64850. /**
  64851. * If true, the light map contains occlusion information instead of lighting info.
  64852. */
  64853. useLightmapAsShadowmap: boolean;
  64854. /**
  64855. * Instantiates a new PBRMaterial instance.
  64856. *
  64857. * @param name The material name
  64858. * @param scene The scene the material will be use in.
  64859. */
  64860. constructor(name: string, scene: Scene);
  64861. getClassName(): string;
  64862. }
  64863. }
  64864. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64865. import { Scene } from "babylonjs/scene";
  64866. import { Color3 } from "babylonjs/Maths/math.color";
  64867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64868. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64869. /**
  64870. * The PBR material of BJS following the metal roughness convention.
  64871. *
  64872. * This fits to the PBR convention in the GLTF definition:
  64873. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64874. */
  64875. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64876. /**
  64877. * The base color has two different interpretations depending on the value of metalness.
  64878. * When the material is a metal, the base color is the specific measured reflectance value
  64879. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64880. * of the material.
  64881. */
  64882. baseColor: Color3;
  64883. /**
  64884. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64885. * well as opacity information in the alpha channel.
  64886. */
  64887. baseTexture: BaseTexture;
  64888. /**
  64889. * Specifies the metallic scalar value of the material.
  64890. * Can also be used to scale the metalness values of the metallic texture.
  64891. */
  64892. metallic: number;
  64893. /**
  64894. * Specifies the roughness scalar value of the material.
  64895. * Can also be used to scale the roughness values of the metallic texture.
  64896. */
  64897. roughness: number;
  64898. /**
  64899. * Texture containing both the metallic value in the B channel and the
  64900. * roughness value in the G channel to keep better precision.
  64901. */
  64902. metallicRoughnessTexture: BaseTexture;
  64903. /**
  64904. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64905. *
  64906. * @param name The material name
  64907. * @param scene The scene the material will be use in.
  64908. */
  64909. constructor(name: string, scene: Scene);
  64910. /**
  64911. * Return the currrent class name of the material.
  64912. */
  64913. getClassName(): string;
  64914. /**
  64915. * Makes a duplicate of the current material.
  64916. * @param name - name to use for the new material.
  64917. */
  64918. clone(name: string): PBRMetallicRoughnessMaterial;
  64919. /**
  64920. * Serialize the material to a parsable JSON object.
  64921. */
  64922. serialize(): any;
  64923. /**
  64924. * Parses a JSON object correponding to the serialize function.
  64925. */
  64926. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64927. }
  64928. }
  64929. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64930. import { Scene } from "babylonjs/scene";
  64931. import { Color3 } from "babylonjs/Maths/math.color";
  64932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64933. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64934. /**
  64935. * The PBR material of BJS following the specular glossiness convention.
  64936. *
  64937. * This fits to the PBR convention in the GLTF definition:
  64938. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64939. */
  64940. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64941. /**
  64942. * Specifies the diffuse color of the material.
  64943. */
  64944. diffuseColor: Color3;
  64945. /**
  64946. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64947. * channel.
  64948. */
  64949. diffuseTexture: BaseTexture;
  64950. /**
  64951. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64952. */
  64953. specularColor: Color3;
  64954. /**
  64955. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64956. */
  64957. glossiness: number;
  64958. /**
  64959. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64960. */
  64961. specularGlossinessTexture: BaseTexture;
  64962. /**
  64963. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64964. *
  64965. * @param name The material name
  64966. * @param scene The scene the material will be use in.
  64967. */
  64968. constructor(name: string, scene: Scene);
  64969. /**
  64970. * Return the currrent class name of the material.
  64971. */
  64972. getClassName(): string;
  64973. /**
  64974. * Makes a duplicate of the current material.
  64975. * @param name - name to use for the new material.
  64976. */
  64977. clone(name: string): PBRSpecularGlossinessMaterial;
  64978. /**
  64979. * Serialize the material to a parsable JSON object.
  64980. */
  64981. serialize(): any;
  64982. /**
  64983. * Parses a JSON object correponding to the serialize function.
  64984. */
  64985. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64986. }
  64987. }
  64988. declare module "babylonjs/Materials/PBR/index" {
  64989. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64990. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64991. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64992. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64993. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64994. }
  64995. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64996. import { Nullable } from "babylonjs/types";
  64997. import { Scene } from "babylonjs/scene";
  64998. import { Matrix } from "babylonjs/Maths/math.vector";
  64999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65000. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65001. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65002. /**
  65003. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65004. * It can help converting any input color in a desired output one. This can then be used to create effects
  65005. * from sepia, black and white to sixties or futuristic rendering...
  65006. *
  65007. * The only supported format is currently 3dl.
  65008. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65009. */
  65010. export class ColorGradingTexture extends BaseTexture {
  65011. /**
  65012. * The texture URL.
  65013. */
  65014. url: string;
  65015. /**
  65016. * Empty line regex stored for GC.
  65017. */
  65018. private static _noneEmptyLineRegex;
  65019. private _textureMatrix;
  65020. private _onLoad;
  65021. /**
  65022. * Instantiates a ColorGradingTexture from the following parameters.
  65023. *
  65024. * @param url The location of the color gradind data (currently only supporting 3dl)
  65025. * @param sceneOrEngine The scene or engine the texture will be used in
  65026. * @param onLoad defines a callback triggered when the texture has been loaded
  65027. */
  65028. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65029. /**
  65030. * Fires the onload event from the constructor if requested.
  65031. */
  65032. private _triggerOnLoad;
  65033. /**
  65034. * Returns the texture matrix used in most of the material.
  65035. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65036. */
  65037. getTextureMatrix(): Matrix;
  65038. /**
  65039. * Occurs when the file being loaded is a .3dl LUT file.
  65040. */
  65041. private load3dlTexture;
  65042. /**
  65043. * Starts the loading process of the texture.
  65044. */
  65045. private loadTexture;
  65046. /**
  65047. * Clones the color gradind texture.
  65048. */
  65049. clone(): ColorGradingTexture;
  65050. /**
  65051. * Called during delayed load for textures.
  65052. */
  65053. delayLoad(): void;
  65054. /**
  65055. * Parses a color grading texture serialized by Babylon.
  65056. * @param parsedTexture The texture information being parsedTexture
  65057. * @param scene The scene to load the texture in
  65058. * @param rootUrl The root url of the data assets to load
  65059. * @return A color gradind texture
  65060. */
  65061. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65062. /**
  65063. * Serializes the LUT texture to json format.
  65064. */
  65065. serialize(): any;
  65066. }
  65067. }
  65068. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65070. import { Scene } from "babylonjs/scene";
  65071. import { Nullable } from "babylonjs/types";
  65072. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65073. /**
  65074. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65075. */
  65076. export class EquiRectangularCubeTexture extends BaseTexture {
  65077. /** The six faces of the cube. */
  65078. private static _FacesMapping;
  65079. private _noMipmap;
  65080. private _onLoad;
  65081. private _onError;
  65082. /** The size of the cubemap. */
  65083. private _size;
  65084. /** The buffer of the image. */
  65085. private _buffer;
  65086. /** The width of the input image. */
  65087. private _width;
  65088. /** The height of the input image. */
  65089. private _height;
  65090. /** The URL to the image. */
  65091. url: string;
  65092. /**
  65093. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65094. * @param url The location of the image
  65095. * @param scene The scene the texture will be used in
  65096. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65097. * @param noMipmap Forces to not generate the mipmap if true
  65098. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65099. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65100. * @param onLoad — defines a callback called when texture is loaded
  65101. * @param onError — defines a callback called if there is an error
  65102. */
  65103. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65104. /**
  65105. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65106. */
  65107. private loadImage;
  65108. /**
  65109. * Convert the image buffer into a cubemap and create a CubeTexture.
  65110. */
  65111. private loadTexture;
  65112. /**
  65113. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65114. * @param buffer The ArrayBuffer that should be converted.
  65115. * @returns The buffer as Float32Array.
  65116. */
  65117. private getFloat32ArrayFromArrayBuffer;
  65118. /**
  65119. * Get the current class name of the texture useful for serialization or dynamic coding.
  65120. * @returns "EquiRectangularCubeTexture"
  65121. */
  65122. getClassName(): string;
  65123. /**
  65124. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65125. * @returns A clone of the current EquiRectangularCubeTexture.
  65126. */
  65127. clone(): EquiRectangularCubeTexture;
  65128. }
  65129. }
  65130. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65131. import { Nullable } from "babylonjs/types";
  65132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65133. import { Matrix } from "babylonjs/Maths/math.vector";
  65134. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65135. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65136. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65137. import { Scene } from "babylonjs/scene";
  65138. /**
  65139. * Defines the options related to the creation of an HtmlElementTexture
  65140. */
  65141. export interface IHtmlElementTextureOptions {
  65142. /**
  65143. * Defines wether mip maps should be created or not.
  65144. */
  65145. generateMipMaps?: boolean;
  65146. /**
  65147. * Defines the sampling mode of the texture.
  65148. */
  65149. samplingMode?: number;
  65150. /**
  65151. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65152. */
  65153. engine: Nullable<ThinEngine>;
  65154. /**
  65155. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65156. */
  65157. scene: Nullable<Scene>;
  65158. }
  65159. /**
  65160. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65161. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65162. * is automatically managed.
  65163. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65164. * in your application.
  65165. *
  65166. * As the update is not automatic, you need to call them manually.
  65167. */
  65168. export class HtmlElementTexture extends BaseTexture {
  65169. /**
  65170. * The texture URL.
  65171. */
  65172. element: HTMLVideoElement | HTMLCanvasElement;
  65173. private static readonly DefaultOptions;
  65174. private _textureMatrix;
  65175. private _isVideo;
  65176. private _generateMipMaps;
  65177. private _samplingMode;
  65178. /**
  65179. * Instantiates a HtmlElementTexture from the following parameters.
  65180. *
  65181. * @param name Defines the name of the texture
  65182. * @param element Defines the video or canvas the texture is filled with
  65183. * @param options Defines the other none mandatory texture creation options
  65184. */
  65185. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65186. private _createInternalTexture;
  65187. /**
  65188. * Returns the texture matrix used in most of the material.
  65189. */
  65190. getTextureMatrix(): Matrix;
  65191. /**
  65192. * Updates the content of the texture.
  65193. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65194. */
  65195. update(invertY?: Nullable<boolean>): void;
  65196. }
  65197. }
  65198. declare module "babylonjs/Misc/tga" {
  65199. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65200. /**
  65201. * Based on jsTGALoader - Javascript loader for TGA file
  65202. * By Vincent Thibault
  65203. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65204. */
  65205. export class TGATools {
  65206. private static _TYPE_INDEXED;
  65207. private static _TYPE_RGB;
  65208. private static _TYPE_GREY;
  65209. private static _TYPE_RLE_INDEXED;
  65210. private static _TYPE_RLE_RGB;
  65211. private static _TYPE_RLE_GREY;
  65212. private static _ORIGIN_MASK;
  65213. private static _ORIGIN_SHIFT;
  65214. private static _ORIGIN_BL;
  65215. private static _ORIGIN_BR;
  65216. private static _ORIGIN_UL;
  65217. private static _ORIGIN_UR;
  65218. /**
  65219. * Gets the header of a TGA file
  65220. * @param data defines the TGA data
  65221. * @returns the header
  65222. */
  65223. static GetTGAHeader(data: Uint8Array): any;
  65224. /**
  65225. * Uploads TGA content to a Babylon Texture
  65226. * @hidden
  65227. */
  65228. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65229. /** @hidden */
  65230. 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;
  65231. /** @hidden */
  65232. 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;
  65233. /** @hidden */
  65234. 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;
  65235. /** @hidden */
  65236. 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;
  65237. /** @hidden */
  65238. 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;
  65239. /** @hidden */
  65240. 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;
  65241. }
  65242. }
  65243. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65244. import { Nullable } from "babylonjs/types";
  65245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65246. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65247. /**
  65248. * Implementation of the TGA Texture Loader.
  65249. * @hidden
  65250. */
  65251. export class _TGATextureLoader implements IInternalTextureLoader {
  65252. /**
  65253. * Defines wether the loader supports cascade loading the different faces.
  65254. */
  65255. readonly supportCascades: boolean;
  65256. /**
  65257. * This returns if the loader support the current file information.
  65258. * @param extension defines the file extension of the file being loaded
  65259. * @returns true if the loader can load the specified file
  65260. */
  65261. canLoad(extension: string): boolean;
  65262. /**
  65263. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65264. * @param data contains the texture data
  65265. * @param texture defines the BabylonJS internal texture
  65266. * @param createPolynomials will be true if polynomials have been requested
  65267. * @param onLoad defines the callback to trigger once the texture is ready
  65268. * @param onError defines the callback to trigger in case of error
  65269. */
  65270. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65271. /**
  65272. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65273. * @param data contains the texture data
  65274. * @param texture defines the BabylonJS internal texture
  65275. * @param callback defines the method to call once ready to upload
  65276. */
  65277. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65278. }
  65279. }
  65280. declare module "babylonjs/Misc/basis" {
  65281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65282. /**
  65283. * Info about the .basis files
  65284. */
  65285. class BasisFileInfo {
  65286. /**
  65287. * If the file has alpha
  65288. */
  65289. hasAlpha: boolean;
  65290. /**
  65291. * Info about each image of the basis file
  65292. */
  65293. images: Array<{
  65294. levels: Array<{
  65295. width: number;
  65296. height: number;
  65297. transcodedPixels: ArrayBufferView;
  65298. }>;
  65299. }>;
  65300. }
  65301. /**
  65302. * Result of transcoding a basis file
  65303. */
  65304. class TranscodeResult {
  65305. /**
  65306. * Info about the .basis file
  65307. */
  65308. fileInfo: BasisFileInfo;
  65309. /**
  65310. * Format to use when loading the file
  65311. */
  65312. format: number;
  65313. }
  65314. /**
  65315. * Configuration options for the Basis transcoder
  65316. */
  65317. export class BasisTranscodeConfiguration {
  65318. /**
  65319. * Supported compression formats used to determine the supported output format of the transcoder
  65320. */
  65321. supportedCompressionFormats?: {
  65322. /**
  65323. * etc1 compression format
  65324. */
  65325. etc1?: boolean;
  65326. /**
  65327. * s3tc compression format
  65328. */
  65329. s3tc?: boolean;
  65330. /**
  65331. * pvrtc compression format
  65332. */
  65333. pvrtc?: boolean;
  65334. /**
  65335. * etc2 compression format
  65336. */
  65337. etc2?: boolean;
  65338. };
  65339. /**
  65340. * If mipmap levels should be loaded for transcoded images (Default: true)
  65341. */
  65342. loadMipmapLevels?: boolean;
  65343. /**
  65344. * Index of a single image to load (Default: all images)
  65345. */
  65346. loadSingleImage?: number;
  65347. }
  65348. /**
  65349. * Used to load .Basis files
  65350. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65351. */
  65352. export class BasisTools {
  65353. private static _IgnoreSupportedFormats;
  65354. /**
  65355. * URL to use when loading the basis transcoder
  65356. */
  65357. static JSModuleURL: string;
  65358. /**
  65359. * URL to use when loading the wasm module for the transcoder
  65360. */
  65361. static WasmModuleURL: string;
  65362. /**
  65363. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65364. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65365. * @returns internal format corresponding to the Basis format
  65366. */
  65367. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65368. private static _WorkerPromise;
  65369. private static _Worker;
  65370. private static _actionId;
  65371. private static _CreateWorkerAsync;
  65372. /**
  65373. * Transcodes a loaded image file to compressed pixel data
  65374. * @param data image data to transcode
  65375. * @param config configuration options for the transcoding
  65376. * @returns a promise resulting in the transcoded image
  65377. */
  65378. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65379. /**
  65380. * Loads a texture from the transcode result
  65381. * @param texture texture load to
  65382. * @param transcodeResult the result of transcoding the basis file to load from
  65383. */
  65384. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65385. }
  65386. }
  65387. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65388. import { Nullable } from "babylonjs/types";
  65389. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65390. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65391. /**
  65392. * Loader for .basis file format
  65393. */
  65394. export class _BasisTextureLoader implements IInternalTextureLoader {
  65395. /**
  65396. * Defines whether the loader supports cascade loading the different faces.
  65397. */
  65398. readonly supportCascades: boolean;
  65399. /**
  65400. * This returns if the loader support the current file information.
  65401. * @param extension defines the file extension of the file being loaded
  65402. * @returns true if the loader can load the specified file
  65403. */
  65404. canLoad(extension: string): boolean;
  65405. /**
  65406. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65407. * @param data contains the texture data
  65408. * @param texture defines the BabylonJS internal texture
  65409. * @param createPolynomials will be true if polynomials have been requested
  65410. * @param onLoad defines the callback to trigger once the texture is ready
  65411. * @param onError defines the callback to trigger in case of error
  65412. */
  65413. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65414. /**
  65415. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65416. * @param data contains the texture data
  65417. * @param texture defines the BabylonJS internal texture
  65418. * @param callback defines the method to call once ready to upload
  65419. */
  65420. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65421. }
  65422. }
  65423. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65424. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65425. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65426. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65427. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65428. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65429. }
  65430. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65431. import { Vector2 } from "babylonjs/Maths/math.vector";
  65432. /**
  65433. * Defines the basic options interface of a TexturePacker Frame
  65434. */
  65435. export interface ITexturePackerFrame {
  65436. /**
  65437. * The frame ID
  65438. */
  65439. id: number;
  65440. /**
  65441. * The frames Scale
  65442. */
  65443. scale: Vector2;
  65444. /**
  65445. * The Frames offset
  65446. */
  65447. offset: Vector2;
  65448. }
  65449. /**
  65450. * This is a support class for frame Data on texture packer sets.
  65451. */
  65452. export class TexturePackerFrame implements ITexturePackerFrame {
  65453. /**
  65454. * The frame ID
  65455. */
  65456. id: number;
  65457. /**
  65458. * The frames Scale
  65459. */
  65460. scale: Vector2;
  65461. /**
  65462. * The Frames offset
  65463. */
  65464. offset: Vector2;
  65465. /**
  65466. * Initializes a texture package frame.
  65467. * @param id The numerical frame identifier
  65468. * @param scale Scalar Vector2 for UV frame
  65469. * @param offset Vector2 for the frame position in UV units.
  65470. * @returns TexturePackerFrame
  65471. */
  65472. constructor(id: number, scale: Vector2, offset: Vector2);
  65473. }
  65474. }
  65475. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65477. import { Scene } from "babylonjs/scene";
  65478. import { Nullable } from "babylonjs/types";
  65479. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65480. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65481. /**
  65482. * Defines the basic options interface of a TexturePacker
  65483. */
  65484. export interface ITexturePackerOptions {
  65485. /**
  65486. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65487. */
  65488. map?: string[];
  65489. /**
  65490. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65491. */
  65492. uvsIn?: string;
  65493. /**
  65494. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65495. */
  65496. uvsOut?: string;
  65497. /**
  65498. * number representing the layout style. Defaults to LAYOUT_STRIP
  65499. */
  65500. layout?: number;
  65501. /**
  65502. * number of columns if using custom column count layout(2). This defaults to 4.
  65503. */
  65504. colnum?: number;
  65505. /**
  65506. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65507. */
  65508. updateInputMeshes?: boolean;
  65509. /**
  65510. * boolean flag to dispose all the source textures. Defaults to true.
  65511. */
  65512. disposeSources?: boolean;
  65513. /**
  65514. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65515. */
  65516. fillBlanks?: boolean;
  65517. /**
  65518. * string value representing the context fill style color. Defaults to 'black'.
  65519. */
  65520. customFillColor?: string;
  65521. /**
  65522. * Width and Height Value of each Frame in the TexturePacker Sets
  65523. */
  65524. frameSize?: number;
  65525. /**
  65526. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65527. */
  65528. paddingRatio?: number;
  65529. /**
  65530. * Number that declares the fill method for the padding gutter.
  65531. */
  65532. paddingMode?: number;
  65533. /**
  65534. * If in SUBUV_COLOR padding mode what color to use.
  65535. */
  65536. paddingColor?: Color3 | Color4;
  65537. }
  65538. /**
  65539. * Defines the basic interface of a TexturePacker JSON File
  65540. */
  65541. export interface ITexturePackerJSON {
  65542. /**
  65543. * The frame ID
  65544. */
  65545. name: string;
  65546. /**
  65547. * The base64 channel data
  65548. */
  65549. sets: any;
  65550. /**
  65551. * The options of the Packer
  65552. */
  65553. options: ITexturePackerOptions;
  65554. /**
  65555. * The frame data of the Packer
  65556. */
  65557. frames: Array<number>;
  65558. }
  65559. /**
  65560. * This is a support class that generates a series of packed texture sets.
  65561. * @see https://doc.babylonjs.com/babylon101/materials
  65562. */
  65563. export class TexturePacker {
  65564. /** Packer Layout Constant 0 */
  65565. static readonly LAYOUT_STRIP: number;
  65566. /** Packer Layout Constant 1 */
  65567. static readonly LAYOUT_POWER2: number;
  65568. /** Packer Layout Constant 2 */
  65569. static readonly LAYOUT_COLNUM: number;
  65570. /** Packer Layout Constant 0 */
  65571. static readonly SUBUV_WRAP: number;
  65572. /** Packer Layout Constant 1 */
  65573. static readonly SUBUV_EXTEND: number;
  65574. /** Packer Layout Constant 2 */
  65575. static readonly SUBUV_COLOR: number;
  65576. /** The Name of the Texture Package */
  65577. name: string;
  65578. /** The scene scope of the TexturePacker */
  65579. scene: Scene;
  65580. /** The Meshes to target */
  65581. meshes: AbstractMesh[];
  65582. /** Arguments passed with the Constructor */
  65583. options: ITexturePackerOptions;
  65584. /** The promise that is started upon initialization */
  65585. promise: Nullable<Promise<TexturePacker | string>>;
  65586. /** The Container object for the channel sets that are generated */
  65587. sets: object;
  65588. /** The Container array for the frames that are generated */
  65589. frames: TexturePackerFrame[];
  65590. /** The expected number of textures the system is parsing. */
  65591. private _expecting;
  65592. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65593. private _paddingValue;
  65594. /**
  65595. * Initializes a texture package series from an array of meshes or a single mesh.
  65596. * @param name The name of the package
  65597. * @param meshes The target meshes to compose the package from
  65598. * @param options The arguments that texture packer should follow while building.
  65599. * @param scene The scene which the textures are scoped to.
  65600. * @returns TexturePacker
  65601. */
  65602. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65603. /**
  65604. * Starts the package process
  65605. * @param resolve The promises resolution function
  65606. * @returns TexturePacker
  65607. */
  65608. private _createFrames;
  65609. /**
  65610. * Calculates the Size of the Channel Sets
  65611. * @returns Vector2
  65612. */
  65613. private _calculateSize;
  65614. /**
  65615. * Calculates the UV data for the frames.
  65616. * @param baseSize the base frameSize
  65617. * @param padding the base frame padding
  65618. * @param dtSize size of the Dynamic Texture for that channel
  65619. * @param dtUnits is 1/dtSize
  65620. * @param update flag to update the input meshes
  65621. */
  65622. private _calculateMeshUVFrames;
  65623. /**
  65624. * Calculates the frames Offset.
  65625. * @param index of the frame
  65626. * @returns Vector2
  65627. */
  65628. private _getFrameOffset;
  65629. /**
  65630. * Updates a Mesh to the frame data
  65631. * @param mesh that is the target
  65632. * @param frameID or the frame index
  65633. */
  65634. private _updateMeshUV;
  65635. /**
  65636. * Updates a Meshes materials to use the texture packer channels
  65637. * @param m is the mesh to target
  65638. * @param force all channels on the packer to be set.
  65639. */
  65640. private _updateTextureReferences;
  65641. /**
  65642. * Public method to set a Mesh to a frame
  65643. * @param m that is the target
  65644. * @param frameID or the frame index
  65645. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65646. */
  65647. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65648. /**
  65649. * Starts the async promise to compile the texture packer.
  65650. * @returns Promise<void>
  65651. */
  65652. processAsync(): Promise<void>;
  65653. /**
  65654. * Disposes all textures associated with this packer
  65655. */
  65656. dispose(): void;
  65657. /**
  65658. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65659. * @param imageType is the image type to use.
  65660. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65661. */
  65662. download(imageType?: string, quality?: number): void;
  65663. /**
  65664. * Public method to load a texturePacker JSON file.
  65665. * @param data of the JSON file in string format.
  65666. */
  65667. updateFromJSON(data: string): void;
  65668. }
  65669. }
  65670. declare module "babylonjs/Materials/Textures/Packer/index" {
  65671. export * from "babylonjs/Materials/Textures/Packer/packer";
  65672. export * from "babylonjs/Materials/Textures/Packer/frame";
  65673. }
  65674. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65675. import { Scene } from "babylonjs/scene";
  65676. import { Texture } from "babylonjs/Materials/Textures/texture";
  65677. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65678. /**
  65679. * 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.
  65680. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65681. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65682. */
  65683. export class CustomProceduralTexture extends ProceduralTexture {
  65684. private _animate;
  65685. private _time;
  65686. private _config;
  65687. private _texturePath;
  65688. /**
  65689. * Instantiates a new Custom Procedural Texture.
  65690. * 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.
  65691. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65692. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65693. * @param name Define the name of the texture
  65694. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65695. * @param size Define the size of the texture to create
  65696. * @param scene Define the scene the texture belongs to
  65697. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65698. * @param generateMipMaps Define if the texture should creates mip maps or not
  65699. */
  65700. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65701. private _loadJson;
  65702. /**
  65703. * Is the texture ready to be used ? (rendered at least once)
  65704. * @returns true if ready, otherwise, false.
  65705. */
  65706. isReady(): boolean;
  65707. /**
  65708. * Render the texture to its associated render target.
  65709. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65710. */
  65711. render(useCameraPostProcess?: boolean): void;
  65712. /**
  65713. * Update the list of dependant textures samplers in the shader.
  65714. */
  65715. updateTextures(): void;
  65716. /**
  65717. * Update the uniform values of the procedural texture in the shader.
  65718. */
  65719. updateShaderUniforms(): void;
  65720. /**
  65721. * Define if the texture animates or not.
  65722. */
  65723. get animate(): boolean;
  65724. set animate(value: boolean);
  65725. }
  65726. }
  65727. declare module "babylonjs/Shaders/noise.fragment" {
  65728. /** @hidden */
  65729. export var noisePixelShader: {
  65730. name: string;
  65731. shader: string;
  65732. };
  65733. }
  65734. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65735. import { Nullable } from "babylonjs/types";
  65736. import { Scene } from "babylonjs/scene";
  65737. import { Texture } from "babylonjs/Materials/Textures/texture";
  65738. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65739. import "babylonjs/Shaders/noise.fragment";
  65740. /**
  65741. * Class used to generate noise procedural textures
  65742. */
  65743. export class NoiseProceduralTexture extends ProceduralTexture {
  65744. /** Gets or sets the start time (default is 0) */
  65745. time: number;
  65746. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65747. brightness: number;
  65748. /** Defines the number of octaves to process */
  65749. octaves: number;
  65750. /** Defines the level of persistence (0.8 by default) */
  65751. persistence: number;
  65752. /** Gets or sets animation speed factor (default is 1) */
  65753. animationSpeedFactor: number;
  65754. /**
  65755. * Creates a new NoiseProceduralTexture
  65756. * @param name defines the name fo the texture
  65757. * @param size defines the size of the texture (default is 256)
  65758. * @param scene defines the hosting scene
  65759. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65760. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65761. */
  65762. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65763. private _updateShaderUniforms;
  65764. protected _getDefines(): string;
  65765. /** Generate the current state of the procedural texture */
  65766. render(useCameraPostProcess?: boolean): void;
  65767. /**
  65768. * Serializes this noise procedural texture
  65769. * @returns a serialized noise procedural texture object
  65770. */
  65771. serialize(): any;
  65772. /**
  65773. * Clone the texture.
  65774. * @returns the cloned texture
  65775. */
  65776. clone(): NoiseProceduralTexture;
  65777. /**
  65778. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65779. * @param parsedTexture defines parsed texture data
  65780. * @param scene defines the current scene
  65781. * @param rootUrl defines the root URL containing noise procedural texture information
  65782. * @returns a parsed NoiseProceduralTexture
  65783. */
  65784. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65785. }
  65786. }
  65787. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65788. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65789. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65790. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65791. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65792. }
  65793. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65794. import { Nullable } from "babylonjs/types";
  65795. import { Scene } from "babylonjs/scene";
  65796. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65798. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65799. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65800. /**
  65801. * Raw cube texture where the raw buffers are passed in
  65802. */
  65803. export class RawCubeTexture extends CubeTexture {
  65804. /**
  65805. * Creates a cube texture where the raw buffers are passed in.
  65806. * @param scene defines the scene the texture is attached to
  65807. * @param data defines the array of data to use to create each face
  65808. * @param size defines the size of the textures
  65809. * @param format defines the format of the data
  65810. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65811. * @param generateMipMaps defines if the engine should generate the mip levels
  65812. * @param invertY defines if data must be stored with Y axis inverted
  65813. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65814. * @param compression defines the compression used (null by default)
  65815. */
  65816. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65817. /**
  65818. * Updates the raw cube texture.
  65819. * @param data defines the data to store
  65820. * @param format defines the data format
  65821. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65822. * @param invertY defines if data must be stored with Y axis inverted
  65823. * @param compression defines the compression used (null by default)
  65824. * @param level defines which level of the texture to update
  65825. */
  65826. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65827. /**
  65828. * Updates a raw cube texture with RGBD encoded data.
  65829. * @param data defines the array of data [mipmap][face] to use to create each face
  65830. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65833. * @returns a promsie that resolves when the operation is complete
  65834. */
  65835. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65836. /**
  65837. * Clones the raw cube texture.
  65838. * @return a new cube texture
  65839. */
  65840. clone(): CubeTexture;
  65841. /** @hidden */
  65842. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65843. }
  65844. }
  65845. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65846. import { Scene } from "babylonjs/scene";
  65847. import { Texture } from "babylonjs/Materials/Textures/texture";
  65848. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65849. /**
  65850. * Class used to store 2D array textures containing user data
  65851. */
  65852. export class RawTexture2DArray extends Texture {
  65853. /** Gets or sets the texture format to use */
  65854. format: number;
  65855. /**
  65856. * Create a new RawTexture2DArray
  65857. * @param data defines the data of the texture
  65858. * @param width defines the width of the texture
  65859. * @param height defines the height of the texture
  65860. * @param depth defines the number of layers of the texture
  65861. * @param format defines the texture format to use
  65862. * @param scene defines the hosting scene
  65863. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65864. * @param invertY defines if texture must be stored with Y axis inverted
  65865. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65866. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65867. */
  65868. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65869. /** Gets or sets the texture format to use */
  65870. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65871. /**
  65872. * Update the texture with new data
  65873. * @param data defines the data to store in the texture
  65874. */
  65875. update(data: ArrayBufferView): void;
  65876. }
  65877. }
  65878. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65879. import { Scene } from "babylonjs/scene";
  65880. import { Texture } from "babylonjs/Materials/Textures/texture";
  65881. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65882. /**
  65883. * Class used to store 3D textures containing user data
  65884. */
  65885. export class RawTexture3D extends Texture {
  65886. /** Gets or sets the texture format to use */
  65887. format: number;
  65888. /**
  65889. * Create a new RawTexture3D
  65890. * @param data defines the data of the texture
  65891. * @param width defines the width of the texture
  65892. * @param height defines the height of the texture
  65893. * @param depth defines the depth of the texture
  65894. * @param format defines the texture format to use
  65895. * @param scene defines the hosting scene
  65896. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65897. * @param invertY defines if texture must be stored with Y axis inverted
  65898. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65899. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65900. */
  65901. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65902. /** Gets or sets the texture format to use */
  65903. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65904. /**
  65905. * Update the texture with new data
  65906. * @param data defines the data to store in the texture
  65907. */
  65908. update(data: ArrayBufferView): void;
  65909. }
  65910. }
  65911. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65912. import { Scene } from "babylonjs/scene";
  65913. import { Plane } from "babylonjs/Maths/math.plane";
  65914. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65915. /**
  65916. * Creates a refraction texture used by refraction channel of the standard material.
  65917. * It is like a mirror but to see through a material.
  65918. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65919. */
  65920. export class RefractionTexture extends RenderTargetTexture {
  65921. /**
  65922. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65923. * 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.
  65924. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65925. */
  65926. refractionPlane: Plane;
  65927. /**
  65928. * Define how deep under the surface we should see.
  65929. */
  65930. depth: number;
  65931. /**
  65932. * Creates a refraction texture used by refraction channel of the standard material.
  65933. * It is like a mirror but to see through a material.
  65934. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65935. * @param name Define the texture name
  65936. * @param size Define the size of the underlying texture
  65937. * @param scene Define the scene the refraction belongs to
  65938. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65939. */
  65940. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65941. /**
  65942. * Clone the refraction texture.
  65943. * @returns the cloned texture
  65944. */
  65945. clone(): RefractionTexture;
  65946. /**
  65947. * Serialize the texture to a JSON representation you could use in Parse later on
  65948. * @returns the serialized JSON representation
  65949. */
  65950. serialize(): any;
  65951. }
  65952. }
  65953. declare module "babylonjs/Materials/Textures/index" {
  65954. export * from "babylonjs/Materials/Textures/baseTexture";
  65955. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65956. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65957. export * from "babylonjs/Materials/Textures/cubeTexture";
  65958. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65959. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65960. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65961. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65962. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65963. export * from "babylonjs/Materials/Textures/internalTexture";
  65964. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65965. export * from "babylonjs/Materials/Textures/Loaders/index";
  65966. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65967. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65968. export * from "babylonjs/Materials/Textures/Packer/index";
  65969. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65970. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65971. export * from "babylonjs/Materials/Textures/rawTexture";
  65972. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65973. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65974. export * from "babylonjs/Materials/Textures/refractionTexture";
  65975. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65976. export * from "babylonjs/Materials/Textures/texture";
  65977. export * from "babylonjs/Materials/Textures/videoTexture";
  65978. }
  65979. declare module "babylonjs/Materials/Node/Enums/index" {
  65980. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65981. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65982. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65983. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65984. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65985. }
  65986. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65990. import { Mesh } from "babylonjs/Meshes/mesh";
  65991. import { Effect } from "babylonjs/Materials/effect";
  65992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65993. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65995. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65996. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65997. /**
  65998. * Block used to add support for vertex skinning (bones)
  65999. */
  66000. export class BonesBlock extends NodeMaterialBlock {
  66001. /**
  66002. * Creates a new BonesBlock
  66003. * @param name defines the block name
  66004. */
  66005. constructor(name: string);
  66006. /**
  66007. * Initialize the block and prepare the context for build
  66008. * @param state defines the state that will be used for the build
  66009. */
  66010. initialize(state: NodeMaterialBuildState): void;
  66011. /**
  66012. * Gets the current class name
  66013. * @returns the class name
  66014. */
  66015. getClassName(): string;
  66016. /**
  66017. * Gets the matrix indices input component
  66018. */
  66019. get matricesIndices(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the matrix weights input component
  66022. */
  66023. get matricesWeights(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the extra matrix indices input component
  66026. */
  66027. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the extra matrix weights input component
  66030. */
  66031. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66032. /**
  66033. * Gets the world input component
  66034. */
  66035. get world(): NodeMaterialConnectionPoint;
  66036. /**
  66037. * Gets the output component
  66038. */
  66039. get output(): NodeMaterialConnectionPoint;
  66040. autoConfigure(material: NodeMaterial): void;
  66041. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66044. protected _buildBlock(state: NodeMaterialBuildState): this;
  66045. }
  66046. }
  66047. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66052. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66054. /**
  66055. * Block used to add support for instances
  66056. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66057. */
  66058. export class InstancesBlock extends NodeMaterialBlock {
  66059. /**
  66060. * Creates a new InstancesBlock
  66061. * @param name defines the block name
  66062. */
  66063. constructor(name: string);
  66064. /**
  66065. * Gets the current class name
  66066. * @returns the class name
  66067. */
  66068. getClassName(): string;
  66069. /**
  66070. * Gets the first world row input component
  66071. */
  66072. get world0(): NodeMaterialConnectionPoint;
  66073. /**
  66074. * Gets the second world row input component
  66075. */
  66076. get world1(): NodeMaterialConnectionPoint;
  66077. /**
  66078. * Gets the third world row input component
  66079. */
  66080. get world2(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the forth world row input component
  66083. */
  66084. get world3(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the world input component
  66087. */
  66088. get world(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the output component
  66091. */
  66092. get output(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the isntanceID component
  66095. */
  66096. get instanceID(): NodeMaterialConnectionPoint;
  66097. autoConfigure(material: NodeMaterial): void;
  66098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66099. protected _buildBlock(state: NodeMaterialBuildState): this;
  66100. }
  66101. }
  66102. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66107. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66108. import { Effect } from "babylonjs/Materials/effect";
  66109. import { Mesh } from "babylonjs/Meshes/mesh";
  66110. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66111. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66112. /**
  66113. * Block used to add morph targets support to vertex shader
  66114. */
  66115. export class MorphTargetsBlock extends NodeMaterialBlock {
  66116. private _repeatableContentAnchor;
  66117. /**
  66118. * Create a new MorphTargetsBlock
  66119. * @param name defines the block name
  66120. */
  66121. constructor(name: string);
  66122. /**
  66123. * Gets the current class name
  66124. * @returns the class name
  66125. */
  66126. getClassName(): string;
  66127. /**
  66128. * Gets the position input component
  66129. */
  66130. get position(): NodeMaterialConnectionPoint;
  66131. /**
  66132. * Gets the normal input component
  66133. */
  66134. get normal(): NodeMaterialConnectionPoint;
  66135. /**
  66136. * Gets the tangent input component
  66137. */
  66138. get tangent(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the tangent input component
  66141. */
  66142. get uv(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the position output component
  66145. */
  66146. get positionOutput(): NodeMaterialConnectionPoint;
  66147. /**
  66148. * Gets the normal output component
  66149. */
  66150. get normalOutput(): NodeMaterialConnectionPoint;
  66151. /**
  66152. * Gets the tangent output component
  66153. */
  66154. get tangentOutput(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the tangent output component
  66157. */
  66158. get uvOutput(): NodeMaterialConnectionPoint;
  66159. initialize(state: NodeMaterialBuildState): void;
  66160. autoConfigure(material: NodeMaterial): void;
  66161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66162. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66163. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66164. protected _buildBlock(state: NodeMaterialBuildState): this;
  66165. }
  66166. }
  66167. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66171. import { Nullable } from "babylonjs/types";
  66172. import { Scene } from "babylonjs/scene";
  66173. import { Effect } from "babylonjs/Materials/effect";
  66174. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66175. import { Mesh } from "babylonjs/Meshes/mesh";
  66176. import { Light } from "babylonjs/Lights/light";
  66177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66178. /**
  66179. * Block used to get data information from a light
  66180. */
  66181. export class LightInformationBlock extends NodeMaterialBlock {
  66182. private _lightDataUniformName;
  66183. private _lightColorUniformName;
  66184. private _lightTypeDefineName;
  66185. /**
  66186. * Gets or sets the light associated with this block
  66187. */
  66188. light: Nullable<Light>;
  66189. /**
  66190. * Creates a new LightInformationBlock
  66191. * @param name defines the block name
  66192. */
  66193. constructor(name: string);
  66194. /**
  66195. * Gets the current class name
  66196. * @returns the class name
  66197. */
  66198. getClassName(): string;
  66199. /**
  66200. * Gets the world position input component
  66201. */
  66202. get worldPosition(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the direction output component
  66205. */
  66206. get direction(): NodeMaterialConnectionPoint;
  66207. /**
  66208. * Gets the direction output component
  66209. */
  66210. get color(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the direction output component
  66213. */
  66214. get intensity(): NodeMaterialConnectionPoint;
  66215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66217. protected _buildBlock(state: NodeMaterialBuildState): this;
  66218. serialize(): any;
  66219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66220. }
  66221. }
  66222. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66223. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66224. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66225. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66226. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66227. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66228. }
  66229. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  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/helperFunctions";
  66238. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66239. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66240. /**
  66241. * Block used to add image processing support to fragment shader
  66242. */
  66243. export class ImageProcessingBlock extends NodeMaterialBlock {
  66244. /**
  66245. * Create a new ImageProcessingBlock
  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 color input component
  66256. */
  66257. get color(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the output component
  66260. */
  66261. get output(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Initialize the block and prepare the context for build
  66264. * @param state defines the state that will be used for the build
  66265. */
  66266. initialize(state: NodeMaterialBuildState): void;
  66267. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66270. protected _buildBlock(state: NodeMaterialBuildState): this;
  66271. }
  66272. }
  66273. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66277. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66279. import { Effect } from "babylonjs/Materials/effect";
  66280. import { Mesh } from "babylonjs/Meshes/mesh";
  66281. import { Scene } from "babylonjs/scene";
  66282. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66283. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66284. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66285. /**
  66286. * Block used to pertub normals based on a normal map
  66287. */
  66288. export class PerturbNormalBlock extends NodeMaterialBlock {
  66289. private _tangentSpaceParameterName;
  66290. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66291. invertX: boolean;
  66292. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66293. invertY: boolean;
  66294. /**
  66295. * Create a new PerturbNormalBlock
  66296. * @param name defines the block name
  66297. */
  66298. constructor(name: string);
  66299. /**
  66300. * Gets the current class name
  66301. * @returns the class name
  66302. */
  66303. getClassName(): string;
  66304. /**
  66305. * Gets the world position input component
  66306. */
  66307. get worldPosition(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the world normal input component
  66310. */
  66311. get worldNormal(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the world tangent input component
  66314. */
  66315. get worldTangent(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the uv input component
  66318. */
  66319. get uv(): NodeMaterialConnectionPoint;
  66320. /**
  66321. * Gets the normal map color input component
  66322. */
  66323. get normalMapColor(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the strength input component
  66326. */
  66327. get strength(): NodeMaterialConnectionPoint;
  66328. /**
  66329. * Gets the output component
  66330. */
  66331. get output(): NodeMaterialConnectionPoint;
  66332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66334. autoConfigure(material: NodeMaterial): void;
  66335. protected _buildBlock(state: NodeMaterialBuildState): this;
  66336. protected _dumpPropertiesCode(): string;
  66337. serialize(): any;
  66338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66339. }
  66340. }
  66341. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66345. /**
  66346. * Block used to discard a pixel if a value is smaller than a cutoff
  66347. */
  66348. export class DiscardBlock extends NodeMaterialBlock {
  66349. /**
  66350. * Create a new DiscardBlock
  66351. * @param name defines the block name
  66352. */
  66353. constructor(name: string);
  66354. /**
  66355. * Gets the current class name
  66356. * @returns the class name
  66357. */
  66358. getClassName(): string;
  66359. /**
  66360. * Gets the color input component
  66361. */
  66362. get value(): NodeMaterialConnectionPoint;
  66363. /**
  66364. * Gets the cutoff input component
  66365. */
  66366. get cutoff(): NodeMaterialConnectionPoint;
  66367. protected _buildBlock(state: NodeMaterialBuildState): this;
  66368. }
  66369. }
  66370. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66374. /**
  66375. * Block used to test if the fragment shader is front facing
  66376. */
  66377. export class FrontFacingBlock extends NodeMaterialBlock {
  66378. /**
  66379. * Creates a new FrontFacingBlock
  66380. * @param name defines the block name
  66381. */
  66382. constructor(name: string);
  66383. /**
  66384. * Gets the current class name
  66385. * @returns the class name
  66386. */
  66387. getClassName(): string;
  66388. /**
  66389. * Gets the output component
  66390. */
  66391. get output(): NodeMaterialConnectionPoint;
  66392. protected _buildBlock(state: NodeMaterialBuildState): this;
  66393. }
  66394. }
  66395. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66399. /**
  66400. * Block used to get the derivative value on x and y of a given input
  66401. */
  66402. export class DerivativeBlock extends NodeMaterialBlock {
  66403. /**
  66404. * Create a new DerivativeBlock
  66405. * @param name defines the block name
  66406. */
  66407. constructor(name: string);
  66408. /**
  66409. * Gets the current class name
  66410. * @returns the class name
  66411. */
  66412. getClassName(): string;
  66413. /**
  66414. * Gets the input component
  66415. */
  66416. get input(): NodeMaterialConnectionPoint;
  66417. /**
  66418. * Gets the derivative output on x
  66419. */
  66420. get dx(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the derivative output on y
  66423. */
  66424. get dy(): NodeMaterialConnectionPoint;
  66425. protected _buildBlock(state: NodeMaterialBuildState): this;
  66426. }
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66432. /**
  66433. * Block used to make gl_FragCoord available
  66434. */
  66435. export class FragCoordBlock extends NodeMaterialBlock {
  66436. /**
  66437. * Creates a new FragCoordBlock
  66438. * @param name defines the block name
  66439. */
  66440. constructor(name: string);
  66441. /**
  66442. * Gets the current class name
  66443. * @returns the class name
  66444. */
  66445. getClassName(): string;
  66446. /**
  66447. * Gets the xy component
  66448. */
  66449. get xy(): NodeMaterialConnectionPoint;
  66450. /**
  66451. * Gets the xyz component
  66452. */
  66453. get xyz(): NodeMaterialConnectionPoint;
  66454. /**
  66455. * Gets the xyzw component
  66456. */
  66457. get xyzw(): NodeMaterialConnectionPoint;
  66458. /**
  66459. * Gets the x component
  66460. */
  66461. get x(): NodeMaterialConnectionPoint;
  66462. /**
  66463. * Gets the y component
  66464. */
  66465. get y(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the z component
  66468. */
  66469. get z(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the w component
  66472. */
  66473. get output(): NodeMaterialConnectionPoint;
  66474. protected writeOutputs(state: NodeMaterialBuildState): string;
  66475. protected _buildBlock(state: NodeMaterialBuildState): this;
  66476. }
  66477. }
  66478. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66482. import { Effect } from "babylonjs/Materials/effect";
  66483. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66484. import { Mesh } from "babylonjs/Meshes/mesh";
  66485. /**
  66486. * Block used to get the screen sizes
  66487. */
  66488. export class ScreenSizeBlock extends NodeMaterialBlock {
  66489. private _varName;
  66490. private _scene;
  66491. /**
  66492. * Creates a new ScreenSizeBlock
  66493. * @param name defines the block name
  66494. */
  66495. constructor(name: string);
  66496. /**
  66497. * Gets the current class name
  66498. * @returns the class name
  66499. */
  66500. getClassName(): string;
  66501. /**
  66502. * Gets the xy component
  66503. */
  66504. get xy(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the x component
  66507. */
  66508. get x(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the y component
  66511. */
  66512. get y(): NodeMaterialConnectionPoint;
  66513. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66514. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66515. protected _buildBlock(state: NodeMaterialBuildState): this;
  66516. }
  66517. }
  66518. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66519. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66520. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66521. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66522. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66523. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66524. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66525. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66526. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66527. }
  66528. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66531. import { Mesh } from "babylonjs/Meshes/mesh";
  66532. import { Effect } from "babylonjs/Materials/effect";
  66533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66535. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66536. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66537. /**
  66538. * Block used to add support for scene fog
  66539. */
  66540. export class FogBlock extends NodeMaterialBlock {
  66541. private _fogDistanceName;
  66542. private _fogParameters;
  66543. /**
  66544. * Create a new FogBlock
  66545. * @param name defines the block name
  66546. */
  66547. constructor(name: string);
  66548. /**
  66549. * Gets the current class name
  66550. * @returns the class name
  66551. */
  66552. getClassName(): string;
  66553. /**
  66554. * Gets the world position input component
  66555. */
  66556. get worldPosition(): NodeMaterialConnectionPoint;
  66557. /**
  66558. * Gets the view input component
  66559. */
  66560. get view(): NodeMaterialConnectionPoint;
  66561. /**
  66562. * Gets the color input component
  66563. */
  66564. get input(): NodeMaterialConnectionPoint;
  66565. /**
  66566. * Gets the fog color input component
  66567. */
  66568. get fogColor(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the output component
  66571. */
  66572. get output(): NodeMaterialConnectionPoint;
  66573. autoConfigure(material: NodeMaterial): void;
  66574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66576. protected _buildBlock(state: NodeMaterialBuildState): this;
  66577. }
  66578. }
  66579. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66584. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66585. import { Effect } from "babylonjs/Materials/effect";
  66586. import { Mesh } from "babylonjs/Meshes/mesh";
  66587. import { Light } from "babylonjs/Lights/light";
  66588. import { Nullable } from "babylonjs/types";
  66589. import { Scene } from "babylonjs/scene";
  66590. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66591. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66592. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66594. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66595. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66596. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66597. /**
  66598. * Block used to add light in the fragment shader
  66599. */
  66600. export class LightBlock extends NodeMaterialBlock {
  66601. private _lightId;
  66602. /**
  66603. * Gets or sets the light associated with this block
  66604. */
  66605. light: Nullable<Light>;
  66606. /**
  66607. * Create a new LightBlock
  66608. * @param name defines the block name
  66609. */
  66610. constructor(name: string);
  66611. /**
  66612. * Gets the current class name
  66613. * @returns the class name
  66614. */
  66615. getClassName(): string;
  66616. /**
  66617. * Gets the world position input component
  66618. */
  66619. get worldPosition(): NodeMaterialConnectionPoint;
  66620. /**
  66621. * Gets the world normal input component
  66622. */
  66623. get worldNormal(): NodeMaterialConnectionPoint;
  66624. /**
  66625. * Gets the camera (or eye) position component
  66626. */
  66627. get cameraPosition(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the glossiness component
  66630. */
  66631. get glossiness(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the glossinness power component
  66634. */
  66635. get glossPower(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the diffuse color component
  66638. */
  66639. get diffuseColor(): NodeMaterialConnectionPoint;
  66640. /**
  66641. * Gets the specular color component
  66642. */
  66643. get specularColor(): NodeMaterialConnectionPoint;
  66644. /**
  66645. * Gets the diffuse output component
  66646. */
  66647. get diffuseOutput(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the specular output component
  66650. */
  66651. get specularOutput(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the shadow output component
  66654. */
  66655. get shadow(): NodeMaterialConnectionPoint;
  66656. autoConfigure(material: NodeMaterial): void;
  66657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66658. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66660. private _injectVertexCode;
  66661. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66662. serialize(): any;
  66663. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66664. }
  66665. }
  66666. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66669. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66670. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66671. /**
  66672. * Block used to read a reflection texture from a sampler
  66673. */
  66674. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66675. /**
  66676. * Create a new ReflectionTextureBlock
  66677. * @param name defines the block name
  66678. */
  66679. constructor(name: string);
  66680. /**
  66681. * Gets the current class name
  66682. * @returns the class name
  66683. */
  66684. getClassName(): string;
  66685. /**
  66686. * Gets the world position input component
  66687. */
  66688. get position(): NodeMaterialConnectionPoint;
  66689. /**
  66690. * Gets the world position input component
  66691. */
  66692. get worldPosition(): NodeMaterialConnectionPoint;
  66693. /**
  66694. * Gets the world normal input component
  66695. */
  66696. get worldNormal(): NodeMaterialConnectionPoint;
  66697. /**
  66698. * Gets the world input component
  66699. */
  66700. get world(): NodeMaterialConnectionPoint;
  66701. /**
  66702. * Gets the camera (or eye) position component
  66703. */
  66704. get cameraPosition(): NodeMaterialConnectionPoint;
  66705. /**
  66706. * Gets the view input component
  66707. */
  66708. get view(): NodeMaterialConnectionPoint;
  66709. /**
  66710. * Gets the rgb output component
  66711. */
  66712. get rgb(): NodeMaterialConnectionPoint;
  66713. /**
  66714. * Gets the rgba output component
  66715. */
  66716. get rgba(): NodeMaterialConnectionPoint;
  66717. /**
  66718. * Gets the r output component
  66719. */
  66720. get r(): NodeMaterialConnectionPoint;
  66721. /**
  66722. * Gets the g output component
  66723. */
  66724. get g(): NodeMaterialConnectionPoint;
  66725. /**
  66726. * Gets the b output component
  66727. */
  66728. get b(): NodeMaterialConnectionPoint;
  66729. /**
  66730. * Gets the a output component
  66731. */
  66732. get a(): NodeMaterialConnectionPoint;
  66733. autoConfigure(material: NodeMaterial): void;
  66734. protected _buildBlock(state: NodeMaterialBuildState): this;
  66735. }
  66736. }
  66737. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66738. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66739. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66740. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66741. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66742. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66743. }
  66744. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66745. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66746. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66747. }
  66748. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66752. /**
  66753. * Block used to add 2 vectors
  66754. */
  66755. export class AddBlock extends NodeMaterialBlock {
  66756. /**
  66757. * Creates a new AddBlock
  66758. * @param name defines the block name
  66759. */
  66760. constructor(name: string);
  66761. /**
  66762. * Gets the current class name
  66763. * @returns the class name
  66764. */
  66765. getClassName(): string;
  66766. /**
  66767. * Gets the left operand input component
  66768. */
  66769. get left(): NodeMaterialConnectionPoint;
  66770. /**
  66771. * Gets the right operand input component
  66772. */
  66773. get right(): NodeMaterialConnectionPoint;
  66774. /**
  66775. * Gets the output component
  66776. */
  66777. get output(): NodeMaterialConnectionPoint;
  66778. protected _buildBlock(state: NodeMaterialBuildState): this;
  66779. }
  66780. }
  66781. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66785. /**
  66786. * Block used to scale a vector by a float
  66787. */
  66788. export class ScaleBlock extends NodeMaterialBlock {
  66789. /**
  66790. * Creates a new ScaleBlock
  66791. * @param name defines the block name
  66792. */
  66793. constructor(name: string);
  66794. /**
  66795. * Gets the current class name
  66796. * @returns the class name
  66797. */
  66798. getClassName(): string;
  66799. /**
  66800. * Gets the input component
  66801. */
  66802. get input(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the factor input component
  66805. */
  66806. get factor(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the output component
  66809. */
  66810. get output(): NodeMaterialConnectionPoint;
  66811. protected _buildBlock(state: NodeMaterialBuildState): this;
  66812. }
  66813. }
  66814. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66818. import { Scene } from "babylonjs/scene";
  66819. /**
  66820. * Block used to clamp a float
  66821. */
  66822. export class ClampBlock extends NodeMaterialBlock {
  66823. /** Gets or sets the minimum range */
  66824. minimum: number;
  66825. /** Gets or sets the maximum range */
  66826. maximum: number;
  66827. /**
  66828. * Creates a new ClampBlock
  66829. * @param name defines the block name
  66830. */
  66831. constructor(name: string);
  66832. /**
  66833. * Gets the current class name
  66834. * @returns the class name
  66835. */
  66836. getClassName(): string;
  66837. /**
  66838. * Gets the value input component
  66839. */
  66840. get value(): NodeMaterialConnectionPoint;
  66841. /**
  66842. * Gets the output component
  66843. */
  66844. get output(): NodeMaterialConnectionPoint;
  66845. protected _buildBlock(state: NodeMaterialBuildState): this;
  66846. protected _dumpPropertiesCode(): string;
  66847. serialize(): any;
  66848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66849. }
  66850. }
  66851. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66855. /**
  66856. * Block used to apply a cross product between 2 vectors
  66857. */
  66858. export class CrossBlock extends NodeMaterialBlock {
  66859. /**
  66860. * Creates a new CrossBlock
  66861. * @param name defines the block name
  66862. */
  66863. constructor(name: string);
  66864. /**
  66865. * Gets the current class name
  66866. * @returns the class name
  66867. */
  66868. getClassName(): string;
  66869. /**
  66870. * Gets the left operand input component
  66871. */
  66872. get left(): NodeMaterialConnectionPoint;
  66873. /**
  66874. * Gets the right operand input component
  66875. */
  66876. get right(): NodeMaterialConnectionPoint;
  66877. /**
  66878. * Gets the output component
  66879. */
  66880. get output(): NodeMaterialConnectionPoint;
  66881. protected _buildBlock(state: NodeMaterialBuildState): this;
  66882. }
  66883. }
  66884. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66888. /**
  66889. * Block used to apply a dot product between 2 vectors
  66890. */
  66891. export class DotBlock extends NodeMaterialBlock {
  66892. /**
  66893. * Creates a new DotBlock
  66894. * @param name defines the block name
  66895. */
  66896. constructor(name: string);
  66897. /**
  66898. * Gets the current class name
  66899. * @returns the class name
  66900. */
  66901. getClassName(): string;
  66902. /**
  66903. * Gets the left operand input component
  66904. */
  66905. get left(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the right operand input component
  66908. */
  66909. get right(): NodeMaterialConnectionPoint;
  66910. /**
  66911. * Gets the output component
  66912. */
  66913. get output(): NodeMaterialConnectionPoint;
  66914. protected _buildBlock(state: NodeMaterialBuildState): this;
  66915. }
  66916. }
  66917. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66921. /**
  66922. * Block used to normalize a vector
  66923. */
  66924. export class NormalizeBlock extends NodeMaterialBlock {
  66925. /**
  66926. * Creates a new NormalizeBlock
  66927. * @param name defines the block name
  66928. */
  66929. constructor(name: string);
  66930. /**
  66931. * Gets the current class name
  66932. * @returns the class name
  66933. */
  66934. getClassName(): string;
  66935. /**
  66936. * Gets the input component
  66937. */
  66938. get input(): NodeMaterialConnectionPoint;
  66939. /**
  66940. * Gets the output component
  66941. */
  66942. get output(): NodeMaterialConnectionPoint;
  66943. protected _buildBlock(state: NodeMaterialBuildState): this;
  66944. }
  66945. }
  66946. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66950. /**
  66951. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66952. */
  66953. export class ColorMergerBlock extends NodeMaterialBlock {
  66954. /**
  66955. * Create a new ColorMergerBlock
  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 rgb component (input)
  66966. */
  66967. get rgbIn(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the r component (input)
  66970. */
  66971. get r(): NodeMaterialConnectionPoint;
  66972. /**
  66973. * Gets the g component (input)
  66974. */
  66975. get g(): NodeMaterialConnectionPoint;
  66976. /**
  66977. * Gets the b component (input)
  66978. */
  66979. get b(): NodeMaterialConnectionPoint;
  66980. /**
  66981. * Gets the a component (input)
  66982. */
  66983. get a(): NodeMaterialConnectionPoint;
  66984. /**
  66985. * Gets the rgba component (output)
  66986. */
  66987. get rgba(): NodeMaterialConnectionPoint;
  66988. /**
  66989. * Gets the rgb component (output)
  66990. */
  66991. get rgbOut(): NodeMaterialConnectionPoint;
  66992. /**
  66993. * Gets the rgb component (output)
  66994. * @deprecated Please use rgbOut instead.
  66995. */
  66996. get rgb(): NodeMaterialConnectionPoint;
  66997. protected _buildBlock(state: NodeMaterialBuildState): this;
  66998. }
  66999. }
  67000. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67004. /**
  67005. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67006. */
  67007. export class VectorSplitterBlock extends NodeMaterialBlock {
  67008. /**
  67009. * Create a new VectorSplitterBlock
  67010. * @param name defines the block name
  67011. */
  67012. constructor(name: string);
  67013. /**
  67014. * Gets the current class name
  67015. * @returns the class name
  67016. */
  67017. getClassName(): string;
  67018. /**
  67019. * Gets the xyzw component (input)
  67020. */
  67021. get xyzw(): NodeMaterialConnectionPoint;
  67022. /**
  67023. * Gets the xyz component (input)
  67024. */
  67025. get xyzIn(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the xy component (input)
  67028. */
  67029. get xyIn(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the xyz component (output)
  67032. */
  67033. get xyzOut(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the xy component (output)
  67036. */
  67037. get xyOut(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the x component (output)
  67040. */
  67041. get x(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the y component (output)
  67044. */
  67045. get y(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the z component (output)
  67048. */
  67049. get z(): NodeMaterialConnectionPoint;
  67050. /**
  67051. * Gets the w component (output)
  67052. */
  67053. get w(): NodeMaterialConnectionPoint;
  67054. protected _inputRename(name: string): string;
  67055. protected _outputRename(name: string): string;
  67056. protected _buildBlock(state: NodeMaterialBuildState): this;
  67057. }
  67058. }
  67059. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67063. /**
  67064. * Block used to lerp between 2 values
  67065. */
  67066. export class LerpBlock extends NodeMaterialBlock {
  67067. /**
  67068. * Creates a new LerpBlock
  67069. * @param name defines the block name
  67070. */
  67071. constructor(name: string);
  67072. /**
  67073. * Gets the current class name
  67074. * @returns the class name
  67075. */
  67076. getClassName(): string;
  67077. /**
  67078. * Gets the left operand input component
  67079. */
  67080. get left(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the right operand input component
  67083. */
  67084. get right(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the gradient operand input component
  67087. */
  67088. get gradient(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the output component
  67091. */
  67092. get output(): NodeMaterialConnectionPoint;
  67093. protected _buildBlock(state: NodeMaterialBuildState): this;
  67094. }
  67095. }
  67096. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67100. /**
  67101. * Block used to divide 2 vectors
  67102. */
  67103. export class DivideBlock extends NodeMaterialBlock {
  67104. /**
  67105. * Creates a new DivideBlock
  67106. * @param name defines the block name
  67107. */
  67108. constructor(name: string);
  67109. /**
  67110. * Gets the current class name
  67111. * @returns the class name
  67112. */
  67113. getClassName(): string;
  67114. /**
  67115. * Gets the left operand input component
  67116. */
  67117. get left(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the right operand input component
  67120. */
  67121. get right(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the output component
  67124. */
  67125. get output(): NodeMaterialConnectionPoint;
  67126. protected _buildBlock(state: NodeMaterialBuildState): this;
  67127. }
  67128. }
  67129. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67133. /**
  67134. * Block used to subtract 2 vectors
  67135. */
  67136. export class SubtractBlock extends NodeMaterialBlock {
  67137. /**
  67138. * Creates a new SubtractBlock
  67139. * @param name defines the block name
  67140. */
  67141. constructor(name: string);
  67142. /**
  67143. * Gets the current class name
  67144. * @returns the class name
  67145. */
  67146. getClassName(): string;
  67147. /**
  67148. * Gets the left operand input component
  67149. */
  67150. get left(): NodeMaterialConnectionPoint;
  67151. /**
  67152. * Gets the right operand input component
  67153. */
  67154. get right(): NodeMaterialConnectionPoint;
  67155. /**
  67156. * Gets the output component
  67157. */
  67158. get output(): NodeMaterialConnectionPoint;
  67159. protected _buildBlock(state: NodeMaterialBuildState): this;
  67160. }
  67161. }
  67162. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67166. /**
  67167. * Block used to step a value
  67168. */
  67169. export class StepBlock extends NodeMaterialBlock {
  67170. /**
  67171. * Creates a new StepBlock
  67172. * @param name defines the block name
  67173. */
  67174. constructor(name: string);
  67175. /**
  67176. * Gets the current class name
  67177. * @returns the class name
  67178. */
  67179. getClassName(): string;
  67180. /**
  67181. * Gets the value operand input component
  67182. */
  67183. get value(): NodeMaterialConnectionPoint;
  67184. /**
  67185. * Gets the edge operand input component
  67186. */
  67187. get edge(): NodeMaterialConnectionPoint;
  67188. /**
  67189. * Gets the output component
  67190. */
  67191. get output(): NodeMaterialConnectionPoint;
  67192. protected _buildBlock(state: NodeMaterialBuildState): this;
  67193. }
  67194. }
  67195. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67199. /**
  67200. * Block used to get the opposite (1 - x) of a value
  67201. */
  67202. export class OneMinusBlock extends NodeMaterialBlock {
  67203. /**
  67204. * Creates a new OneMinusBlock
  67205. * @param name defines the block name
  67206. */
  67207. constructor(name: string);
  67208. /**
  67209. * Gets the current class name
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Gets the input component
  67215. */
  67216. get input(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the output component
  67219. */
  67220. get output(): NodeMaterialConnectionPoint;
  67221. protected _buildBlock(state: NodeMaterialBuildState): this;
  67222. }
  67223. }
  67224. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67228. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67229. /**
  67230. * Block used to get the view direction
  67231. */
  67232. export class ViewDirectionBlock extends NodeMaterialBlock {
  67233. /**
  67234. * Creates a new ViewDirectionBlock
  67235. * @param name defines the block name
  67236. */
  67237. constructor(name: string);
  67238. /**
  67239. * Gets the current class name
  67240. * @returns the class name
  67241. */
  67242. getClassName(): string;
  67243. /**
  67244. * Gets the world position component
  67245. */
  67246. get worldPosition(): NodeMaterialConnectionPoint;
  67247. /**
  67248. * Gets the camera position component
  67249. */
  67250. get cameraPosition(): NodeMaterialConnectionPoint;
  67251. /**
  67252. * Gets the output component
  67253. */
  67254. get output(): NodeMaterialConnectionPoint;
  67255. autoConfigure(material: NodeMaterial): void;
  67256. protected _buildBlock(state: NodeMaterialBuildState): this;
  67257. }
  67258. }
  67259. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67263. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67264. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67265. /**
  67266. * Block used to compute fresnel value
  67267. */
  67268. export class FresnelBlock extends NodeMaterialBlock {
  67269. /**
  67270. * Create a new FresnelBlock
  67271. * @param name defines the block name
  67272. */
  67273. constructor(name: string);
  67274. /**
  67275. * Gets the current class name
  67276. * @returns the class name
  67277. */
  67278. getClassName(): string;
  67279. /**
  67280. * Gets the world normal input component
  67281. */
  67282. get worldNormal(): NodeMaterialConnectionPoint;
  67283. /**
  67284. * Gets the view direction input component
  67285. */
  67286. get viewDirection(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the bias input component
  67289. */
  67290. get bias(): NodeMaterialConnectionPoint;
  67291. /**
  67292. * Gets the camera (or eye) position component
  67293. */
  67294. get power(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the fresnel output component
  67297. */
  67298. get fresnel(): NodeMaterialConnectionPoint;
  67299. autoConfigure(material: NodeMaterial): void;
  67300. protected _buildBlock(state: NodeMaterialBuildState): this;
  67301. }
  67302. }
  67303. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67307. /**
  67308. * Block used to get the max of 2 values
  67309. */
  67310. export class MaxBlock extends NodeMaterialBlock {
  67311. /**
  67312. * Creates a new MaxBlock
  67313. * @param name defines the block name
  67314. */
  67315. constructor(name: string);
  67316. /**
  67317. * Gets the current class name
  67318. * @returns the class name
  67319. */
  67320. getClassName(): string;
  67321. /**
  67322. * Gets the left operand input component
  67323. */
  67324. get left(): NodeMaterialConnectionPoint;
  67325. /**
  67326. * Gets the right operand input component
  67327. */
  67328. get right(): NodeMaterialConnectionPoint;
  67329. /**
  67330. * Gets the output component
  67331. */
  67332. get output(): NodeMaterialConnectionPoint;
  67333. protected _buildBlock(state: NodeMaterialBuildState): this;
  67334. }
  67335. }
  67336. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67340. /**
  67341. * Block used to get the min of 2 values
  67342. */
  67343. export class MinBlock extends NodeMaterialBlock {
  67344. /**
  67345. * Creates a new MinBlock
  67346. * @param name defines the block name
  67347. */
  67348. constructor(name: string);
  67349. /**
  67350. * Gets the current class name
  67351. * @returns the class name
  67352. */
  67353. getClassName(): string;
  67354. /**
  67355. * Gets the left operand input component
  67356. */
  67357. get left(): NodeMaterialConnectionPoint;
  67358. /**
  67359. * Gets the right operand input component
  67360. */
  67361. get right(): NodeMaterialConnectionPoint;
  67362. /**
  67363. * Gets the output component
  67364. */
  67365. get output(): NodeMaterialConnectionPoint;
  67366. protected _buildBlock(state: NodeMaterialBuildState): this;
  67367. }
  67368. }
  67369. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67373. /**
  67374. * Block used to get the distance between 2 values
  67375. */
  67376. export class DistanceBlock extends NodeMaterialBlock {
  67377. /**
  67378. * Creates a new DistanceBlock
  67379. * @param name defines the block name
  67380. */
  67381. constructor(name: string);
  67382. /**
  67383. * Gets the current class name
  67384. * @returns the class name
  67385. */
  67386. getClassName(): string;
  67387. /**
  67388. * Gets the left operand input component
  67389. */
  67390. get left(): NodeMaterialConnectionPoint;
  67391. /**
  67392. * Gets the right operand input component
  67393. */
  67394. get right(): NodeMaterialConnectionPoint;
  67395. /**
  67396. * Gets the output component
  67397. */
  67398. get output(): NodeMaterialConnectionPoint;
  67399. protected _buildBlock(state: NodeMaterialBuildState): this;
  67400. }
  67401. }
  67402. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67406. /**
  67407. * Block used to get the length of a vector
  67408. */
  67409. export class LengthBlock extends NodeMaterialBlock {
  67410. /**
  67411. * Creates a new LengthBlock
  67412. * @param name defines the block name
  67413. */
  67414. constructor(name: string);
  67415. /**
  67416. * Gets the current class name
  67417. * @returns the class name
  67418. */
  67419. getClassName(): string;
  67420. /**
  67421. * Gets the value input component
  67422. */
  67423. get value(): NodeMaterialConnectionPoint;
  67424. /**
  67425. * Gets the output component
  67426. */
  67427. get output(): NodeMaterialConnectionPoint;
  67428. protected _buildBlock(state: NodeMaterialBuildState): this;
  67429. }
  67430. }
  67431. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67435. /**
  67436. * Block used to get negative version of a value (i.e. x * -1)
  67437. */
  67438. export class NegateBlock extends NodeMaterialBlock {
  67439. /**
  67440. * Creates a new NegateBlock
  67441. * @param name defines the block name
  67442. */
  67443. constructor(name: string);
  67444. /**
  67445. * Gets the current class name
  67446. * @returns the class name
  67447. */
  67448. getClassName(): string;
  67449. /**
  67450. * Gets the value input component
  67451. */
  67452. get value(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the output component
  67455. */
  67456. get output(): NodeMaterialConnectionPoint;
  67457. protected _buildBlock(state: NodeMaterialBuildState): this;
  67458. }
  67459. }
  67460. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67464. /**
  67465. * Block used to get the value of the first parameter raised to the power of the second
  67466. */
  67467. export class PowBlock extends NodeMaterialBlock {
  67468. /**
  67469. * Creates a new PowBlock
  67470. * @param name defines the block name
  67471. */
  67472. constructor(name: string);
  67473. /**
  67474. * Gets the current class name
  67475. * @returns the class name
  67476. */
  67477. getClassName(): string;
  67478. /**
  67479. * Gets the value operand input component
  67480. */
  67481. get value(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the power operand input component
  67484. */
  67485. get power(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the output component
  67488. */
  67489. get output(): NodeMaterialConnectionPoint;
  67490. protected _buildBlock(state: NodeMaterialBuildState): this;
  67491. }
  67492. }
  67493. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67498. /**
  67499. * Block used to get a random number
  67500. */
  67501. export class RandomNumberBlock extends NodeMaterialBlock {
  67502. /**
  67503. * Creates a new RandomNumberBlock
  67504. * @param name defines the block name
  67505. */
  67506. constructor(name: string);
  67507. /**
  67508. * Gets the current class name
  67509. * @returns the class name
  67510. */
  67511. getClassName(): string;
  67512. /**
  67513. * Gets the seed input component
  67514. */
  67515. get seed(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the output component
  67518. */
  67519. get output(): NodeMaterialConnectionPoint;
  67520. protected _buildBlock(state: NodeMaterialBuildState): this;
  67521. }
  67522. }
  67523. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67527. /**
  67528. * Block used to compute arc tangent of 2 values
  67529. */
  67530. export class ArcTan2Block extends NodeMaterialBlock {
  67531. /**
  67532. * Creates a new ArcTan2Block
  67533. * @param name defines the block name
  67534. */
  67535. constructor(name: string);
  67536. /**
  67537. * Gets the current class name
  67538. * @returns the class name
  67539. */
  67540. getClassName(): string;
  67541. /**
  67542. * Gets the x operand input component
  67543. */
  67544. get x(): NodeMaterialConnectionPoint;
  67545. /**
  67546. * Gets the y operand input component
  67547. */
  67548. get y(): NodeMaterialConnectionPoint;
  67549. /**
  67550. * Gets the output component
  67551. */
  67552. get output(): NodeMaterialConnectionPoint;
  67553. protected _buildBlock(state: NodeMaterialBuildState): this;
  67554. }
  67555. }
  67556. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67560. /**
  67561. * Block used to smooth step a value
  67562. */
  67563. export class SmoothStepBlock extends NodeMaterialBlock {
  67564. /**
  67565. * Creates a new SmoothStepBlock
  67566. * @param name defines the block name
  67567. */
  67568. constructor(name: string);
  67569. /**
  67570. * Gets the current class name
  67571. * @returns the class name
  67572. */
  67573. getClassName(): string;
  67574. /**
  67575. * Gets the value operand input component
  67576. */
  67577. get value(): NodeMaterialConnectionPoint;
  67578. /**
  67579. * Gets the first edge operand input component
  67580. */
  67581. get edge0(): NodeMaterialConnectionPoint;
  67582. /**
  67583. * Gets the second edge operand input component
  67584. */
  67585. get edge1(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the output component
  67588. */
  67589. get output(): NodeMaterialConnectionPoint;
  67590. protected _buildBlock(state: NodeMaterialBuildState): this;
  67591. }
  67592. }
  67593. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67597. /**
  67598. * Block used to get the reciprocal (1 / x) of a value
  67599. */
  67600. export class ReciprocalBlock extends NodeMaterialBlock {
  67601. /**
  67602. * Creates a new ReciprocalBlock
  67603. * @param name defines the block name
  67604. */
  67605. constructor(name: string);
  67606. /**
  67607. * Gets the current class name
  67608. * @returns the class name
  67609. */
  67610. getClassName(): string;
  67611. /**
  67612. * Gets the input component
  67613. */
  67614. get input(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the output component
  67617. */
  67618. get output(): NodeMaterialConnectionPoint;
  67619. protected _buildBlock(state: NodeMaterialBuildState): this;
  67620. }
  67621. }
  67622. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67626. /**
  67627. * Block used to replace a color by another one
  67628. */
  67629. export class ReplaceColorBlock extends NodeMaterialBlock {
  67630. /**
  67631. * Creates a new ReplaceColorBlock
  67632. * @param name defines the block name
  67633. */
  67634. constructor(name: string);
  67635. /**
  67636. * Gets the current class name
  67637. * @returns the class name
  67638. */
  67639. getClassName(): string;
  67640. /**
  67641. * Gets the value input component
  67642. */
  67643. get value(): NodeMaterialConnectionPoint;
  67644. /**
  67645. * Gets the reference input component
  67646. */
  67647. get reference(): NodeMaterialConnectionPoint;
  67648. /**
  67649. * Gets the distance input component
  67650. */
  67651. get distance(): NodeMaterialConnectionPoint;
  67652. /**
  67653. * Gets the replacement input component
  67654. */
  67655. get replacement(): NodeMaterialConnectionPoint;
  67656. /**
  67657. * Gets the output component
  67658. */
  67659. get output(): NodeMaterialConnectionPoint;
  67660. protected _buildBlock(state: NodeMaterialBuildState): this;
  67661. }
  67662. }
  67663. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67667. /**
  67668. * Block used to posterize a value
  67669. * @see https://en.wikipedia.org/wiki/Posterization
  67670. */
  67671. export class PosterizeBlock extends NodeMaterialBlock {
  67672. /**
  67673. * Creates a new PosterizeBlock
  67674. * @param name defines the block name
  67675. */
  67676. constructor(name: string);
  67677. /**
  67678. * Gets the current class name
  67679. * @returns the class name
  67680. */
  67681. getClassName(): string;
  67682. /**
  67683. * Gets the value input component
  67684. */
  67685. get value(): NodeMaterialConnectionPoint;
  67686. /**
  67687. * Gets the steps input component
  67688. */
  67689. get steps(): NodeMaterialConnectionPoint;
  67690. /**
  67691. * Gets the output component
  67692. */
  67693. get output(): NodeMaterialConnectionPoint;
  67694. protected _buildBlock(state: NodeMaterialBuildState): this;
  67695. }
  67696. }
  67697. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67701. import { Scene } from "babylonjs/scene";
  67702. /**
  67703. * Operations supported by the Wave block
  67704. */
  67705. export enum WaveBlockKind {
  67706. /** SawTooth */
  67707. SawTooth = 0,
  67708. /** Square */
  67709. Square = 1,
  67710. /** Triangle */
  67711. Triangle = 2
  67712. }
  67713. /**
  67714. * Block used to apply wave operation to floats
  67715. */
  67716. export class WaveBlock extends NodeMaterialBlock {
  67717. /**
  67718. * Gets or sets the kibnd of wave to be applied by the block
  67719. */
  67720. kind: WaveBlockKind;
  67721. /**
  67722. * Creates a new WaveBlock
  67723. * @param name defines the block name
  67724. */
  67725. constructor(name: string);
  67726. /**
  67727. * Gets the current class name
  67728. * @returns the class name
  67729. */
  67730. getClassName(): string;
  67731. /**
  67732. * Gets the input component
  67733. */
  67734. get input(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the output component
  67737. */
  67738. get output(): NodeMaterialConnectionPoint;
  67739. protected _buildBlock(state: NodeMaterialBuildState): this;
  67740. serialize(): any;
  67741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67742. }
  67743. }
  67744. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67748. import { Color3 } from "babylonjs/Maths/math.color";
  67749. import { Scene } from "babylonjs/scene";
  67750. import { Observable } from "babylonjs/Misc/observable";
  67751. /**
  67752. * Class used to store a color step for the GradientBlock
  67753. */
  67754. export class GradientBlockColorStep {
  67755. private _step;
  67756. /**
  67757. * Gets value indicating which step this color is associated with (between 0 and 1)
  67758. */
  67759. get step(): number;
  67760. /**
  67761. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67762. */
  67763. set step(val: number);
  67764. private _color;
  67765. /**
  67766. * Gets the color associated with this step
  67767. */
  67768. get color(): Color3;
  67769. /**
  67770. * Sets the color associated with this step
  67771. */
  67772. set color(val: Color3);
  67773. /**
  67774. * Creates a new GradientBlockColorStep
  67775. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67776. * @param color defines the color associated with this step
  67777. */
  67778. constructor(step: number, color: Color3);
  67779. }
  67780. /**
  67781. * Block used to return a color from a gradient based on an input value between 0 and 1
  67782. */
  67783. export class GradientBlock extends NodeMaterialBlock {
  67784. /**
  67785. * Gets or sets the list of color steps
  67786. */
  67787. colorSteps: GradientBlockColorStep[];
  67788. /** Gets an observable raised when the value is changed */
  67789. onValueChangedObservable: Observable<GradientBlock>;
  67790. /** calls observable when the value is changed*/
  67791. colorStepsUpdated(): void;
  67792. /**
  67793. * Creates a new GradientBlock
  67794. * @param name defines the block name
  67795. */
  67796. constructor(name: string);
  67797. /**
  67798. * Gets the current class name
  67799. * @returns the class name
  67800. */
  67801. getClassName(): string;
  67802. /**
  67803. * Gets the gradient input component
  67804. */
  67805. get gradient(): NodeMaterialConnectionPoint;
  67806. /**
  67807. * Gets the output component
  67808. */
  67809. get output(): NodeMaterialConnectionPoint;
  67810. private _writeColorConstant;
  67811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67812. serialize(): any;
  67813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67814. protected _dumpPropertiesCode(): string;
  67815. }
  67816. }
  67817. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67821. /**
  67822. * Block used to normalize lerp between 2 values
  67823. */
  67824. export class NLerpBlock extends NodeMaterialBlock {
  67825. /**
  67826. * Creates a new NLerpBlock
  67827. * @param name defines the block name
  67828. */
  67829. constructor(name: string);
  67830. /**
  67831. * Gets the current class name
  67832. * @returns the class name
  67833. */
  67834. getClassName(): string;
  67835. /**
  67836. * Gets the left operand input component
  67837. */
  67838. get left(): NodeMaterialConnectionPoint;
  67839. /**
  67840. * Gets the right operand input component
  67841. */
  67842. get right(): NodeMaterialConnectionPoint;
  67843. /**
  67844. * Gets the gradient operand input component
  67845. */
  67846. get gradient(): NodeMaterialConnectionPoint;
  67847. /**
  67848. * Gets the output component
  67849. */
  67850. get output(): NodeMaterialConnectionPoint;
  67851. protected _buildBlock(state: NodeMaterialBuildState): this;
  67852. }
  67853. }
  67854. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67858. import { Scene } from "babylonjs/scene";
  67859. /**
  67860. * block used to Generate a Worley Noise 3D Noise Pattern
  67861. */
  67862. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67863. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67864. manhattanDistance: boolean;
  67865. /**
  67866. * Creates a new WorleyNoise3DBlock
  67867. * @param name defines the block name
  67868. */
  67869. constructor(name: string);
  67870. /**
  67871. * Gets the current class name
  67872. * @returns the class name
  67873. */
  67874. getClassName(): string;
  67875. /**
  67876. * Gets the seed input component
  67877. */
  67878. get seed(): NodeMaterialConnectionPoint;
  67879. /**
  67880. * Gets the jitter input component
  67881. */
  67882. get jitter(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the output component
  67885. */
  67886. get output(): NodeMaterialConnectionPoint;
  67887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67888. /**
  67889. * Exposes the properties to the UI?
  67890. */
  67891. protected _dumpPropertiesCode(): string;
  67892. /**
  67893. * Exposes the properties to the Seralize?
  67894. */
  67895. serialize(): any;
  67896. /**
  67897. * Exposes the properties to the deseralize?
  67898. */
  67899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67900. }
  67901. }
  67902. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67906. /**
  67907. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67908. */
  67909. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67910. /**
  67911. * Creates a new SimplexPerlin3DBlock
  67912. * @param name defines the block name
  67913. */
  67914. constructor(name: string);
  67915. /**
  67916. * Gets the current class name
  67917. * @returns the class name
  67918. */
  67919. getClassName(): string;
  67920. /**
  67921. * Gets the seed operand input component
  67922. */
  67923. get seed(): NodeMaterialConnectionPoint;
  67924. /**
  67925. * Gets the output component
  67926. */
  67927. get output(): NodeMaterialConnectionPoint;
  67928. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67929. }
  67930. }
  67931. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67935. /**
  67936. * Block used to blend normals
  67937. */
  67938. export class NormalBlendBlock extends NodeMaterialBlock {
  67939. /**
  67940. * Creates a new NormalBlendBlock
  67941. * @param name defines the block name
  67942. */
  67943. constructor(name: string);
  67944. /**
  67945. * Gets the current class name
  67946. * @returns the class name
  67947. */
  67948. getClassName(): string;
  67949. /**
  67950. * Gets the first input component
  67951. */
  67952. get normalMap0(): NodeMaterialConnectionPoint;
  67953. /**
  67954. * Gets the second input component
  67955. */
  67956. get normalMap1(): NodeMaterialConnectionPoint;
  67957. /**
  67958. * Gets the output component
  67959. */
  67960. get output(): NodeMaterialConnectionPoint;
  67961. protected _buildBlock(state: NodeMaterialBuildState): this;
  67962. }
  67963. }
  67964. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67968. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67969. /**
  67970. * Block used to rotate a 2d vector by a given angle
  67971. */
  67972. export class Rotate2dBlock extends NodeMaterialBlock {
  67973. /**
  67974. * Creates a new Rotate2dBlock
  67975. * @param name defines the block name
  67976. */
  67977. constructor(name: string);
  67978. /**
  67979. * Gets the current class name
  67980. * @returns the class name
  67981. */
  67982. getClassName(): string;
  67983. /**
  67984. * Gets the input vector
  67985. */
  67986. get input(): NodeMaterialConnectionPoint;
  67987. /**
  67988. * Gets the input angle
  67989. */
  67990. get angle(): NodeMaterialConnectionPoint;
  67991. /**
  67992. * Gets the output component
  67993. */
  67994. get output(): NodeMaterialConnectionPoint;
  67995. autoConfigure(material: NodeMaterial): void;
  67996. protected _buildBlock(state: NodeMaterialBuildState): this;
  67997. }
  67998. }
  67999. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68003. /**
  68004. * Block used to get the reflected vector from a direction and a normal
  68005. */
  68006. export class ReflectBlock extends NodeMaterialBlock {
  68007. /**
  68008. * Creates a new ReflectBlock
  68009. * @param name defines the block name
  68010. */
  68011. constructor(name: string);
  68012. /**
  68013. * Gets the current class name
  68014. * @returns the class name
  68015. */
  68016. getClassName(): string;
  68017. /**
  68018. * Gets the incident component
  68019. */
  68020. get incident(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the normal component
  68023. */
  68024. get normal(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the output component
  68027. */
  68028. get output(): NodeMaterialConnectionPoint;
  68029. protected _buildBlock(state: NodeMaterialBuildState): this;
  68030. }
  68031. }
  68032. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68036. /**
  68037. * Block used to get the refracted vector from a direction and a normal
  68038. */
  68039. export class RefractBlock extends NodeMaterialBlock {
  68040. /**
  68041. * Creates a new RefractBlock
  68042. * @param name defines the block name
  68043. */
  68044. constructor(name: string);
  68045. /**
  68046. * Gets the current class name
  68047. * @returns the class name
  68048. */
  68049. getClassName(): string;
  68050. /**
  68051. * Gets the incident component
  68052. */
  68053. get incident(): NodeMaterialConnectionPoint;
  68054. /**
  68055. * Gets the normal component
  68056. */
  68057. get normal(): NodeMaterialConnectionPoint;
  68058. /**
  68059. * Gets the index of refraction component
  68060. */
  68061. get ior(): NodeMaterialConnectionPoint;
  68062. /**
  68063. * Gets the output component
  68064. */
  68065. get output(): NodeMaterialConnectionPoint;
  68066. protected _buildBlock(state: NodeMaterialBuildState): this;
  68067. }
  68068. }
  68069. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68073. /**
  68074. * Block used to desaturate a color
  68075. */
  68076. export class DesaturateBlock extends NodeMaterialBlock {
  68077. /**
  68078. * Creates a new DesaturateBlock
  68079. * @param name defines the block name
  68080. */
  68081. constructor(name: string);
  68082. /**
  68083. * Gets the current class name
  68084. * @returns the class name
  68085. */
  68086. getClassName(): string;
  68087. /**
  68088. * Gets the color operand input component
  68089. */
  68090. get color(): NodeMaterialConnectionPoint;
  68091. /**
  68092. * Gets the level operand input component
  68093. */
  68094. get level(): NodeMaterialConnectionPoint;
  68095. /**
  68096. * Gets the output component
  68097. */
  68098. get output(): NodeMaterialConnectionPoint;
  68099. protected _buildBlock(state: NodeMaterialBuildState): this;
  68100. }
  68101. }
  68102. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68106. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68107. import { Nullable } from "babylonjs/types";
  68108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68109. import { Scene } from "babylonjs/scene";
  68110. /**
  68111. * Block used to implement the ambient occlusion module of the PBR material
  68112. */
  68113. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68114. /**
  68115. * Create a new AmbientOcclusionBlock
  68116. * @param name defines the block name
  68117. */
  68118. constructor(name: string);
  68119. /**
  68120. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68121. */
  68122. useAmbientInGrayScale: boolean;
  68123. /**
  68124. * Initialize the block and prepare the context for build
  68125. * @param state defines the state that will be used for the build
  68126. */
  68127. initialize(state: NodeMaterialBuildState): void;
  68128. /**
  68129. * Gets the current class name
  68130. * @returns the class name
  68131. */
  68132. getClassName(): string;
  68133. /**
  68134. * Gets the texture input component
  68135. */
  68136. get texture(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the texture intensity component
  68139. */
  68140. get intensity(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the direct light intensity input component
  68143. */
  68144. get directLightIntensity(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the ambient occlusion object output component
  68147. */
  68148. get ambientOcc(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the main code of the block (fragment side)
  68151. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68152. * @returns the shader code
  68153. */
  68154. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68156. protected _buildBlock(state: NodeMaterialBuildState): this;
  68157. protected _dumpPropertiesCode(): string;
  68158. serialize(): any;
  68159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68160. }
  68161. }
  68162. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68166. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68168. import { Nullable } from "babylonjs/types";
  68169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68170. import { Mesh } from "babylonjs/Meshes/mesh";
  68171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68172. import { Effect } from "babylonjs/Materials/effect";
  68173. import { Scene } from "babylonjs/scene";
  68174. /**
  68175. * Block used to implement the reflection module of the PBR material
  68176. */
  68177. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68178. /** @hidden */
  68179. _defineLODReflectionAlpha: string;
  68180. /** @hidden */
  68181. _defineLinearSpecularReflection: string;
  68182. private _vEnvironmentIrradianceName;
  68183. /** @hidden */
  68184. _vReflectionMicrosurfaceInfosName: string;
  68185. /** @hidden */
  68186. _vReflectionInfosName: string;
  68187. /** @hidden */
  68188. _vReflectionFilteringInfoName: string;
  68189. private _scene;
  68190. /**
  68191. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68192. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68193. * It's less burden on the user side in the editor part.
  68194. */
  68195. /** @hidden */
  68196. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68197. /** @hidden */
  68198. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68199. /** @hidden */
  68200. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68201. /**
  68202. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68203. * diffuse part of the IBL.
  68204. */
  68205. useSphericalHarmonics: boolean;
  68206. /**
  68207. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68208. */
  68209. forceIrradianceInFragment: boolean;
  68210. /**
  68211. * Create a new ReflectionBlock
  68212. * @param name defines the block name
  68213. */
  68214. constructor(name: string);
  68215. /**
  68216. * Gets the current class name
  68217. * @returns the class name
  68218. */
  68219. getClassName(): string;
  68220. /**
  68221. * Gets the position input component
  68222. */
  68223. get position(): NodeMaterialConnectionPoint;
  68224. /**
  68225. * Gets the world position input component
  68226. */
  68227. get worldPosition(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the world normal input component
  68230. */
  68231. get worldNormal(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the world input component
  68234. */
  68235. get world(): NodeMaterialConnectionPoint;
  68236. /**
  68237. * Gets the camera (or eye) position component
  68238. */
  68239. get cameraPosition(): NodeMaterialConnectionPoint;
  68240. /**
  68241. * Gets the view input component
  68242. */
  68243. get view(): NodeMaterialConnectionPoint;
  68244. /**
  68245. * Gets the color input component
  68246. */
  68247. get color(): NodeMaterialConnectionPoint;
  68248. /**
  68249. * Gets the reflection object output component
  68250. */
  68251. get reflection(): NodeMaterialConnectionPoint;
  68252. /**
  68253. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68254. */
  68255. get hasTexture(): boolean;
  68256. /**
  68257. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68258. */
  68259. get reflectionColor(): string;
  68260. protected _getTexture(): Nullable<BaseTexture>;
  68261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68262. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68263. /**
  68264. * Gets the code to inject in the vertex shader
  68265. * @param state current state of the node material building
  68266. * @returns the shader code
  68267. */
  68268. handleVertexSide(state: NodeMaterialBuildState): string;
  68269. /**
  68270. * Gets the main code of the block (fragment side)
  68271. * @param state current state of the node material building
  68272. * @param normalVarName name of the existing variable corresponding to the normal
  68273. * @returns the shader code
  68274. */
  68275. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68276. protected _buildBlock(state: NodeMaterialBuildState): this;
  68277. protected _dumpPropertiesCode(): string;
  68278. serialize(): any;
  68279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68280. }
  68281. }
  68282. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68286. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68288. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68289. import { Scene } from "babylonjs/scene";
  68290. import { Nullable } from "babylonjs/types";
  68291. /**
  68292. * Block used to implement the sheen module of the PBR material
  68293. */
  68294. export class SheenBlock extends NodeMaterialBlock {
  68295. /**
  68296. * Create a new SheenBlock
  68297. * @param name defines the block name
  68298. */
  68299. constructor(name: string);
  68300. /**
  68301. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68302. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68303. * making it easier to setup and tweak the effect
  68304. */
  68305. albedoScaling: boolean;
  68306. /**
  68307. * Defines if the sheen is linked to the sheen color.
  68308. */
  68309. linkSheenWithAlbedo: boolean;
  68310. /**
  68311. * Initialize the block and prepare the context for build
  68312. * @param state defines the state that will be used for the build
  68313. */
  68314. initialize(state: NodeMaterialBuildState): void;
  68315. /**
  68316. * Gets the current class name
  68317. * @returns the class name
  68318. */
  68319. getClassName(): string;
  68320. /**
  68321. * Gets the intensity input component
  68322. */
  68323. get intensity(): NodeMaterialConnectionPoint;
  68324. /**
  68325. * Gets the color input component
  68326. */
  68327. get color(): NodeMaterialConnectionPoint;
  68328. /**
  68329. * Gets the roughness input component
  68330. */
  68331. get roughness(): NodeMaterialConnectionPoint;
  68332. /**
  68333. * Gets the sheen object output component
  68334. */
  68335. get sheen(): NodeMaterialConnectionPoint;
  68336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68337. /**
  68338. * Gets the main code of the block (fragment side)
  68339. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68340. * @returns the shader code
  68341. */
  68342. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68343. protected _buildBlock(state: NodeMaterialBuildState): this;
  68344. protected _dumpPropertiesCode(): string;
  68345. serialize(): any;
  68346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68347. }
  68348. }
  68349. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68350. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68355. import { Scene } from "babylonjs/scene";
  68356. import { Nullable } from "babylonjs/types";
  68357. import { Mesh } from "babylonjs/Meshes/mesh";
  68358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68359. import { Effect } from "babylonjs/Materials/effect";
  68360. /**
  68361. * Block used to implement the reflectivity module of the PBR material
  68362. */
  68363. export class ReflectivityBlock extends NodeMaterialBlock {
  68364. private _metallicReflectanceColor;
  68365. private _metallicF0Factor;
  68366. /** @hidden */
  68367. _vMetallicReflectanceFactorsName: string;
  68368. /**
  68369. * The property below is set by the main PBR block prior to calling methods of this class.
  68370. */
  68371. /** @hidden */
  68372. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68373. /**
  68374. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68375. */
  68376. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68377. /**
  68378. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68379. */
  68380. useMetallnessFromMetallicTextureBlue: boolean;
  68381. /**
  68382. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68383. */
  68384. useRoughnessFromMetallicTextureAlpha: boolean;
  68385. /**
  68386. * Specifies if the metallic texture contains the roughness information in its green channel.
  68387. */
  68388. useRoughnessFromMetallicTextureGreen: boolean;
  68389. /**
  68390. * Create a new ReflectivityBlock
  68391. * @param name defines the block name
  68392. */
  68393. constructor(name: string);
  68394. /**
  68395. * Initialize the block and prepare the context for build
  68396. * @param state defines the state that will be used for the build
  68397. */
  68398. initialize(state: NodeMaterialBuildState): void;
  68399. /**
  68400. * Gets the current class name
  68401. * @returns the class name
  68402. */
  68403. getClassName(): string;
  68404. /**
  68405. * Gets the metallic input component
  68406. */
  68407. get metallic(): NodeMaterialConnectionPoint;
  68408. /**
  68409. * Gets the roughness input component
  68410. */
  68411. get roughness(): NodeMaterialConnectionPoint;
  68412. /**
  68413. * Gets the texture input component
  68414. */
  68415. get texture(): NodeMaterialConnectionPoint;
  68416. /**
  68417. * Gets the reflectivity object output component
  68418. */
  68419. get reflectivity(): NodeMaterialConnectionPoint;
  68420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68421. /**
  68422. * Gets the main code of the block (fragment side)
  68423. * @param state current state of the node material building
  68424. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68425. * @returns the shader code
  68426. */
  68427. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68429. protected _buildBlock(state: NodeMaterialBuildState): this;
  68430. protected _dumpPropertiesCode(): string;
  68431. serialize(): any;
  68432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68433. }
  68434. }
  68435. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68436. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68441. /**
  68442. * Block used to implement the anisotropy module of the PBR material
  68443. */
  68444. export class AnisotropyBlock extends NodeMaterialBlock {
  68445. /**
  68446. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68447. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68448. * It's less burden on the user side in the editor part.
  68449. */
  68450. /** @hidden */
  68451. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68452. /** @hidden */
  68453. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68454. /**
  68455. * Create a new AnisotropyBlock
  68456. * @param name defines the block name
  68457. */
  68458. constructor(name: string);
  68459. /**
  68460. * Initialize the block and prepare the context for build
  68461. * @param state defines the state that will be used for the build
  68462. */
  68463. initialize(state: NodeMaterialBuildState): void;
  68464. /**
  68465. * Gets the current class name
  68466. * @returns the class name
  68467. */
  68468. getClassName(): string;
  68469. /**
  68470. * Gets the intensity input component
  68471. */
  68472. get intensity(): NodeMaterialConnectionPoint;
  68473. /**
  68474. * Gets the direction input component
  68475. */
  68476. get direction(): NodeMaterialConnectionPoint;
  68477. /**
  68478. * Gets the texture input component
  68479. */
  68480. get texture(): NodeMaterialConnectionPoint;
  68481. /**
  68482. * Gets the uv input component
  68483. */
  68484. get uv(): NodeMaterialConnectionPoint;
  68485. /**
  68486. * Gets the worldTangent input component
  68487. */
  68488. get worldTangent(): NodeMaterialConnectionPoint;
  68489. /**
  68490. * Gets the anisotropy object output component
  68491. */
  68492. get anisotropy(): NodeMaterialConnectionPoint;
  68493. private _generateTBNSpace;
  68494. /**
  68495. * Gets the main code of the block (fragment side)
  68496. * @param state current state of the node material building
  68497. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68498. * @returns the shader code
  68499. */
  68500. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68502. protected _buildBlock(state: NodeMaterialBuildState): this;
  68503. }
  68504. }
  68505. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68509. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68511. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68512. import { Nullable } from "babylonjs/types";
  68513. import { Mesh } from "babylonjs/Meshes/mesh";
  68514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68515. import { Effect } from "babylonjs/Materials/effect";
  68516. /**
  68517. * Block used to implement the clear coat module of the PBR material
  68518. */
  68519. export class ClearCoatBlock extends NodeMaterialBlock {
  68520. private _scene;
  68521. /**
  68522. * Create a new ClearCoatBlock
  68523. * @param name defines the block name
  68524. */
  68525. constructor(name: string);
  68526. /**
  68527. * Initialize the block and prepare the context for build
  68528. * @param state defines the state that will be used for the build
  68529. */
  68530. initialize(state: NodeMaterialBuildState): void;
  68531. /**
  68532. * Gets the current class name
  68533. * @returns the class name
  68534. */
  68535. getClassName(): string;
  68536. /**
  68537. * Gets the intensity input component
  68538. */
  68539. get intensity(): NodeMaterialConnectionPoint;
  68540. /**
  68541. * Gets the roughness input component
  68542. */
  68543. get roughness(): NodeMaterialConnectionPoint;
  68544. /**
  68545. * Gets the ior input component
  68546. */
  68547. get ior(): NodeMaterialConnectionPoint;
  68548. /**
  68549. * Gets the texture input component
  68550. */
  68551. get texture(): NodeMaterialConnectionPoint;
  68552. /**
  68553. * Gets the bump texture input component
  68554. */
  68555. get bumpTexture(): NodeMaterialConnectionPoint;
  68556. /**
  68557. * Gets the uv input component
  68558. */
  68559. get uv(): NodeMaterialConnectionPoint;
  68560. /**
  68561. * Gets the tint color input component
  68562. */
  68563. get tintColor(): NodeMaterialConnectionPoint;
  68564. /**
  68565. * Gets the tint "at distance" input component
  68566. */
  68567. get tintAtDistance(): NodeMaterialConnectionPoint;
  68568. /**
  68569. * Gets the tint thickness input component
  68570. */
  68571. get tintThickness(): NodeMaterialConnectionPoint;
  68572. /**
  68573. * Gets the world tangent input component
  68574. */
  68575. get worldTangent(): NodeMaterialConnectionPoint;
  68576. /**
  68577. * Gets the clear coat object output component
  68578. */
  68579. get clearcoat(): NodeMaterialConnectionPoint;
  68580. autoConfigure(material: NodeMaterial): void;
  68581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68583. private _generateTBNSpace;
  68584. /**
  68585. * Gets the main code of the block (fragment side)
  68586. * @param state current state of the node material building
  68587. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68588. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68589. * @param worldPosVarName name of the variable holding the world position
  68590. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68591. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68592. * @param worldNormalVarName name of the variable holding the world normal
  68593. * @returns the shader code
  68594. */
  68595. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68596. protected _buildBlock(state: NodeMaterialBuildState): this;
  68597. }
  68598. }
  68599. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68603. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68605. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68606. import { Nullable } from "babylonjs/types";
  68607. /**
  68608. * Block used to implement the sub surface module of the PBR material
  68609. */
  68610. export class SubSurfaceBlock extends NodeMaterialBlock {
  68611. /**
  68612. * Create a new SubSurfaceBlock
  68613. * @param name defines the block name
  68614. */
  68615. constructor(name: string);
  68616. /**
  68617. * Stores the intensity of the different subsurface effects in the thickness texture.
  68618. * * the green channel is the translucency intensity.
  68619. * * the blue channel is the scattering intensity.
  68620. * * the alpha channel is the refraction intensity.
  68621. */
  68622. useMaskFromThicknessTexture: boolean;
  68623. /**
  68624. * Initialize the block and prepare the context for build
  68625. * @param state defines the state that will be used for the build
  68626. */
  68627. initialize(state: NodeMaterialBuildState): void;
  68628. /**
  68629. * Gets the current class name
  68630. * @returns the class name
  68631. */
  68632. getClassName(): string;
  68633. /**
  68634. * Gets the min thickness input component
  68635. */
  68636. get minThickness(): NodeMaterialConnectionPoint;
  68637. /**
  68638. * Gets the max thickness input component
  68639. */
  68640. get maxThickness(): NodeMaterialConnectionPoint;
  68641. /**
  68642. * Gets the thickness texture component
  68643. */
  68644. get thicknessTexture(): NodeMaterialConnectionPoint;
  68645. /**
  68646. * Gets the tint color input component
  68647. */
  68648. get tintColor(): NodeMaterialConnectionPoint;
  68649. /**
  68650. * Gets the translucency intensity input component
  68651. */
  68652. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68653. /**
  68654. * Gets the translucency diffusion distance input component
  68655. */
  68656. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68657. /**
  68658. * Gets the refraction object parameters
  68659. */
  68660. get refraction(): NodeMaterialConnectionPoint;
  68661. /**
  68662. * Gets the sub surface object output component
  68663. */
  68664. get subsurface(): NodeMaterialConnectionPoint;
  68665. autoConfigure(material: NodeMaterial): void;
  68666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68667. /**
  68668. * Gets the main code of the block (fragment side)
  68669. * @param state current state of the node material building
  68670. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68671. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68672. * @param worldPosVarName name of the variable holding the world position
  68673. * @returns the shader code
  68674. */
  68675. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68676. protected _buildBlock(state: NodeMaterialBuildState): this;
  68677. }
  68678. }
  68679. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68684. import { Light } from "babylonjs/Lights/light";
  68685. import { Nullable } from "babylonjs/types";
  68686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68687. import { Effect } from "babylonjs/Materials/effect";
  68688. import { Mesh } from "babylonjs/Meshes/mesh";
  68689. import { Scene } from "babylonjs/scene";
  68690. /**
  68691. * Block used to implement the PBR metallic/roughness model
  68692. */
  68693. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68694. /**
  68695. * Gets or sets the light associated with this block
  68696. */
  68697. light: Nullable<Light>;
  68698. private _lightId;
  68699. private _scene;
  68700. private _environmentBRDFTexture;
  68701. private _environmentBrdfSamplerName;
  68702. private _vNormalWName;
  68703. private _invertNormalName;
  68704. /**
  68705. * Create a new ReflectionBlock
  68706. * @param name defines the block name
  68707. */
  68708. constructor(name: string);
  68709. /**
  68710. * Intensity of the direct lights e.g. the four lights available in your scene.
  68711. * This impacts both the direct diffuse and specular highlights.
  68712. */
  68713. directIntensity: number;
  68714. /**
  68715. * Intensity of the environment e.g. how much the environment will light the object
  68716. * either through harmonics for rough material or through the refelction for shiny ones.
  68717. */
  68718. environmentIntensity: number;
  68719. /**
  68720. * This is a special control allowing the reduction of the specular highlights coming from the
  68721. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68722. */
  68723. specularIntensity: number;
  68724. /**
  68725. * Defines the falloff type used in this material.
  68726. * It by default is Physical.
  68727. */
  68728. lightFalloff: number;
  68729. /**
  68730. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68731. */
  68732. useAlphaFromAlbedoTexture: boolean;
  68733. /**
  68734. * Specifies that alpha test should be used
  68735. */
  68736. useAlphaTest: boolean;
  68737. /**
  68738. * Defines the alpha limits in alpha test mode.
  68739. */
  68740. alphaTestCutoff: number;
  68741. /**
  68742. * Specifies that alpha blending should be used
  68743. */
  68744. useAlphaBlending: boolean;
  68745. /**
  68746. * Defines if the alpha value should be determined via the rgb values.
  68747. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68748. */
  68749. opacityRGB: boolean;
  68750. /**
  68751. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68752. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68753. */
  68754. useRadianceOverAlpha: boolean;
  68755. /**
  68756. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68757. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68758. */
  68759. useSpecularOverAlpha: boolean;
  68760. /**
  68761. * Enables specular anti aliasing in the PBR shader.
  68762. * It will both interacts on the Geometry for analytical and IBL lighting.
  68763. * It also prefilter the roughness map based on the bump values.
  68764. */
  68765. enableSpecularAntiAliasing: boolean;
  68766. /**
  68767. * Enables realtime filtering on the texture.
  68768. */
  68769. realTimeFiltering: boolean;
  68770. /**
  68771. * Quality switch for realtime filtering
  68772. */
  68773. realTimeFilteringQuality: number;
  68774. /**
  68775. * Defines if the material uses energy conservation.
  68776. */
  68777. useEnergyConservation: boolean;
  68778. /**
  68779. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68780. * too much the area relying on ambient texture to define their ambient occlusion.
  68781. */
  68782. useRadianceOcclusion: boolean;
  68783. /**
  68784. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68785. * makes the reflect vector face the model (under horizon).
  68786. */
  68787. useHorizonOcclusion: boolean;
  68788. /**
  68789. * If set to true, no lighting calculations will be applied.
  68790. */
  68791. unlit: boolean;
  68792. /**
  68793. * Force normal to face away from face.
  68794. */
  68795. forceNormalForward: boolean;
  68796. /**
  68797. * Defines the material debug mode.
  68798. * It helps seeing only some components of the material while troubleshooting.
  68799. */
  68800. debugMode: number;
  68801. /**
  68802. * Specify from where on screen the debug mode should start.
  68803. * The value goes from -1 (full screen) to 1 (not visible)
  68804. * It helps with side by side comparison against the final render
  68805. * This defaults to 0
  68806. */
  68807. debugLimit: number;
  68808. /**
  68809. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68810. * You can use the factor to better multiply the final value.
  68811. */
  68812. debugFactor: number;
  68813. /**
  68814. * Initialize the block and prepare the context for build
  68815. * @param state defines the state that will be used for the build
  68816. */
  68817. initialize(state: NodeMaterialBuildState): void;
  68818. /**
  68819. * Gets the current class name
  68820. * @returns the class name
  68821. */
  68822. getClassName(): string;
  68823. /**
  68824. * Gets the world position input component
  68825. */
  68826. get worldPosition(): NodeMaterialConnectionPoint;
  68827. /**
  68828. * Gets the world normal input component
  68829. */
  68830. get worldNormal(): NodeMaterialConnectionPoint;
  68831. /**
  68832. * Gets the perturbed normal input component
  68833. */
  68834. get perturbedNormal(): NodeMaterialConnectionPoint;
  68835. /**
  68836. * Gets the camera position input component
  68837. */
  68838. get cameraPosition(): NodeMaterialConnectionPoint;
  68839. /**
  68840. * Gets the base color input component
  68841. */
  68842. get baseColor(): NodeMaterialConnectionPoint;
  68843. /**
  68844. * Gets the opacity texture input component
  68845. */
  68846. get opacityTexture(): NodeMaterialConnectionPoint;
  68847. /**
  68848. * Gets the ambient color input component
  68849. */
  68850. get ambientColor(): NodeMaterialConnectionPoint;
  68851. /**
  68852. * Gets the reflectivity object parameters
  68853. */
  68854. get reflectivity(): NodeMaterialConnectionPoint;
  68855. /**
  68856. * Gets the ambient occlusion object parameters
  68857. */
  68858. get ambientOcc(): NodeMaterialConnectionPoint;
  68859. /**
  68860. * Gets the reflection object parameters
  68861. */
  68862. get reflection(): NodeMaterialConnectionPoint;
  68863. /**
  68864. * Gets the sheen object parameters
  68865. */
  68866. get sheen(): NodeMaterialConnectionPoint;
  68867. /**
  68868. * Gets the clear coat object parameters
  68869. */
  68870. get clearcoat(): NodeMaterialConnectionPoint;
  68871. /**
  68872. * Gets the sub surface object parameters
  68873. */
  68874. get subsurface(): NodeMaterialConnectionPoint;
  68875. /**
  68876. * Gets the anisotropy object parameters
  68877. */
  68878. get anisotropy(): NodeMaterialConnectionPoint;
  68879. /**
  68880. * Gets the ambient output component
  68881. */
  68882. get ambient(): NodeMaterialConnectionPoint;
  68883. /**
  68884. * Gets the diffuse output component
  68885. */
  68886. get diffuse(): NodeMaterialConnectionPoint;
  68887. /**
  68888. * Gets the specular output component
  68889. */
  68890. get specular(): NodeMaterialConnectionPoint;
  68891. /**
  68892. * Gets the sheen output component
  68893. */
  68894. get sheenDir(): NodeMaterialConnectionPoint;
  68895. /**
  68896. * Gets the clear coat output component
  68897. */
  68898. get clearcoatDir(): NodeMaterialConnectionPoint;
  68899. /**
  68900. * Gets the indirect diffuse output component
  68901. */
  68902. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68903. /**
  68904. * Gets the indirect specular output component
  68905. */
  68906. get specularIndirect(): NodeMaterialConnectionPoint;
  68907. /**
  68908. * Gets the indirect sheen output component
  68909. */
  68910. get sheenIndirect(): NodeMaterialConnectionPoint;
  68911. /**
  68912. * Gets the indirect clear coat output component
  68913. */
  68914. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68915. /**
  68916. * Gets the refraction output component
  68917. */
  68918. get refraction(): NodeMaterialConnectionPoint;
  68919. /**
  68920. * Gets the global lighting output component
  68921. */
  68922. get lighting(): NodeMaterialConnectionPoint;
  68923. /**
  68924. * Gets the shadow output component
  68925. */
  68926. get shadow(): NodeMaterialConnectionPoint;
  68927. /**
  68928. * Gets the alpha output component
  68929. */
  68930. get alpha(): NodeMaterialConnectionPoint;
  68931. autoConfigure(material: NodeMaterial): void;
  68932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68933. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68935. private _injectVertexCode;
  68936. /**
  68937. * Gets the code corresponding to the albedo/opacity module
  68938. * @returns the shader code
  68939. */
  68940. getAlbedoOpacityCode(): string;
  68941. protected _buildBlock(state: NodeMaterialBuildState): this;
  68942. protected _dumpPropertiesCode(): string;
  68943. serialize(): any;
  68944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68945. }
  68946. }
  68947. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68948. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68949. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68950. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68951. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68952. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68953. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68954. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68955. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68956. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68957. }
  68958. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68959. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68960. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68961. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68962. }
  68963. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68967. /**
  68968. * Block used to compute value of one parameter modulo another
  68969. */
  68970. export class ModBlock extends NodeMaterialBlock {
  68971. /**
  68972. * Creates a new ModBlock
  68973. * @param name defines the block name
  68974. */
  68975. constructor(name: string);
  68976. /**
  68977. * Gets the current class name
  68978. * @returns the class name
  68979. */
  68980. getClassName(): string;
  68981. /**
  68982. * Gets the left operand input component
  68983. */
  68984. get left(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the right operand input component
  68987. */
  68988. get right(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the output component
  68991. */
  68992. get output(): NodeMaterialConnectionPoint;
  68993. protected _buildBlock(state: NodeMaterialBuildState): this;
  68994. }
  68995. }
  68996. declare module "babylonjs/Materials/Node/Blocks/index" {
  68997. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68998. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68999. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69000. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69001. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69002. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69003. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69004. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69005. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69006. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69007. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69008. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69009. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69010. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69011. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69012. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69013. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69014. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69015. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69016. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69017. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69018. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69019. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69020. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69021. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69022. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69023. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69024. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69025. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69026. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69027. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69028. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69029. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69030. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69031. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69032. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69033. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69034. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69035. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69036. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69037. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69038. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69039. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69040. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69041. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69042. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69043. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69044. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69045. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69046. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69047. }
  69048. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69049. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69050. }
  69051. declare module "babylonjs/Materials/Node/index" {
  69052. export * from "babylonjs/Materials/Node/Enums/index";
  69053. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69054. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69055. export * from "babylonjs/Materials/Node/nodeMaterial";
  69056. export * from "babylonjs/Materials/Node/Blocks/index";
  69057. export * from "babylonjs/Materials/Node/Optimizers/index";
  69058. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69059. }
  69060. declare module "babylonjs/Materials/index" {
  69061. export * from "babylonjs/Materials/Background/index";
  69062. export * from "babylonjs/Materials/colorCurves";
  69063. export * from "babylonjs/Materials/iEffectFallbacks";
  69064. export * from "babylonjs/Materials/effectFallbacks";
  69065. export * from "babylonjs/Materials/effect";
  69066. export * from "babylonjs/Materials/fresnelParameters";
  69067. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69068. export * from "babylonjs/Materials/material";
  69069. export * from "babylonjs/Materials/materialDefines";
  69070. export * from "babylonjs/Materials/thinMaterialHelper";
  69071. export * from "babylonjs/Materials/materialHelper";
  69072. export * from "babylonjs/Materials/multiMaterial";
  69073. export * from "babylonjs/Materials/PBR/index";
  69074. export * from "babylonjs/Materials/pushMaterial";
  69075. export * from "babylonjs/Materials/shaderMaterial";
  69076. export * from "babylonjs/Materials/standardMaterial";
  69077. export * from "babylonjs/Materials/Textures/index";
  69078. export * from "babylonjs/Materials/uniformBuffer";
  69079. export * from "babylonjs/Materials/materialFlags";
  69080. export * from "babylonjs/Materials/Node/index";
  69081. export * from "babylonjs/Materials/effectRenderer";
  69082. export * from "babylonjs/Materials/shadowDepthWrapper";
  69083. }
  69084. declare module "babylonjs/Maths/index" {
  69085. export * from "babylonjs/Maths/math.scalar";
  69086. export * from "babylonjs/Maths/math";
  69087. export * from "babylonjs/Maths/sphericalPolynomial";
  69088. }
  69089. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69090. import { IDisposable } from "babylonjs/scene";
  69091. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69092. /**
  69093. * Configuration for Draco compression
  69094. */
  69095. export interface IDracoCompressionConfiguration {
  69096. /**
  69097. * Configuration for the decoder.
  69098. */
  69099. decoder: {
  69100. /**
  69101. * The url to the WebAssembly module.
  69102. */
  69103. wasmUrl?: string;
  69104. /**
  69105. * The url to the WebAssembly binary.
  69106. */
  69107. wasmBinaryUrl?: string;
  69108. /**
  69109. * The url to the fallback JavaScript module.
  69110. */
  69111. fallbackUrl?: string;
  69112. };
  69113. }
  69114. /**
  69115. * Draco compression (https://google.github.io/draco/)
  69116. *
  69117. * This class wraps the Draco module.
  69118. *
  69119. * **Encoder**
  69120. *
  69121. * The encoder is not currently implemented.
  69122. *
  69123. * **Decoder**
  69124. *
  69125. * 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.
  69126. *
  69127. * To update the configuration, use the following code:
  69128. * ```javascript
  69129. * DracoCompression.Configuration = {
  69130. * decoder: {
  69131. * wasmUrl: "<url to the WebAssembly library>",
  69132. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69133. * fallbackUrl: "<url to the fallback JavaScript library>",
  69134. * }
  69135. * };
  69136. * ```
  69137. *
  69138. * 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.
  69139. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69140. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69141. *
  69142. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69143. * ```javascript
  69144. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69145. * ```
  69146. *
  69147. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69148. */
  69149. export class DracoCompression implements IDisposable {
  69150. private _workerPoolPromise?;
  69151. private _decoderModulePromise?;
  69152. /**
  69153. * The configuration. Defaults to the following urls:
  69154. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69155. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69156. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69157. */
  69158. static Configuration: IDracoCompressionConfiguration;
  69159. /**
  69160. * Returns true if the decoder configuration is available.
  69161. */
  69162. static get DecoderAvailable(): boolean;
  69163. /**
  69164. * Default number of workers to create when creating the draco compression object.
  69165. */
  69166. static DefaultNumWorkers: number;
  69167. private static GetDefaultNumWorkers;
  69168. private static _Default;
  69169. /**
  69170. * Default instance for the draco compression object.
  69171. */
  69172. static get Default(): DracoCompression;
  69173. /**
  69174. * Constructor
  69175. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69176. */
  69177. constructor(numWorkers?: number);
  69178. /**
  69179. * Stop all async operations and release resources.
  69180. */
  69181. dispose(): void;
  69182. /**
  69183. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69184. * @returns a promise that resolves when ready
  69185. */
  69186. whenReadyAsync(): Promise<void>;
  69187. /**
  69188. * Decode Draco compressed mesh data to vertex data.
  69189. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69190. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69191. * @returns A promise that resolves with the decoded vertex data
  69192. */
  69193. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69194. [kind: string]: number;
  69195. }): Promise<VertexData>;
  69196. }
  69197. }
  69198. declare module "babylonjs/Meshes/Compression/index" {
  69199. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69200. }
  69201. declare module "babylonjs/Meshes/csg" {
  69202. import { Nullable } from "babylonjs/types";
  69203. import { Scene } from "babylonjs/scene";
  69204. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69205. import { Mesh } from "babylonjs/Meshes/mesh";
  69206. import { Material } from "babylonjs/Materials/material";
  69207. /**
  69208. * Class for building Constructive Solid Geometry
  69209. */
  69210. export class CSG {
  69211. private polygons;
  69212. /**
  69213. * The world matrix
  69214. */
  69215. matrix: Matrix;
  69216. /**
  69217. * Stores the position
  69218. */
  69219. position: Vector3;
  69220. /**
  69221. * Stores the rotation
  69222. */
  69223. rotation: Vector3;
  69224. /**
  69225. * Stores the rotation quaternion
  69226. */
  69227. rotationQuaternion: Nullable<Quaternion>;
  69228. /**
  69229. * Stores the scaling vector
  69230. */
  69231. scaling: Vector3;
  69232. /**
  69233. * Convert the Mesh to CSG
  69234. * @param mesh The Mesh to convert to CSG
  69235. * @returns A new CSG from the Mesh
  69236. */
  69237. static FromMesh(mesh: Mesh): CSG;
  69238. /**
  69239. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69240. * @param polygons Polygons used to construct a CSG solid
  69241. */
  69242. private static FromPolygons;
  69243. /**
  69244. * Clones, or makes a deep copy, of the CSG
  69245. * @returns A new CSG
  69246. */
  69247. clone(): CSG;
  69248. /**
  69249. * Unions this CSG with another CSG
  69250. * @param csg The CSG to union against this CSG
  69251. * @returns The unioned CSG
  69252. */
  69253. union(csg: CSG): CSG;
  69254. /**
  69255. * Unions this CSG with another CSG in place
  69256. * @param csg The CSG to union against this CSG
  69257. */
  69258. unionInPlace(csg: CSG): void;
  69259. /**
  69260. * Subtracts this CSG with another CSG
  69261. * @param csg The CSG to subtract against this CSG
  69262. * @returns A new CSG
  69263. */
  69264. subtract(csg: CSG): CSG;
  69265. /**
  69266. * Subtracts this CSG with another CSG in place
  69267. * @param csg The CSG to subtact against this CSG
  69268. */
  69269. subtractInPlace(csg: CSG): void;
  69270. /**
  69271. * Intersect this CSG with another CSG
  69272. * @param csg The CSG to intersect against this CSG
  69273. * @returns A new CSG
  69274. */
  69275. intersect(csg: CSG): CSG;
  69276. /**
  69277. * Intersects this CSG with another CSG in place
  69278. * @param csg The CSG to intersect against this CSG
  69279. */
  69280. intersectInPlace(csg: CSG): void;
  69281. /**
  69282. * Return a new CSG solid with solid and empty space switched. This solid is
  69283. * not modified.
  69284. * @returns A new CSG solid with solid and empty space switched
  69285. */
  69286. inverse(): CSG;
  69287. /**
  69288. * Inverses the CSG in place
  69289. */
  69290. inverseInPlace(): void;
  69291. /**
  69292. * This is used to keep meshes transformations so they can be restored
  69293. * when we build back a Babylon Mesh
  69294. * NB : All CSG operations are performed in world coordinates
  69295. * @param csg The CSG to copy the transform attributes from
  69296. * @returns This CSG
  69297. */
  69298. copyTransformAttributes(csg: CSG): CSG;
  69299. /**
  69300. * Build Raw mesh from CSG
  69301. * Coordinates here are in world space
  69302. * @param name The name of the mesh geometry
  69303. * @param scene The Scene
  69304. * @param keepSubMeshes Specifies if the submeshes should be kept
  69305. * @returns A new Mesh
  69306. */
  69307. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69308. /**
  69309. * Build Mesh from CSG taking material and transforms into account
  69310. * @param name The name of the Mesh
  69311. * @param material The material of the Mesh
  69312. * @param scene The Scene
  69313. * @param keepSubMeshes Specifies if submeshes should be kept
  69314. * @returns The new Mesh
  69315. */
  69316. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69317. }
  69318. }
  69319. declare module "babylonjs/Meshes/trailMesh" {
  69320. import { Mesh } from "babylonjs/Meshes/mesh";
  69321. import { Scene } from "babylonjs/scene";
  69322. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69323. /**
  69324. * Class used to create a trail following a mesh
  69325. */
  69326. export class TrailMesh extends Mesh {
  69327. private _generator;
  69328. private _autoStart;
  69329. private _running;
  69330. private _diameter;
  69331. private _length;
  69332. private _sectionPolygonPointsCount;
  69333. private _sectionVectors;
  69334. private _sectionNormalVectors;
  69335. private _beforeRenderObserver;
  69336. /**
  69337. * @constructor
  69338. * @param name The value used by scene.getMeshByName() to do a lookup.
  69339. * @param generator The mesh or transform node to generate a trail.
  69340. * @param scene The scene to add this mesh to.
  69341. * @param diameter Diameter of trailing mesh. Default is 1.
  69342. * @param length Length of trailing mesh. Default is 60.
  69343. * @param autoStart Automatically start trailing mesh. Default true.
  69344. */
  69345. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69346. /**
  69347. * "TrailMesh"
  69348. * @returns "TrailMesh"
  69349. */
  69350. getClassName(): string;
  69351. private _createMesh;
  69352. /**
  69353. * Start trailing mesh.
  69354. */
  69355. start(): void;
  69356. /**
  69357. * Stop trailing mesh.
  69358. */
  69359. stop(): void;
  69360. /**
  69361. * Update trailing mesh geometry.
  69362. */
  69363. update(): void;
  69364. /**
  69365. * Returns a new TrailMesh object.
  69366. * @param name is a string, the name given to the new mesh
  69367. * @param newGenerator use new generator object for cloned trail mesh
  69368. * @returns a new mesh
  69369. */
  69370. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69371. /**
  69372. * Serializes this trail mesh
  69373. * @param serializationObject object to write serialization to
  69374. */
  69375. serialize(serializationObject: any): void;
  69376. /**
  69377. * Parses a serialized trail mesh
  69378. * @param parsedMesh the serialized mesh
  69379. * @param scene the scene to create the trail mesh in
  69380. * @returns the created trail mesh
  69381. */
  69382. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69383. }
  69384. }
  69385. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69386. import { Nullable } from "babylonjs/types";
  69387. import { Scene } from "babylonjs/scene";
  69388. import { Vector4 } from "babylonjs/Maths/math.vector";
  69389. import { Color4 } from "babylonjs/Maths/math.color";
  69390. import { Mesh } from "babylonjs/Meshes/mesh";
  69391. /**
  69392. * Class containing static functions to help procedurally build meshes
  69393. */
  69394. export class TiledBoxBuilder {
  69395. /**
  69396. * Creates a box mesh
  69397. * 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)
  69398. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69402. * @param name defines the name of the mesh
  69403. * @param options defines the options used to create the mesh
  69404. * @param scene defines the hosting scene
  69405. * @returns the box mesh
  69406. */
  69407. static CreateTiledBox(name: string, options: {
  69408. pattern?: number;
  69409. width?: number;
  69410. height?: number;
  69411. depth?: number;
  69412. tileSize?: number;
  69413. tileWidth?: number;
  69414. tileHeight?: number;
  69415. alignHorizontal?: number;
  69416. alignVertical?: number;
  69417. faceUV?: Vector4[];
  69418. faceColors?: Color4[];
  69419. sideOrientation?: number;
  69420. updatable?: boolean;
  69421. }, scene?: Nullable<Scene>): Mesh;
  69422. }
  69423. }
  69424. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69425. import { Vector4 } from "babylonjs/Maths/math.vector";
  69426. import { Mesh } from "babylonjs/Meshes/mesh";
  69427. /**
  69428. * Class containing static functions to help procedurally build meshes
  69429. */
  69430. export class TorusKnotBuilder {
  69431. /**
  69432. * Creates a torus knot mesh
  69433. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69434. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69435. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69436. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69440. * @param name defines the name of the mesh
  69441. * @param options defines the options used to create the mesh
  69442. * @param scene defines the hosting scene
  69443. * @returns the torus knot mesh
  69444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69445. */
  69446. static CreateTorusKnot(name: string, options: {
  69447. radius?: number;
  69448. tube?: number;
  69449. radialSegments?: number;
  69450. tubularSegments?: number;
  69451. p?: number;
  69452. q?: number;
  69453. updatable?: boolean;
  69454. sideOrientation?: number;
  69455. frontUVs?: Vector4;
  69456. backUVs?: Vector4;
  69457. }, scene: any): Mesh;
  69458. }
  69459. }
  69460. declare module "babylonjs/Meshes/polygonMesh" {
  69461. import { Scene } from "babylonjs/scene";
  69462. import { Vector2 } from "babylonjs/Maths/math.vector";
  69463. import { Mesh } from "babylonjs/Meshes/mesh";
  69464. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69465. import { Path2 } from "babylonjs/Maths/math.path";
  69466. /**
  69467. * Polygon
  69468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69469. */
  69470. export class Polygon {
  69471. /**
  69472. * Creates a rectangle
  69473. * @param xmin bottom X coord
  69474. * @param ymin bottom Y coord
  69475. * @param xmax top X coord
  69476. * @param ymax top Y coord
  69477. * @returns points that make the resulting rectation
  69478. */
  69479. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69480. /**
  69481. * Creates a circle
  69482. * @param radius radius of circle
  69483. * @param cx scale in x
  69484. * @param cy scale in y
  69485. * @param numberOfSides number of sides that make up the circle
  69486. * @returns points that make the resulting circle
  69487. */
  69488. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69489. /**
  69490. * Creates a polygon from input string
  69491. * @param input Input polygon data
  69492. * @returns the parsed points
  69493. */
  69494. static Parse(input: string): Vector2[];
  69495. /**
  69496. * Starts building a polygon from x and y coordinates
  69497. * @param x x coordinate
  69498. * @param y y coordinate
  69499. * @returns the started path2
  69500. */
  69501. static StartingAt(x: number, y: number): Path2;
  69502. }
  69503. /**
  69504. * Builds a polygon
  69505. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69506. */
  69507. export class PolygonMeshBuilder {
  69508. private _points;
  69509. private _outlinepoints;
  69510. private _holes;
  69511. private _name;
  69512. private _scene;
  69513. private _epoints;
  69514. private _eholes;
  69515. private _addToepoint;
  69516. /**
  69517. * Babylon reference to the earcut plugin.
  69518. */
  69519. bjsEarcut: any;
  69520. /**
  69521. * Creates a PolygonMeshBuilder
  69522. * @param name name of the builder
  69523. * @param contours Path of the polygon
  69524. * @param scene scene to add to when creating the mesh
  69525. * @param earcutInjection can be used to inject your own earcut reference
  69526. */
  69527. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69528. /**
  69529. * Adds a whole within the polygon
  69530. * @param hole Array of points defining the hole
  69531. * @returns this
  69532. */
  69533. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69534. /**
  69535. * Creates the polygon
  69536. * @param updatable If the mesh should be updatable
  69537. * @param depth The depth of the mesh created
  69538. * @returns the created mesh
  69539. */
  69540. build(updatable?: boolean, depth?: number): Mesh;
  69541. /**
  69542. * Creates the polygon
  69543. * @param depth The depth of the mesh created
  69544. * @returns the created VertexData
  69545. */
  69546. buildVertexData(depth?: number): VertexData;
  69547. /**
  69548. * Adds a side to the polygon
  69549. * @param positions points that make the polygon
  69550. * @param normals normals of the polygon
  69551. * @param uvs uvs of the polygon
  69552. * @param indices indices of the polygon
  69553. * @param bounds bounds of the polygon
  69554. * @param points points of the polygon
  69555. * @param depth depth of the polygon
  69556. * @param flip flip of the polygon
  69557. */
  69558. private addSide;
  69559. }
  69560. }
  69561. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69562. import { Scene } from "babylonjs/scene";
  69563. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69564. import { Color4 } from "babylonjs/Maths/math.color";
  69565. import { Mesh } from "babylonjs/Meshes/mesh";
  69566. import { Nullable } from "babylonjs/types";
  69567. /**
  69568. * Class containing static functions to help procedurally build meshes
  69569. */
  69570. export class PolygonBuilder {
  69571. /**
  69572. * Creates a polygon mesh
  69573. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69574. * * 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
  69575. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69578. * * Remember you can only change the shape positions, not their number when updating a polygon
  69579. * @param name defines the name of the mesh
  69580. * @param options defines the options used to create the mesh
  69581. * @param scene defines the hosting scene
  69582. * @param earcutInjection can be used to inject your own earcut reference
  69583. * @returns the polygon mesh
  69584. */
  69585. static CreatePolygon(name: string, options: {
  69586. shape: Vector3[];
  69587. holes?: Vector3[][];
  69588. depth?: number;
  69589. faceUV?: Vector4[];
  69590. faceColors?: Color4[];
  69591. updatable?: boolean;
  69592. sideOrientation?: number;
  69593. frontUVs?: Vector4;
  69594. backUVs?: Vector4;
  69595. wrap?: boolean;
  69596. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69597. /**
  69598. * Creates an extruded polygon mesh, with depth in the Y direction.
  69599. * * 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)
  69600. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69601. * @param name defines the name of the mesh
  69602. * @param options defines the options used to create the mesh
  69603. * @param scene defines the hosting scene
  69604. * @param earcutInjection can be used to inject your own earcut reference
  69605. * @returns the polygon mesh
  69606. */
  69607. static ExtrudePolygon(name: string, options: {
  69608. shape: Vector3[];
  69609. holes?: Vector3[][];
  69610. depth?: number;
  69611. faceUV?: Vector4[];
  69612. faceColors?: Color4[];
  69613. updatable?: boolean;
  69614. sideOrientation?: number;
  69615. frontUVs?: Vector4;
  69616. backUVs?: Vector4;
  69617. wrap?: boolean;
  69618. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69619. }
  69620. }
  69621. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69622. import { Scene } from "babylonjs/scene";
  69623. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69624. import { Mesh } from "babylonjs/Meshes/mesh";
  69625. import { Nullable } from "babylonjs/types";
  69626. /**
  69627. * Class containing static functions to help procedurally build meshes
  69628. */
  69629. export class LatheBuilder {
  69630. /**
  69631. * Creates lathe mesh.
  69632. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69633. * * 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
  69634. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69635. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69636. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69637. * * 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
  69638. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69639. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  69640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69644. * @param name defines the name of the mesh
  69645. * @param options defines the options used to create the mesh
  69646. * @param scene defines the hosting scene
  69647. * @returns the lathe mesh
  69648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69649. */
  69650. static CreateLathe(name: string, options: {
  69651. shape: Vector3[];
  69652. radius?: number;
  69653. tessellation?: number;
  69654. clip?: number;
  69655. arc?: number;
  69656. closed?: boolean;
  69657. updatable?: boolean;
  69658. sideOrientation?: number;
  69659. frontUVs?: Vector4;
  69660. backUVs?: Vector4;
  69661. cap?: number;
  69662. invertUV?: boolean;
  69663. }, scene?: Nullable<Scene>): Mesh;
  69664. }
  69665. }
  69666. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69667. import { Nullable } from "babylonjs/types";
  69668. import { Scene } from "babylonjs/scene";
  69669. import { Vector4 } from "babylonjs/Maths/math.vector";
  69670. import { Mesh } from "babylonjs/Meshes/mesh";
  69671. /**
  69672. * Class containing static functions to help procedurally build meshes
  69673. */
  69674. export class TiledPlaneBuilder {
  69675. /**
  69676. * Creates a tiled plane mesh
  69677. * * The parameter `pattern` will, depending on value, do nothing or
  69678. * * * flip (reflect about central vertical) alternate tiles across and up
  69679. * * * flip every tile on alternate rows
  69680. * * * rotate (180 degs) alternate tiles across and up
  69681. * * * rotate every tile on alternate rows
  69682. * * * flip and rotate alternate tiles across and up
  69683. * * * flip and rotate every tile on alternate rows
  69684. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69685. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69688. * * 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)
  69689. * * 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)
  69690. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69691. * @param name defines the name of the mesh
  69692. * @param options defines the options used to create the mesh
  69693. * @param scene defines the hosting scene
  69694. * @returns the box mesh
  69695. */
  69696. static CreateTiledPlane(name: string, options: {
  69697. pattern?: number;
  69698. tileSize?: number;
  69699. tileWidth?: number;
  69700. tileHeight?: number;
  69701. size?: number;
  69702. width?: number;
  69703. height?: number;
  69704. alignHorizontal?: number;
  69705. alignVertical?: number;
  69706. sideOrientation?: number;
  69707. frontUVs?: Vector4;
  69708. backUVs?: Vector4;
  69709. updatable?: boolean;
  69710. }, scene?: Nullable<Scene>): Mesh;
  69711. }
  69712. }
  69713. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69714. import { Nullable } from "babylonjs/types";
  69715. import { Scene } from "babylonjs/scene";
  69716. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69717. import { Mesh } from "babylonjs/Meshes/mesh";
  69718. /**
  69719. * Class containing static functions to help procedurally build meshes
  69720. */
  69721. export class TubeBuilder {
  69722. /**
  69723. * Creates a tube mesh.
  69724. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69725. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69726. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69727. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69728. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69729. * * 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)
  69730. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69731. * * 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
  69732. * * 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
  69733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69735. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69737. * @param name defines the name of the mesh
  69738. * @param options defines the options used to create the mesh
  69739. * @param scene defines the hosting scene
  69740. * @returns the tube mesh
  69741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69742. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69743. */
  69744. static CreateTube(name: string, options: {
  69745. path: Vector3[];
  69746. radius?: number;
  69747. tessellation?: number;
  69748. radiusFunction?: {
  69749. (i: number, distance: number): number;
  69750. };
  69751. cap?: number;
  69752. arc?: number;
  69753. updatable?: boolean;
  69754. sideOrientation?: number;
  69755. frontUVs?: Vector4;
  69756. backUVs?: Vector4;
  69757. instance?: Mesh;
  69758. invertUV?: boolean;
  69759. }, scene?: Nullable<Scene>): Mesh;
  69760. }
  69761. }
  69762. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69763. import { Scene } from "babylonjs/scene";
  69764. import { Vector4 } from "babylonjs/Maths/math.vector";
  69765. import { Mesh } from "babylonjs/Meshes/mesh";
  69766. import { Nullable } from "babylonjs/types";
  69767. /**
  69768. * Class containing static functions to help procedurally build meshes
  69769. */
  69770. export class IcoSphereBuilder {
  69771. /**
  69772. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69773. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69774. * * 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`)
  69775. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69776. * * 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
  69777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69780. * @param name defines the name of the mesh
  69781. * @param options defines the options used to create the mesh
  69782. * @param scene defines the hosting scene
  69783. * @returns the icosahedron mesh
  69784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69785. */
  69786. static CreateIcoSphere(name: string, options: {
  69787. radius?: number;
  69788. radiusX?: number;
  69789. radiusY?: number;
  69790. radiusZ?: number;
  69791. flat?: boolean;
  69792. subdivisions?: number;
  69793. sideOrientation?: number;
  69794. frontUVs?: Vector4;
  69795. backUVs?: Vector4;
  69796. updatable?: boolean;
  69797. }, scene?: Nullable<Scene>): Mesh;
  69798. }
  69799. }
  69800. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69801. import { Vector3 } from "babylonjs/Maths/math.vector";
  69802. import { Mesh } from "babylonjs/Meshes/mesh";
  69803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69804. /**
  69805. * Class containing static functions to help procedurally build meshes
  69806. */
  69807. export class DecalBuilder {
  69808. /**
  69809. * Creates a decal mesh.
  69810. * 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
  69811. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69812. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69813. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69814. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69815. * @param name defines the name of the mesh
  69816. * @param sourceMesh defines the mesh where the decal must be applied
  69817. * @param options defines the options used to create the mesh
  69818. * @param scene defines the hosting scene
  69819. * @returns the decal mesh
  69820. * @see https://doc.babylonjs.com/how_to/decals
  69821. */
  69822. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69823. position?: Vector3;
  69824. normal?: Vector3;
  69825. size?: Vector3;
  69826. angle?: number;
  69827. }): Mesh;
  69828. }
  69829. }
  69830. declare module "babylonjs/Meshes/meshBuilder" {
  69831. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69832. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69833. import { Nullable } from "babylonjs/types";
  69834. import { Scene } from "babylonjs/scene";
  69835. import { Mesh } from "babylonjs/Meshes/mesh";
  69836. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69837. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69839. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69840. import { Plane } from "babylonjs/Maths/math.plane";
  69841. /**
  69842. * Class containing static functions to help procedurally build meshes
  69843. */
  69844. export class MeshBuilder {
  69845. /**
  69846. * Creates a box mesh
  69847. * * The parameter `size` sets the size (float) of each box side (default 1)
  69848. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69849. * * 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)
  69850. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69854. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69855. * @param name defines the name of the mesh
  69856. * @param options defines the options used to create the mesh
  69857. * @param scene defines the hosting scene
  69858. * @returns the box mesh
  69859. */
  69860. static CreateBox(name: string, options: {
  69861. size?: number;
  69862. width?: number;
  69863. height?: number;
  69864. depth?: number;
  69865. faceUV?: Vector4[];
  69866. faceColors?: Color4[];
  69867. sideOrientation?: number;
  69868. frontUVs?: Vector4;
  69869. backUVs?: Vector4;
  69870. wrap?: boolean;
  69871. topBaseAt?: number;
  69872. bottomBaseAt?: number;
  69873. updatable?: boolean;
  69874. }, scene?: Nullable<Scene>): Mesh;
  69875. /**
  69876. * Creates a tiled box mesh
  69877. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69879. * @param name defines the name of the mesh
  69880. * @param options defines the options used to create the mesh
  69881. * @param scene defines the hosting scene
  69882. * @returns the tiled box mesh
  69883. */
  69884. static CreateTiledBox(name: string, options: {
  69885. pattern?: number;
  69886. size?: number;
  69887. width?: number;
  69888. height?: number;
  69889. depth: number;
  69890. tileSize?: number;
  69891. tileWidth?: number;
  69892. tileHeight?: number;
  69893. faceUV?: Vector4[];
  69894. faceColors?: Color4[];
  69895. alignHorizontal?: number;
  69896. alignVertical?: number;
  69897. sideOrientation?: number;
  69898. updatable?: boolean;
  69899. }, scene?: Nullable<Scene>): Mesh;
  69900. /**
  69901. * Creates a sphere mesh
  69902. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69903. * * 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`)
  69904. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69905. * * 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
  69906. * * 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)
  69907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69910. * @param name defines the name of the mesh
  69911. * @param options defines the options used to create the mesh
  69912. * @param scene defines the hosting scene
  69913. * @returns the sphere mesh
  69914. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69915. */
  69916. static CreateSphere(name: string, options: {
  69917. segments?: number;
  69918. diameter?: number;
  69919. diameterX?: number;
  69920. diameterY?: number;
  69921. diameterZ?: number;
  69922. arc?: number;
  69923. slice?: number;
  69924. sideOrientation?: number;
  69925. frontUVs?: Vector4;
  69926. backUVs?: Vector4;
  69927. updatable?: boolean;
  69928. }, scene?: Nullable<Scene>): Mesh;
  69929. /**
  69930. * Creates a plane polygonal mesh. By default, this is a disc
  69931. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69932. * * 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
  69933. * * 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
  69934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69937. * @param name defines the name of the mesh
  69938. * @param options defines the options used to create the mesh
  69939. * @param scene defines the hosting scene
  69940. * @returns the plane polygonal mesh
  69941. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69942. */
  69943. static CreateDisc(name: string, options: {
  69944. radius?: number;
  69945. tessellation?: number;
  69946. arc?: number;
  69947. updatable?: boolean;
  69948. sideOrientation?: number;
  69949. frontUVs?: Vector4;
  69950. backUVs?: Vector4;
  69951. }, scene?: Nullable<Scene>): Mesh;
  69952. /**
  69953. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69954. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69955. * * 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`)
  69956. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69957. * * 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
  69958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69961. * @param name defines the name of the mesh
  69962. * @param options defines the options used to create the mesh
  69963. * @param scene defines the hosting scene
  69964. * @returns the icosahedron mesh
  69965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69966. */
  69967. static CreateIcoSphere(name: string, options: {
  69968. radius?: number;
  69969. radiusX?: number;
  69970. radiusY?: number;
  69971. radiusZ?: number;
  69972. flat?: boolean;
  69973. subdivisions?: number;
  69974. sideOrientation?: number;
  69975. frontUVs?: Vector4;
  69976. backUVs?: Vector4;
  69977. updatable?: boolean;
  69978. }, scene?: Nullable<Scene>): Mesh;
  69979. /**
  69980. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69981. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69982. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69983. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69984. * * 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
  69985. * * 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
  69986. * * 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
  69987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69990. * * 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
  69991. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69992. * * 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
  69993. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69995. * @param name defines the name of the mesh
  69996. * @param options defines the options used to create the mesh
  69997. * @param scene defines the hosting scene
  69998. * @returns the ribbon mesh
  69999. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70001. */
  70002. static CreateRibbon(name: string, options: {
  70003. pathArray: Vector3[][];
  70004. closeArray?: boolean;
  70005. closePath?: boolean;
  70006. offset?: number;
  70007. updatable?: boolean;
  70008. sideOrientation?: number;
  70009. frontUVs?: Vector4;
  70010. backUVs?: Vector4;
  70011. instance?: Mesh;
  70012. invertUV?: boolean;
  70013. uvs?: Vector2[];
  70014. colors?: Color4[];
  70015. }, scene?: Nullable<Scene>): Mesh;
  70016. /**
  70017. * Creates a cylinder or a cone mesh
  70018. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70019. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70020. * * 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.
  70021. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70022. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70023. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70024. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70025. * * 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).
  70026. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70027. * * 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).
  70028. * * 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
  70029. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70030. * * 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
  70031. * * 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.
  70032. * * If `enclose` is false, a ring surface is one element.
  70033. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70034. * * 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
  70035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70038. * @param name defines the name of the mesh
  70039. * @param options defines the options used to create the mesh
  70040. * @param scene defines the hosting scene
  70041. * @returns the cylinder mesh
  70042. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70043. */
  70044. static CreateCylinder(name: string, options: {
  70045. height?: number;
  70046. diameterTop?: number;
  70047. diameterBottom?: number;
  70048. diameter?: number;
  70049. tessellation?: number;
  70050. subdivisions?: number;
  70051. arc?: number;
  70052. faceColors?: Color4[];
  70053. faceUV?: Vector4[];
  70054. updatable?: boolean;
  70055. hasRings?: boolean;
  70056. enclose?: boolean;
  70057. cap?: number;
  70058. sideOrientation?: number;
  70059. frontUVs?: Vector4;
  70060. backUVs?: Vector4;
  70061. }, scene?: Nullable<Scene>): Mesh;
  70062. /**
  70063. * Creates a torus mesh
  70064. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70065. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70066. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70070. * @param name defines the name of the mesh
  70071. * @param options defines the options used to create the mesh
  70072. * @param scene defines the hosting scene
  70073. * @returns the torus mesh
  70074. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70075. */
  70076. static CreateTorus(name: string, options: {
  70077. diameter?: number;
  70078. thickness?: number;
  70079. tessellation?: number;
  70080. updatable?: boolean;
  70081. sideOrientation?: number;
  70082. frontUVs?: Vector4;
  70083. backUVs?: Vector4;
  70084. }, scene?: Nullable<Scene>): Mesh;
  70085. /**
  70086. * Creates a torus knot mesh
  70087. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70088. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70089. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70090. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70094. * @param name defines the name of the mesh
  70095. * @param options defines the options used to create the mesh
  70096. * @param scene defines the hosting scene
  70097. * @returns the torus knot mesh
  70098. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70099. */
  70100. static CreateTorusKnot(name: string, options: {
  70101. radius?: number;
  70102. tube?: number;
  70103. radialSegments?: number;
  70104. tubularSegments?: number;
  70105. p?: number;
  70106. q?: number;
  70107. updatable?: boolean;
  70108. sideOrientation?: number;
  70109. frontUVs?: Vector4;
  70110. backUVs?: Vector4;
  70111. }, scene?: Nullable<Scene>): Mesh;
  70112. /**
  70113. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70114. * * 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
  70115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70116. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70117. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70118. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70120. * * 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
  70121. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70124. * @param name defines the name of the new line system
  70125. * @param options defines the options used to create the line system
  70126. * @param scene defines the hosting scene
  70127. * @returns a new line system mesh
  70128. */
  70129. static CreateLineSystem(name: string, options: {
  70130. lines: Vector3[][];
  70131. updatable?: boolean;
  70132. instance?: Nullable<LinesMesh>;
  70133. colors?: Nullable<Color4[][]>;
  70134. useVertexAlpha?: boolean;
  70135. }, scene: Nullable<Scene>): LinesMesh;
  70136. /**
  70137. * Creates a line mesh
  70138. * 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
  70139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70140. * * The parameter `points` is an array successive Vector3
  70141. * * 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
  70142. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70144. * * When updating an instance, remember that only point positions can change, not the number of points
  70145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70147. * @param name defines the name of the new line system
  70148. * @param options defines the options used to create the line system
  70149. * @param scene defines the hosting scene
  70150. * @returns a new line mesh
  70151. */
  70152. static CreateLines(name: string, options: {
  70153. points: Vector3[];
  70154. updatable?: boolean;
  70155. instance?: Nullable<LinesMesh>;
  70156. colors?: Color4[];
  70157. useVertexAlpha?: boolean;
  70158. }, scene?: Nullable<Scene>): LinesMesh;
  70159. /**
  70160. * Creates a dashed line mesh
  70161. * * 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
  70162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70163. * * The parameter `points` is an array successive Vector3
  70164. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70165. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70166. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70167. * * 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
  70168. * * When updating an instance, remember that only point positions can change, not the number of points
  70169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70170. * @param name defines the name of the mesh
  70171. * @param options defines the options used to create the mesh
  70172. * @param scene defines the hosting scene
  70173. * @returns the dashed line mesh
  70174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70175. */
  70176. static CreateDashedLines(name: string, options: {
  70177. points: Vector3[];
  70178. dashSize?: number;
  70179. gapSize?: number;
  70180. dashNb?: number;
  70181. updatable?: boolean;
  70182. instance?: LinesMesh;
  70183. }, scene?: Nullable<Scene>): LinesMesh;
  70184. /**
  70185. * 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.
  70186. * * 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.
  70187. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70188. * * 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.
  70189. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70190. * * 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
  70191. * * 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
  70192. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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 extruded shape mesh
  70201. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70203. */
  70204. static ExtrudeShape(name: string, options: {
  70205. shape: Vector3[];
  70206. path: Vector3[];
  70207. scale?: number;
  70208. rotation?: number;
  70209. cap?: number;
  70210. updatable?: boolean;
  70211. sideOrientation?: number;
  70212. frontUVs?: Vector4;
  70213. backUVs?: Vector4;
  70214. instance?: Mesh;
  70215. invertUV?: boolean;
  70216. }, scene?: Nullable<Scene>): Mesh;
  70217. /**
  70218. * Creates an custom extruded shape mesh.
  70219. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70220. * * 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.
  70221. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70222. * * 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
  70223. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70224. * * 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
  70225. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70226. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70227. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70228. * * 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
  70229. * * 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
  70230. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70235. * @param name defines the name of the mesh
  70236. * @param options defines the options used to create the mesh
  70237. * @param scene defines the hosting scene
  70238. * @returns the custom extruded shape mesh
  70239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70242. */
  70243. static ExtrudeShapeCustom(name: string, options: {
  70244. shape: Vector3[];
  70245. path: Vector3[];
  70246. scaleFunction?: any;
  70247. rotationFunction?: any;
  70248. ribbonCloseArray?: boolean;
  70249. ribbonClosePath?: boolean;
  70250. cap?: number;
  70251. updatable?: boolean;
  70252. sideOrientation?: number;
  70253. frontUVs?: Vector4;
  70254. backUVs?: Vector4;
  70255. instance?: Mesh;
  70256. invertUV?: boolean;
  70257. }, scene?: Nullable<Scene>): Mesh;
  70258. /**
  70259. * Creates lathe mesh.
  70260. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70261. * * 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
  70262. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70263. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70264. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70265. * * 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
  70266. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70267. * * 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
  70268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70272. * @param name defines the name of the mesh
  70273. * @param options defines the options used to create the mesh
  70274. * @param scene defines the hosting scene
  70275. * @returns the lathe mesh
  70276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70277. */
  70278. static CreateLathe(name: string, options: {
  70279. shape: Vector3[];
  70280. radius?: number;
  70281. tessellation?: number;
  70282. clip?: number;
  70283. arc?: number;
  70284. closed?: boolean;
  70285. updatable?: boolean;
  70286. sideOrientation?: number;
  70287. frontUVs?: Vector4;
  70288. backUVs?: Vector4;
  70289. cap?: number;
  70290. invertUV?: boolean;
  70291. }, scene?: Nullable<Scene>): Mesh;
  70292. /**
  70293. * Creates a tiled plane mesh
  70294. * * You can set a limited pattern arrangement with the tiles
  70295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70298. * @param name defines the name of the mesh
  70299. * @param options defines the options used to create the mesh
  70300. * @param scene defines the hosting scene
  70301. * @returns the plane mesh
  70302. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70303. */
  70304. static CreateTiledPlane(name: string, options: {
  70305. pattern?: number;
  70306. tileSize?: number;
  70307. tileWidth?: number;
  70308. tileHeight?: number;
  70309. size?: number;
  70310. width?: number;
  70311. height?: number;
  70312. alignHorizontal?: number;
  70313. alignVertical?: number;
  70314. sideOrientation?: number;
  70315. frontUVs?: Vector4;
  70316. backUVs?: Vector4;
  70317. updatable?: boolean;
  70318. }, scene?: Nullable<Scene>): Mesh;
  70319. /**
  70320. * Creates a plane mesh
  70321. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70322. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70323. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70327. * @param name defines the name of the mesh
  70328. * @param options defines the options used to create the mesh
  70329. * @param scene defines the hosting scene
  70330. * @returns the plane mesh
  70331. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70332. */
  70333. static CreatePlane(name: string, options: {
  70334. size?: number;
  70335. width?: number;
  70336. height?: number;
  70337. sideOrientation?: number;
  70338. frontUVs?: Vector4;
  70339. backUVs?: Vector4;
  70340. updatable?: boolean;
  70341. sourcePlane?: Plane;
  70342. }, scene?: Nullable<Scene>): Mesh;
  70343. /**
  70344. * Creates a ground mesh
  70345. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70346. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70348. * @param name defines the name of the mesh
  70349. * @param options defines the options used to create the mesh
  70350. * @param scene defines the hosting scene
  70351. * @returns the ground mesh
  70352. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70353. */
  70354. static CreateGround(name: string, options: {
  70355. width?: number;
  70356. height?: number;
  70357. subdivisions?: number;
  70358. subdivisionsX?: number;
  70359. subdivisionsY?: number;
  70360. updatable?: boolean;
  70361. }, scene?: Nullable<Scene>): Mesh;
  70362. /**
  70363. * Creates a tiled ground mesh
  70364. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70365. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70366. * * 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
  70367. * * 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
  70368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70369. * @param name defines the name of the mesh
  70370. * @param options defines the options used to create the mesh
  70371. * @param scene defines the hosting scene
  70372. * @returns the tiled ground mesh
  70373. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70374. */
  70375. static CreateTiledGround(name: string, options: {
  70376. xmin: number;
  70377. zmin: number;
  70378. xmax: number;
  70379. zmax: number;
  70380. subdivisions?: {
  70381. w: number;
  70382. h: number;
  70383. };
  70384. precision?: {
  70385. w: number;
  70386. h: number;
  70387. };
  70388. updatable?: boolean;
  70389. }, scene?: Nullable<Scene>): Mesh;
  70390. /**
  70391. * Creates a ground mesh from a height map
  70392. * * The parameter `url` sets the URL of the height map image resource.
  70393. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70394. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70395. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70396. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70397. * * 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.
  70398. * * 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).
  70399. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70401. * @param name defines the name of the mesh
  70402. * @param url defines the url to the height map
  70403. * @param options defines the options used to create the mesh
  70404. * @param scene defines the hosting scene
  70405. * @returns the ground mesh
  70406. * @see https://doc.babylonjs.com/babylon101/height_map
  70407. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70408. */
  70409. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70410. width?: number;
  70411. height?: number;
  70412. subdivisions?: number;
  70413. minHeight?: number;
  70414. maxHeight?: number;
  70415. colorFilter?: Color3;
  70416. alphaFilter?: number;
  70417. updatable?: boolean;
  70418. onReady?: (mesh: GroundMesh) => void;
  70419. }, scene?: Nullable<Scene>): GroundMesh;
  70420. /**
  70421. * Creates a polygon mesh
  70422. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70423. * * 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
  70424. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70427. * * Remember you can only change the shape positions, not their number when updating a polygon
  70428. * @param name defines the name of the mesh
  70429. * @param options defines the options used to create the mesh
  70430. * @param scene defines the hosting scene
  70431. * @param earcutInjection can be used to inject your own earcut reference
  70432. * @returns the polygon mesh
  70433. */
  70434. static CreatePolygon(name: string, options: {
  70435. shape: Vector3[];
  70436. holes?: Vector3[][];
  70437. depth?: number;
  70438. faceUV?: Vector4[];
  70439. faceColors?: Color4[];
  70440. updatable?: boolean;
  70441. sideOrientation?: number;
  70442. frontUVs?: Vector4;
  70443. backUVs?: Vector4;
  70444. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70445. /**
  70446. * Creates an extruded polygon mesh, with depth in the Y direction.
  70447. * * 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)
  70448. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70449. * @param name defines the name of the mesh
  70450. * @param options defines the options used to create the mesh
  70451. * @param scene defines the hosting scene
  70452. * @param earcutInjection can be used to inject your own earcut reference
  70453. * @returns the polygon mesh
  70454. */
  70455. static ExtrudePolygon(name: string, options: {
  70456. shape: Vector3[];
  70457. holes?: Vector3[][];
  70458. depth?: number;
  70459. faceUV?: Vector4[];
  70460. faceColors?: Color4[];
  70461. updatable?: boolean;
  70462. sideOrientation?: number;
  70463. frontUVs?: Vector4;
  70464. backUVs?: Vector4;
  70465. wrap?: boolean;
  70466. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70467. /**
  70468. * Creates a tube mesh.
  70469. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70470. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70471. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70472. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70473. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70474. * * 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)
  70475. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70476. * * 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
  70477. * * 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
  70478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70482. * @param name defines the name of the mesh
  70483. * @param options defines the options used to create the mesh
  70484. * @param scene defines the hosting scene
  70485. * @returns the tube mesh
  70486. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70487. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70488. */
  70489. static CreateTube(name: string, options: {
  70490. path: Vector3[];
  70491. radius?: number;
  70492. tessellation?: number;
  70493. radiusFunction?: {
  70494. (i: number, distance: number): number;
  70495. };
  70496. cap?: number;
  70497. arc?: number;
  70498. updatable?: boolean;
  70499. sideOrientation?: number;
  70500. frontUVs?: Vector4;
  70501. backUVs?: Vector4;
  70502. instance?: Mesh;
  70503. invertUV?: boolean;
  70504. }, scene?: Nullable<Scene>): Mesh;
  70505. /**
  70506. * Creates a polyhedron mesh
  70507. * * 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
  70508. * * The parameter `size` (positive float, default 1) sets the polygon size
  70509. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70510. * * 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`
  70511. * * 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
  70512. * * 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)`)
  70513. * * 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
  70514. * * 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
  70515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70518. * @param name defines the name of the mesh
  70519. * @param options defines the options used to create the mesh
  70520. * @param scene defines the hosting scene
  70521. * @returns the polyhedron mesh
  70522. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70523. */
  70524. static CreatePolyhedron(name: string, options: {
  70525. type?: number;
  70526. size?: number;
  70527. sizeX?: number;
  70528. sizeY?: number;
  70529. sizeZ?: number;
  70530. custom?: any;
  70531. faceUV?: Vector4[];
  70532. faceColors?: Color4[];
  70533. flat?: boolean;
  70534. updatable?: boolean;
  70535. sideOrientation?: number;
  70536. frontUVs?: Vector4;
  70537. backUVs?: Vector4;
  70538. }, scene?: Nullable<Scene>): Mesh;
  70539. /**
  70540. * Creates a decal mesh.
  70541. * 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
  70542. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70543. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70544. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70545. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70546. * @param name defines the name of the mesh
  70547. * @param sourceMesh defines the mesh where the decal must be applied
  70548. * @param options defines the options used to create the mesh
  70549. * @param scene defines the hosting scene
  70550. * @returns the decal mesh
  70551. * @see https://doc.babylonjs.com/how_to/decals
  70552. */
  70553. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70554. position?: Vector3;
  70555. normal?: Vector3;
  70556. size?: Vector3;
  70557. angle?: number;
  70558. }): Mesh;
  70559. /**
  70560. * Creates a Capsule Mesh
  70561. * @param name defines the name of the mesh.
  70562. * @param options the constructors options used to shape the mesh.
  70563. * @param scene defines the scene the mesh is scoped to.
  70564. * @returns the capsule mesh
  70565. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70566. */
  70567. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70568. }
  70569. }
  70570. declare module "babylonjs/Meshes/meshSimplification" {
  70571. import { Mesh } from "babylonjs/Meshes/mesh";
  70572. /**
  70573. * A simplifier interface for future simplification implementations
  70574. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70575. */
  70576. export interface ISimplifier {
  70577. /**
  70578. * Simplification of a given mesh according to the given settings.
  70579. * Since this requires computation, it is assumed that the function runs async.
  70580. * @param settings The settings of the simplification, including quality and distance
  70581. * @param successCallback A callback that will be called after the mesh was simplified.
  70582. * @param errorCallback in case of an error, this callback will be called. optional.
  70583. */
  70584. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70585. }
  70586. /**
  70587. * Expected simplification settings.
  70588. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70589. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70590. */
  70591. export interface ISimplificationSettings {
  70592. /**
  70593. * Gets or sets the expected quality
  70594. */
  70595. quality: number;
  70596. /**
  70597. * Gets or sets the distance when this optimized version should be used
  70598. */
  70599. distance: number;
  70600. /**
  70601. * Gets an already optimized mesh
  70602. */
  70603. optimizeMesh?: boolean;
  70604. }
  70605. /**
  70606. * Class used to specify simplification options
  70607. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70608. */
  70609. export class SimplificationSettings implements ISimplificationSettings {
  70610. /** expected quality */
  70611. quality: number;
  70612. /** distance when this optimized version should be used */
  70613. distance: number;
  70614. /** already optimized mesh */
  70615. optimizeMesh?: boolean | undefined;
  70616. /**
  70617. * Creates a SimplificationSettings
  70618. * @param quality expected quality
  70619. * @param distance distance when this optimized version should be used
  70620. * @param optimizeMesh already optimized mesh
  70621. */
  70622. constructor(
  70623. /** expected quality */
  70624. quality: number,
  70625. /** distance when this optimized version should be used */
  70626. distance: number,
  70627. /** already optimized mesh */
  70628. optimizeMesh?: boolean | undefined);
  70629. }
  70630. /**
  70631. * Interface used to define a simplification task
  70632. */
  70633. export interface ISimplificationTask {
  70634. /**
  70635. * Array of settings
  70636. */
  70637. settings: Array<ISimplificationSettings>;
  70638. /**
  70639. * Simplification type
  70640. */
  70641. simplificationType: SimplificationType;
  70642. /**
  70643. * Mesh to simplify
  70644. */
  70645. mesh: Mesh;
  70646. /**
  70647. * Callback called on success
  70648. */
  70649. successCallback?: () => void;
  70650. /**
  70651. * Defines if parallel processing can be used
  70652. */
  70653. parallelProcessing: boolean;
  70654. }
  70655. /**
  70656. * Queue used to order the simplification tasks
  70657. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70658. */
  70659. export class SimplificationQueue {
  70660. private _simplificationArray;
  70661. /**
  70662. * Gets a boolean indicating that the process is still running
  70663. */
  70664. running: boolean;
  70665. /**
  70666. * Creates a new queue
  70667. */
  70668. constructor();
  70669. /**
  70670. * Adds a new simplification task
  70671. * @param task defines a task to add
  70672. */
  70673. addTask(task: ISimplificationTask): void;
  70674. /**
  70675. * Execute next task
  70676. */
  70677. executeNext(): void;
  70678. /**
  70679. * Execute a simplification task
  70680. * @param task defines the task to run
  70681. */
  70682. runSimplification(task: ISimplificationTask): void;
  70683. private getSimplifier;
  70684. }
  70685. /**
  70686. * The implemented types of simplification
  70687. * At the moment only Quadratic Error Decimation is implemented
  70688. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70689. */
  70690. export enum SimplificationType {
  70691. /** Quadratic error decimation */
  70692. QUADRATIC = 0
  70693. }
  70694. /**
  70695. * An implementation of the Quadratic Error simplification algorithm.
  70696. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70697. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70698. * @author RaananW
  70699. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70700. */
  70701. export class QuadraticErrorSimplification implements ISimplifier {
  70702. private _mesh;
  70703. private triangles;
  70704. private vertices;
  70705. private references;
  70706. private _reconstructedMesh;
  70707. /** Gets or sets the number pf sync interations */
  70708. syncIterations: number;
  70709. /** Gets or sets the aggressiveness of the simplifier */
  70710. aggressiveness: number;
  70711. /** Gets or sets the number of allowed iterations for decimation */
  70712. decimationIterations: number;
  70713. /** Gets or sets the espilon to use for bounding box computation */
  70714. boundingBoxEpsilon: number;
  70715. /**
  70716. * Creates a new QuadraticErrorSimplification
  70717. * @param _mesh defines the target mesh
  70718. */
  70719. constructor(_mesh: Mesh);
  70720. /**
  70721. * Simplification of a given mesh according to the given settings.
  70722. * Since this requires computation, it is assumed that the function runs async.
  70723. * @param settings The settings of the simplification, including quality and distance
  70724. * @param successCallback A callback that will be called after the mesh was simplified.
  70725. */
  70726. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70727. private runDecimation;
  70728. private initWithMesh;
  70729. private init;
  70730. private reconstructMesh;
  70731. private initDecimatedMesh;
  70732. private isFlipped;
  70733. private updateTriangles;
  70734. private identifyBorder;
  70735. private updateMesh;
  70736. private vertexError;
  70737. private calculateError;
  70738. }
  70739. }
  70740. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70741. import { Scene } from "babylonjs/scene";
  70742. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70743. import { ISceneComponent } from "babylonjs/sceneComponent";
  70744. module "babylonjs/scene" {
  70745. interface Scene {
  70746. /** @hidden (Backing field) */
  70747. _simplificationQueue: SimplificationQueue;
  70748. /**
  70749. * Gets or sets the simplification queue attached to the scene
  70750. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70751. */
  70752. simplificationQueue: SimplificationQueue;
  70753. }
  70754. }
  70755. module "babylonjs/Meshes/mesh" {
  70756. interface Mesh {
  70757. /**
  70758. * Simplify the mesh according to the given array of settings.
  70759. * Function will return immediately and will simplify async
  70760. * @param settings a collection of simplification settings
  70761. * @param parallelProcessing should all levels calculate parallel or one after the other
  70762. * @param simplificationType the type of simplification to run
  70763. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70764. * @returns the current mesh
  70765. */
  70766. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70767. }
  70768. }
  70769. /**
  70770. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70771. * created in a scene
  70772. */
  70773. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70774. /**
  70775. * The component name helpfull to identify the component in the list of scene components.
  70776. */
  70777. readonly name: string;
  70778. /**
  70779. * The scene the component belongs to.
  70780. */
  70781. scene: Scene;
  70782. /**
  70783. * Creates a new instance of the component for the given scene
  70784. * @param scene Defines the scene to register the component in
  70785. */
  70786. constructor(scene: Scene);
  70787. /**
  70788. * Registers the component in a given scene
  70789. */
  70790. register(): void;
  70791. /**
  70792. * Rebuilds the elements related to this component in case of
  70793. * context lost for instance.
  70794. */
  70795. rebuild(): void;
  70796. /**
  70797. * Disposes the component and the associated ressources
  70798. */
  70799. dispose(): void;
  70800. private _beforeCameraUpdate;
  70801. }
  70802. }
  70803. declare module "babylonjs/Meshes/Builders/index" {
  70804. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70805. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70806. export * from "babylonjs/Meshes/Builders/discBuilder";
  70807. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70808. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70809. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70810. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70811. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70812. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70813. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70814. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70815. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70816. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70817. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70818. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70819. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70820. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70821. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70822. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70823. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70824. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70825. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70826. }
  70827. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70828. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70829. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70830. import { Matrix } from "babylonjs/Maths/math.vector";
  70831. module "babylonjs/Meshes/mesh" {
  70832. interface Mesh {
  70833. /**
  70834. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70835. */
  70836. thinInstanceEnablePicking: boolean;
  70837. /**
  70838. * Creates a new thin instance
  70839. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70840. * @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
  70841. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70842. */
  70843. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70844. /**
  70845. * Adds the transformation (matrix) of the current mesh as a thin instance
  70846. * @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
  70847. * @returns the thin instance index number
  70848. */
  70849. thinInstanceAddSelf(refresh: boolean): number;
  70850. /**
  70851. * Registers a custom attribute to be used with thin instances
  70852. * @param kind name of the attribute
  70853. * @param stride size in floats of the attribute
  70854. */
  70855. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70856. /**
  70857. * Sets the matrix of a thin instance
  70858. * @param index index of the thin instance
  70859. * @param matrix matrix to set
  70860. * @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
  70861. */
  70862. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70863. /**
  70864. * Sets the value of a custom attribute for a thin instance
  70865. * @param kind name of the attribute
  70866. * @param index index of the thin instance
  70867. * @param value value to set
  70868. * @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
  70869. */
  70870. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70871. /**
  70872. * 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.
  70873. */
  70874. thinInstanceCount: number;
  70875. /**
  70876. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70877. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70878. * @param buffer buffer to set
  70879. * @param stride size in floats of each value of the buffer
  70880. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70881. */
  70882. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70883. /**
  70884. * Gets the list of world matrices
  70885. * @return an array containing all the world matrices from the thin instances
  70886. */
  70887. thinInstanceGetWorldMatrices(): Matrix[];
  70888. /**
  70889. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70890. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70891. */
  70892. thinInstanceBufferUpdated(kind: string): void;
  70893. /**
  70894. * Applies a partial update to a buffer directly on the GPU
  70895. * 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
  70896. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70897. * @param data the data to set in the GPU buffer
  70898. * @param offset the offset in the GPU buffer where to update the data
  70899. */
  70900. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70901. /**
  70902. * Refreshes the bounding info, taking into account all the thin instances defined
  70903. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70904. */
  70905. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70906. /** @hidden */
  70907. _thinInstanceInitializeUserStorage(): void;
  70908. /** @hidden */
  70909. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70910. /** @hidden */
  70911. _userThinInstanceBuffersStorage: {
  70912. data: {
  70913. [key: string]: Float32Array;
  70914. };
  70915. sizes: {
  70916. [key: string]: number;
  70917. };
  70918. vertexBuffers: {
  70919. [key: string]: Nullable<VertexBuffer>;
  70920. };
  70921. strides: {
  70922. [key: string]: number;
  70923. };
  70924. };
  70925. }
  70926. }
  70927. }
  70928. declare module "babylonjs/Meshes/index" {
  70929. export * from "babylonjs/Meshes/abstractMesh";
  70930. export * from "babylonjs/Meshes/buffer";
  70931. export * from "babylonjs/Meshes/Compression/index";
  70932. export * from "babylonjs/Meshes/csg";
  70933. export * from "babylonjs/Meshes/geometry";
  70934. export * from "babylonjs/Meshes/groundMesh";
  70935. export * from "babylonjs/Meshes/trailMesh";
  70936. export * from "babylonjs/Meshes/instancedMesh";
  70937. export * from "babylonjs/Meshes/linesMesh";
  70938. export * from "babylonjs/Meshes/mesh";
  70939. export * from "babylonjs/Meshes/mesh.vertexData";
  70940. export * from "babylonjs/Meshes/meshBuilder";
  70941. export * from "babylonjs/Meshes/meshSimplification";
  70942. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70943. export * from "babylonjs/Meshes/polygonMesh";
  70944. export * from "babylonjs/Meshes/subMesh";
  70945. export * from "babylonjs/Meshes/meshLODLevel";
  70946. export * from "babylonjs/Meshes/transformNode";
  70947. export * from "babylonjs/Meshes/Builders/index";
  70948. export * from "babylonjs/Meshes/dataBuffer";
  70949. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70950. import "babylonjs/Meshes/thinInstanceMesh";
  70951. export * from "babylonjs/Meshes/thinInstanceMesh";
  70952. }
  70953. declare module "babylonjs/Morph/index" {
  70954. export * from "babylonjs/Morph/morphTarget";
  70955. export * from "babylonjs/Morph/morphTargetManager";
  70956. }
  70957. declare module "babylonjs/Navigation/INavigationEngine" {
  70958. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70959. import { Vector3 } from "babylonjs/Maths/math";
  70960. import { Mesh } from "babylonjs/Meshes/mesh";
  70961. import { Scene } from "babylonjs/scene";
  70962. /**
  70963. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70964. */
  70965. export interface INavigationEnginePlugin {
  70966. /**
  70967. * plugin name
  70968. */
  70969. name: string;
  70970. /**
  70971. * Creates a navigation mesh
  70972. * @param meshes array of all the geometry used to compute the navigatio mesh
  70973. * @param parameters bunch of parameters used to filter geometry
  70974. */
  70975. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70976. /**
  70977. * Create a navigation mesh debug mesh
  70978. * @param scene is where the mesh will be added
  70979. * @returns debug display mesh
  70980. */
  70981. createDebugNavMesh(scene: Scene): Mesh;
  70982. /**
  70983. * Get a navigation mesh constrained position, closest to the parameter position
  70984. * @param position world position
  70985. * @returns the closest point to position constrained by the navigation mesh
  70986. */
  70987. getClosestPoint(position: Vector3): Vector3;
  70988. /**
  70989. * Get a navigation mesh constrained position, closest to the parameter position
  70990. * @param position world position
  70991. * @param result output the closest point to position constrained by the navigation mesh
  70992. */
  70993. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70994. /**
  70995. * Get a navigation mesh constrained position, within a particular radius
  70996. * @param position world position
  70997. * @param maxRadius the maximum distance to the constrained world position
  70998. * @returns the closest point to position constrained by the navigation mesh
  70999. */
  71000. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71001. /**
  71002. * Get a navigation mesh constrained position, within a particular radius
  71003. * @param position world position
  71004. * @param maxRadius the maximum distance to the constrained world position
  71005. * @param result output the closest point to position constrained by the navigation mesh
  71006. */
  71007. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71008. /**
  71009. * Compute the final position from a segment made of destination-position
  71010. * @param position world position
  71011. * @param destination world position
  71012. * @returns the resulting point along the navmesh
  71013. */
  71014. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71015. /**
  71016. * Compute the final position from a segment made of destination-position
  71017. * @param position world position
  71018. * @param destination world position
  71019. * @param result output the resulting point along the navmesh
  71020. */
  71021. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71022. /**
  71023. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71024. * @param start world position
  71025. * @param end world position
  71026. * @returns array containing world position composing the path
  71027. */
  71028. computePath(start: Vector3, end: Vector3): Vector3[];
  71029. /**
  71030. * If this plugin is supported
  71031. * @returns true if plugin is supported
  71032. */
  71033. isSupported(): boolean;
  71034. /**
  71035. * Create a new Crowd so you can add agents
  71036. * @param maxAgents the maximum agent count in the crowd
  71037. * @param maxAgentRadius the maximum radius an agent can have
  71038. * @param scene to attach the crowd to
  71039. * @returns the crowd you can add agents to
  71040. */
  71041. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71042. /**
  71043. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71044. * The queries will try to find a solution within those bounds
  71045. * default is (1,1,1)
  71046. * @param extent x,y,z value that define the extent around the queries point of reference
  71047. */
  71048. setDefaultQueryExtent(extent: Vector3): void;
  71049. /**
  71050. * Get the Bounding box extent specified by setDefaultQueryExtent
  71051. * @returns the box extent values
  71052. */
  71053. getDefaultQueryExtent(): Vector3;
  71054. /**
  71055. * build the navmesh from a previously saved state using getNavmeshData
  71056. * @param data the Uint8Array returned by getNavmeshData
  71057. */
  71058. buildFromNavmeshData(data: Uint8Array): void;
  71059. /**
  71060. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71061. * @returns data the Uint8Array that can be saved and reused
  71062. */
  71063. getNavmeshData(): Uint8Array;
  71064. /**
  71065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71066. * @param result output the box extent values
  71067. */
  71068. getDefaultQueryExtentToRef(result: Vector3): void;
  71069. /**
  71070. * Release all resources
  71071. */
  71072. dispose(): void;
  71073. }
  71074. /**
  71075. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71076. */
  71077. export interface ICrowd {
  71078. /**
  71079. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71080. * You can attach anything to that node. The node position is updated in the scene update tick.
  71081. * @param pos world position that will be constrained by the navigation mesh
  71082. * @param parameters agent parameters
  71083. * @param transform hooked to the agent that will be update by the scene
  71084. * @returns agent index
  71085. */
  71086. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71087. /**
  71088. * Returns the agent position in world space
  71089. * @param index agent index returned by addAgent
  71090. * @returns world space position
  71091. */
  71092. getAgentPosition(index: number): Vector3;
  71093. /**
  71094. * Gets the agent position result in world space
  71095. * @param index agent index returned by addAgent
  71096. * @param result output world space position
  71097. */
  71098. getAgentPositionToRef(index: number, result: Vector3): void;
  71099. /**
  71100. * Gets the agent velocity in world space
  71101. * @param index agent index returned by addAgent
  71102. * @returns world space velocity
  71103. */
  71104. getAgentVelocity(index: number): Vector3;
  71105. /**
  71106. * Gets the agent velocity result in world space
  71107. * @param index agent index returned by addAgent
  71108. * @param result output world space velocity
  71109. */
  71110. getAgentVelocityToRef(index: number, result: Vector3): void;
  71111. /**
  71112. * remove a particular agent previously created
  71113. * @param index agent index returned by addAgent
  71114. */
  71115. removeAgent(index: number): void;
  71116. /**
  71117. * get the list of all agents attached to this crowd
  71118. * @returns list of agent indices
  71119. */
  71120. getAgents(): number[];
  71121. /**
  71122. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71123. * @param deltaTime in seconds
  71124. */
  71125. update(deltaTime: number): void;
  71126. /**
  71127. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71128. * @param index agent index returned by addAgent
  71129. * @param destination targeted world position
  71130. */
  71131. agentGoto(index: number, destination: Vector3): void;
  71132. /**
  71133. * Teleport the agent to a new position
  71134. * @param index agent index returned by addAgent
  71135. * @param destination targeted world position
  71136. */
  71137. agentTeleport(index: number, destination: Vector3): void;
  71138. /**
  71139. * Update agent parameters
  71140. * @param index agent index returned by addAgent
  71141. * @param parameters agent parameters
  71142. */
  71143. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71144. /**
  71145. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71146. * The queries will try to find a solution within those bounds
  71147. * default is (1,1,1)
  71148. * @param extent x,y,z value that define the extent around the queries point of reference
  71149. */
  71150. setDefaultQueryExtent(extent: Vector3): void;
  71151. /**
  71152. * Get the Bounding box extent specified by setDefaultQueryExtent
  71153. * @returns the box extent values
  71154. */
  71155. getDefaultQueryExtent(): Vector3;
  71156. /**
  71157. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71158. * @param result output the box extent values
  71159. */
  71160. getDefaultQueryExtentToRef(result: Vector3): void;
  71161. /**
  71162. * Release all resources
  71163. */
  71164. dispose(): void;
  71165. }
  71166. /**
  71167. * Configures an agent
  71168. */
  71169. export interface IAgentParameters {
  71170. /**
  71171. * Agent radius. [Limit: >= 0]
  71172. */
  71173. radius: number;
  71174. /**
  71175. * Agent height. [Limit: > 0]
  71176. */
  71177. height: number;
  71178. /**
  71179. * Maximum allowed acceleration. [Limit: >= 0]
  71180. */
  71181. maxAcceleration: number;
  71182. /**
  71183. * Maximum allowed speed. [Limit: >= 0]
  71184. */
  71185. maxSpeed: number;
  71186. /**
  71187. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71188. */
  71189. collisionQueryRange: number;
  71190. /**
  71191. * The path visibility optimization range. [Limit: > 0]
  71192. */
  71193. pathOptimizationRange: number;
  71194. /**
  71195. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71196. */
  71197. separationWeight: number;
  71198. }
  71199. /**
  71200. * Configures the navigation mesh creation
  71201. */
  71202. export interface INavMeshParameters {
  71203. /**
  71204. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71205. */
  71206. cs: number;
  71207. /**
  71208. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71209. */
  71210. ch: number;
  71211. /**
  71212. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71213. */
  71214. walkableSlopeAngle: number;
  71215. /**
  71216. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71217. * be considered walkable. [Limit: >= 3] [Units: vx]
  71218. */
  71219. walkableHeight: number;
  71220. /**
  71221. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71222. */
  71223. walkableClimb: number;
  71224. /**
  71225. * The distance to erode/shrink the walkable area of the heightfield away from
  71226. * obstructions. [Limit: >=0] [Units: vx]
  71227. */
  71228. walkableRadius: number;
  71229. /**
  71230. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71231. */
  71232. maxEdgeLen: number;
  71233. /**
  71234. * The maximum distance a simplfied contour's border edges should deviate
  71235. * the original raw contour. [Limit: >=0] [Units: vx]
  71236. */
  71237. maxSimplificationError: number;
  71238. /**
  71239. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71240. */
  71241. minRegionArea: number;
  71242. /**
  71243. * Any regions with a span count smaller than this value will, if possible,
  71244. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71245. */
  71246. mergeRegionArea: number;
  71247. /**
  71248. * The maximum number of vertices allowed for polygons generated during the
  71249. * contour to polygon conversion process. [Limit: >= 3]
  71250. */
  71251. maxVertsPerPoly: number;
  71252. /**
  71253. * Sets the sampling distance to use when generating the detail mesh.
  71254. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71255. */
  71256. detailSampleDist: number;
  71257. /**
  71258. * The maximum distance the detail mesh surface should deviate from heightfield
  71259. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71260. */
  71261. detailSampleMaxError: number;
  71262. }
  71263. }
  71264. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71265. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71266. import { Mesh } from "babylonjs/Meshes/mesh";
  71267. import { Scene } from "babylonjs/scene";
  71268. import { Vector3 } from "babylonjs/Maths/math";
  71269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71270. /**
  71271. * RecastJS navigation plugin
  71272. */
  71273. export class RecastJSPlugin implements INavigationEnginePlugin {
  71274. /**
  71275. * Reference to the Recast library
  71276. */
  71277. bjsRECAST: any;
  71278. /**
  71279. * plugin name
  71280. */
  71281. name: string;
  71282. /**
  71283. * the first navmesh created. We might extend this to support multiple navmeshes
  71284. */
  71285. navMesh: any;
  71286. /**
  71287. * Initializes the recastJS plugin
  71288. * @param recastInjection can be used to inject your own recast reference
  71289. */
  71290. constructor(recastInjection?: any);
  71291. /**
  71292. * Creates a navigation mesh
  71293. * @param meshes array of all the geometry used to compute the navigatio mesh
  71294. * @param parameters bunch of parameters used to filter geometry
  71295. */
  71296. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71297. /**
  71298. * Create a navigation mesh debug mesh
  71299. * @param scene is where the mesh will be added
  71300. * @returns debug display mesh
  71301. */
  71302. createDebugNavMesh(scene: Scene): Mesh;
  71303. /**
  71304. * Get a navigation mesh constrained position, closest to the parameter position
  71305. * @param position world position
  71306. * @returns the closest point to position constrained by the navigation mesh
  71307. */
  71308. getClosestPoint(position: Vector3): Vector3;
  71309. /**
  71310. * Get a navigation mesh constrained position, closest to the parameter position
  71311. * @param position world position
  71312. * @param result output the closest point to position constrained by the navigation mesh
  71313. */
  71314. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71315. /**
  71316. * Get a navigation mesh constrained position, within a particular radius
  71317. * @param position world position
  71318. * @param maxRadius the maximum distance to the constrained world position
  71319. * @returns the closest point to position constrained by the navigation mesh
  71320. */
  71321. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71322. /**
  71323. * Get a navigation mesh constrained position, within a particular radius
  71324. * @param position world position
  71325. * @param maxRadius the maximum distance to the constrained world position
  71326. * @param result output the closest point to position constrained by the navigation mesh
  71327. */
  71328. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71329. /**
  71330. * Compute the final position from a segment made of destination-position
  71331. * @param position world position
  71332. * @param destination world position
  71333. * @returns the resulting point along the navmesh
  71334. */
  71335. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71336. /**
  71337. * Compute the final position from a segment made of destination-position
  71338. * @param position world position
  71339. * @param destination world position
  71340. * @param result output the resulting point along the navmesh
  71341. */
  71342. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71343. /**
  71344. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71345. * @param start world position
  71346. * @param end world position
  71347. * @returns array containing world position composing the path
  71348. */
  71349. computePath(start: Vector3, end: Vector3): Vector3[];
  71350. /**
  71351. * Create a new Crowd so you can add agents
  71352. * @param maxAgents the maximum agent count in the crowd
  71353. * @param maxAgentRadius the maximum radius an agent can have
  71354. * @param scene to attach the crowd to
  71355. * @returns the crowd you can add agents to
  71356. */
  71357. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71358. /**
  71359. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71360. * The queries will try to find a solution within those bounds
  71361. * default is (1,1,1)
  71362. * @param extent x,y,z value that define the extent around the queries point of reference
  71363. */
  71364. setDefaultQueryExtent(extent: Vector3): void;
  71365. /**
  71366. * Get the Bounding box extent specified by setDefaultQueryExtent
  71367. * @returns the box extent values
  71368. */
  71369. getDefaultQueryExtent(): Vector3;
  71370. /**
  71371. * build the navmesh from a previously saved state using getNavmeshData
  71372. * @param data the Uint8Array returned by getNavmeshData
  71373. */
  71374. buildFromNavmeshData(data: Uint8Array): void;
  71375. /**
  71376. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71377. * @returns data the Uint8Array that can be saved and reused
  71378. */
  71379. getNavmeshData(): Uint8Array;
  71380. /**
  71381. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71382. * @param result output the box extent values
  71383. */
  71384. getDefaultQueryExtentToRef(result: Vector3): void;
  71385. /**
  71386. * Disposes
  71387. */
  71388. dispose(): void;
  71389. /**
  71390. * If this plugin is supported
  71391. * @returns true if plugin is supported
  71392. */
  71393. isSupported(): boolean;
  71394. }
  71395. /**
  71396. * Recast detour crowd implementation
  71397. */
  71398. export class RecastJSCrowd implements ICrowd {
  71399. /**
  71400. * Recast/detour plugin
  71401. */
  71402. bjsRECASTPlugin: RecastJSPlugin;
  71403. /**
  71404. * Link to the detour crowd
  71405. */
  71406. recastCrowd: any;
  71407. /**
  71408. * One transform per agent
  71409. */
  71410. transforms: TransformNode[];
  71411. /**
  71412. * All agents created
  71413. */
  71414. agents: number[];
  71415. /**
  71416. * Link to the scene is kept to unregister the crowd from the scene
  71417. */
  71418. private _scene;
  71419. /**
  71420. * Observer for crowd updates
  71421. */
  71422. private _onBeforeAnimationsObserver;
  71423. /**
  71424. * Constructor
  71425. * @param plugin recastJS plugin
  71426. * @param maxAgents the maximum agent count in the crowd
  71427. * @param maxAgentRadius the maximum radius an agent can have
  71428. * @param scene to attach the crowd to
  71429. * @returns the crowd you can add agents to
  71430. */
  71431. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71432. /**
  71433. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71434. * You can attach anything to that node. The node position is updated in the scene update tick.
  71435. * @param pos world position that will be constrained by the navigation mesh
  71436. * @param parameters agent parameters
  71437. * @param transform hooked to the agent that will be update by the scene
  71438. * @returns agent index
  71439. */
  71440. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71441. /**
  71442. * Returns the agent position in world space
  71443. * @param index agent index returned by addAgent
  71444. * @returns world space position
  71445. */
  71446. getAgentPosition(index: number): Vector3;
  71447. /**
  71448. * Returns the agent position result in world space
  71449. * @param index agent index returned by addAgent
  71450. * @param result output world space position
  71451. */
  71452. getAgentPositionToRef(index: number, result: Vector3): void;
  71453. /**
  71454. * Returns the agent velocity in world space
  71455. * @param index agent index returned by addAgent
  71456. * @returns world space velocity
  71457. */
  71458. getAgentVelocity(index: number): Vector3;
  71459. /**
  71460. * Returns the agent velocity result in world space
  71461. * @param index agent index returned by addAgent
  71462. * @param result output world space velocity
  71463. */
  71464. getAgentVelocityToRef(index: number, result: Vector3): void;
  71465. /**
  71466. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71467. * @param index agent index returned by addAgent
  71468. * @param destination targeted world position
  71469. */
  71470. agentGoto(index: number, destination: Vector3): void;
  71471. /**
  71472. * Teleport the agent to a new position
  71473. * @param index agent index returned by addAgent
  71474. * @param destination targeted world position
  71475. */
  71476. agentTeleport(index: number, destination: Vector3): void;
  71477. /**
  71478. * Update agent parameters
  71479. * @param index agent index returned by addAgent
  71480. * @param parameters agent parameters
  71481. */
  71482. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71483. /**
  71484. * remove a particular agent previously created
  71485. * @param index agent index returned by addAgent
  71486. */
  71487. removeAgent(index: number): void;
  71488. /**
  71489. * get the list of all agents attached to this crowd
  71490. * @returns list of agent indices
  71491. */
  71492. getAgents(): number[];
  71493. /**
  71494. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71495. * @param deltaTime in seconds
  71496. */
  71497. update(deltaTime: number): void;
  71498. /**
  71499. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71500. * The queries will try to find a solution within those bounds
  71501. * default is (1,1,1)
  71502. * @param extent x,y,z value that define the extent around the queries point of reference
  71503. */
  71504. setDefaultQueryExtent(extent: Vector3): void;
  71505. /**
  71506. * Get the Bounding box extent specified by setDefaultQueryExtent
  71507. * @returns the box extent values
  71508. */
  71509. getDefaultQueryExtent(): Vector3;
  71510. /**
  71511. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71512. * @param result output the box extent values
  71513. */
  71514. getDefaultQueryExtentToRef(result: Vector3): void;
  71515. /**
  71516. * Release all resources
  71517. */
  71518. dispose(): void;
  71519. }
  71520. }
  71521. declare module "babylonjs/Navigation/Plugins/index" {
  71522. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71523. }
  71524. declare module "babylonjs/Navigation/index" {
  71525. export * from "babylonjs/Navigation/INavigationEngine";
  71526. export * from "babylonjs/Navigation/Plugins/index";
  71527. }
  71528. declare module "babylonjs/Offline/database" {
  71529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71530. /**
  71531. * Class used to enable access to IndexedDB
  71532. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71533. */
  71534. export class Database implements IOfflineProvider {
  71535. private _callbackManifestChecked;
  71536. private _currentSceneUrl;
  71537. private _db;
  71538. private _enableSceneOffline;
  71539. private _enableTexturesOffline;
  71540. private _manifestVersionFound;
  71541. private _mustUpdateRessources;
  71542. private _hasReachedQuota;
  71543. private _isSupported;
  71544. private _idbFactory;
  71545. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71546. private static IsUASupportingBlobStorage;
  71547. /**
  71548. * Gets a boolean indicating if Database storate is enabled (off by default)
  71549. */
  71550. static IDBStorageEnabled: boolean;
  71551. /**
  71552. * Gets a boolean indicating if scene must be saved in the database
  71553. */
  71554. get enableSceneOffline(): boolean;
  71555. /**
  71556. * Gets a boolean indicating if textures must be saved in the database
  71557. */
  71558. get enableTexturesOffline(): boolean;
  71559. /**
  71560. * Creates a new Database
  71561. * @param urlToScene defines the url to load the scene
  71562. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71563. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71564. */
  71565. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71566. private static _ParseURL;
  71567. private static _ReturnFullUrlLocation;
  71568. private _checkManifestFile;
  71569. /**
  71570. * Open the database and make it available
  71571. * @param successCallback defines the callback to call on success
  71572. * @param errorCallback defines the callback to call on error
  71573. */
  71574. open(successCallback: () => void, errorCallback: () => void): void;
  71575. /**
  71576. * Loads an image from the database
  71577. * @param url defines the url to load from
  71578. * @param image defines the target DOM image
  71579. */
  71580. loadImage(url: string, image: HTMLImageElement): void;
  71581. private _loadImageFromDBAsync;
  71582. private _saveImageIntoDBAsync;
  71583. private _checkVersionFromDB;
  71584. private _loadVersionFromDBAsync;
  71585. private _saveVersionIntoDBAsync;
  71586. /**
  71587. * Loads a file from database
  71588. * @param url defines the URL to load from
  71589. * @param sceneLoaded defines a callback to call on success
  71590. * @param progressCallBack defines a callback to call when progress changed
  71591. * @param errorCallback defines a callback to call on error
  71592. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71593. */
  71594. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71595. private _loadFileAsync;
  71596. private _saveFileAsync;
  71597. /**
  71598. * Validates if xhr data is correct
  71599. * @param xhr defines the request to validate
  71600. * @param dataType defines the expected data type
  71601. * @returns true if data is correct
  71602. */
  71603. private static _ValidateXHRData;
  71604. }
  71605. }
  71606. declare module "babylonjs/Offline/index" {
  71607. export * from "babylonjs/Offline/database";
  71608. export * from "babylonjs/Offline/IOfflineProvider";
  71609. }
  71610. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71611. /** @hidden */
  71612. export var gpuUpdateParticlesPixelShader: {
  71613. name: string;
  71614. shader: string;
  71615. };
  71616. }
  71617. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71618. /** @hidden */
  71619. export var gpuUpdateParticlesVertexShader: {
  71620. name: string;
  71621. shader: string;
  71622. };
  71623. }
  71624. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71625. /** @hidden */
  71626. export var clipPlaneFragmentDeclaration2: {
  71627. name: string;
  71628. shader: string;
  71629. };
  71630. }
  71631. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71632. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71633. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71634. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71635. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71637. /** @hidden */
  71638. export var gpuRenderParticlesPixelShader: {
  71639. name: string;
  71640. shader: string;
  71641. };
  71642. }
  71643. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71644. /** @hidden */
  71645. export var clipPlaneVertexDeclaration2: {
  71646. name: string;
  71647. shader: string;
  71648. };
  71649. }
  71650. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71651. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71652. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71653. /** @hidden */
  71654. export var gpuRenderParticlesVertexShader: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module "babylonjs/Particles/gpuParticleSystem" {
  71660. import { Nullable } from "babylonjs/types";
  71661. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71662. import { Observable } from "babylonjs/Misc/observable";
  71663. import { Matrix } from "babylonjs/Maths/math.vector";
  71664. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71665. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71666. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71667. import { IDisposable } from "babylonjs/scene";
  71668. import { Effect } from "babylonjs/Materials/effect";
  71669. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71671. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71672. import { Scene } from "babylonjs/scene";
  71673. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71674. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71675. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71676. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71677. /**
  71678. * This represents a GPU particle system in Babylon
  71679. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71680. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71681. */
  71682. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71683. /**
  71684. * The layer mask we are rendering the particles through.
  71685. */
  71686. layerMask: number;
  71687. private _capacity;
  71688. private _activeCount;
  71689. private _currentActiveCount;
  71690. private _accumulatedCount;
  71691. private _renderEffect;
  71692. private _updateEffect;
  71693. private _buffer0;
  71694. private _buffer1;
  71695. private _spriteBuffer;
  71696. private _updateVAO;
  71697. private _renderVAO;
  71698. private _targetIndex;
  71699. private _sourceBuffer;
  71700. private _targetBuffer;
  71701. private _currentRenderId;
  71702. private _started;
  71703. private _stopped;
  71704. private _timeDelta;
  71705. private _randomTexture;
  71706. private _randomTexture2;
  71707. private _attributesStrideSize;
  71708. private _updateEffectOptions;
  71709. private _randomTextureSize;
  71710. private _actualFrame;
  71711. private _customEffect;
  71712. private readonly _rawTextureWidth;
  71713. /**
  71714. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71715. */
  71716. static get IsSupported(): boolean;
  71717. /**
  71718. * An event triggered when the system is disposed.
  71719. */
  71720. onDisposeObservable: Observable<IParticleSystem>;
  71721. /**
  71722. * An event triggered when the system is stopped
  71723. */
  71724. onStoppedObservable: Observable<IParticleSystem>;
  71725. /**
  71726. * Gets the maximum number of particles active at the same time.
  71727. * @returns The max number of active particles.
  71728. */
  71729. getCapacity(): number;
  71730. /**
  71731. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71732. * to override the particles.
  71733. */
  71734. forceDepthWrite: boolean;
  71735. /**
  71736. * Gets or set the number of active particles
  71737. */
  71738. get activeParticleCount(): number;
  71739. set activeParticleCount(value: number);
  71740. private _preWarmDone;
  71741. /**
  71742. * Specifies if the particles are updated in emitter local space or world space.
  71743. */
  71744. isLocal: boolean;
  71745. /** Gets or sets a matrix to use to compute projection */
  71746. defaultProjectionMatrix: Matrix;
  71747. /**
  71748. * Is this system ready to be used/rendered
  71749. * @return true if the system is ready
  71750. */
  71751. isReady(): boolean;
  71752. /**
  71753. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71754. * @returns True if it has been started, otherwise false.
  71755. */
  71756. isStarted(): boolean;
  71757. /**
  71758. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71759. * @returns True if it has been stopped, otherwise false.
  71760. */
  71761. isStopped(): boolean;
  71762. /**
  71763. * Gets a boolean indicating that the system is stopping
  71764. * @returns true if the system is currently stopping
  71765. */
  71766. isStopping(): boolean;
  71767. /**
  71768. * Gets the number of particles active at the same time.
  71769. * @returns The number of active particles.
  71770. */
  71771. getActiveCount(): number;
  71772. /**
  71773. * Starts the particle system and begins to emit
  71774. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71775. */
  71776. start(delay?: number): void;
  71777. /**
  71778. * Stops the particle system.
  71779. */
  71780. stop(): void;
  71781. /**
  71782. * Remove all active particles
  71783. */
  71784. reset(): void;
  71785. /**
  71786. * Returns the string "GPUParticleSystem"
  71787. * @returns a string containing the class name
  71788. */
  71789. getClassName(): string;
  71790. /**
  71791. * Gets the custom effect used to render the particles
  71792. * @param blendMode Blend mode for which the effect should be retrieved
  71793. * @returns The effect
  71794. */
  71795. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71796. /**
  71797. * Sets the custom effect used to render the particles
  71798. * @param effect The effect to set
  71799. * @param blendMode Blend mode for which the effect should be set
  71800. */
  71801. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71802. /** @hidden */
  71803. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71804. /**
  71805. * Observable that will be called just before the particles are drawn
  71806. */
  71807. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71808. /**
  71809. * Gets the name of the particle vertex shader
  71810. */
  71811. get vertexShaderName(): string;
  71812. private _colorGradientsTexture;
  71813. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71814. /**
  71815. * Adds a new color gradient
  71816. * @param gradient defines the gradient to use (between 0 and 1)
  71817. * @param color1 defines the color to affect to the specified gradient
  71818. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71819. * @returns the current particle system
  71820. */
  71821. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71822. private _refreshColorGradient;
  71823. /** Force the system to rebuild all gradients that need to be resync */
  71824. forceRefreshGradients(): void;
  71825. /**
  71826. * Remove a specific color gradient
  71827. * @param gradient defines the gradient to remove
  71828. * @returns the current particle system
  71829. */
  71830. removeColorGradient(gradient: number): GPUParticleSystem;
  71831. private _angularSpeedGradientsTexture;
  71832. private _sizeGradientsTexture;
  71833. private _velocityGradientsTexture;
  71834. private _limitVelocityGradientsTexture;
  71835. private _dragGradientsTexture;
  71836. private _addFactorGradient;
  71837. /**
  71838. * Adds a new size gradient
  71839. * @param gradient defines the gradient to use (between 0 and 1)
  71840. * @param factor defines the size factor to affect to the specified gradient
  71841. * @returns the current particle system
  71842. */
  71843. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71844. /**
  71845. * Remove a specific size gradient
  71846. * @param gradient defines the gradient to remove
  71847. * @returns the current particle system
  71848. */
  71849. removeSizeGradient(gradient: number): GPUParticleSystem;
  71850. private _refreshFactorGradient;
  71851. /**
  71852. * Adds a new angular speed gradient
  71853. * @param gradient defines the gradient to use (between 0 and 1)
  71854. * @param factor defines the angular speed to affect to the specified gradient
  71855. * @returns the current particle system
  71856. */
  71857. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71858. /**
  71859. * Remove a specific angular speed gradient
  71860. * @param gradient defines the gradient to remove
  71861. * @returns the current particle system
  71862. */
  71863. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71864. /**
  71865. * Adds a new velocity gradient
  71866. * @param gradient defines the gradient to use (between 0 and 1)
  71867. * @param factor defines the velocity to affect to the specified gradient
  71868. * @returns the current particle system
  71869. */
  71870. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71871. /**
  71872. * Remove a specific velocity gradient
  71873. * @param gradient defines the gradient to remove
  71874. * @returns the current particle system
  71875. */
  71876. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71877. /**
  71878. * Adds a new limit velocity gradient
  71879. * @param gradient defines the gradient to use (between 0 and 1)
  71880. * @param factor defines the limit velocity value to affect to the specified gradient
  71881. * @returns the current particle system
  71882. */
  71883. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71884. /**
  71885. * Remove a specific limit velocity gradient
  71886. * @param gradient defines the gradient to remove
  71887. * @returns the current particle system
  71888. */
  71889. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71890. /**
  71891. * Adds a new drag gradient
  71892. * @param gradient defines the gradient to use (between 0 and 1)
  71893. * @param factor defines the drag value to affect to the specified gradient
  71894. * @returns the current particle system
  71895. */
  71896. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71897. /**
  71898. * Remove a specific drag gradient
  71899. * @param gradient defines the gradient to remove
  71900. * @returns the current particle system
  71901. */
  71902. removeDragGradient(gradient: number): GPUParticleSystem;
  71903. /**
  71904. * Not supported by GPUParticleSystem
  71905. * @param gradient defines the gradient to use (between 0 and 1)
  71906. * @param factor defines the emit rate value to affect to the specified gradient
  71907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71908. * @returns the current particle system
  71909. */
  71910. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71911. /**
  71912. * Not supported by GPUParticleSystem
  71913. * @param gradient defines the gradient to remove
  71914. * @returns the current particle system
  71915. */
  71916. removeEmitRateGradient(gradient: number): IParticleSystem;
  71917. /**
  71918. * Not supported by GPUParticleSystem
  71919. * @param gradient defines the gradient to use (between 0 and 1)
  71920. * @param factor defines the start size value to affect to the specified gradient
  71921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71922. * @returns the current particle system
  71923. */
  71924. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71925. /**
  71926. * Not supported by GPUParticleSystem
  71927. * @param gradient defines the gradient to remove
  71928. * @returns the current particle system
  71929. */
  71930. removeStartSizeGradient(gradient: number): IParticleSystem;
  71931. /**
  71932. * Not supported by GPUParticleSystem
  71933. * @param gradient defines the gradient to use (between 0 and 1)
  71934. * @param min defines the color remap minimal range
  71935. * @param max defines the color remap maximal range
  71936. * @returns the current particle system
  71937. */
  71938. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71939. /**
  71940. * Not supported by GPUParticleSystem
  71941. * @param gradient defines the gradient to remove
  71942. * @returns the current particle system
  71943. */
  71944. removeColorRemapGradient(): IParticleSystem;
  71945. /**
  71946. * Not supported by GPUParticleSystem
  71947. * @param gradient defines the gradient to use (between 0 and 1)
  71948. * @param min defines the alpha remap minimal range
  71949. * @param max defines the alpha remap maximal range
  71950. * @returns the current particle system
  71951. */
  71952. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71953. /**
  71954. * Not supported by GPUParticleSystem
  71955. * @param gradient defines the gradient to remove
  71956. * @returns the current particle system
  71957. */
  71958. removeAlphaRemapGradient(): IParticleSystem;
  71959. /**
  71960. * Not supported by GPUParticleSystem
  71961. * @param gradient defines the gradient to use (between 0 and 1)
  71962. * @param color defines the color to affect to the specified gradient
  71963. * @returns the current particle system
  71964. */
  71965. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71966. /**
  71967. * Not supported by GPUParticleSystem
  71968. * @param gradient defines the gradient to remove
  71969. * @returns the current particle system
  71970. */
  71971. removeRampGradient(): IParticleSystem;
  71972. /**
  71973. * Not supported by GPUParticleSystem
  71974. * @returns the list of ramp gradients
  71975. */
  71976. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71977. /**
  71978. * Not supported by GPUParticleSystem
  71979. * Gets or sets a boolean indicating that ramp gradients must be used
  71980. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71981. */
  71982. get useRampGradients(): boolean;
  71983. set useRampGradients(value: boolean);
  71984. /**
  71985. * Not supported by GPUParticleSystem
  71986. * @param gradient defines the gradient to use (between 0 and 1)
  71987. * @param factor defines the life time factor to affect to the specified gradient
  71988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71989. * @returns the current particle system
  71990. */
  71991. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71992. /**
  71993. * Not supported by GPUParticleSystem
  71994. * @param gradient defines the gradient to remove
  71995. * @returns the current particle system
  71996. */
  71997. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71998. /**
  71999. * Instantiates a GPU particle system.
  72000. * 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.
  72001. * @param name The name of the particle system
  72002. * @param options The options used to create the system
  72003. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72004. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72005. * @param customEffect a custom effect used to change the way particles are rendered by default
  72006. */
  72007. constructor(name: string, options: Partial<{
  72008. capacity: number;
  72009. randomTextureSize: number;
  72010. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72011. protected _reset(): void;
  72012. private _createUpdateVAO;
  72013. private _createRenderVAO;
  72014. private _initialize;
  72015. /** @hidden */
  72016. _recreateUpdateEffect(): void;
  72017. private _getEffect;
  72018. /**
  72019. * Fill the defines array according to the current settings of the particle system
  72020. * @param defines Array to be updated
  72021. * @param blendMode blend mode to take into account when updating the array
  72022. */
  72023. fillDefines(defines: Array<string>, blendMode?: number): void;
  72024. /**
  72025. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72026. * @param uniforms Uniforms array to fill
  72027. * @param attributes Attributes array to fill
  72028. * @param samplers Samplers array to fill
  72029. */
  72030. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72031. /** @hidden */
  72032. _recreateRenderEffect(): Effect;
  72033. /**
  72034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72035. * @param preWarm defines if we are in the pre-warmimg phase
  72036. */
  72037. animate(preWarm?: boolean): void;
  72038. private _createFactorGradientTexture;
  72039. private _createSizeGradientTexture;
  72040. private _createAngularSpeedGradientTexture;
  72041. private _createVelocityGradientTexture;
  72042. private _createLimitVelocityGradientTexture;
  72043. private _createDragGradientTexture;
  72044. private _createColorGradientTexture;
  72045. /**
  72046. * Renders the particle system in its current state
  72047. * @param preWarm defines if the system should only update the particles but not render them
  72048. * @returns the current number of particles
  72049. */
  72050. render(preWarm?: boolean): number;
  72051. /**
  72052. * Rebuilds the particle system
  72053. */
  72054. rebuild(): void;
  72055. private _releaseBuffers;
  72056. private _releaseVAOs;
  72057. /**
  72058. * Disposes the particle system and free the associated resources
  72059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72060. */
  72061. dispose(disposeTexture?: boolean): void;
  72062. /**
  72063. * Clones the particle system.
  72064. * @param name The name of the cloned object
  72065. * @param newEmitter The new emitter to use
  72066. * @returns the cloned particle system
  72067. */
  72068. clone(name: string, newEmitter: any): GPUParticleSystem;
  72069. /**
  72070. * Serializes the particle system to a JSON object
  72071. * @param serializeTexture defines if the texture must be serialized as well
  72072. * @returns the JSON object
  72073. */
  72074. serialize(serializeTexture?: boolean): any;
  72075. /**
  72076. * Parses a JSON object to create a GPU particle system.
  72077. * @param parsedParticleSystem The JSON object to parse
  72078. * @param sceneOrEngine The scene or the engine to create the particle system in
  72079. * @param rootUrl The root url to use to load external dependencies like texture
  72080. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72081. * @returns the parsed GPU particle system
  72082. */
  72083. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72084. }
  72085. }
  72086. declare module "babylonjs/Particles/particleSystemSet" {
  72087. import { Nullable } from "babylonjs/types";
  72088. import { Color3 } from "babylonjs/Maths/math.color";
  72089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72091. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72092. import { Scene, IDisposable } from "babylonjs/scene";
  72093. /**
  72094. * Represents a set of particle systems working together to create a specific effect
  72095. */
  72096. export class ParticleSystemSet implements IDisposable {
  72097. /**
  72098. * Gets or sets base Assets URL
  72099. */
  72100. static BaseAssetsUrl: string;
  72101. private _emitterCreationOptions;
  72102. private _emitterNode;
  72103. /**
  72104. * Gets the particle system list
  72105. */
  72106. systems: IParticleSystem[];
  72107. /**
  72108. * Gets the emitter node used with this set
  72109. */
  72110. get emitterNode(): Nullable<TransformNode>;
  72111. /**
  72112. * Creates a new emitter mesh as a sphere
  72113. * @param options defines the options used to create the sphere
  72114. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72115. * @param scene defines the hosting scene
  72116. */
  72117. setEmitterAsSphere(options: {
  72118. diameter: number;
  72119. segments: number;
  72120. color: Color3;
  72121. }, renderingGroupId: number, scene: Scene): void;
  72122. /**
  72123. * Starts all particle systems of the set
  72124. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72125. */
  72126. start(emitter?: AbstractMesh): void;
  72127. /**
  72128. * Release all associated resources
  72129. */
  72130. dispose(): void;
  72131. /**
  72132. * Serialize the set into a JSON compatible object
  72133. * @param serializeTexture defines if the texture must be serialized as well
  72134. * @returns a JSON compatible representation of the set
  72135. */
  72136. serialize(serializeTexture?: boolean): any;
  72137. /**
  72138. * Parse a new ParticleSystemSet from a serialized source
  72139. * @param data defines a JSON compatible representation of the set
  72140. * @param scene defines the hosting scene
  72141. * @param gpu defines if we want GPU particles or CPU particles
  72142. * @returns a new ParticleSystemSet
  72143. */
  72144. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72145. }
  72146. }
  72147. declare module "babylonjs/Particles/particleHelper" {
  72148. import { Nullable } from "babylonjs/types";
  72149. import { Scene } from "babylonjs/scene";
  72150. import { Vector3 } from "babylonjs/Maths/math.vector";
  72151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72152. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72153. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72154. /**
  72155. * This class is made for on one-liner static method to help creating particle system set.
  72156. */
  72157. export class ParticleHelper {
  72158. /**
  72159. * Gets or sets base Assets URL
  72160. */
  72161. static BaseAssetsUrl: string;
  72162. /** Define the Url to load snippets */
  72163. static SnippetUrl: string;
  72164. /**
  72165. * Create a default particle system that you can tweak
  72166. * @param emitter defines the emitter to use
  72167. * @param capacity defines the system capacity (default is 500 particles)
  72168. * @param scene defines the hosting scene
  72169. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72170. * @returns the new Particle system
  72171. */
  72172. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72173. /**
  72174. * This is the main static method (one-liner) of this helper to create different particle systems
  72175. * @param type This string represents the type to the particle system to create
  72176. * @param scene The scene where the particle system should live
  72177. * @param gpu If the system will use gpu
  72178. * @returns the ParticleSystemSet created
  72179. */
  72180. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72181. /**
  72182. * Static function used to export a particle system to a ParticleSystemSet variable.
  72183. * Please note that the emitter shape is not exported
  72184. * @param systems defines the particle systems to export
  72185. * @returns the created particle system set
  72186. */
  72187. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72188. /**
  72189. * Creates a particle system from a snippet saved in a remote file
  72190. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72191. * @param url defines the url to load from
  72192. * @param scene defines the hosting scene
  72193. * @param gpu If the system will use gpu
  72194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72195. * @returns a promise that will resolve to the new particle system
  72196. */
  72197. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72198. /**
  72199. * Creates a particle system from a snippet saved by the particle system editor
  72200. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72201. * @param scene defines the hosting scene
  72202. * @param gpu If the system will use gpu
  72203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72204. * @returns a promise that will resolve to the new particle system
  72205. */
  72206. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72207. }
  72208. }
  72209. declare module "babylonjs/Particles/particleSystemComponent" {
  72210. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72211. import { Effect } from "babylonjs/Materials/effect";
  72212. import "babylonjs/Shaders/particles.vertex";
  72213. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72214. module "babylonjs/Engines/engine" {
  72215. interface Engine {
  72216. /**
  72217. * Create an effect to use with particle systems.
  72218. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72219. * the particle system for which you want to create a custom effect in the last parameter
  72220. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72221. * @param uniformsNames defines a list of attribute names
  72222. * @param samplers defines an array of string used to represent textures
  72223. * @param defines defines the string containing the defines to use to compile the shaders
  72224. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72225. * @param onCompiled defines a function to call when the effect creation is successful
  72226. * @param onError defines a function to call when the effect creation has failed
  72227. * @param particleSystem the particle system you want to create the effect for
  72228. * @returns the new Effect
  72229. */
  72230. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72231. }
  72232. }
  72233. module "babylonjs/Meshes/mesh" {
  72234. interface Mesh {
  72235. /**
  72236. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72237. * @returns an array of IParticleSystem
  72238. */
  72239. getEmittedParticleSystems(): IParticleSystem[];
  72240. /**
  72241. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72242. * @returns an array of IParticleSystem
  72243. */
  72244. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72245. }
  72246. }
  72247. }
  72248. declare module "babylonjs/Particles/pointsCloudSystem" {
  72249. import { Color4 } from "babylonjs/Maths/math";
  72250. import { Mesh } from "babylonjs/Meshes/mesh";
  72251. import { Scene, IDisposable } from "babylonjs/scene";
  72252. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72253. /** Defines the 4 color options */
  72254. export enum PointColor {
  72255. /** color value */
  72256. Color = 2,
  72257. /** uv value */
  72258. UV = 1,
  72259. /** random value */
  72260. Random = 0,
  72261. /** stated value */
  72262. Stated = 3
  72263. }
  72264. /**
  72265. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72266. * 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.
  72267. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72268. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72269. *
  72270. * Full documentation here : TO BE ENTERED
  72271. */
  72272. export class PointsCloudSystem implements IDisposable {
  72273. /**
  72274. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72275. * Example : var p = SPS.particles[i];
  72276. */
  72277. particles: CloudPoint[];
  72278. /**
  72279. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72280. */
  72281. nbParticles: number;
  72282. /**
  72283. * This a counter for your own usage. It's not set by any SPS functions.
  72284. */
  72285. counter: number;
  72286. /**
  72287. * The PCS name. This name is also given to the underlying mesh.
  72288. */
  72289. name: string;
  72290. /**
  72291. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72292. */
  72293. mesh: Mesh;
  72294. /**
  72295. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72296. * Please read :
  72297. */
  72298. vars: any;
  72299. /**
  72300. * @hidden
  72301. */
  72302. _size: number;
  72303. private _scene;
  72304. private _promises;
  72305. private _positions;
  72306. private _indices;
  72307. private _normals;
  72308. private _colors;
  72309. private _uvs;
  72310. private _indices32;
  72311. private _positions32;
  72312. private _colors32;
  72313. private _uvs32;
  72314. private _updatable;
  72315. private _isVisibilityBoxLocked;
  72316. private _alwaysVisible;
  72317. private _groups;
  72318. private _groupCounter;
  72319. private _computeParticleColor;
  72320. private _computeParticleTexture;
  72321. private _computeParticleRotation;
  72322. private _computeBoundingBox;
  72323. private _isReady;
  72324. /**
  72325. * Creates a PCS (Points Cloud System) object
  72326. * @param name (String) is the PCS name, this will be the underlying mesh name
  72327. * @param pointSize (number) is the size for each point
  72328. * @param scene (Scene) is the scene in which the PCS is added
  72329. * @param options defines the options of the PCS e.g.
  72330. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72331. */
  72332. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72333. updatable?: boolean;
  72334. });
  72335. /**
  72336. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72337. * If no points were added to the PCS, the returned mesh is just a single point.
  72338. * @returns a promise for the created mesh
  72339. */
  72340. buildMeshAsync(): Promise<Mesh>;
  72341. /**
  72342. * @hidden
  72343. */
  72344. private _buildMesh;
  72345. private _addParticle;
  72346. private _randomUnitVector;
  72347. private _getColorIndicesForCoord;
  72348. private _setPointsColorOrUV;
  72349. private _colorFromTexture;
  72350. private _calculateDensity;
  72351. /**
  72352. * Adds points to the PCS in random positions within a unit sphere
  72353. * @param nb (positive integer) the number of particles to be created from this model
  72354. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72355. * @returns the number of groups in the system
  72356. */
  72357. addPoints(nb: number, pointFunction?: any): number;
  72358. /**
  72359. * Adds points to the PCS from the surface of the model shape
  72360. * @param mesh is any Mesh object that will be used as a surface model for the points
  72361. * @param nb (positive integer) the number of particles to be created from this model
  72362. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72363. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72364. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72365. * @returns the number of groups in the system
  72366. */
  72367. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72368. /**
  72369. * Adds points to the PCS inside the model shape
  72370. * @param mesh is any Mesh object that will be used as a surface model for the points
  72371. * @param nb (positive integer) the number of particles to be created from this model
  72372. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72373. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72374. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72375. * @returns the number of groups in the system
  72376. */
  72377. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72378. /**
  72379. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72380. * This method calls `updateParticle()` for each particle of the SPS.
  72381. * For an animated SPS, it is usually called within the render loop.
  72382. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72383. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72384. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72385. * @returns the PCS.
  72386. */
  72387. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72388. /**
  72389. * Disposes the PCS.
  72390. */
  72391. dispose(): void;
  72392. /**
  72393. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72394. * doc :
  72395. * @returns the PCS.
  72396. */
  72397. refreshVisibleSize(): PointsCloudSystem;
  72398. /**
  72399. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72400. * @param size the size (float) of the visibility box
  72401. * note : this doesn't lock the PCS mesh bounding box.
  72402. * doc :
  72403. */
  72404. setVisibilityBox(size: number): void;
  72405. /**
  72406. * Gets whether the PCS is always visible or not
  72407. * doc :
  72408. */
  72409. get isAlwaysVisible(): boolean;
  72410. /**
  72411. * Sets the PCS as always visible or not
  72412. * doc :
  72413. */
  72414. set isAlwaysVisible(val: boolean);
  72415. /**
  72416. * Tells to `setParticles()` to compute the particle rotations or not
  72417. * Default value : false. The PCS is faster when it's set to false
  72418. * Note : particle rotations are only applied to parent particles
  72419. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72420. */
  72421. set computeParticleRotation(val: boolean);
  72422. /**
  72423. * Tells to `setParticles()` to compute the particle colors or not.
  72424. * Default value : true. The PCS is faster when it's set to false.
  72425. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72426. */
  72427. set computeParticleColor(val: boolean);
  72428. set computeParticleTexture(val: boolean);
  72429. /**
  72430. * Gets if `setParticles()` computes the particle colors or not.
  72431. * Default value : false. The PCS is faster when it's set to false.
  72432. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72433. */
  72434. get computeParticleColor(): boolean;
  72435. /**
  72436. * Gets if `setParticles()` computes the particle textures or not.
  72437. * Default value : false. The PCS is faster when it's set to false.
  72438. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72439. */
  72440. get computeParticleTexture(): boolean;
  72441. /**
  72442. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72443. */
  72444. set computeBoundingBox(val: boolean);
  72445. /**
  72446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72447. */
  72448. get computeBoundingBox(): boolean;
  72449. /**
  72450. * This function does nothing. It may be overwritten to set all the particle first values.
  72451. * The PCS doesn't call this function, you may have to call it by your own.
  72452. * doc :
  72453. */
  72454. initParticles(): void;
  72455. /**
  72456. * This function does nothing. It may be overwritten to recycle a particle
  72457. * The PCS doesn't call this function, you can to call it
  72458. * doc :
  72459. * @param particle The particle to recycle
  72460. * @returns the recycled particle
  72461. */
  72462. recycleParticle(particle: CloudPoint): CloudPoint;
  72463. /**
  72464. * Updates a particle : this function should be overwritten by the user.
  72465. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72466. * doc :
  72467. * @example : just set a particle position or velocity and recycle conditions
  72468. * @param particle The particle to update
  72469. * @returns the updated particle
  72470. */
  72471. updateParticle(particle: CloudPoint): CloudPoint;
  72472. /**
  72473. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72474. * This does nothing and may be overwritten by the user.
  72475. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72476. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72477. * @param update the boolean update value actually passed to setParticles()
  72478. */
  72479. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72480. /**
  72481. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72482. * This will be passed three parameters.
  72483. * This does nothing and may be overwritten by the user.
  72484. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72485. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72486. * @param update the boolean update value actually passed to setParticles()
  72487. */
  72488. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72489. }
  72490. }
  72491. declare module "babylonjs/Particles/cloudPoint" {
  72492. import { Nullable } from "babylonjs/types";
  72493. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72494. import { Mesh } from "babylonjs/Meshes/mesh";
  72495. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72496. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72497. /**
  72498. * Represents one particle of a points cloud system.
  72499. */
  72500. export class CloudPoint {
  72501. /**
  72502. * particle global index
  72503. */
  72504. idx: number;
  72505. /**
  72506. * The color of the particle
  72507. */
  72508. color: Nullable<Color4>;
  72509. /**
  72510. * The world space position of the particle.
  72511. */
  72512. position: Vector3;
  72513. /**
  72514. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72515. */
  72516. rotation: Vector3;
  72517. /**
  72518. * The world space rotation quaternion of the particle.
  72519. */
  72520. rotationQuaternion: Nullable<Quaternion>;
  72521. /**
  72522. * The uv of the particle.
  72523. */
  72524. uv: Nullable<Vector2>;
  72525. /**
  72526. * The current speed of the particle.
  72527. */
  72528. velocity: Vector3;
  72529. /**
  72530. * The pivot point in the particle local space.
  72531. */
  72532. pivot: Vector3;
  72533. /**
  72534. * Must the particle be translated from its pivot point in its local space ?
  72535. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72536. * Default : false
  72537. */
  72538. translateFromPivot: boolean;
  72539. /**
  72540. * Index of this particle in the global "positions" array (Internal use)
  72541. * @hidden
  72542. */
  72543. _pos: number;
  72544. /**
  72545. * @hidden Index of this particle in the global "indices" array (Internal use)
  72546. */
  72547. _ind: number;
  72548. /**
  72549. * Group this particle belongs to
  72550. */
  72551. _group: PointsGroup;
  72552. /**
  72553. * Group id of this particle
  72554. */
  72555. groupId: number;
  72556. /**
  72557. * Index of the particle in its group id (Internal use)
  72558. */
  72559. idxInGroup: number;
  72560. /**
  72561. * @hidden Particle BoundingInfo object (Internal use)
  72562. */
  72563. _boundingInfo: BoundingInfo;
  72564. /**
  72565. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72566. */
  72567. _pcs: PointsCloudSystem;
  72568. /**
  72569. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72570. */
  72571. _stillInvisible: boolean;
  72572. /**
  72573. * @hidden Last computed particle rotation matrix
  72574. */
  72575. _rotationMatrix: number[];
  72576. /**
  72577. * Parent particle Id, if any.
  72578. * Default null.
  72579. */
  72580. parentId: Nullable<number>;
  72581. /**
  72582. * @hidden Internal global position in the PCS.
  72583. */
  72584. _globalPosition: Vector3;
  72585. /**
  72586. * Creates a Point Cloud object.
  72587. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72588. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72589. * @param group (PointsGroup) is the group the particle belongs to
  72590. * @param groupId (integer) is the group identifier in the PCS.
  72591. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72592. * @param pcs defines the PCS it is associated to
  72593. */
  72594. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72595. /**
  72596. * get point size
  72597. */
  72598. get size(): Vector3;
  72599. /**
  72600. * Set point size
  72601. */
  72602. set size(scale: Vector3);
  72603. /**
  72604. * Legacy support, changed quaternion to rotationQuaternion
  72605. */
  72606. get quaternion(): Nullable<Quaternion>;
  72607. /**
  72608. * Legacy support, changed quaternion to rotationQuaternion
  72609. */
  72610. set quaternion(q: Nullable<Quaternion>);
  72611. /**
  72612. * Returns a boolean. True if the particle intersects a mesh, else false
  72613. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72614. * @param target is the object (point or mesh) what the intersection is computed against
  72615. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72616. * @returns true if it intersects
  72617. */
  72618. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72619. /**
  72620. * get the rotation matrix of the particle
  72621. * @hidden
  72622. */
  72623. getRotationMatrix(m: Matrix): void;
  72624. }
  72625. /**
  72626. * Represents a group of points in a points cloud system
  72627. * * PCS internal tool, don't use it manually.
  72628. */
  72629. export class PointsGroup {
  72630. /**
  72631. * The group id
  72632. * @hidden
  72633. */
  72634. groupID: number;
  72635. /**
  72636. * image data for group (internal use)
  72637. * @hidden
  72638. */
  72639. _groupImageData: Nullable<ArrayBufferView>;
  72640. /**
  72641. * Image Width (internal use)
  72642. * @hidden
  72643. */
  72644. _groupImgWidth: number;
  72645. /**
  72646. * Image Height (internal use)
  72647. * @hidden
  72648. */
  72649. _groupImgHeight: number;
  72650. /**
  72651. * Custom position function (internal use)
  72652. * @hidden
  72653. */
  72654. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72655. /**
  72656. * density per facet for surface points
  72657. * @hidden
  72658. */
  72659. _groupDensity: number[];
  72660. /**
  72661. * Only when points are colored by texture carries pointer to texture list array
  72662. * @hidden
  72663. */
  72664. _textureNb: number;
  72665. /**
  72666. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72667. * PCS internal tool, don't use it manually.
  72668. * @hidden
  72669. */
  72670. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72671. }
  72672. }
  72673. declare module "babylonjs/Particles/index" {
  72674. export * from "babylonjs/Particles/baseParticleSystem";
  72675. export * from "babylonjs/Particles/EmitterTypes/index";
  72676. export * from "babylonjs/Particles/gpuParticleSystem";
  72677. export * from "babylonjs/Particles/IParticleSystem";
  72678. export * from "babylonjs/Particles/particle";
  72679. export * from "babylonjs/Particles/particleHelper";
  72680. export * from "babylonjs/Particles/particleSystem";
  72681. import "babylonjs/Particles/particleSystemComponent";
  72682. export * from "babylonjs/Particles/particleSystemComponent";
  72683. export * from "babylonjs/Particles/particleSystemSet";
  72684. export * from "babylonjs/Particles/solidParticle";
  72685. export * from "babylonjs/Particles/solidParticleSystem";
  72686. export * from "babylonjs/Particles/cloudPoint";
  72687. export * from "babylonjs/Particles/pointsCloudSystem";
  72688. export * from "babylonjs/Particles/subEmitter";
  72689. }
  72690. declare module "babylonjs/Physics/physicsEngineComponent" {
  72691. import { Nullable } from "babylonjs/types";
  72692. import { Observable, Observer } from "babylonjs/Misc/observable";
  72693. import { Vector3 } from "babylonjs/Maths/math.vector";
  72694. import { Mesh } from "babylonjs/Meshes/mesh";
  72695. import { ISceneComponent } from "babylonjs/sceneComponent";
  72696. import { Scene } from "babylonjs/scene";
  72697. import { Node } from "babylonjs/node";
  72698. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72699. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72700. module "babylonjs/scene" {
  72701. interface Scene {
  72702. /** @hidden (Backing field) */
  72703. _physicsEngine: Nullable<IPhysicsEngine>;
  72704. /** @hidden */
  72705. _physicsTimeAccumulator: number;
  72706. /**
  72707. * Gets the current physics engine
  72708. * @returns a IPhysicsEngine or null if none attached
  72709. */
  72710. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72711. /**
  72712. * Enables physics to the current scene
  72713. * @param gravity defines the scene's gravity for the physics engine
  72714. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72715. * @return a boolean indicating if the physics engine was initialized
  72716. */
  72717. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72718. /**
  72719. * Disables and disposes the physics engine associated with the scene
  72720. */
  72721. disablePhysicsEngine(): void;
  72722. /**
  72723. * Gets a boolean indicating if there is an active physics engine
  72724. * @returns a boolean indicating if there is an active physics engine
  72725. */
  72726. isPhysicsEnabled(): boolean;
  72727. /**
  72728. * Deletes a physics compound impostor
  72729. * @param compound defines the compound to delete
  72730. */
  72731. deleteCompoundImpostor(compound: any): void;
  72732. /**
  72733. * An event triggered when physic simulation is about to be run
  72734. */
  72735. onBeforePhysicsObservable: Observable<Scene>;
  72736. /**
  72737. * An event triggered when physic simulation has been done
  72738. */
  72739. onAfterPhysicsObservable: Observable<Scene>;
  72740. }
  72741. }
  72742. module "babylonjs/Meshes/abstractMesh" {
  72743. interface AbstractMesh {
  72744. /** @hidden */
  72745. _physicsImpostor: Nullable<PhysicsImpostor>;
  72746. /**
  72747. * Gets or sets impostor used for physic simulation
  72748. * @see https://doc.babylonjs.com/features/physics_engine
  72749. */
  72750. physicsImpostor: Nullable<PhysicsImpostor>;
  72751. /**
  72752. * Gets the current physics impostor
  72753. * @see https://doc.babylonjs.com/features/physics_engine
  72754. * @returns a physics impostor or null
  72755. */
  72756. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72757. /** Apply a physic impulse to the mesh
  72758. * @param force defines the force to apply
  72759. * @param contactPoint defines where to apply the force
  72760. * @returns the current mesh
  72761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72762. */
  72763. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72764. /**
  72765. * Creates a physic joint between two meshes
  72766. * @param otherMesh defines the other mesh to use
  72767. * @param pivot1 defines the pivot to use on this mesh
  72768. * @param pivot2 defines the pivot to use on the other mesh
  72769. * @param options defines additional options (can be plugin dependent)
  72770. * @returns the current mesh
  72771. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72772. */
  72773. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72774. /** @hidden */
  72775. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72776. }
  72777. }
  72778. /**
  72779. * Defines the physics engine scene component responsible to manage a physics engine
  72780. */
  72781. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72782. /**
  72783. * The component name helpful to identify the component in the list of scene components.
  72784. */
  72785. readonly name: string;
  72786. /**
  72787. * The scene the component belongs to.
  72788. */
  72789. scene: Scene;
  72790. /**
  72791. * Creates a new instance of the component for the given scene
  72792. * @param scene Defines the scene to register the component in
  72793. */
  72794. constructor(scene: Scene);
  72795. /**
  72796. * Registers the component in a given scene
  72797. */
  72798. register(): void;
  72799. /**
  72800. * Rebuilds the elements related to this component in case of
  72801. * context lost for instance.
  72802. */
  72803. rebuild(): void;
  72804. /**
  72805. * Disposes the component and the associated ressources
  72806. */
  72807. dispose(): void;
  72808. }
  72809. }
  72810. declare module "babylonjs/Physics/physicsHelper" {
  72811. import { Nullable } from "babylonjs/types";
  72812. import { Vector3 } from "babylonjs/Maths/math.vector";
  72813. import { Mesh } from "babylonjs/Meshes/mesh";
  72814. import { Scene } from "babylonjs/scene";
  72815. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72816. /**
  72817. * A helper for physics simulations
  72818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72819. */
  72820. export class PhysicsHelper {
  72821. private _scene;
  72822. private _physicsEngine;
  72823. /**
  72824. * Initializes the Physics helper
  72825. * @param scene Babylon.js scene
  72826. */
  72827. constructor(scene: Scene);
  72828. /**
  72829. * Applies a radial explosion impulse
  72830. * @param origin the origin of the explosion
  72831. * @param radiusOrEventOptions the radius or the options of radial explosion
  72832. * @param strength the explosion strength
  72833. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72834. * @returns A physics radial explosion event, or null
  72835. */
  72836. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72837. /**
  72838. * Applies a radial explosion force
  72839. * @param origin the origin of the explosion
  72840. * @param radiusOrEventOptions the radius or the options of radial explosion
  72841. * @param strength the explosion strength
  72842. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72843. * @returns A physics radial explosion event, or null
  72844. */
  72845. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72846. /**
  72847. * Creates a gravitational field
  72848. * @param origin the origin of the explosion
  72849. * @param radiusOrEventOptions the radius or the options of radial explosion
  72850. * @param strength the explosion strength
  72851. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72852. * @returns A physics gravitational field event, or null
  72853. */
  72854. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72855. /**
  72856. * Creates a physics updraft event
  72857. * @param origin the origin of the updraft
  72858. * @param radiusOrEventOptions the radius or the options of the updraft
  72859. * @param strength the strength of the updraft
  72860. * @param height the height of the updraft
  72861. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72862. * @returns A physics updraft event, or null
  72863. */
  72864. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72865. /**
  72866. * Creates a physics vortex event
  72867. * @param origin the of the vortex
  72868. * @param radiusOrEventOptions the radius or the options of the vortex
  72869. * @param strength the strength of the vortex
  72870. * @param height the height of the vortex
  72871. * @returns a Physics vortex event, or null
  72872. * A physics vortex event or null
  72873. */
  72874. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72875. }
  72876. /**
  72877. * Represents a physics radial explosion event
  72878. */
  72879. class PhysicsRadialExplosionEvent {
  72880. private _scene;
  72881. private _options;
  72882. private _sphere;
  72883. private _dataFetched;
  72884. /**
  72885. * Initializes a radial explosioin event
  72886. * @param _scene BabylonJS scene
  72887. * @param _options The options for the vortex event
  72888. */
  72889. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72890. /**
  72891. * Returns the data related to the radial explosion event (sphere).
  72892. * @returns The radial explosion event data
  72893. */
  72894. getData(): PhysicsRadialExplosionEventData;
  72895. /**
  72896. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72897. * @param impostor A physics imposter
  72898. * @param origin the origin of the explosion
  72899. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72900. */
  72901. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72902. /**
  72903. * Triggers affecterd impostors callbacks
  72904. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72905. */
  72906. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72907. /**
  72908. * Disposes the sphere.
  72909. * @param force Specifies if the sphere should be disposed by force
  72910. */
  72911. dispose(force?: boolean): void;
  72912. /*** Helpers ***/
  72913. private _prepareSphere;
  72914. private _intersectsWithSphere;
  72915. }
  72916. /**
  72917. * Represents a gravitational field event
  72918. */
  72919. class PhysicsGravitationalFieldEvent {
  72920. private _physicsHelper;
  72921. private _scene;
  72922. private _origin;
  72923. private _options;
  72924. private _tickCallback;
  72925. private _sphere;
  72926. private _dataFetched;
  72927. /**
  72928. * Initializes the physics gravitational field event
  72929. * @param _physicsHelper A physics helper
  72930. * @param _scene BabylonJS scene
  72931. * @param _origin The origin position of the gravitational field event
  72932. * @param _options The options for the vortex event
  72933. */
  72934. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72935. /**
  72936. * Returns the data related to the gravitational field event (sphere).
  72937. * @returns A gravitational field event
  72938. */
  72939. getData(): PhysicsGravitationalFieldEventData;
  72940. /**
  72941. * Enables the gravitational field.
  72942. */
  72943. enable(): void;
  72944. /**
  72945. * Disables the gravitational field.
  72946. */
  72947. disable(): void;
  72948. /**
  72949. * Disposes the sphere.
  72950. * @param force The force to dispose from the gravitational field event
  72951. */
  72952. dispose(force?: boolean): void;
  72953. private _tick;
  72954. }
  72955. /**
  72956. * Represents a physics updraft event
  72957. */
  72958. class PhysicsUpdraftEvent {
  72959. private _scene;
  72960. private _origin;
  72961. private _options;
  72962. private _physicsEngine;
  72963. private _originTop;
  72964. private _originDirection;
  72965. private _tickCallback;
  72966. private _cylinder;
  72967. private _cylinderPosition;
  72968. private _dataFetched;
  72969. /**
  72970. * Initializes the physics updraft event
  72971. * @param _scene BabylonJS scene
  72972. * @param _origin The origin position of the updraft
  72973. * @param _options The options for the updraft event
  72974. */
  72975. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72976. /**
  72977. * Returns the data related to the updraft event (cylinder).
  72978. * @returns A physics updraft event
  72979. */
  72980. getData(): PhysicsUpdraftEventData;
  72981. /**
  72982. * Enables the updraft.
  72983. */
  72984. enable(): void;
  72985. /**
  72986. * Disables the updraft.
  72987. */
  72988. disable(): void;
  72989. /**
  72990. * Disposes the cylinder.
  72991. * @param force Specifies if the updraft should be disposed by force
  72992. */
  72993. dispose(force?: boolean): void;
  72994. private getImpostorHitData;
  72995. private _tick;
  72996. /*** Helpers ***/
  72997. private _prepareCylinder;
  72998. private _intersectsWithCylinder;
  72999. }
  73000. /**
  73001. * Represents a physics vortex event
  73002. */
  73003. class PhysicsVortexEvent {
  73004. private _scene;
  73005. private _origin;
  73006. private _options;
  73007. private _physicsEngine;
  73008. private _originTop;
  73009. private _tickCallback;
  73010. private _cylinder;
  73011. private _cylinderPosition;
  73012. private _dataFetched;
  73013. /**
  73014. * Initializes the physics vortex event
  73015. * @param _scene The BabylonJS scene
  73016. * @param _origin The origin position of the vortex
  73017. * @param _options The options for the vortex event
  73018. */
  73019. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73020. /**
  73021. * Returns the data related to the vortex event (cylinder).
  73022. * @returns The physics vortex event data
  73023. */
  73024. getData(): PhysicsVortexEventData;
  73025. /**
  73026. * Enables the vortex.
  73027. */
  73028. enable(): void;
  73029. /**
  73030. * Disables the cortex.
  73031. */
  73032. disable(): void;
  73033. /**
  73034. * Disposes the sphere.
  73035. * @param force
  73036. */
  73037. dispose(force?: boolean): void;
  73038. private getImpostorHitData;
  73039. private _tick;
  73040. /*** Helpers ***/
  73041. private _prepareCylinder;
  73042. private _intersectsWithCylinder;
  73043. }
  73044. /**
  73045. * Options fot the radial explosion event
  73046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73047. */
  73048. export class PhysicsRadialExplosionEventOptions {
  73049. /**
  73050. * The radius of the sphere for the radial explosion.
  73051. */
  73052. radius: number;
  73053. /**
  73054. * The strenth of the explosion.
  73055. */
  73056. strength: number;
  73057. /**
  73058. * The strenght of the force in correspondence to the distance of the affected object
  73059. */
  73060. falloff: PhysicsRadialImpulseFalloff;
  73061. /**
  73062. * Sphere options for the radial explosion.
  73063. */
  73064. sphere: {
  73065. segments: number;
  73066. diameter: number;
  73067. };
  73068. /**
  73069. * Sphere options for the radial explosion.
  73070. */
  73071. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73072. }
  73073. /**
  73074. * Options fot the updraft event
  73075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73076. */
  73077. export class PhysicsUpdraftEventOptions {
  73078. /**
  73079. * The radius of the cylinder for the vortex
  73080. */
  73081. radius: number;
  73082. /**
  73083. * The strenth of the updraft.
  73084. */
  73085. strength: number;
  73086. /**
  73087. * The height of the cylinder for the updraft.
  73088. */
  73089. height: number;
  73090. /**
  73091. * The mode for the the updraft.
  73092. */
  73093. updraftMode: PhysicsUpdraftMode;
  73094. }
  73095. /**
  73096. * Options fot the vortex event
  73097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73098. */
  73099. export class PhysicsVortexEventOptions {
  73100. /**
  73101. * The radius of the cylinder for the vortex
  73102. */
  73103. radius: number;
  73104. /**
  73105. * The strenth of the vortex.
  73106. */
  73107. strength: number;
  73108. /**
  73109. * The height of the cylinder for the vortex.
  73110. */
  73111. height: number;
  73112. /**
  73113. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73114. */
  73115. centripetalForceThreshold: number;
  73116. /**
  73117. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73118. */
  73119. centripetalForceMultiplier: number;
  73120. /**
  73121. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73122. */
  73123. centrifugalForceMultiplier: number;
  73124. /**
  73125. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73126. */
  73127. updraftForceMultiplier: number;
  73128. }
  73129. /**
  73130. * The strenght of the force in correspondence to the distance of the affected object
  73131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73132. */
  73133. export enum PhysicsRadialImpulseFalloff {
  73134. /** Defines that impulse is constant in strength across it's whole radius */
  73135. Constant = 0,
  73136. /** Defines that impulse gets weaker if it's further from the origin */
  73137. Linear = 1
  73138. }
  73139. /**
  73140. * The strength of the force in correspondence to the distance of the affected object
  73141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73142. */
  73143. export enum PhysicsUpdraftMode {
  73144. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73145. Center = 0,
  73146. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73147. Perpendicular = 1
  73148. }
  73149. /**
  73150. * Interface for a physics hit data
  73151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73152. */
  73153. export interface PhysicsHitData {
  73154. /**
  73155. * The force applied at the contact point
  73156. */
  73157. force: Vector3;
  73158. /**
  73159. * The contact point
  73160. */
  73161. contactPoint: Vector3;
  73162. /**
  73163. * The distance from the origin to the contact point
  73164. */
  73165. distanceFromOrigin: number;
  73166. }
  73167. /**
  73168. * Interface for radial explosion event data
  73169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73170. */
  73171. export interface PhysicsRadialExplosionEventData {
  73172. /**
  73173. * A sphere used for the radial explosion event
  73174. */
  73175. sphere: Mesh;
  73176. }
  73177. /**
  73178. * Interface for gravitational field event data
  73179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73180. */
  73181. export interface PhysicsGravitationalFieldEventData {
  73182. /**
  73183. * A sphere mesh used for the gravitational field event
  73184. */
  73185. sphere: Mesh;
  73186. }
  73187. /**
  73188. * Interface for updraft event data
  73189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73190. */
  73191. export interface PhysicsUpdraftEventData {
  73192. /**
  73193. * A cylinder used for the updraft event
  73194. */
  73195. cylinder: Mesh;
  73196. }
  73197. /**
  73198. * Interface for vortex event data
  73199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73200. */
  73201. export interface PhysicsVortexEventData {
  73202. /**
  73203. * A cylinder used for the vortex event
  73204. */
  73205. cylinder: Mesh;
  73206. }
  73207. /**
  73208. * Interface for an affected physics impostor
  73209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73210. */
  73211. export interface PhysicsAffectedImpostorWithData {
  73212. /**
  73213. * The impostor affected by the effect
  73214. */
  73215. impostor: PhysicsImpostor;
  73216. /**
  73217. * The data about the hit/horce from the explosion
  73218. */
  73219. hitData: PhysicsHitData;
  73220. }
  73221. }
  73222. declare module "babylonjs/Physics/Plugins/index" {
  73223. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73224. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73225. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73226. }
  73227. declare module "babylonjs/Physics/index" {
  73228. export * from "babylonjs/Physics/IPhysicsEngine";
  73229. export * from "babylonjs/Physics/physicsEngine";
  73230. export * from "babylonjs/Physics/physicsEngineComponent";
  73231. export * from "babylonjs/Physics/physicsHelper";
  73232. export * from "babylonjs/Physics/physicsImpostor";
  73233. export * from "babylonjs/Physics/physicsJoint";
  73234. export * from "babylonjs/Physics/Plugins/index";
  73235. }
  73236. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73237. /** @hidden */
  73238. export var blackAndWhitePixelShader: {
  73239. name: string;
  73240. shader: string;
  73241. };
  73242. }
  73243. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73245. import { Camera } from "babylonjs/Cameras/camera";
  73246. import { Engine } from "babylonjs/Engines/engine";
  73247. import "babylonjs/Shaders/blackAndWhite.fragment";
  73248. import { Nullable } from "babylonjs/types";
  73249. import { Scene } from "babylonjs/scene";
  73250. /**
  73251. * Post process used to render in black and white
  73252. */
  73253. export class BlackAndWhitePostProcess extends PostProcess {
  73254. /**
  73255. * Linear about to convert he result to black and white (default: 1)
  73256. */
  73257. degree: number;
  73258. /**
  73259. * Gets a string identifying the name of the class
  73260. * @returns "BlackAndWhitePostProcess" string
  73261. */
  73262. getClassName(): string;
  73263. /**
  73264. * Creates a black and white post process
  73265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73266. * @param name The name of the effect.
  73267. * @param options The required width/height ratio to downsize to before computing the render pass.
  73268. * @param camera The camera to apply the render pass to.
  73269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73270. * @param engine The engine which the post process will be applied. (default: current engine)
  73271. * @param reusable If the post process can be reused on the same frame. (default: false)
  73272. */
  73273. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73274. /** @hidden */
  73275. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73276. }
  73277. }
  73278. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73279. import { Nullable } from "babylonjs/types";
  73280. import { Camera } from "babylonjs/Cameras/camera";
  73281. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73282. import { Engine } from "babylonjs/Engines/engine";
  73283. /**
  73284. * This represents a set of one or more post processes in Babylon.
  73285. * A post process can be used to apply a shader to a texture after it is rendered.
  73286. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73287. */
  73288. export class PostProcessRenderEffect {
  73289. private _postProcesses;
  73290. private _getPostProcesses;
  73291. private _singleInstance;
  73292. private _cameras;
  73293. private _indicesForCamera;
  73294. /**
  73295. * Name of the effect
  73296. * @hidden
  73297. */
  73298. _name: string;
  73299. /**
  73300. * Instantiates a post process render effect.
  73301. * A post process can be used to apply a shader to a texture after it is rendered.
  73302. * @param engine The engine the effect is tied to
  73303. * @param name The name of the effect
  73304. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73305. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73306. */
  73307. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73308. /**
  73309. * Checks if all the post processes in the effect are supported.
  73310. */
  73311. get isSupported(): boolean;
  73312. /**
  73313. * Updates the current state of the effect
  73314. * @hidden
  73315. */
  73316. _update(): void;
  73317. /**
  73318. * Attaches the effect on cameras
  73319. * @param cameras The camera to attach to.
  73320. * @hidden
  73321. */
  73322. _attachCameras(cameras: Camera): void;
  73323. /**
  73324. * Attaches the effect on cameras
  73325. * @param cameras The camera to attach to.
  73326. * @hidden
  73327. */
  73328. _attachCameras(cameras: Camera[]): void;
  73329. /**
  73330. * Detaches the effect on cameras
  73331. * @param cameras The camera to detatch from.
  73332. * @hidden
  73333. */
  73334. _detachCameras(cameras: Camera): void;
  73335. /**
  73336. * Detatches the effect on cameras
  73337. * @param cameras The camera to detatch from.
  73338. * @hidden
  73339. */
  73340. _detachCameras(cameras: Camera[]): void;
  73341. /**
  73342. * Enables the effect on given cameras
  73343. * @param cameras The camera to enable.
  73344. * @hidden
  73345. */
  73346. _enable(cameras: Camera): void;
  73347. /**
  73348. * Enables the effect on given cameras
  73349. * @param cameras The camera to enable.
  73350. * @hidden
  73351. */
  73352. _enable(cameras: Nullable<Camera[]>): void;
  73353. /**
  73354. * Disables the effect on the given cameras
  73355. * @param cameras The camera to disable.
  73356. * @hidden
  73357. */
  73358. _disable(cameras: Camera): void;
  73359. /**
  73360. * Disables the effect on the given cameras
  73361. * @param cameras The camera to disable.
  73362. * @hidden
  73363. */
  73364. _disable(cameras: Nullable<Camera[]>): void;
  73365. /**
  73366. * Gets a list of the post processes contained in the effect.
  73367. * @param camera The camera to get the post processes on.
  73368. * @returns The list of the post processes in the effect.
  73369. */
  73370. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73371. }
  73372. }
  73373. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73374. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73375. /** @hidden */
  73376. export var extractHighlightsPixelShader: {
  73377. name: string;
  73378. shader: string;
  73379. };
  73380. }
  73381. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73382. import { Nullable } from "babylonjs/types";
  73383. import { Camera } from "babylonjs/Cameras/camera";
  73384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73385. import { Engine } from "babylonjs/Engines/engine";
  73386. import "babylonjs/Shaders/extractHighlights.fragment";
  73387. /**
  73388. * 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.
  73389. */
  73390. export class ExtractHighlightsPostProcess extends PostProcess {
  73391. /**
  73392. * The luminance threshold, pixels below this value will be set to black.
  73393. */
  73394. threshold: number;
  73395. /** @hidden */
  73396. _exposure: number;
  73397. /**
  73398. * Post process which has the input texture to be used when performing highlight extraction
  73399. * @hidden
  73400. */
  73401. _inputPostProcess: Nullable<PostProcess>;
  73402. /**
  73403. * Gets a string identifying the name of the class
  73404. * @returns "ExtractHighlightsPostProcess" string
  73405. */
  73406. getClassName(): string;
  73407. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73408. }
  73409. }
  73410. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73411. /** @hidden */
  73412. export var bloomMergePixelShader: {
  73413. name: string;
  73414. shader: string;
  73415. };
  73416. }
  73417. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73419. import { Nullable } from "babylonjs/types";
  73420. import { Engine } from "babylonjs/Engines/engine";
  73421. import { Camera } from "babylonjs/Cameras/camera";
  73422. import "babylonjs/Shaders/bloomMerge.fragment";
  73423. /**
  73424. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73425. */
  73426. export class BloomMergePostProcess extends PostProcess {
  73427. /** Weight of the bloom to be added to the original input. */
  73428. weight: number;
  73429. /**
  73430. * Gets a string identifying the name of the class
  73431. * @returns "BloomMergePostProcess" string
  73432. */
  73433. getClassName(): string;
  73434. /**
  73435. * Creates a new instance of @see BloomMergePostProcess
  73436. * @param name The name of the effect.
  73437. * @param originalFromInput Post process which's input will be used for the merge.
  73438. * @param blurred Blurred highlights post process which's output will be used.
  73439. * @param weight Weight of the bloom to be added to the original input.
  73440. * @param options The required width/height ratio to downsize to before computing the render pass.
  73441. * @param camera The camera to apply the render pass to.
  73442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73443. * @param engine The engine which the post process will be applied. (default: current engine)
  73444. * @param reusable If the post process can be reused on the same frame. (default: false)
  73445. * @param textureType Type of textures used when performing the post process. (default: 0)
  73446. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  73447. */
  73448. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73449. /** Weight of the bloom to be added to the original input. */
  73450. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73451. }
  73452. }
  73453. declare module "babylonjs/PostProcesses/bloomEffect" {
  73454. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73455. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73456. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73457. import { Camera } from "babylonjs/Cameras/camera";
  73458. import { Scene } from "babylonjs/scene";
  73459. /**
  73460. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73461. */
  73462. export class BloomEffect extends PostProcessRenderEffect {
  73463. private bloomScale;
  73464. /**
  73465. * @hidden Internal
  73466. */
  73467. _effects: Array<PostProcess>;
  73468. /**
  73469. * @hidden Internal
  73470. */
  73471. _downscale: ExtractHighlightsPostProcess;
  73472. private _blurX;
  73473. private _blurY;
  73474. private _merge;
  73475. /**
  73476. * The luminance threshold to find bright areas of the image to bloom.
  73477. */
  73478. get threshold(): number;
  73479. set threshold(value: number);
  73480. /**
  73481. * The strength of the bloom.
  73482. */
  73483. get weight(): number;
  73484. set weight(value: number);
  73485. /**
  73486. * Specifies the size of the bloom blur kernel, relative to the final output size
  73487. */
  73488. get kernel(): number;
  73489. set kernel(value: number);
  73490. /**
  73491. * Creates a new instance of @see BloomEffect
  73492. * @param scene The scene the effect belongs to.
  73493. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73494. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73495. * @param bloomWeight The the strength of bloom.
  73496. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73497. * @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)
  73498. */
  73499. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73500. /**
  73501. * Disposes each of the internal effects for a given camera.
  73502. * @param camera The camera to dispose the effect on.
  73503. */
  73504. disposeEffects(camera: Camera): void;
  73505. /**
  73506. * @hidden Internal
  73507. */
  73508. _updateEffects(): void;
  73509. /**
  73510. * Internal
  73511. * @returns if all the contained post processes are ready.
  73512. * @hidden
  73513. */
  73514. _isReady(): boolean;
  73515. }
  73516. }
  73517. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73518. /** @hidden */
  73519. export var chromaticAberrationPixelShader: {
  73520. name: string;
  73521. shader: string;
  73522. };
  73523. }
  73524. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73525. import { Vector2 } from "babylonjs/Maths/math.vector";
  73526. import { Nullable } from "babylonjs/types";
  73527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73528. import { Camera } from "babylonjs/Cameras/camera";
  73529. import { Engine } from "babylonjs/Engines/engine";
  73530. import "babylonjs/Shaders/chromaticAberration.fragment";
  73531. import { Scene } from "babylonjs/scene";
  73532. /**
  73533. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73534. */
  73535. export class ChromaticAberrationPostProcess extends PostProcess {
  73536. /**
  73537. * The amount of seperation of rgb channels (default: 30)
  73538. */
  73539. aberrationAmount: number;
  73540. /**
  73541. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73542. */
  73543. radialIntensity: number;
  73544. /**
  73545. * 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))
  73546. */
  73547. direction: Vector2;
  73548. /**
  73549. * 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))
  73550. */
  73551. centerPosition: Vector2;
  73552. /** The width of the screen to apply the effect on */
  73553. screenWidth: number;
  73554. /** The height of the screen to apply the effect on */
  73555. screenHeight: number;
  73556. /**
  73557. * Gets a string identifying the name of the class
  73558. * @returns "ChromaticAberrationPostProcess" string
  73559. */
  73560. getClassName(): string;
  73561. /**
  73562. * Creates a new instance ChromaticAberrationPostProcess
  73563. * @param name The name of the effect.
  73564. * @param screenWidth The width of the screen to apply the effect on.
  73565. * @param screenHeight The height of the screen to apply the effect on.
  73566. * @param options The required width/height ratio to downsize to before computing the render pass.
  73567. * @param camera The camera to apply the render pass to.
  73568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73569. * @param engine The engine which the post process will be applied. (default: current engine)
  73570. * @param reusable If the post process can be reused on the same frame. (default: false)
  73571. * @param textureType Type of textures used when performing the post process. (default: 0)
  73572. * @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)
  73573. */
  73574. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73575. /** @hidden */
  73576. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73577. }
  73578. }
  73579. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73580. /** @hidden */
  73581. export var circleOfConfusionPixelShader: {
  73582. name: string;
  73583. shader: string;
  73584. };
  73585. }
  73586. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73587. import { Nullable } from "babylonjs/types";
  73588. import { Engine } from "babylonjs/Engines/engine";
  73589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73591. import { Camera } from "babylonjs/Cameras/camera";
  73592. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73593. /**
  73594. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73595. */
  73596. export class CircleOfConfusionPostProcess extends PostProcess {
  73597. /**
  73598. * 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.
  73599. */
  73600. lensSize: number;
  73601. /**
  73602. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73603. */
  73604. fStop: number;
  73605. /**
  73606. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73607. */
  73608. focusDistance: number;
  73609. /**
  73610. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73611. */
  73612. focalLength: number;
  73613. /**
  73614. * Gets a string identifying the name of the class
  73615. * @returns "CircleOfConfusionPostProcess" string
  73616. */
  73617. getClassName(): string;
  73618. private _depthTexture;
  73619. /**
  73620. * Creates a new instance CircleOfConfusionPostProcess
  73621. * @param name The name of the effect.
  73622. * @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.
  73623. * @param options The required width/height ratio to downsize to before computing the render pass.
  73624. * @param camera The camera to apply the render pass to.
  73625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73626. * @param engine The engine which the post process will be applied. (default: current engine)
  73627. * @param reusable If the post process can be reused on the same frame. (default: false)
  73628. * @param textureType Type of textures used when performing the post process. (default: 0)
  73629. * @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)
  73630. */
  73631. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73632. /**
  73633. * 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.
  73634. */
  73635. set depthTexture(value: RenderTargetTexture);
  73636. }
  73637. }
  73638. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73639. /** @hidden */
  73640. export var colorCorrectionPixelShader: {
  73641. name: string;
  73642. shader: string;
  73643. };
  73644. }
  73645. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73647. import { Engine } from "babylonjs/Engines/engine";
  73648. import { Camera } from "babylonjs/Cameras/camera";
  73649. import "babylonjs/Shaders/colorCorrection.fragment";
  73650. import { Nullable } from "babylonjs/types";
  73651. import { Scene } from "babylonjs/scene";
  73652. /**
  73653. *
  73654. * This post-process allows the modification of rendered colors by using
  73655. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73656. *
  73657. * The object needs to be provided an url to a texture containing the color
  73658. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73659. * Use an image editing software to tweak the LUT to match your needs.
  73660. *
  73661. * For an example of a color LUT, see here:
  73662. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73663. * For explanations on color grading, see here:
  73664. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73665. *
  73666. */
  73667. export class ColorCorrectionPostProcess extends PostProcess {
  73668. private _colorTableTexture;
  73669. /**
  73670. * Gets the color table url used to create the LUT texture
  73671. */
  73672. colorTableUrl: string;
  73673. /**
  73674. * Gets a string identifying the name of the class
  73675. * @returns "ColorCorrectionPostProcess" string
  73676. */
  73677. getClassName(): string;
  73678. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73679. /** @hidden */
  73680. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73681. }
  73682. }
  73683. declare module "babylonjs/Shaders/convolution.fragment" {
  73684. /** @hidden */
  73685. export var convolutionPixelShader: {
  73686. name: string;
  73687. shader: string;
  73688. };
  73689. }
  73690. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73692. import { Nullable } from "babylonjs/types";
  73693. import { Camera } from "babylonjs/Cameras/camera";
  73694. import { Engine } from "babylonjs/Engines/engine";
  73695. import "babylonjs/Shaders/convolution.fragment";
  73696. import { Scene } from "babylonjs/scene";
  73697. /**
  73698. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73699. * input texture to perform effects such as edge detection or sharpening
  73700. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73701. */
  73702. export class ConvolutionPostProcess extends PostProcess {
  73703. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73704. kernel: number[];
  73705. /**
  73706. * Gets a string identifying the name of the class
  73707. * @returns "ConvolutionPostProcess" string
  73708. */
  73709. getClassName(): string;
  73710. /**
  73711. * Creates a new instance ConvolutionPostProcess
  73712. * @param name The name of the effect.
  73713. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73714. * @param options The required width/height ratio to downsize to before computing the render pass.
  73715. * @param camera The camera to apply the render pass to.
  73716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73717. * @param engine The engine which the post process will be applied. (default: current engine)
  73718. * @param reusable If the post process can be reused on the same frame. (default: false)
  73719. * @param textureType Type of textures used when performing the post process. (default: 0)
  73720. */
  73721. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73722. /** @hidden */
  73723. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73724. /**
  73725. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73726. */
  73727. static EdgeDetect0Kernel: number[];
  73728. /**
  73729. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73730. */
  73731. static EdgeDetect1Kernel: number[];
  73732. /**
  73733. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73734. */
  73735. static EdgeDetect2Kernel: number[];
  73736. /**
  73737. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73738. */
  73739. static SharpenKernel: number[];
  73740. /**
  73741. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73742. */
  73743. static EmbossKernel: number[];
  73744. /**
  73745. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73746. */
  73747. static GaussianKernel: number[];
  73748. }
  73749. }
  73750. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73751. import { Nullable } from "babylonjs/types";
  73752. import { Vector2 } from "babylonjs/Maths/math.vector";
  73753. import { Camera } from "babylonjs/Cameras/camera";
  73754. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73755. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73756. import { Engine } from "babylonjs/Engines/engine";
  73757. import { Scene } from "babylonjs/scene";
  73758. /**
  73759. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73760. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73761. * based on samples that have a large difference in distance than the center pixel.
  73762. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73763. */
  73764. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73765. /**
  73766. * The direction the blur should be applied
  73767. */
  73768. direction: Vector2;
  73769. /**
  73770. * Gets a string identifying the name of the class
  73771. * @returns "DepthOfFieldBlurPostProcess" string
  73772. */
  73773. getClassName(): string;
  73774. /**
  73775. * Creates a new instance CircleOfConfusionPostProcess
  73776. * @param name The name of the effect.
  73777. * @param scene The scene the effect belongs to.
  73778. * @param direction The direction the blur should be applied.
  73779. * @param kernel The size of the kernel used to blur.
  73780. * @param options The required width/height ratio to downsize to before computing the render pass.
  73781. * @param camera The camera to apply the render pass to.
  73782. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73783. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73785. * @param engine The engine which the post process will be applied. (default: current engine)
  73786. * @param reusable If the post process can be reused on the same frame. (default: false)
  73787. * @param textureType Type of textures used when performing the post process. (default: 0)
  73788. * @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)
  73789. */
  73790. 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);
  73791. }
  73792. }
  73793. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73794. /** @hidden */
  73795. export var depthOfFieldMergePixelShader: {
  73796. name: string;
  73797. shader: string;
  73798. };
  73799. }
  73800. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73801. import { Nullable } from "babylonjs/types";
  73802. import { Camera } from "babylonjs/Cameras/camera";
  73803. import { Effect } from "babylonjs/Materials/effect";
  73804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73805. import { Engine } from "babylonjs/Engines/engine";
  73806. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73807. /**
  73808. * Options to be set when merging outputs from the default pipeline.
  73809. */
  73810. export class DepthOfFieldMergePostProcessOptions {
  73811. /**
  73812. * The original image to merge on top of
  73813. */
  73814. originalFromInput: PostProcess;
  73815. /**
  73816. * Parameters to perform the merge of the depth of field effect
  73817. */
  73818. depthOfField?: {
  73819. circleOfConfusion: PostProcess;
  73820. blurSteps: Array<PostProcess>;
  73821. };
  73822. /**
  73823. * Parameters to perform the merge of bloom effect
  73824. */
  73825. bloom?: {
  73826. blurred: PostProcess;
  73827. weight: number;
  73828. };
  73829. }
  73830. /**
  73831. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73832. */
  73833. export class DepthOfFieldMergePostProcess extends PostProcess {
  73834. private blurSteps;
  73835. /**
  73836. * Gets a string identifying the name of the class
  73837. * @returns "DepthOfFieldMergePostProcess" string
  73838. */
  73839. getClassName(): string;
  73840. /**
  73841. * Creates a new instance of DepthOfFieldMergePostProcess
  73842. * @param name The name of the effect.
  73843. * @param originalFromInput Post process which's input will be used for the merge.
  73844. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73845. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73846. * @param options The required width/height ratio to downsize to before computing the render pass.
  73847. * @param camera The camera to apply the render pass to.
  73848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73849. * @param engine The engine which the post process will be applied. (default: current engine)
  73850. * @param reusable If the post process can be reused on the same frame. (default: false)
  73851. * @param textureType Type of textures used when performing the post process. (default: 0)
  73852. * @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)
  73853. */
  73854. 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);
  73855. /**
  73856. * Updates the effect with the current post process compile time values and recompiles the shader.
  73857. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73858. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73859. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73860. * @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
  73861. * @param onCompiled Called when the shader has been compiled.
  73862. * @param onError Called if there is an error when compiling a shader.
  73863. */
  73864. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73865. }
  73866. }
  73867. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73868. import { Nullable } from "babylonjs/types";
  73869. import { Camera } from "babylonjs/Cameras/camera";
  73870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73871. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73872. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73873. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73874. import { Scene } from "babylonjs/scene";
  73875. /**
  73876. * Specifies the level of max blur that should be applied when using the depth of field effect
  73877. */
  73878. export enum DepthOfFieldEffectBlurLevel {
  73879. /**
  73880. * Subtle blur
  73881. */
  73882. Low = 0,
  73883. /**
  73884. * Medium blur
  73885. */
  73886. Medium = 1,
  73887. /**
  73888. * Large blur
  73889. */
  73890. High = 2
  73891. }
  73892. /**
  73893. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73894. */
  73895. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73896. private _circleOfConfusion;
  73897. /**
  73898. * @hidden Internal, blurs from high to low
  73899. */
  73900. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73901. private _depthOfFieldBlurY;
  73902. private _dofMerge;
  73903. /**
  73904. * @hidden Internal post processes in depth of field effect
  73905. */
  73906. _effects: Array<PostProcess>;
  73907. /**
  73908. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73909. */
  73910. set focalLength(value: number);
  73911. get focalLength(): number;
  73912. /**
  73913. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73914. */
  73915. set fStop(value: number);
  73916. get fStop(): number;
  73917. /**
  73918. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73919. */
  73920. set focusDistance(value: number);
  73921. get focusDistance(): number;
  73922. /**
  73923. * 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.
  73924. */
  73925. set lensSize(value: number);
  73926. get lensSize(): number;
  73927. /**
  73928. * Creates a new instance DepthOfFieldEffect
  73929. * @param scene The scene the effect belongs to.
  73930. * @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.
  73931. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73932. * @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)
  73933. */
  73934. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73935. /**
  73936. * Get the current class name of the current effet
  73937. * @returns "DepthOfFieldEffect"
  73938. */
  73939. getClassName(): string;
  73940. /**
  73941. * 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.
  73942. */
  73943. set depthTexture(value: RenderTargetTexture);
  73944. /**
  73945. * Disposes each of the internal effects for a given camera.
  73946. * @param camera The camera to dispose the effect on.
  73947. */
  73948. disposeEffects(camera: Camera): void;
  73949. /**
  73950. * @hidden Internal
  73951. */
  73952. _updateEffects(): void;
  73953. /**
  73954. * Internal
  73955. * @returns if all the contained post processes are ready.
  73956. * @hidden
  73957. */
  73958. _isReady(): boolean;
  73959. }
  73960. }
  73961. declare module "babylonjs/Shaders/displayPass.fragment" {
  73962. /** @hidden */
  73963. export var displayPassPixelShader: {
  73964. name: string;
  73965. shader: string;
  73966. };
  73967. }
  73968. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73969. import { Nullable } from "babylonjs/types";
  73970. import { Camera } from "babylonjs/Cameras/camera";
  73971. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73972. import { Engine } from "babylonjs/Engines/engine";
  73973. import "babylonjs/Shaders/displayPass.fragment";
  73974. import { Scene } from "babylonjs/scene";
  73975. /**
  73976. * DisplayPassPostProcess which produces an output the same as it's input
  73977. */
  73978. export class DisplayPassPostProcess extends PostProcess {
  73979. /**
  73980. * Gets a string identifying the name of the class
  73981. * @returns "DisplayPassPostProcess" string
  73982. */
  73983. getClassName(): string;
  73984. /**
  73985. * Creates the DisplayPassPostProcess
  73986. * @param name The name of the effect.
  73987. * @param options The required width/height ratio to downsize to before computing the render pass.
  73988. * @param camera The camera to apply the render pass to.
  73989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73990. * @param engine The engine which the post process will be applied. (default: current engine)
  73991. * @param reusable If the post process can be reused on the same frame. (default: false)
  73992. */
  73993. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73994. /** @hidden */
  73995. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73996. }
  73997. }
  73998. declare module "babylonjs/Shaders/filter.fragment" {
  73999. /** @hidden */
  74000. export var filterPixelShader: {
  74001. name: string;
  74002. shader: string;
  74003. };
  74004. }
  74005. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74006. import { Nullable } from "babylonjs/types";
  74007. import { Matrix } from "babylonjs/Maths/math.vector";
  74008. import { Camera } from "babylonjs/Cameras/camera";
  74009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74010. import { Engine } from "babylonjs/Engines/engine";
  74011. import "babylonjs/Shaders/filter.fragment";
  74012. import { Scene } from "babylonjs/scene";
  74013. /**
  74014. * Applies a kernel filter to the image
  74015. */
  74016. export class FilterPostProcess extends PostProcess {
  74017. /** The matrix to be applied to the image */
  74018. kernelMatrix: Matrix;
  74019. /**
  74020. * Gets a string identifying the name of the class
  74021. * @returns "FilterPostProcess" string
  74022. */
  74023. getClassName(): string;
  74024. /**
  74025. *
  74026. * @param name The name of the effect.
  74027. * @param kernelMatrix The matrix to be applied to the image
  74028. * @param options The required width/height ratio to downsize to before computing the render pass.
  74029. * @param camera The camera to apply the render pass to.
  74030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74031. * @param engine The engine which the post process will be applied. (default: current engine)
  74032. * @param reusable If the post process can be reused on the same frame. (default: false)
  74033. */
  74034. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74035. /** @hidden */
  74036. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74037. }
  74038. }
  74039. declare module "babylonjs/Shaders/fxaa.fragment" {
  74040. /** @hidden */
  74041. export var fxaaPixelShader: {
  74042. name: string;
  74043. shader: string;
  74044. };
  74045. }
  74046. declare module "babylonjs/Shaders/fxaa.vertex" {
  74047. /** @hidden */
  74048. export var fxaaVertexShader: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74054. import { Nullable } from "babylonjs/types";
  74055. import { Camera } from "babylonjs/Cameras/camera";
  74056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74057. import { Engine } from "babylonjs/Engines/engine";
  74058. import "babylonjs/Shaders/fxaa.fragment";
  74059. import "babylonjs/Shaders/fxaa.vertex";
  74060. import { Scene } from "babylonjs/scene";
  74061. /**
  74062. * Fxaa post process
  74063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74064. */
  74065. export class FxaaPostProcess extends PostProcess {
  74066. /**
  74067. * Gets a string identifying the name of the class
  74068. * @returns "FxaaPostProcess" string
  74069. */
  74070. getClassName(): string;
  74071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74072. private _getDefines;
  74073. /** @hidden */
  74074. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74075. }
  74076. }
  74077. declare module "babylonjs/Shaders/grain.fragment" {
  74078. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74079. /** @hidden */
  74080. export var grainPixelShader: {
  74081. name: string;
  74082. shader: string;
  74083. };
  74084. }
  74085. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74086. import { Nullable } from "babylonjs/types";
  74087. import { Camera } from "babylonjs/Cameras/camera";
  74088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74089. import { Engine } from "babylonjs/Engines/engine";
  74090. import "babylonjs/Shaders/grain.fragment";
  74091. import { Scene } from "babylonjs/scene";
  74092. /**
  74093. * The GrainPostProcess adds noise to the image at mid luminance levels
  74094. */
  74095. export class GrainPostProcess extends PostProcess {
  74096. /**
  74097. * The intensity of the grain added (default: 30)
  74098. */
  74099. intensity: number;
  74100. /**
  74101. * If the grain should be randomized on every frame
  74102. */
  74103. animated: boolean;
  74104. /**
  74105. * Gets a string identifying the name of the class
  74106. * @returns "GrainPostProcess" string
  74107. */
  74108. getClassName(): string;
  74109. /**
  74110. * Creates a new instance of @see GrainPostProcess
  74111. * @param name The name of the effect.
  74112. * @param options The required width/height ratio to downsize to before computing the render pass.
  74113. * @param camera The camera to apply the render pass to.
  74114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74115. * @param engine The engine which the post process will be applied. (default: current engine)
  74116. * @param reusable If the post process can be reused on the same frame. (default: false)
  74117. * @param textureType Type of textures used when performing the post process. (default: 0)
  74118. * @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)
  74119. */
  74120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74121. /** @hidden */
  74122. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74123. }
  74124. }
  74125. declare module "babylonjs/Shaders/highlights.fragment" {
  74126. /** @hidden */
  74127. export var highlightsPixelShader: {
  74128. name: string;
  74129. shader: string;
  74130. };
  74131. }
  74132. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74133. import { Nullable } from "babylonjs/types";
  74134. import { Camera } from "babylonjs/Cameras/camera";
  74135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74136. import { Engine } from "babylonjs/Engines/engine";
  74137. import "babylonjs/Shaders/highlights.fragment";
  74138. /**
  74139. * Extracts highlights from the image
  74140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74141. */
  74142. export class HighlightsPostProcess extends PostProcess {
  74143. /**
  74144. * Gets a string identifying the name of the class
  74145. * @returns "HighlightsPostProcess" string
  74146. */
  74147. getClassName(): string;
  74148. /**
  74149. * Extracts highlights from the image
  74150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74151. * @param name The name of the effect.
  74152. * @param options The required width/height ratio to downsize to before computing the render pass.
  74153. * @param camera The camera to apply the render pass to.
  74154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74155. * @param engine The engine which the post process will be applied. (default: current engine)
  74156. * @param reusable If the post process can be reused on the same frame. (default: false)
  74157. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74158. */
  74159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74160. }
  74161. }
  74162. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74163. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74164. /**
  74165. * Contains all parameters needed for the prepass to perform
  74166. * motion blur
  74167. */
  74168. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74169. /**
  74170. * Is motion blur enabled
  74171. */
  74172. enabled: boolean;
  74173. /**
  74174. * Name of the configuration
  74175. */
  74176. name: string;
  74177. /**
  74178. * Textures that should be present in the MRT for this effect to work
  74179. */
  74180. readonly texturesRequired: number[];
  74181. }
  74182. }
  74183. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74184. import { Nullable } from "babylonjs/types";
  74185. import { Scene } from "babylonjs/scene";
  74186. import { ISceneComponent } from "babylonjs/sceneComponent";
  74187. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74188. module "babylonjs/scene" {
  74189. interface Scene {
  74190. /** @hidden (Backing field) */
  74191. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74192. /**
  74193. * Gets or Sets the current geometry buffer associated to the scene.
  74194. */
  74195. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74196. /**
  74197. * Enables a GeometryBufferRender and associates it with the scene
  74198. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74199. * @returns the GeometryBufferRenderer
  74200. */
  74201. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74202. /**
  74203. * Disables the GeometryBufferRender associated with the scene
  74204. */
  74205. disableGeometryBufferRenderer(): void;
  74206. }
  74207. }
  74208. /**
  74209. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74210. * in several rendering techniques.
  74211. */
  74212. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74213. /**
  74214. * The component name helpful to identify the component in the list of scene components.
  74215. */
  74216. readonly name: string;
  74217. /**
  74218. * The scene the component belongs to.
  74219. */
  74220. scene: Scene;
  74221. /**
  74222. * Creates a new instance of the component for the given scene
  74223. * @param scene Defines the scene to register the component in
  74224. */
  74225. constructor(scene: Scene);
  74226. /**
  74227. * Registers the component in a given scene
  74228. */
  74229. register(): void;
  74230. /**
  74231. * Rebuilds the elements related to this component in case of
  74232. * context lost for instance.
  74233. */
  74234. rebuild(): void;
  74235. /**
  74236. * Disposes the component and the associated ressources
  74237. */
  74238. dispose(): void;
  74239. private _gatherRenderTargets;
  74240. }
  74241. }
  74242. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74243. /** @hidden */
  74244. export var motionBlurPixelShader: {
  74245. name: string;
  74246. shader: string;
  74247. };
  74248. }
  74249. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74250. import { Nullable } from "babylonjs/types";
  74251. import { Camera } from "babylonjs/Cameras/camera";
  74252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74254. import "babylonjs/Animations/animatable";
  74255. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74256. import "babylonjs/Shaders/motionBlur.fragment";
  74257. import { Engine } from "babylonjs/Engines/engine";
  74258. import { Scene } from "babylonjs/scene";
  74259. /**
  74260. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74261. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74262. * As an example, all you have to do is to create the post-process:
  74263. * var mb = new BABYLON.MotionBlurPostProcess(
  74264. * 'mb', // The name of the effect.
  74265. * scene, // The scene containing the objects to blur according to their velocity.
  74266. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74267. * camera // The camera to apply the render pass to.
  74268. * );
  74269. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74270. */
  74271. export class MotionBlurPostProcess extends PostProcess {
  74272. /**
  74273. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74274. */
  74275. motionStrength: number;
  74276. /**
  74277. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74278. */
  74279. get motionBlurSamples(): number;
  74280. /**
  74281. * Sets the number of iterations to be used for motion blur quality
  74282. */
  74283. set motionBlurSamples(samples: number);
  74284. private _motionBlurSamples;
  74285. private _forceGeometryBuffer;
  74286. private _geometryBufferRenderer;
  74287. private _prePassRenderer;
  74288. /**
  74289. * Gets a string identifying the name of the class
  74290. * @returns "MotionBlurPostProcess" string
  74291. */
  74292. getClassName(): string;
  74293. /**
  74294. * Creates a new instance MotionBlurPostProcess
  74295. * @param name The name of the effect.
  74296. * @param scene The scene containing the objects to blur according to their velocity.
  74297. * @param options The required width/height ratio to downsize to before computing the render pass.
  74298. * @param camera The camera to apply the render pass to.
  74299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74300. * @param engine The engine which the post process will be applied. (default: current engine)
  74301. * @param reusable If the post process can be reused on the same frame. (default: false)
  74302. * @param textureType Type of textures used when performing the post process. (default: 0)
  74303. * @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)
  74304. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74305. */
  74306. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74307. /**
  74308. * Excludes the given skinned mesh from computing bones velocities.
  74309. * 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.
  74310. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74311. */
  74312. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74313. /**
  74314. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74315. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74316. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74317. */
  74318. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74319. /**
  74320. * Disposes the post process.
  74321. * @param camera The camera to dispose the post process on.
  74322. */
  74323. dispose(camera?: Camera): void;
  74324. /** @hidden */
  74325. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74326. }
  74327. }
  74328. declare module "babylonjs/Shaders/refraction.fragment" {
  74329. /** @hidden */
  74330. export var refractionPixelShader: {
  74331. name: string;
  74332. shader: string;
  74333. };
  74334. }
  74335. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74336. import { Color3 } from "babylonjs/Maths/math.color";
  74337. import { Camera } from "babylonjs/Cameras/camera";
  74338. import { Texture } from "babylonjs/Materials/Textures/texture";
  74339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74340. import { Engine } from "babylonjs/Engines/engine";
  74341. import "babylonjs/Shaders/refraction.fragment";
  74342. import { Scene } from "babylonjs/scene";
  74343. /**
  74344. * Post process which applies a refractin texture
  74345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74346. */
  74347. export class RefractionPostProcess extends PostProcess {
  74348. private _refTexture;
  74349. private _ownRefractionTexture;
  74350. /** the base color of the refraction (used to taint the rendering) */
  74351. color: Color3;
  74352. /** simulated refraction depth */
  74353. depth: number;
  74354. /** the coefficient of the base color (0 to remove base color tainting) */
  74355. colorLevel: number;
  74356. /** Gets the url used to load the refraction texture */
  74357. refractionTextureUrl: string;
  74358. /**
  74359. * Gets or sets the refraction texture
  74360. * Please note that you are responsible for disposing the texture if you set it manually
  74361. */
  74362. get refractionTexture(): Texture;
  74363. set refractionTexture(value: Texture);
  74364. /**
  74365. * Gets a string identifying the name of the class
  74366. * @returns "RefractionPostProcess" string
  74367. */
  74368. getClassName(): string;
  74369. /**
  74370. * Initializes the RefractionPostProcess
  74371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74372. * @param name The name of the effect.
  74373. * @param refractionTextureUrl Url of the refraction texture to use
  74374. * @param color the base color of the refraction (used to taint the rendering)
  74375. * @param depth simulated refraction depth
  74376. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74377. * @param camera The camera to apply the render pass to.
  74378. * @param options The required width/height ratio to downsize to before computing the render pass.
  74379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74380. * @param engine The engine which the post process will be applied. (default: current engine)
  74381. * @param reusable If the post process can be reused on the same frame. (default: false)
  74382. */
  74383. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74384. /**
  74385. * Disposes of the post process
  74386. * @param camera Camera to dispose post process on
  74387. */
  74388. dispose(camera: Camera): void;
  74389. /** @hidden */
  74390. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74391. }
  74392. }
  74393. declare module "babylonjs/Shaders/sharpen.fragment" {
  74394. /** @hidden */
  74395. export var sharpenPixelShader: {
  74396. name: string;
  74397. shader: string;
  74398. };
  74399. }
  74400. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74401. import { Nullable } from "babylonjs/types";
  74402. import { Camera } from "babylonjs/Cameras/camera";
  74403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74404. import "babylonjs/Shaders/sharpen.fragment";
  74405. import { Engine } from "babylonjs/Engines/engine";
  74406. import { Scene } from "babylonjs/scene";
  74407. /**
  74408. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74409. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74410. */
  74411. export class SharpenPostProcess extends PostProcess {
  74412. /**
  74413. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74414. */
  74415. colorAmount: number;
  74416. /**
  74417. * How much sharpness should be applied (default: 0.3)
  74418. */
  74419. edgeAmount: number;
  74420. /**
  74421. * Gets a string identifying the name of the class
  74422. * @returns "SharpenPostProcess" string
  74423. */
  74424. getClassName(): string;
  74425. /**
  74426. * Creates a new instance ConvolutionPostProcess
  74427. * @param name The name of the effect.
  74428. * @param options The required width/height ratio to downsize to before computing the render pass.
  74429. * @param camera The camera to apply the render pass to.
  74430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74431. * @param engine The engine which the post process will be applied. (default: current engine)
  74432. * @param reusable If the post process can be reused on the same frame. (default: false)
  74433. * @param textureType Type of textures used when performing the post process. (default: 0)
  74434. * @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)
  74435. */
  74436. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74437. /** @hidden */
  74438. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74439. }
  74440. }
  74441. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74442. import { Nullable } from "babylonjs/types";
  74443. import { Camera } from "babylonjs/Cameras/camera";
  74444. import { Engine } from "babylonjs/Engines/engine";
  74445. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74446. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74447. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74448. /**
  74449. * PostProcessRenderPipeline
  74450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74451. */
  74452. export class PostProcessRenderPipeline {
  74453. private engine;
  74454. private _renderEffects;
  74455. private _renderEffectsForIsolatedPass;
  74456. /**
  74457. * List of inspectable custom properties (used by the Inspector)
  74458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74459. */
  74460. inspectableCustomProperties: IInspectable[];
  74461. /**
  74462. * @hidden
  74463. */
  74464. protected _cameras: Camera[];
  74465. /** @hidden */
  74466. _name: string;
  74467. /**
  74468. * Gets pipeline name
  74469. */
  74470. get name(): string;
  74471. /** Gets the list of attached cameras */
  74472. get cameras(): Camera[];
  74473. /**
  74474. * Initializes a PostProcessRenderPipeline
  74475. * @param engine engine to add the pipeline to
  74476. * @param name name of the pipeline
  74477. */
  74478. constructor(engine: Engine, name: string);
  74479. /**
  74480. * Gets the class name
  74481. * @returns "PostProcessRenderPipeline"
  74482. */
  74483. getClassName(): string;
  74484. /**
  74485. * If all the render effects in the pipeline are supported
  74486. */
  74487. get isSupported(): boolean;
  74488. /**
  74489. * Adds an effect to the pipeline
  74490. * @param renderEffect the effect to add
  74491. */
  74492. addEffect(renderEffect: PostProcessRenderEffect): void;
  74493. /** @hidden */
  74494. _rebuild(): void;
  74495. /** @hidden */
  74496. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74497. /** @hidden */
  74498. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74499. /** @hidden */
  74500. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74501. /** @hidden */
  74502. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74503. /** @hidden */
  74504. _attachCameras(cameras: Camera, unique: boolean): void;
  74505. /** @hidden */
  74506. _attachCameras(cameras: Camera[], unique: boolean): void;
  74507. /** @hidden */
  74508. _detachCameras(cameras: Camera): void;
  74509. /** @hidden */
  74510. _detachCameras(cameras: Nullable<Camera[]>): void;
  74511. /** @hidden */
  74512. _update(): void;
  74513. /** @hidden */
  74514. _reset(): void;
  74515. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74516. /**
  74517. * Sets the required values to the prepass renderer.
  74518. * @param prePassRenderer defines the prepass renderer to setup.
  74519. * @returns true if the pre pass is needed.
  74520. */
  74521. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74522. /**
  74523. * Disposes of the pipeline
  74524. */
  74525. dispose(): void;
  74526. }
  74527. }
  74528. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74529. import { Camera } from "babylonjs/Cameras/camera";
  74530. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74531. /**
  74532. * PostProcessRenderPipelineManager class
  74533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74534. */
  74535. export class PostProcessRenderPipelineManager {
  74536. private _renderPipelines;
  74537. /**
  74538. * Initializes a PostProcessRenderPipelineManager
  74539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74540. */
  74541. constructor();
  74542. /**
  74543. * Gets the list of supported render pipelines
  74544. */
  74545. get supportedPipelines(): PostProcessRenderPipeline[];
  74546. /**
  74547. * Adds a pipeline to the manager
  74548. * @param renderPipeline The pipeline to add
  74549. */
  74550. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74551. /**
  74552. * Attaches a camera to the pipeline
  74553. * @param renderPipelineName The name of the pipeline to attach to
  74554. * @param cameras the camera to attach
  74555. * @param unique if the camera can be attached multiple times to the pipeline
  74556. */
  74557. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74558. /**
  74559. * Detaches a camera from the pipeline
  74560. * @param renderPipelineName The name of the pipeline to detach from
  74561. * @param cameras the camera to detach
  74562. */
  74563. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74564. /**
  74565. * Enables an effect by name on a pipeline
  74566. * @param renderPipelineName the name of the pipeline to enable the effect in
  74567. * @param renderEffectName the name of the effect to enable
  74568. * @param cameras the cameras that the effect should be enabled on
  74569. */
  74570. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74571. /**
  74572. * Disables an effect by name on a pipeline
  74573. * @param renderPipelineName the name of the pipeline to disable the effect in
  74574. * @param renderEffectName the name of the effect to disable
  74575. * @param cameras the cameras that the effect should be disabled on
  74576. */
  74577. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74578. /**
  74579. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74580. */
  74581. update(): void;
  74582. /** @hidden */
  74583. _rebuild(): void;
  74584. /**
  74585. * Disposes of the manager and pipelines
  74586. */
  74587. dispose(): void;
  74588. }
  74589. }
  74590. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74591. import { ISceneComponent } from "babylonjs/sceneComponent";
  74592. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74593. import { Scene } from "babylonjs/scene";
  74594. module "babylonjs/scene" {
  74595. interface Scene {
  74596. /** @hidden (Backing field) */
  74597. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74598. /**
  74599. * Gets the postprocess render pipeline manager
  74600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74601. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74602. */
  74603. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74604. }
  74605. }
  74606. /**
  74607. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74608. */
  74609. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74610. /**
  74611. * The component name helpfull to identify the component in the list of scene components.
  74612. */
  74613. readonly name: string;
  74614. /**
  74615. * The scene the component belongs to.
  74616. */
  74617. scene: Scene;
  74618. /**
  74619. * Creates a new instance of the component for the given scene
  74620. * @param scene Defines the scene to register the component in
  74621. */
  74622. constructor(scene: Scene);
  74623. /**
  74624. * Registers the component in a given scene
  74625. */
  74626. register(): void;
  74627. /**
  74628. * Rebuilds the elements related to this component in case of
  74629. * context lost for instance.
  74630. */
  74631. rebuild(): void;
  74632. /**
  74633. * Disposes the component and the associated ressources
  74634. */
  74635. dispose(): void;
  74636. private _gatherRenderTargets;
  74637. }
  74638. }
  74639. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74640. import { Nullable } from "babylonjs/types";
  74641. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74642. import { Camera } from "babylonjs/Cameras/camera";
  74643. import { IDisposable } from "babylonjs/scene";
  74644. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74645. import { Scene } from "babylonjs/scene";
  74646. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74647. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74648. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74649. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74650. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74651. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74652. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74653. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74654. import { Animation } from "babylonjs/Animations/animation";
  74655. /**
  74656. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74657. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74658. */
  74659. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74660. private _scene;
  74661. private _camerasToBeAttached;
  74662. /**
  74663. * ID of the sharpen post process,
  74664. */
  74665. private readonly SharpenPostProcessId;
  74666. /**
  74667. * @ignore
  74668. * ID of the image processing post process;
  74669. */
  74670. readonly ImageProcessingPostProcessId: string;
  74671. /**
  74672. * @ignore
  74673. * ID of the Fast Approximate Anti-Aliasing post process;
  74674. */
  74675. readonly FxaaPostProcessId: string;
  74676. /**
  74677. * ID of the chromatic aberration post process,
  74678. */
  74679. private readonly ChromaticAberrationPostProcessId;
  74680. /**
  74681. * ID of the grain post process
  74682. */
  74683. private readonly GrainPostProcessId;
  74684. /**
  74685. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74686. */
  74687. sharpen: SharpenPostProcess;
  74688. private _sharpenEffect;
  74689. private bloom;
  74690. /**
  74691. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74692. */
  74693. depthOfField: DepthOfFieldEffect;
  74694. /**
  74695. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74696. */
  74697. fxaa: FxaaPostProcess;
  74698. /**
  74699. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74700. */
  74701. imageProcessing: ImageProcessingPostProcess;
  74702. /**
  74703. * Chromatic aberration post process which will shift rgb colors in the image
  74704. */
  74705. chromaticAberration: ChromaticAberrationPostProcess;
  74706. private _chromaticAberrationEffect;
  74707. /**
  74708. * Grain post process which add noise to the image
  74709. */
  74710. grain: GrainPostProcess;
  74711. private _grainEffect;
  74712. /**
  74713. * Glow post process which adds a glow to emissive areas of the image
  74714. */
  74715. private _glowLayer;
  74716. /**
  74717. * Animations which can be used to tweak settings over a period of time
  74718. */
  74719. animations: Animation[];
  74720. private _imageProcessingConfigurationObserver;
  74721. private _sharpenEnabled;
  74722. private _bloomEnabled;
  74723. private _depthOfFieldEnabled;
  74724. private _depthOfFieldBlurLevel;
  74725. private _fxaaEnabled;
  74726. private _imageProcessingEnabled;
  74727. private _defaultPipelineTextureType;
  74728. private _bloomScale;
  74729. private _chromaticAberrationEnabled;
  74730. private _grainEnabled;
  74731. private _buildAllowed;
  74732. /**
  74733. * Gets active scene
  74734. */
  74735. get scene(): Scene;
  74736. /**
  74737. * Enable or disable the sharpen process from the pipeline
  74738. */
  74739. set sharpenEnabled(enabled: boolean);
  74740. get sharpenEnabled(): boolean;
  74741. private _resizeObserver;
  74742. private _hardwareScaleLevel;
  74743. private _bloomKernel;
  74744. /**
  74745. * Specifies the size of the bloom blur kernel, relative to the final output size
  74746. */
  74747. get bloomKernel(): number;
  74748. set bloomKernel(value: number);
  74749. /**
  74750. * Specifies the weight of the bloom in the final rendering
  74751. */
  74752. private _bloomWeight;
  74753. /**
  74754. * Specifies the luma threshold for the area that will be blurred by the bloom
  74755. */
  74756. private _bloomThreshold;
  74757. private _hdr;
  74758. /**
  74759. * The strength of the bloom.
  74760. */
  74761. set bloomWeight(value: number);
  74762. get bloomWeight(): number;
  74763. /**
  74764. * The strength of the bloom.
  74765. */
  74766. set bloomThreshold(value: number);
  74767. get bloomThreshold(): number;
  74768. /**
  74769. * The scale of the bloom, lower value will provide better performance.
  74770. */
  74771. set bloomScale(value: number);
  74772. get bloomScale(): number;
  74773. /**
  74774. * Enable or disable the bloom from the pipeline
  74775. */
  74776. set bloomEnabled(enabled: boolean);
  74777. get bloomEnabled(): boolean;
  74778. private _rebuildBloom;
  74779. /**
  74780. * If the depth of field is enabled.
  74781. */
  74782. get depthOfFieldEnabled(): boolean;
  74783. set depthOfFieldEnabled(enabled: boolean);
  74784. /**
  74785. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74786. */
  74787. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74788. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74789. /**
  74790. * If the anti aliasing is enabled.
  74791. */
  74792. set fxaaEnabled(enabled: boolean);
  74793. get fxaaEnabled(): boolean;
  74794. private _samples;
  74795. /**
  74796. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74797. */
  74798. set samples(sampleCount: number);
  74799. get samples(): number;
  74800. /**
  74801. * If image processing is enabled.
  74802. */
  74803. set imageProcessingEnabled(enabled: boolean);
  74804. get imageProcessingEnabled(): boolean;
  74805. /**
  74806. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74807. */
  74808. set glowLayerEnabled(enabled: boolean);
  74809. get glowLayerEnabled(): boolean;
  74810. /**
  74811. * Gets the glow layer (or null if not defined)
  74812. */
  74813. get glowLayer(): Nullable<GlowLayer>;
  74814. /**
  74815. * Enable or disable the chromaticAberration process from the pipeline
  74816. */
  74817. set chromaticAberrationEnabled(enabled: boolean);
  74818. get chromaticAberrationEnabled(): boolean;
  74819. /**
  74820. * Enable or disable the grain process from the pipeline
  74821. */
  74822. set grainEnabled(enabled: boolean);
  74823. get grainEnabled(): boolean;
  74824. /**
  74825. * @constructor
  74826. * @param name - The rendering pipeline name (default: "")
  74827. * @param hdr - If high dynamic range textures should be used (default: true)
  74828. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74829. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74830. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74831. */
  74832. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74833. /**
  74834. * Get the class name
  74835. * @returns "DefaultRenderingPipeline"
  74836. */
  74837. getClassName(): string;
  74838. /**
  74839. * Force the compilation of the entire pipeline.
  74840. */
  74841. prepare(): void;
  74842. private _hasCleared;
  74843. private _prevPostProcess;
  74844. private _prevPrevPostProcess;
  74845. private _setAutoClearAndTextureSharing;
  74846. private _depthOfFieldSceneObserver;
  74847. private _buildPipeline;
  74848. private _disposePostProcesses;
  74849. /**
  74850. * Adds a camera to the pipeline
  74851. * @param camera the camera to be added
  74852. */
  74853. addCamera(camera: Camera): void;
  74854. /**
  74855. * Removes a camera from the pipeline
  74856. * @param camera the camera to remove
  74857. */
  74858. removeCamera(camera: Camera): void;
  74859. /**
  74860. * Dispose of the pipeline and stop all post processes
  74861. */
  74862. dispose(): void;
  74863. /**
  74864. * Serialize the rendering pipeline (Used when exporting)
  74865. * @returns the serialized object
  74866. */
  74867. serialize(): any;
  74868. /**
  74869. * Parse the serialized pipeline
  74870. * @param source Source pipeline.
  74871. * @param scene The scene to load the pipeline to.
  74872. * @param rootUrl The URL of the serialized pipeline.
  74873. * @returns An instantiated pipeline from the serialized object.
  74874. */
  74875. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74876. }
  74877. }
  74878. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74879. /** @hidden */
  74880. export var lensHighlightsPixelShader: {
  74881. name: string;
  74882. shader: string;
  74883. };
  74884. }
  74885. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74886. /** @hidden */
  74887. export var depthOfFieldPixelShader: {
  74888. name: string;
  74889. shader: string;
  74890. };
  74891. }
  74892. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74893. import { Camera } from "babylonjs/Cameras/camera";
  74894. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74895. import { Scene } from "babylonjs/scene";
  74896. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74897. import "babylonjs/Shaders/chromaticAberration.fragment";
  74898. import "babylonjs/Shaders/lensHighlights.fragment";
  74899. import "babylonjs/Shaders/depthOfField.fragment";
  74900. /**
  74901. * BABYLON.JS Chromatic Aberration GLSL Shader
  74902. * Author: Olivier Guyot
  74903. * Separates very slightly R, G and B colors on the edges of the screen
  74904. * Inspired by Francois Tarlier & Martins Upitis
  74905. */
  74906. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74907. /**
  74908. * @ignore
  74909. * The chromatic aberration PostProcess id in the pipeline
  74910. */
  74911. LensChromaticAberrationEffect: string;
  74912. /**
  74913. * @ignore
  74914. * The highlights enhancing PostProcess id in the pipeline
  74915. */
  74916. HighlightsEnhancingEffect: string;
  74917. /**
  74918. * @ignore
  74919. * The depth-of-field PostProcess id in the pipeline
  74920. */
  74921. LensDepthOfFieldEffect: string;
  74922. private _scene;
  74923. private _depthTexture;
  74924. private _grainTexture;
  74925. private _chromaticAberrationPostProcess;
  74926. private _highlightsPostProcess;
  74927. private _depthOfFieldPostProcess;
  74928. private _edgeBlur;
  74929. private _grainAmount;
  74930. private _chromaticAberration;
  74931. private _distortion;
  74932. private _highlightsGain;
  74933. private _highlightsThreshold;
  74934. private _dofDistance;
  74935. private _dofAperture;
  74936. private _dofDarken;
  74937. private _dofPentagon;
  74938. private _blurNoise;
  74939. /**
  74940. * @constructor
  74941. *
  74942. * Effect parameters are as follow:
  74943. * {
  74944. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74945. * edge_blur: number; // from 0 to x (1 for realism)
  74946. * distortion: number; // from 0 to x (1 for realism)
  74947. * grain_amount: number; // from 0 to 1
  74948. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74949. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74950. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74951. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74952. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74953. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74954. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74955. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74956. * }
  74957. * Note: if an effect parameter is unset, effect is disabled
  74958. *
  74959. * @param name The rendering pipeline name
  74960. * @param parameters - An object containing all parameters (see above)
  74961. * @param scene The scene linked to this pipeline
  74962. * @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)
  74963. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74964. */
  74965. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74966. /**
  74967. * Get the class name
  74968. * @returns "LensRenderingPipeline"
  74969. */
  74970. getClassName(): string;
  74971. /**
  74972. * Gets associated scene
  74973. */
  74974. get scene(): Scene;
  74975. /**
  74976. * Gets or sets the edge blur
  74977. */
  74978. get edgeBlur(): number;
  74979. set edgeBlur(value: number);
  74980. /**
  74981. * Gets or sets the grain amount
  74982. */
  74983. get grainAmount(): number;
  74984. set grainAmount(value: number);
  74985. /**
  74986. * Gets or sets the chromatic aberration amount
  74987. */
  74988. get chromaticAberration(): number;
  74989. set chromaticAberration(value: number);
  74990. /**
  74991. * Gets or sets the depth of field aperture
  74992. */
  74993. get dofAperture(): number;
  74994. set dofAperture(value: number);
  74995. /**
  74996. * Gets or sets the edge distortion
  74997. */
  74998. get edgeDistortion(): number;
  74999. set edgeDistortion(value: number);
  75000. /**
  75001. * Gets or sets the depth of field distortion
  75002. */
  75003. get dofDistortion(): number;
  75004. set dofDistortion(value: number);
  75005. /**
  75006. * Gets or sets the darken out of focus amount
  75007. */
  75008. get darkenOutOfFocus(): number;
  75009. set darkenOutOfFocus(value: number);
  75010. /**
  75011. * Gets or sets a boolean indicating if blur noise is enabled
  75012. */
  75013. get blurNoise(): boolean;
  75014. set blurNoise(value: boolean);
  75015. /**
  75016. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75017. */
  75018. get pentagonBokeh(): boolean;
  75019. set pentagonBokeh(value: boolean);
  75020. /**
  75021. * Gets or sets the highlight grain amount
  75022. */
  75023. get highlightsGain(): number;
  75024. set highlightsGain(value: number);
  75025. /**
  75026. * Gets or sets the highlight threshold
  75027. */
  75028. get highlightsThreshold(): number;
  75029. set highlightsThreshold(value: number);
  75030. /**
  75031. * Sets the amount of blur at the edges
  75032. * @param amount blur amount
  75033. */
  75034. setEdgeBlur(amount: number): void;
  75035. /**
  75036. * Sets edge blur to 0
  75037. */
  75038. disableEdgeBlur(): void;
  75039. /**
  75040. * Sets the amout of grain
  75041. * @param amount Amount of grain
  75042. */
  75043. setGrainAmount(amount: number): void;
  75044. /**
  75045. * Set grain amount to 0
  75046. */
  75047. disableGrain(): void;
  75048. /**
  75049. * Sets the chromatic aberration amount
  75050. * @param amount amount of chromatic aberration
  75051. */
  75052. setChromaticAberration(amount: number): void;
  75053. /**
  75054. * Sets chromatic aberration amount to 0
  75055. */
  75056. disableChromaticAberration(): void;
  75057. /**
  75058. * Sets the EdgeDistortion amount
  75059. * @param amount amount of EdgeDistortion
  75060. */
  75061. setEdgeDistortion(amount: number): void;
  75062. /**
  75063. * Sets edge distortion to 0
  75064. */
  75065. disableEdgeDistortion(): void;
  75066. /**
  75067. * Sets the FocusDistance amount
  75068. * @param amount amount of FocusDistance
  75069. */
  75070. setFocusDistance(amount: number): void;
  75071. /**
  75072. * Disables depth of field
  75073. */
  75074. disableDepthOfField(): void;
  75075. /**
  75076. * Sets the Aperture amount
  75077. * @param amount amount of Aperture
  75078. */
  75079. setAperture(amount: number): void;
  75080. /**
  75081. * Sets the DarkenOutOfFocus amount
  75082. * @param amount amount of DarkenOutOfFocus
  75083. */
  75084. setDarkenOutOfFocus(amount: number): void;
  75085. private _pentagonBokehIsEnabled;
  75086. /**
  75087. * Creates a pentagon bokeh effect
  75088. */
  75089. enablePentagonBokeh(): void;
  75090. /**
  75091. * Disables the pentagon bokeh effect
  75092. */
  75093. disablePentagonBokeh(): void;
  75094. /**
  75095. * Enables noise blur
  75096. */
  75097. enableNoiseBlur(): void;
  75098. /**
  75099. * Disables noise blur
  75100. */
  75101. disableNoiseBlur(): void;
  75102. /**
  75103. * Sets the HighlightsGain amount
  75104. * @param amount amount of HighlightsGain
  75105. */
  75106. setHighlightsGain(amount: number): void;
  75107. /**
  75108. * Sets the HighlightsThreshold amount
  75109. * @param amount amount of HighlightsThreshold
  75110. */
  75111. setHighlightsThreshold(amount: number): void;
  75112. /**
  75113. * Disables highlights
  75114. */
  75115. disableHighlights(): void;
  75116. /**
  75117. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75118. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75119. */
  75120. dispose(disableDepthRender?: boolean): void;
  75121. private _createChromaticAberrationPostProcess;
  75122. private _createHighlightsPostProcess;
  75123. private _createDepthOfFieldPostProcess;
  75124. private _createGrainTexture;
  75125. }
  75126. }
  75127. declare module "babylonjs/Rendering/ssao2Configuration" {
  75128. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75129. /**
  75130. * Contains all parameters needed for the prepass to perform
  75131. * screen space subsurface scattering
  75132. */
  75133. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75134. /**
  75135. * Is subsurface enabled
  75136. */
  75137. enabled: boolean;
  75138. /**
  75139. * Name of the configuration
  75140. */
  75141. name: string;
  75142. /**
  75143. * Textures that should be present in the MRT for this effect to work
  75144. */
  75145. readonly texturesRequired: number[];
  75146. }
  75147. }
  75148. declare module "babylonjs/Shaders/ssao2.fragment" {
  75149. /** @hidden */
  75150. export var ssao2PixelShader: {
  75151. name: string;
  75152. shader: string;
  75153. };
  75154. }
  75155. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75156. /** @hidden */
  75157. export var ssaoCombinePixelShader: {
  75158. name: string;
  75159. shader: string;
  75160. };
  75161. }
  75162. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75163. import { Camera } from "babylonjs/Cameras/camera";
  75164. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75165. import { Scene } from "babylonjs/scene";
  75166. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75167. import "babylonjs/Shaders/ssao2.fragment";
  75168. import "babylonjs/Shaders/ssaoCombine.fragment";
  75169. /**
  75170. * Render pipeline to produce ssao effect
  75171. */
  75172. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75173. /**
  75174. * @ignore
  75175. * The PassPostProcess id in the pipeline that contains the original scene color
  75176. */
  75177. SSAOOriginalSceneColorEffect: string;
  75178. /**
  75179. * @ignore
  75180. * The SSAO PostProcess id in the pipeline
  75181. */
  75182. SSAORenderEffect: string;
  75183. /**
  75184. * @ignore
  75185. * The horizontal blur PostProcess id in the pipeline
  75186. */
  75187. SSAOBlurHRenderEffect: string;
  75188. /**
  75189. * @ignore
  75190. * The vertical blur PostProcess id in the pipeline
  75191. */
  75192. SSAOBlurVRenderEffect: string;
  75193. /**
  75194. * @ignore
  75195. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75196. */
  75197. SSAOCombineRenderEffect: string;
  75198. /**
  75199. * The output strength of the SSAO post-process. Default value is 1.0.
  75200. */
  75201. totalStrength: number;
  75202. /**
  75203. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75204. */
  75205. maxZ: number;
  75206. /**
  75207. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75208. */
  75209. minZAspect: number;
  75210. private _samples;
  75211. /**
  75212. * Number of samples used for the SSAO calculations. Default value is 8
  75213. */
  75214. set samples(n: number);
  75215. get samples(): number;
  75216. private _textureSamples;
  75217. /**
  75218. * Number of samples to use for antialiasing
  75219. */
  75220. set textureSamples(n: number);
  75221. get textureSamples(): number;
  75222. /**
  75223. * Force rendering the geometry through geometry buffer
  75224. */
  75225. private _forceGeometryBuffer;
  75226. /**
  75227. * Ratio object used for SSAO ratio and blur ratio
  75228. */
  75229. private _ratio;
  75230. /**
  75231. * Dynamically generated sphere sampler.
  75232. */
  75233. private _sampleSphere;
  75234. /**
  75235. * Blur filter offsets
  75236. */
  75237. private _samplerOffsets;
  75238. private _expensiveBlur;
  75239. /**
  75240. * If bilateral blur should be used
  75241. */
  75242. set expensiveBlur(b: boolean);
  75243. get expensiveBlur(): boolean;
  75244. /**
  75245. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75246. */
  75247. radius: number;
  75248. /**
  75249. * The base color of the SSAO post-process
  75250. * The final result is "base + ssao" between [0, 1]
  75251. */
  75252. base: number;
  75253. /**
  75254. * Support test.
  75255. */
  75256. static get IsSupported(): boolean;
  75257. private _scene;
  75258. private _randomTexture;
  75259. private _originalColorPostProcess;
  75260. private _ssaoPostProcess;
  75261. private _blurHPostProcess;
  75262. private _blurVPostProcess;
  75263. private _ssaoCombinePostProcess;
  75264. private _prePassRenderer;
  75265. /**
  75266. * Gets active scene
  75267. */
  75268. get scene(): Scene;
  75269. /**
  75270. * @constructor
  75271. * @param name The rendering pipeline name
  75272. * @param scene The scene linked to this pipeline
  75273. * @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 }
  75274. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75275. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75276. */
  75277. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75278. /**
  75279. * Get the class name
  75280. * @returns "SSAO2RenderingPipeline"
  75281. */
  75282. getClassName(): string;
  75283. /**
  75284. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75285. */
  75286. dispose(disableGeometryBufferRenderer?: boolean): void;
  75287. private _createBlurPostProcess;
  75288. /** @hidden */
  75289. _rebuild(): void;
  75290. private _bits;
  75291. private _radicalInverse_VdC;
  75292. private _hammersley;
  75293. private _hemisphereSample_uniform;
  75294. private _generateHemisphere;
  75295. private _getDefinesForSSAO;
  75296. private _createSSAOPostProcess;
  75297. private _createSSAOCombinePostProcess;
  75298. private _createRandomTexture;
  75299. /**
  75300. * Serialize the rendering pipeline (Used when exporting)
  75301. * @returns the serialized object
  75302. */
  75303. serialize(): any;
  75304. /**
  75305. * Parse the serialized pipeline
  75306. * @param source Source pipeline.
  75307. * @param scene The scene to load the pipeline to.
  75308. * @param rootUrl The URL of the serialized pipeline.
  75309. * @returns An instantiated pipeline from the serialized object.
  75310. */
  75311. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75312. }
  75313. }
  75314. declare module "babylonjs/Shaders/ssao.fragment" {
  75315. /** @hidden */
  75316. export var ssaoPixelShader: {
  75317. name: string;
  75318. shader: string;
  75319. };
  75320. }
  75321. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75322. import { Camera } from "babylonjs/Cameras/camera";
  75323. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75324. import { Scene } from "babylonjs/scene";
  75325. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75326. import "babylonjs/Shaders/ssao.fragment";
  75327. import "babylonjs/Shaders/ssaoCombine.fragment";
  75328. /**
  75329. * Render pipeline to produce ssao effect
  75330. */
  75331. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75332. /**
  75333. * @ignore
  75334. * The PassPostProcess id in the pipeline that contains the original scene color
  75335. */
  75336. SSAOOriginalSceneColorEffect: string;
  75337. /**
  75338. * @ignore
  75339. * The SSAO PostProcess id in the pipeline
  75340. */
  75341. SSAORenderEffect: string;
  75342. /**
  75343. * @ignore
  75344. * The horizontal blur PostProcess id in the pipeline
  75345. */
  75346. SSAOBlurHRenderEffect: string;
  75347. /**
  75348. * @ignore
  75349. * The vertical blur PostProcess id in the pipeline
  75350. */
  75351. SSAOBlurVRenderEffect: string;
  75352. /**
  75353. * @ignore
  75354. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75355. */
  75356. SSAOCombineRenderEffect: string;
  75357. /**
  75358. * The output strength of the SSAO post-process. Default value is 1.0.
  75359. */
  75360. totalStrength: number;
  75361. /**
  75362. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75363. */
  75364. radius: number;
  75365. /**
  75366. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75367. * Must not be equal to fallOff and superior to fallOff.
  75368. * Default value is 0.0075
  75369. */
  75370. area: number;
  75371. /**
  75372. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75373. * Must not be equal to area and inferior to area.
  75374. * Default value is 0.000001
  75375. */
  75376. fallOff: number;
  75377. /**
  75378. * The base color of the SSAO post-process
  75379. * The final result is "base + ssao" between [0, 1]
  75380. */
  75381. base: number;
  75382. private _scene;
  75383. private _depthTexture;
  75384. private _randomTexture;
  75385. private _originalColorPostProcess;
  75386. private _ssaoPostProcess;
  75387. private _blurHPostProcess;
  75388. private _blurVPostProcess;
  75389. private _ssaoCombinePostProcess;
  75390. private _firstUpdate;
  75391. /**
  75392. * Gets active scene
  75393. */
  75394. get scene(): Scene;
  75395. /**
  75396. * @constructor
  75397. * @param name - The rendering pipeline name
  75398. * @param scene - The scene linked to this pipeline
  75399. * @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 }
  75400. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75401. */
  75402. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75403. /**
  75404. * Get the class name
  75405. * @returns "SSAORenderingPipeline"
  75406. */
  75407. getClassName(): string;
  75408. /**
  75409. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75410. */
  75411. dispose(disableDepthRender?: boolean): void;
  75412. private _createBlurPostProcess;
  75413. /** @hidden */
  75414. _rebuild(): void;
  75415. private _createSSAOPostProcess;
  75416. private _createSSAOCombinePostProcess;
  75417. private _createRandomTexture;
  75418. }
  75419. }
  75420. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75421. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75422. /**
  75423. * Contains all parameters needed for the prepass to perform
  75424. * screen space reflections
  75425. */
  75426. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75427. /**
  75428. * Is ssr enabled
  75429. */
  75430. enabled: boolean;
  75431. /**
  75432. * Name of the configuration
  75433. */
  75434. name: string;
  75435. /**
  75436. * Textures that should be present in the MRT for this effect to work
  75437. */
  75438. readonly texturesRequired: number[];
  75439. }
  75440. }
  75441. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75442. /** @hidden */
  75443. export var screenSpaceReflectionPixelShader: {
  75444. name: string;
  75445. shader: string;
  75446. };
  75447. }
  75448. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75449. import { Nullable } from "babylonjs/types";
  75450. import { Camera } from "babylonjs/Cameras/camera";
  75451. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75452. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75453. import { Engine } from "babylonjs/Engines/engine";
  75454. import { Scene } from "babylonjs/scene";
  75455. /**
  75456. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75457. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75458. */
  75459. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75460. /**
  75461. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75462. */
  75463. threshold: number;
  75464. /**
  75465. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75466. */
  75467. strength: number;
  75468. /**
  75469. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75470. */
  75471. reflectionSpecularFalloffExponent: number;
  75472. /**
  75473. * 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]
  75474. */
  75475. step: number;
  75476. /**
  75477. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75478. */
  75479. roughnessFactor: number;
  75480. private _forceGeometryBuffer;
  75481. private _geometryBufferRenderer;
  75482. private _prePassRenderer;
  75483. private _enableSmoothReflections;
  75484. private _reflectionSamples;
  75485. private _smoothSteps;
  75486. /**
  75487. * Gets a string identifying the name of the class
  75488. * @returns "ScreenSpaceReflectionPostProcess" string
  75489. */
  75490. getClassName(): string;
  75491. /**
  75492. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75493. * @param name The name of the effect.
  75494. * @param scene The scene containing the objects to calculate reflections.
  75495. * @param options The required width/height ratio to downsize to before computing the render pass.
  75496. * @param camera The camera to apply the render pass to.
  75497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75498. * @param engine The engine which the post process will be applied. (default: current engine)
  75499. * @param reusable If the post process can be reused on the same frame. (default: false)
  75500. * @param textureType Type of textures used when performing the post process. (default: 0)
  75501. * @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)
  75502. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75503. */
  75504. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75505. /**
  75506. * Gets wether or not smoothing reflections is enabled.
  75507. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75508. */
  75509. get enableSmoothReflections(): boolean;
  75510. /**
  75511. * Sets wether or not smoothing reflections is enabled.
  75512. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75513. */
  75514. set enableSmoothReflections(enabled: boolean);
  75515. /**
  75516. * Gets the number of samples taken while computing reflections. More samples count is high,
  75517. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75518. */
  75519. get reflectionSamples(): number;
  75520. /**
  75521. * Sets the number of samples taken while computing reflections. More samples count is high,
  75522. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75523. */
  75524. set reflectionSamples(samples: number);
  75525. /**
  75526. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75527. * more the post-process will require GPU power and can generate a drop in FPS.
  75528. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75529. */
  75530. get smoothSteps(): number;
  75531. set smoothSteps(steps: number);
  75532. private _updateEffectDefines;
  75533. /** @hidden */
  75534. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75535. }
  75536. }
  75537. declare module "babylonjs/Shaders/standard.fragment" {
  75538. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75539. /** @hidden */
  75540. export var standardPixelShader: {
  75541. name: string;
  75542. shader: string;
  75543. };
  75544. }
  75545. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75546. import { Nullable } from "babylonjs/types";
  75547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75548. import { Camera } from "babylonjs/Cameras/camera";
  75549. import { Texture } from "babylonjs/Materials/Textures/texture";
  75550. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75551. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75552. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75553. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75554. import { IDisposable } from "babylonjs/scene";
  75555. import { SpotLight } from "babylonjs/Lights/spotLight";
  75556. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75557. import { Scene } from "babylonjs/scene";
  75558. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75559. import { Animation } from "babylonjs/Animations/animation";
  75560. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75561. import "babylonjs/Shaders/standard.fragment";
  75562. /**
  75563. * Standard rendering pipeline
  75564. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75565. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75566. */
  75567. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75568. /**
  75569. * Public members
  75570. */
  75571. /**
  75572. * Post-process which contains the original scene color before the pipeline applies all the effects
  75573. */
  75574. originalPostProcess: Nullable<PostProcess>;
  75575. /**
  75576. * Post-process used to down scale an image x4
  75577. */
  75578. downSampleX4PostProcess: Nullable<PostProcess>;
  75579. /**
  75580. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75581. */
  75582. brightPassPostProcess: Nullable<PostProcess>;
  75583. /**
  75584. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75585. */
  75586. blurHPostProcesses: PostProcess[];
  75587. /**
  75588. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75589. */
  75590. blurVPostProcesses: PostProcess[];
  75591. /**
  75592. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75593. */
  75594. textureAdderPostProcess: Nullable<PostProcess>;
  75595. /**
  75596. * Post-process used to create volumetric lighting effect
  75597. */
  75598. volumetricLightPostProcess: Nullable<PostProcess>;
  75599. /**
  75600. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75601. */
  75602. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75603. /**
  75604. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75605. */
  75606. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75607. /**
  75608. * Post-process used to merge the volumetric light effect and the real scene color
  75609. */
  75610. volumetricLightMergePostProces: Nullable<PostProcess>;
  75611. /**
  75612. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75613. */
  75614. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75615. /**
  75616. * Base post-process used to calculate the average luminance of the final image for HDR
  75617. */
  75618. luminancePostProcess: Nullable<PostProcess>;
  75619. /**
  75620. * Post-processes used to create down sample post-processes in order to get
  75621. * the average luminance of the final image for HDR
  75622. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75623. */
  75624. luminanceDownSamplePostProcesses: PostProcess[];
  75625. /**
  75626. * Post-process used to create a HDR effect (light adaptation)
  75627. */
  75628. hdrPostProcess: Nullable<PostProcess>;
  75629. /**
  75630. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75631. */
  75632. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75633. /**
  75634. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75635. */
  75636. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75637. /**
  75638. * Post-process used to merge the final HDR post-process and the real scene color
  75639. */
  75640. hdrFinalPostProcess: Nullable<PostProcess>;
  75641. /**
  75642. * Post-process used to create a lens flare effect
  75643. */
  75644. lensFlarePostProcess: Nullable<PostProcess>;
  75645. /**
  75646. * Post-process that merges the result of the lens flare post-process and the real scene color
  75647. */
  75648. lensFlareComposePostProcess: Nullable<PostProcess>;
  75649. /**
  75650. * Post-process used to create a motion blur effect
  75651. */
  75652. motionBlurPostProcess: Nullable<PostProcess>;
  75653. /**
  75654. * Post-process used to create a depth of field effect
  75655. */
  75656. depthOfFieldPostProcess: Nullable<PostProcess>;
  75657. /**
  75658. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75659. */
  75660. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75661. /**
  75662. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75663. */
  75664. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75665. /**
  75666. * Represents the brightness threshold in order to configure the illuminated surfaces
  75667. */
  75668. brightThreshold: number;
  75669. /**
  75670. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75671. */
  75672. blurWidth: number;
  75673. /**
  75674. * Sets if the blur for highlighted surfaces must be only horizontal
  75675. */
  75676. horizontalBlur: boolean;
  75677. /**
  75678. * Gets the overall exposure used by the pipeline
  75679. */
  75680. get exposure(): number;
  75681. /**
  75682. * Sets the overall exposure used by the pipeline
  75683. */
  75684. set exposure(value: number);
  75685. /**
  75686. * Texture used typically to simulate "dirty" on camera lens
  75687. */
  75688. lensTexture: Nullable<Texture>;
  75689. /**
  75690. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75691. */
  75692. volumetricLightCoefficient: number;
  75693. /**
  75694. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75695. */
  75696. volumetricLightPower: number;
  75697. /**
  75698. * Used the set the blur intensity to smooth the volumetric lights
  75699. */
  75700. volumetricLightBlurScale: number;
  75701. /**
  75702. * Light (spot or directional) used to generate the volumetric lights rays
  75703. * The source light must have a shadow generate so the pipeline can get its
  75704. * depth map
  75705. */
  75706. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75707. /**
  75708. * For eye adaptation, represents the minimum luminance the eye can see
  75709. */
  75710. hdrMinimumLuminance: number;
  75711. /**
  75712. * For eye adaptation, represents the decrease luminance speed
  75713. */
  75714. hdrDecreaseRate: number;
  75715. /**
  75716. * For eye adaptation, represents the increase luminance speed
  75717. */
  75718. hdrIncreaseRate: number;
  75719. /**
  75720. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75721. */
  75722. get hdrAutoExposure(): boolean;
  75723. /**
  75724. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75725. */
  75726. set hdrAutoExposure(value: boolean);
  75727. /**
  75728. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75729. */
  75730. lensColorTexture: Nullable<Texture>;
  75731. /**
  75732. * The overall strengh for the lens flare effect
  75733. */
  75734. lensFlareStrength: number;
  75735. /**
  75736. * Dispersion coefficient for lens flare ghosts
  75737. */
  75738. lensFlareGhostDispersal: number;
  75739. /**
  75740. * Main lens flare halo width
  75741. */
  75742. lensFlareHaloWidth: number;
  75743. /**
  75744. * Based on the lens distortion effect, defines how much the lens flare result
  75745. * is distorted
  75746. */
  75747. lensFlareDistortionStrength: number;
  75748. /**
  75749. * Configures the blur intensity used for for lens flare (halo)
  75750. */
  75751. lensFlareBlurWidth: number;
  75752. /**
  75753. * Lens star texture must be used to simulate rays on the flares and is available
  75754. * in the documentation
  75755. */
  75756. lensStarTexture: Nullable<Texture>;
  75757. /**
  75758. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75759. * flare effect by taking account of the dirt texture
  75760. */
  75761. lensFlareDirtTexture: Nullable<Texture>;
  75762. /**
  75763. * Represents the focal length for the depth of field effect
  75764. */
  75765. depthOfFieldDistance: number;
  75766. /**
  75767. * Represents the blur intensity for the blurred part of the depth of field effect
  75768. */
  75769. depthOfFieldBlurWidth: number;
  75770. /**
  75771. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75772. */
  75773. get motionStrength(): number;
  75774. /**
  75775. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75776. */
  75777. set motionStrength(strength: number);
  75778. /**
  75779. * Gets wether or not the motion blur post-process is object based or screen based.
  75780. */
  75781. get objectBasedMotionBlur(): boolean;
  75782. /**
  75783. * Sets wether or not the motion blur post-process should be object based or screen based
  75784. */
  75785. set objectBasedMotionBlur(value: boolean);
  75786. /**
  75787. * List of animations for the pipeline (IAnimatable implementation)
  75788. */
  75789. animations: Animation[];
  75790. /**
  75791. * Private members
  75792. */
  75793. private _scene;
  75794. private _currentDepthOfFieldSource;
  75795. private _basePostProcess;
  75796. private _fixedExposure;
  75797. private _currentExposure;
  75798. private _hdrAutoExposure;
  75799. private _hdrCurrentLuminance;
  75800. private _motionStrength;
  75801. private _isObjectBasedMotionBlur;
  75802. private _floatTextureType;
  75803. private _camerasToBeAttached;
  75804. private _ratio;
  75805. private _bloomEnabled;
  75806. private _depthOfFieldEnabled;
  75807. private _vlsEnabled;
  75808. private _lensFlareEnabled;
  75809. private _hdrEnabled;
  75810. private _motionBlurEnabled;
  75811. private _fxaaEnabled;
  75812. private _screenSpaceReflectionsEnabled;
  75813. private _motionBlurSamples;
  75814. private _volumetricLightStepsCount;
  75815. private _samples;
  75816. /**
  75817. * @ignore
  75818. * Specifies if the bloom pipeline is enabled
  75819. */
  75820. get BloomEnabled(): boolean;
  75821. set BloomEnabled(enabled: boolean);
  75822. /**
  75823. * @ignore
  75824. * Specifies if the depth of field pipeline is enabed
  75825. */
  75826. get DepthOfFieldEnabled(): boolean;
  75827. set DepthOfFieldEnabled(enabled: boolean);
  75828. /**
  75829. * @ignore
  75830. * Specifies if the lens flare pipeline is enabed
  75831. */
  75832. get LensFlareEnabled(): boolean;
  75833. set LensFlareEnabled(enabled: boolean);
  75834. /**
  75835. * @ignore
  75836. * Specifies if the HDR pipeline is enabled
  75837. */
  75838. get HDREnabled(): boolean;
  75839. set HDREnabled(enabled: boolean);
  75840. /**
  75841. * @ignore
  75842. * Specifies if the volumetric lights scattering effect is enabled
  75843. */
  75844. get VLSEnabled(): boolean;
  75845. set VLSEnabled(enabled: boolean);
  75846. /**
  75847. * @ignore
  75848. * Specifies if the motion blur effect is enabled
  75849. */
  75850. get MotionBlurEnabled(): boolean;
  75851. set MotionBlurEnabled(enabled: boolean);
  75852. /**
  75853. * Specifies if anti-aliasing is enabled
  75854. */
  75855. get fxaaEnabled(): boolean;
  75856. set fxaaEnabled(enabled: boolean);
  75857. /**
  75858. * Specifies if screen space reflections are enabled.
  75859. */
  75860. get screenSpaceReflectionsEnabled(): boolean;
  75861. set screenSpaceReflectionsEnabled(enabled: boolean);
  75862. /**
  75863. * Specifies the number of steps used to calculate the volumetric lights
  75864. * Typically in interval [50, 200]
  75865. */
  75866. get volumetricLightStepsCount(): number;
  75867. set volumetricLightStepsCount(count: number);
  75868. /**
  75869. * Specifies the number of samples used for the motion blur effect
  75870. * Typically in interval [16, 64]
  75871. */
  75872. get motionBlurSamples(): number;
  75873. set motionBlurSamples(samples: number);
  75874. /**
  75875. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75876. */
  75877. get samples(): number;
  75878. set samples(sampleCount: number);
  75879. /**
  75880. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75881. * @constructor
  75882. * @param name The rendering pipeline name
  75883. * @param scene The scene linked to this pipeline
  75884. * @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)
  75885. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75887. */
  75888. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75889. private _buildPipeline;
  75890. private _createDownSampleX4PostProcess;
  75891. private _createBrightPassPostProcess;
  75892. private _createBlurPostProcesses;
  75893. private _createTextureAdderPostProcess;
  75894. private _createVolumetricLightPostProcess;
  75895. private _createLuminancePostProcesses;
  75896. private _createHdrPostProcess;
  75897. private _createLensFlarePostProcess;
  75898. private _createDepthOfFieldPostProcess;
  75899. private _createMotionBlurPostProcess;
  75900. private _getDepthTexture;
  75901. private _disposePostProcesses;
  75902. /**
  75903. * Dispose of the pipeline and stop all post processes
  75904. */
  75905. dispose(): void;
  75906. /**
  75907. * Serialize the rendering pipeline (Used when exporting)
  75908. * @returns the serialized object
  75909. */
  75910. serialize(): any;
  75911. /**
  75912. * Parse the serialized pipeline
  75913. * @param source Source pipeline.
  75914. * @param scene The scene to load the pipeline to.
  75915. * @param rootUrl The URL of the serialized pipeline.
  75916. * @returns An instantiated pipeline from the serialized object.
  75917. */
  75918. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75919. /**
  75920. * Luminance steps
  75921. */
  75922. static LuminanceSteps: number;
  75923. }
  75924. }
  75925. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75926. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75927. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75928. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75929. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75930. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75931. }
  75932. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75933. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75934. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75935. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75936. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75937. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75938. }
  75939. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75940. /** @hidden */
  75941. export var stereoscopicInterlacePixelShader: {
  75942. name: string;
  75943. shader: string;
  75944. };
  75945. }
  75946. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75947. import { Camera } from "babylonjs/Cameras/camera";
  75948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75949. import { Engine } from "babylonjs/Engines/engine";
  75950. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75951. /**
  75952. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75953. */
  75954. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75955. private _stepSize;
  75956. private _passedProcess;
  75957. /**
  75958. * Gets a string identifying the name of the class
  75959. * @returns "StereoscopicInterlacePostProcessI" string
  75960. */
  75961. getClassName(): string;
  75962. /**
  75963. * Initializes a StereoscopicInterlacePostProcessI
  75964. * @param name The name of the effect.
  75965. * @param rigCameras The rig cameras to be appled to the post process
  75966. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75967. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75969. * @param engine The engine which the post process will be applied. (default: current engine)
  75970. * @param reusable If the post process can be reused on the same frame. (default: false)
  75971. */
  75972. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75973. }
  75974. /**
  75975. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75976. */
  75977. export class StereoscopicInterlacePostProcess extends PostProcess {
  75978. private _stepSize;
  75979. private _passedProcess;
  75980. /**
  75981. * Gets a string identifying the name of the class
  75982. * @returns "StereoscopicInterlacePostProcess" string
  75983. */
  75984. getClassName(): string;
  75985. /**
  75986. * Initializes a StereoscopicInterlacePostProcess
  75987. * @param name The name of the effect.
  75988. * @param rigCameras The rig cameras to be appled to the post process
  75989. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75991. * @param engine The engine which the post process will be applied. (default: current engine)
  75992. * @param reusable If the post process can be reused on the same frame. (default: false)
  75993. */
  75994. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75995. }
  75996. }
  75997. declare module "babylonjs/Shaders/tonemap.fragment" {
  75998. /** @hidden */
  75999. export var tonemapPixelShader: {
  76000. name: string;
  76001. shader: string;
  76002. };
  76003. }
  76004. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76005. import { Camera } from "babylonjs/Cameras/camera";
  76006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76007. import "babylonjs/Shaders/tonemap.fragment";
  76008. import { Engine } from "babylonjs/Engines/engine";
  76009. /** Defines operator used for tonemapping */
  76010. export enum TonemappingOperator {
  76011. /** Hable */
  76012. Hable = 0,
  76013. /** Reinhard */
  76014. Reinhard = 1,
  76015. /** HejiDawson */
  76016. HejiDawson = 2,
  76017. /** Photographic */
  76018. Photographic = 3
  76019. }
  76020. /**
  76021. * Defines a post process to apply tone mapping
  76022. */
  76023. export class TonemapPostProcess extends PostProcess {
  76024. private _operator;
  76025. /** Defines the required exposure adjustement */
  76026. exposureAdjustment: number;
  76027. /**
  76028. * Gets a string identifying the name of the class
  76029. * @returns "TonemapPostProcess" string
  76030. */
  76031. getClassName(): string;
  76032. /**
  76033. * Creates a new TonemapPostProcess
  76034. * @param name defines the name of the postprocess
  76035. * @param _operator defines the operator to use
  76036. * @param exposureAdjustment defines the required exposure adjustement
  76037. * @param camera defines the camera to use (can be null)
  76038. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76039. * @param engine defines the hosting engine (can be ignore if camera is set)
  76040. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76041. */
  76042. constructor(name: string, _operator: TonemappingOperator,
  76043. /** Defines the required exposure adjustement */
  76044. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76045. }
  76046. }
  76047. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76048. /** @hidden */
  76049. export var volumetricLightScatteringPixelShader: {
  76050. name: string;
  76051. shader: string;
  76052. };
  76053. }
  76054. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76055. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76056. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76057. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76058. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76059. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76060. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76061. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76062. /** @hidden */
  76063. export var volumetricLightScatteringPassVertexShader: {
  76064. name: string;
  76065. shader: string;
  76066. };
  76067. }
  76068. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76069. /** @hidden */
  76070. export var volumetricLightScatteringPassPixelShader: {
  76071. name: string;
  76072. shader: string;
  76073. };
  76074. }
  76075. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76076. import { Vector3 } from "babylonjs/Maths/math.vector";
  76077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76078. import { Mesh } from "babylonjs/Meshes/mesh";
  76079. import { Camera } from "babylonjs/Cameras/camera";
  76080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76082. import { Scene } from "babylonjs/scene";
  76083. import "babylonjs/Meshes/Builders/planeBuilder";
  76084. import "babylonjs/Shaders/depth.vertex";
  76085. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76086. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76087. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76088. import { Engine } from "babylonjs/Engines/engine";
  76089. /**
  76090. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76091. */
  76092. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76093. private _volumetricLightScatteringPass;
  76094. private _volumetricLightScatteringRTT;
  76095. private _viewPort;
  76096. private _screenCoordinates;
  76097. private _cachedDefines;
  76098. /**
  76099. * If not undefined, the mesh position is computed from the attached node position
  76100. */
  76101. attachedNode: {
  76102. position: Vector3;
  76103. };
  76104. /**
  76105. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76106. */
  76107. customMeshPosition: Vector3;
  76108. /**
  76109. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76110. */
  76111. useCustomMeshPosition: boolean;
  76112. /**
  76113. * If the post-process should inverse the light scattering direction
  76114. */
  76115. invert: boolean;
  76116. /**
  76117. * The internal mesh used by the post-process
  76118. */
  76119. mesh: Mesh;
  76120. /**
  76121. * @hidden
  76122. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76123. */
  76124. get useDiffuseColor(): boolean;
  76125. set useDiffuseColor(useDiffuseColor: boolean);
  76126. /**
  76127. * Array containing the excluded meshes not rendered in the internal pass
  76128. */
  76129. excludedMeshes: AbstractMesh[];
  76130. /**
  76131. * Controls the overall intensity of the post-process
  76132. */
  76133. exposure: number;
  76134. /**
  76135. * Dissipates each sample's contribution in range [0, 1]
  76136. */
  76137. decay: number;
  76138. /**
  76139. * Controls the overall intensity of each sample
  76140. */
  76141. weight: number;
  76142. /**
  76143. * Controls the density of each sample
  76144. */
  76145. density: number;
  76146. /**
  76147. * @constructor
  76148. * @param name The post-process name
  76149. * @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)
  76150. * @param camera The camera that the post-process will be attached to
  76151. * @param mesh The mesh used to create the light scattering
  76152. * @param samples The post-process quality, default 100
  76153. * @param samplingModeThe post-process filtering mode
  76154. * @param engine The babylon engine
  76155. * @param reusable If the post-process is reusable
  76156. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76157. */
  76158. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76159. /**
  76160. * Returns the string "VolumetricLightScatteringPostProcess"
  76161. * @returns "VolumetricLightScatteringPostProcess"
  76162. */
  76163. getClassName(): string;
  76164. private _isReady;
  76165. /**
  76166. * Sets the new light position for light scattering effect
  76167. * @param position The new custom light position
  76168. */
  76169. setCustomMeshPosition(position: Vector3): void;
  76170. /**
  76171. * Returns the light position for light scattering effect
  76172. * @return Vector3 The custom light position
  76173. */
  76174. getCustomMeshPosition(): Vector3;
  76175. /**
  76176. * Disposes the internal assets and detaches the post-process from the camera
  76177. */
  76178. dispose(camera: Camera): void;
  76179. /**
  76180. * Returns the render target texture used by the post-process
  76181. * @return the render target texture used by the post-process
  76182. */
  76183. getPass(): RenderTargetTexture;
  76184. private _meshExcluded;
  76185. private _createPass;
  76186. private _updateMeshScreenCoordinates;
  76187. /**
  76188. * Creates a default mesh for the Volumeric Light Scattering post-process
  76189. * @param name The mesh name
  76190. * @param scene The scene where to create the mesh
  76191. * @return the default mesh
  76192. */
  76193. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76194. }
  76195. }
  76196. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76197. /** @hidden */
  76198. export var screenSpaceCurvaturePixelShader: {
  76199. name: string;
  76200. shader: string;
  76201. };
  76202. }
  76203. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76204. import { Nullable } from "babylonjs/types";
  76205. import { Camera } from "babylonjs/Cameras/camera";
  76206. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76207. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76208. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76209. import { Engine } from "babylonjs/Engines/engine";
  76210. import { Scene } from "babylonjs/scene";
  76211. /**
  76212. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76213. */
  76214. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76215. /**
  76216. * Defines how much ridge the curvature effect displays.
  76217. */
  76218. ridge: number;
  76219. /**
  76220. * Defines how much valley the curvature effect displays.
  76221. */
  76222. valley: number;
  76223. private _geometryBufferRenderer;
  76224. /**
  76225. * Gets a string identifying the name of the class
  76226. * @returns "ScreenSpaceCurvaturePostProcess" string
  76227. */
  76228. getClassName(): string;
  76229. /**
  76230. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76231. * @param name The name of the effect.
  76232. * @param scene The scene containing the objects to blur according to their velocity.
  76233. * @param options The required width/height ratio to downsize to before computing the render pass.
  76234. * @param camera The camera to apply the render pass to.
  76235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76236. * @param engine The engine which the post process will be applied. (default: current engine)
  76237. * @param reusable If the post process can be reused on the same frame. (default: false)
  76238. * @param textureType Type of textures used when performing the post process. (default: 0)
  76239. * @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)
  76240. */
  76241. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76242. /**
  76243. * Support test.
  76244. */
  76245. static get IsSupported(): boolean;
  76246. /** @hidden */
  76247. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76248. }
  76249. }
  76250. declare module "babylonjs/PostProcesses/index" {
  76251. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76252. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76253. export * from "babylonjs/PostProcesses/bloomEffect";
  76254. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76255. export * from "babylonjs/PostProcesses/blurPostProcess";
  76256. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76257. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76258. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76259. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76260. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76261. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76262. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76263. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76264. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76265. export * from "babylonjs/PostProcesses/filterPostProcess";
  76266. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76267. export * from "babylonjs/PostProcesses/grainPostProcess";
  76268. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76269. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76270. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76271. export * from "babylonjs/PostProcesses/passPostProcess";
  76272. export * from "babylonjs/PostProcesses/postProcess";
  76273. export * from "babylonjs/PostProcesses/postProcessManager";
  76274. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76275. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76276. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76277. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76278. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76279. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76280. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76281. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76282. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76283. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76284. }
  76285. declare module "babylonjs/Probes/index" {
  76286. export * from "babylonjs/Probes/reflectionProbe";
  76287. }
  76288. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76289. import { Scene } from "babylonjs/scene";
  76290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76291. import { SmartArray } from "babylonjs/Misc/smartArray";
  76292. import { ISceneComponent } from "babylonjs/sceneComponent";
  76293. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76294. import "babylonjs/Meshes/Builders/boxBuilder";
  76295. import "babylonjs/Shaders/color.fragment";
  76296. import "babylonjs/Shaders/color.vertex";
  76297. import { Color3 } from "babylonjs/Maths/math.color";
  76298. import { Observable } from "babylonjs/Misc/observable";
  76299. module "babylonjs/scene" {
  76300. interface Scene {
  76301. /** @hidden (Backing field) */
  76302. _boundingBoxRenderer: BoundingBoxRenderer;
  76303. /** @hidden (Backing field) */
  76304. _forceShowBoundingBoxes: boolean;
  76305. /**
  76306. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76307. */
  76308. forceShowBoundingBoxes: boolean;
  76309. /**
  76310. * Gets the bounding box renderer associated with the scene
  76311. * @returns a BoundingBoxRenderer
  76312. */
  76313. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76314. }
  76315. }
  76316. module "babylonjs/Meshes/abstractMesh" {
  76317. interface AbstractMesh {
  76318. /** @hidden (Backing field) */
  76319. _showBoundingBox: boolean;
  76320. /**
  76321. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76322. */
  76323. showBoundingBox: boolean;
  76324. }
  76325. }
  76326. /**
  76327. * Component responsible of rendering the bounding box of the meshes in a scene.
  76328. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76329. */
  76330. export class BoundingBoxRenderer implements ISceneComponent {
  76331. /**
  76332. * The component name helpfull to identify the component in the list of scene components.
  76333. */
  76334. readonly name: string;
  76335. /**
  76336. * The scene the component belongs to.
  76337. */
  76338. scene: Scene;
  76339. /**
  76340. * Color of the bounding box lines placed in front of an object
  76341. */
  76342. frontColor: Color3;
  76343. /**
  76344. * Color of the bounding box lines placed behind an object
  76345. */
  76346. backColor: Color3;
  76347. /**
  76348. * Defines if the renderer should show the back lines or not
  76349. */
  76350. showBackLines: boolean;
  76351. /**
  76352. * Observable raised before rendering a bounding box
  76353. */
  76354. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76355. /**
  76356. * Observable raised after rendering a bounding box
  76357. */
  76358. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76359. /**
  76360. * @hidden
  76361. */
  76362. renderList: SmartArray<BoundingBox>;
  76363. private _colorShader;
  76364. private _vertexBuffers;
  76365. private _indexBuffer;
  76366. private _fillIndexBuffer;
  76367. private _fillIndexData;
  76368. /**
  76369. * Instantiates a new bounding box renderer in a scene.
  76370. * @param scene the scene the renderer renders in
  76371. */
  76372. constructor(scene: Scene);
  76373. /**
  76374. * Registers the component in a given scene
  76375. */
  76376. register(): void;
  76377. private _evaluateSubMesh;
  76378. private _activeMesh;
  76379. private _prepareRessources;
  76380. private _createIndexBuffer;
  76381. /**
  76382. * Rebuilds the elements related to this component in case of
  76383. * context lost for instance.
  76384. */
  76385. rebuild(): void;
  76386. /**
  76387. * @hidden
  76388. */
  76389. reset(): void;
  76390. /**
  76391. * Render the bounding boxes of a specific rendering group
  76392. * @param renderingGroupId defines the rendering group to render
  76393. */
  76394. render(renderingGroupId: number): void;
  76395. /**
  76396. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76397. * @param mesh Define the mesh to render the occlusion bounding box for
  76398. */
  76399. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76400. /**
  76401. * Dispose and release the resources attached to this renderer.
  76402. */
  76403. dispose(): void;
  76404. }
  76405. }
  76406. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76407. import { Nullable } from "babylonjs/types";
  76408. import { Scene } from "babylonjs/scene";
  76409. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76410. import { Camera } from "babylonjs/Cameras/camera";
  76411. import { ISceneComponent } from "babylonjs/sceneComponent";
  76412. module "babylonjs/scene" {
  76413. interface Scene {
  76414. /** @hidden (Backing field) */
  76415. _depthRenderer: {
  76416. [id: string]: DepthRenderer;
  76417. };
  76418. /**
  76419. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76420. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76421. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76422. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76423. * @returns the created depth renderer
  76424. */
  76425. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76426. /**
  76427. * Disables a depth renderer for a given camera
  76428. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76429. */
  76430. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76431. }
  76432. }
  76433. /**
  76434. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76435. * in several rendering techniques.
  76436. */
  76437. export class DepthRendererSceneComponent implements ISceneComponent {
  76438. /**
  76439. * The component name helpfull to identify the component in the list of scene components.
  76440. */
  76441. readonly name: string;
  76442. /**
  76443. * The scene the component belongs to.
  76444. */
  76445. scene: Scene;
  76446. /**
  76447. * Creates a new instance of the component for the given scene
  76448. * @param scene Defines the scene to register the component in
  76449. */
  76450. constructor(scene: Scene);
  76451. /**
  76452. * Registers the component in a given scene
  76453. */
  76454. register(): void;
  76455. /**
  76456. * Rebuilds the elements related to this component in case of
  76457. * context lost for instance.
  76458. */
  76459. rebuild(): void;
  76460. /**
  76461. * Disposes the component and the associated ressources
  76462. */
  76463. dispose(): void;
  76464. private _gatherRenderTargets;
  76465. private _gatherActiveCameraRenderTargets;
  76466. }
  76467. }
  76468. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76469. import { Nullable } from "babylonjs/types";
  76470. import { Scene } from "babylonjs/scene";
  76471. import { ISceneComponent } from "babylonjs/sceneComponent";
  76472. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76473. module "babylonjs/abstractScene" {
  76474. interface AbstractScene {
  76475. /** @hidden (Backing field) */
  76476. _prePassRenderer: Nullable<PrePassRenderer>;
  76477. /**
  76478. * Gets or Sets the current prepass renderer associated to the scene.
  76479. */
  76480. prePassRenderer: Nullable<PrePassRenderer>;
  76481. /**
  76482. * Enables the prepass and associates it with the scene
  76483. * @returns the PrePassRenderer
  76484. */
  76485. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76486. /**
  76487. * Disables the prepass associated with the scene
  76488. */
  76489. disablePrePassRenderer(): void;
  76490. }
  76491. }
  76492. /**
  76493. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76494. * in several rendering techniques.
  76495. */
  76496. export class PrePassRendererSceneComponent implements ISceneComponent {
  76497. /**
  76498. * The component name helpful to identify the component in the list of scene components.
  76499. */
  76500. readonly name: string;
  76501. /**
  76502. * The scene the component belongs to.
  76503. */
  76504. scene: Scene;
  76505. /**
  76506. * Creates a new instance of the component for the given scene
  76507. * @param scene Defines the scene to register the component in
  76508. */
  76509. constructor(scene: Scene);
  76510. /**
  76511. * Registers the component in a given scene
  76512. */
  76513. register(): void;
  76514. private _beforeCameraDraw;
  76515. private _afterCameraDraw;
  76516. private _beforeClearStage;
  76517. /**
  76518. * Rebuilds the elements related to this component in case of
  76519. * context lost for instance.
  76520. */
  76521. rebuild(): void;
  76522. /**
  76523. * Disposes the component and the associated ressources
  76524. */
  76525. dispose(): void;
  76526. }
  76527. }
  76528. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76529. /** @hidden */
  76530. export var fibonacci: {
  76531. name: string;
  76532. shader: string;
  76533. };
  76534. }
  76535. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76536. /** @hidden */
  76537. export var diffusionProfile: {
  76538. name: string;
  76539. shader: string;
  76540. };
  76541. }
  76542. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76543. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76544. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76545. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76546. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76547. /** @hidden */
  76548. export var subSurfaceScatteringPixelShader: {
  76549. name: string;
  76550. shader: string;
  76551. };
  76552. }
  76553. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76554. import { Nullable } from "babylonjs/types";
  76555. import { Camera } from "babylonjs/Cameras/camera";
  76556. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76557. import { Engine } from "babylonjs/Engines/engine";
  76558. import { Scene } from "babylonjs/scene";
  76559. import "babylonjs/Shaders/imageProcessing.fragment";
  76560. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76561. import "babylonjs/Shaders/postprocess.vertex";
  76562. /**
  76563. * Sub surface scattering post process
  76564. */
  76565. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76566. /**
  76567. * Gets a string identifying the name of the class
  76568. * @returns "SubSurfaceScatteringPostProcess" string
  76569. */
  76570. getClassName(): string;
  76571. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76572. }
  76573. }
  76574. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76575. import { Scene } from "babylonjs/scene";
  76576. import { Color3 } from "babylonjs/Maths/math.color";
  76577. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76578. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76579. /**
  76580. * Contains all parameters needed for the prepass to perform
  76581. * screen space subsurface scattering
  76582. */
  76583. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76584. /** @hidden */
  76585. static _SceneComponentInitialization: (scene: Scene) => void;
  76586. private _ssDiffusionS;
  76587. private _ssFilterRadii;
  76588. private _ssDiffusionD;
  76589. /**
  76590. * Post process to attach for screen space subsurface scattering
  76591. */
  76592. postProcess: SubSurfaceScatteringPostProcess;
  76593. /**
  76594. * Diffusion profile color for subsurface scattering
  76595. */
  76596. get ssDiffusionS(): number[];
  76597. /**
  76598. * Diffusion profile max color channel value for subsurface scattering
  76599. */
  76600. get ssDiffusionD(): number[];
  76601. /**
  76602. * Diffusion profile filter radius for subsurface scattering
  76603. */
  76604. get ssFilterRadii(): number[];
  76605. /**
  76606. * Is subsurface enabled
  76607. */
  76608. enabled: boolean;
  76609. /**
  76610. * Name of the configuration
  76611. */
  76612. name: string;
  76613. /**
  76614. * Diffusion profile colors for subsurface scattering
  76615. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76616. * See ...
  76617. * Note that you can only store up to 5 of them
  76618. */
  76619. ssDiffusionProfileColors: Color3[];
  76620. /**
  76621. * Defines the ratio real world => scene units.
  76622. * Used for subsurface scattering
  76623. */
  76624. metersPerUnit: number;
  76625. /**
  76626. * Textures that should be present in the MRT for this effect to work
  76627. */
  76628. readonly texturesRequired: number[];
  76629. private _scene;
  76630. /**
  76631. * Builds a subsurface configuration object
  76632. * @param scene The scene
  76633. */
  76634. constructor(scene: Scene);
  76635. /**
  76636. * Adds a new diffusion profile.
  76637. * Useful for more realistic subsurface scattering on diverse materials.
  76638. * @param color The color of the diffusion profile. Should be the average color of the material.
  76639. * @return The index of the diffusion profile for the material subsurface configuration
  76640. */
  76641. addDiffusionProfile(color: Color3): number;
  76642. /**
  76643. * Creates the sss post process
  76644. * @return The created post process
  76645. */
  76646. createPostProcess(): SubSurfaceScatteringPostProcess;
  76647. /**
  76648. * Deletes all diffusion profiles.
  76649. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76650. */
  76651. clearAllDiffusionProfiles(): void;
  76652. /**
  76653. * Disposes this object
  76654. */
  76655. dispose(): void;
  76656. /**
  76657. * @hidden
  76658. * https://zero-radiance.github.io/post/sampling-diffusion/
  76659. *
  76660. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76661. * ------------------------------------------------------------------------------------
  76662. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76663. * PDF[r, phi, s] = r * R[r, phi, s]
  76664. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76665. * ------------------------------------------------------------------------------------
  76666. * We importance sample the color channel with the widest scattering distance.
  76667. */
  76668. getDiffusionProfileParameters(color: Color3): number;
  76669. /**
  76670. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76671. * 'u' is the random number (the value of the CDF): [0, 1).
  76672. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76673. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76674. */
  76675. private _sampleBurleyDiffusionProfile;
  76676. }
  76677. }
  76678. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76679. import { Nullable } from "babylonjs/types";
  76680. import { Scene } from "babylonjs/scene";
  76681. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76682. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76683. import { AbstractScene } from "babylonjs/abstractScene";
  76684. module "babylonjs/abstractScene" {
  76685. interface AbstractScene {
  76686. /** @hidden (Backing field) */
  76687. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76688. /**
  76689. * Gets or Sets the current prepass renderer associated to the scene.
  76690. */
  76691. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76692. /**
  76693. * Enables the subsurface effect for prepass
  76694. * @returns the SubSurfaceConfiguration
  76695. */
  76696. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76697. /**
  76698. * Disables the subsurface effect for prepass
  76699. */
  76700. disableSubSurfaceForPrePass(): void;
  76701. }
  76702. }
  76703. /**
  76704. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76705. * in several rendering techniques.
  76706. */
  76707. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76708. /**
  76709. * The component name helpful to identify the component in the list of scene components.
  76710. */
  76711. readonly name: string;
  76712. /**
  76713. * The scene the component belongs to.
  76714. */
  76715. scene: Scene;
  76716. /**
  76717. * Creates a new instance of the component for the given scene
  76718. * @param scene Defines the scene to register the component in
  76719. */
  76720. constructor(scene: Scene);
  76721. /**
  76722. * Registers the component in a given scene
  76723. */
  76724. register(): void;
  76725. /**
  76726. * Serializes the component data to the specified json object
  76727. * @param serializationObject The object to serialize to
  76728. */
  76729. serialize(serializationObject: any): void;
  76730. /**
  76731. * Adds all the elements from the container to the scene
  76732. * @param container the container holding the elements
  76733. */
  76734. addFromContainer(container: AbstractScene): void;
  76735. /**
  76736. * Removes all the elements in the container from the scene
  76737. * @param container contains the elements to remove
  76738. * @param dispose if the removed element should be disposed (default: false)
  76739. */
  76740. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76741. /**
  76742. * Rebuilds the elements related to this component in case of
  76743. * context lost for instance.
  76744. */
  76745. rebuild(): void;
  76746. /**
  76747. * Disposes the component and the associated ressources
  76748. */
  76749. dispose(): void;
  76750. }
  76751. }
  76752. declare module "babylonjs/Shaders/outline.fragment" {
  76753. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76754. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76755. /** @hidden */
  76756. export var outlinePixelShader: {
  76757. name: string;
  76758. shader: string;
  76759. };
  76760. }
  76761. declare module "babylonjs/Shaders/outline.vertex" {
  76762. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76765. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76766. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76768. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76769. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76770. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76771. /** @hidden */
  76772. export var outlineVertexShader: {
  76773. name: string;
  76774. shader: string;
  76775. };
  76776. }
  76777. declare module "babylonjs/Rendering/outlineRenderer" {
  76778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76779. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76780. import { Scene } from "babylonjs/scene";
  76781. import { ISceneComponent } from "babylonjs/sceneComponent";
  76782. import "babylonjs/Shaders/outline.fragment";
  76783. import "babylonjs/Shaders/outline.vertex";
  76784. module "babylonjs/scene" {
  76785. interface Scene {
  76786. /** @hidden */
  76787. _outlineRenderer: OutlineRenderer;
  76788. /**
  76789. * Gets the outline renderer associated with the scene
  76790. * @returns a OutlineRenderer
  76791. */
  76792. getOutlineRenderer(): OutlineRenderer;
  76793. }
  76794. }
  76795. module "babylonjs/Meshes/abstractMesh" {
  76796. interface AbstractMesh {
  76797. /** @hidden (Backing field) */
  76798. _renderOutline: boolean;
  76799. /**
  76800. * Gets or sets a boolean indicating if the outline must be rendered as well
  76801. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76802. */
  76803. renderOutline: boolean;
  76804. /** @hidden (Backing field) */
  76805. _renderOverlay: boolean;
  76806. /**
  76807. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76808. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76809. */
  76810. renderOverlay: boolean;
  76811. }
  76812. }
  76813. /**
  76814. * This class is responsible to draw bothe outline/overlay of meshes.
  76815. * It should not be used directly but through the available method on mesh.
  76816. */
  76817. export class OutlineRenderer implements ISceneComponent {
  76818. /**
  76819. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76820. */
  76821. private static _StencilReference;
  76822. /**
  76823. * The name of the component. Each component must have a unique name.
  76824. */
  76825. name: string;
  76826. /**
  76827. * The scene the component belongs to.
  76828. */
  76829. scene: Scene;
  76830. /**
  76831. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76832. */
  76833. zOffset: number;
  76834. private _engine;
  76835. private _effect;
  76836. private _cachedDefines;
  76837. private _savedDepthWrite;
  76838. /**
  76839. * Instantiates a new outline renderer. (There could be only one per scene).
  76840. * @param scene Defines the scene it belongs to
  76841. */
  76842. constructor(scene: Scene);
  76843. /**
  76844. * Register the component to one instance of a scene.
  76845. */
  76846. register(): void;
  76847. /**
  76848. * Rebuilds the elements related to this component in case of
  76849. * context lost for instance.
  76850. */
  76851. rebuild(): void;
  76852. /**
  76853. * Disposes the component and the associated ressources.
  76854. */
  76855. dispose(): void;
  76856. /**
  76857. * Renders the outline in the canvas.
  76858. * @param subMesh Defines the sumesh to render
  76859. * @param batch Defines the batch of meshes in case of instances
  76860. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76861. */
  76862. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76863. /**
  76864. * Returns whether or not the outline renderer is ready for a given submesh.
  76865. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76866. * @param subMesh Defines the submesh to check readyness for
  76867. * @param useInstances Defines wheter wee are trying to render instances or not
  76868. * @returns true if ready otherwise false
  76869. */
  76870. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76871. private _beforeRenderingMesh;
  76872. private _afterRenderingMesh;
  76873. }
  76874. }
  76875. declare module "babylonjs/Rendering/index" {
  76876. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76877. export * from "babylonjs/Rendering/depthRenderer";
  76878. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76879. export * from "babylonjs/Rendering/edgesRenderer";
  76880. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76881. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76882. export * from "babylonjs/Rendering/prePassRenderer";
  76883. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76884. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76885. export * from "babylonjs/Rendering/outlineRenderer";
  76886. export * from "babylonjs/Rendering/renderingGroup";
  76887. export * from "babylonjs/Rendering/renderingManager";
  76888. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76889. }
  76890. declare module "babylonjs/Sprites/ISprites" {
  76891. /**
  76892. * Defines the basic options interface of a Sprite Frame Source Size.
  76893. */
  76894. export interface ISpriteJSONSpriteSourceSize {
  76895. /**
  76896. * number of the original width of the Frame
  76897. */
  76898. w: number;
  76899. /**
  76900. * number of the original height of the Frame
  76901. */
  76902. h: number;
  76903. }
  76904. /**
  76905. * Defines the basic options interface of a Sprite Frame Data.
  76906. */
  76907. export interface ISpriteJSONSpriteFrameData {
  76908. /**
  76909. * number of the x offset of the Frame
  76910. */
  76911. x: number;
  76912. /**
  76913. * number of the y offset of the Frame
  76914. */
  76915. y: number;
  76916. /**
  76917. * number of the width of the Frame
  76918. */
  76919. w: number;
  76920. /**
  76921. * number of the height of the Frame
  76922. */
  76923. h: number;
  76924. }
  76925. /**
  76926. * Defines the basic options interface of a JSON Sprite.
  76927. */
  76928. export interface ISpriteJSONSprite {
  76929. /**
  76930. * string name of the Frame
  76931. */
  76932. filename: string;
  76933. /**
  76934. * ISpriteJSONSpriteFrame basic object of the frame data
  76935. */
  76936. frame: ISpriteJSONSpriteFrameData;
  76937. /**
  76938. * boolean to flag is the frame was rotated.
  76939. */
  76940. rotated: boolean;
  76941. /**
  76942. * boolean to flag is the frame was trimmed.
  76943. */
  76944. trimmed: boolean;
  76945. /**
  76946. * ISpriteJSONSpriteFrame basic object of the source data
  76947. */
  76948. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76949. /**
  76950. * ISpriteJSONSpriteFrame basic object of the source data
  76951. */
  76952. sourceSize: ISpriteJSONSpriteSourceSize;
  76953. }
  76954. /**
  76955. * Defines the basic options interface of a JSON atlas.
  76956. */
  76957. export interface ISpriteJSONAtlas {
  76958. /**
  76959. * Array of objects that contain the frame data.
  76960. */
  76961. frames: Array<ISpriteJSONSprite>;
  76962. /**
  76963. * object basic object containing the sprite meta data.
  76964. */
  76965. meta?: object;
  76966. }
  76967. }
  76968. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76969. /** @hidden */
  76970. export var spriteMapPixelShader: {
  76971. name: string;
  76972. shader: string;
  76973. };
  76974. }
  76975. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76976. /** @hidden */
  76977. export var spriteMapVertexShader: {
  76978. name: string;
  76979. shader: string;
  76980. };
  76981. }
  76982. declare module "babylonjs/Sprites/spriteMap" {
  76983. import { IDisposable, Scene } from "babylonjs/scene";
  76984. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76985. import { Texture } from "babylonjs/Materials/Textures/texture";
  76986. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76987. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76988. import "babylonjs/Meshes/Builders/planeBuilder";
  76989. import "babylonjs/Shaders/spriteMap.fragment";
  76990. import "babylonjs/Shaders/spriteMap.vertex";
  76991. /**
  76992. * Defines the basic options interface of a SpriteMap
  76993. */
  76994. export interface ISpriteMapOptions {
  76995. /**
  76996. * Vector2 of the number of cells in the grid.
  76997. */
  76998. stageSize?: Vector2;
  76999. /**
  77000. * Vector2 of the size of the output plane in World Units.
  77001. */
  77002. outputSize?: Vector2;
  77003. /**
  77004. * Vector3 of the position of the output plane in World Units.
  77005. */
  77006. outputPosition?: Vector3;
  77007. /**
  77008. * Vector3 of the rotation of the output plane.
  77009. */
  77010. outputRotation?: Vector3;
  77011. /**
  77012. * number of layers that the system will reserve in resources.
  77013. */
  77014. layerCount?: number;
  77015. /**
  77016. * number of max animation frames a single cell will reserve in resources.
  77017. */
  77018. maxAnimationFrames?: number;
  77019. /**
  77020. * number cell index of the base tile when the system compiles.
  77021. */
  77022. baseTile?: number;
  77023. /**
  77024. * boolean flip the sprite after its been repositioned by the framing data.
  77025. */
  77026. flipU?: boolean;
  77027. /**
  77028. * Vector3 scalar of the global RGB values of the SpriteMap.
  77029. */
  77030. colorMultiply?: Vector3;
  77031. }
  77032. /**
  77033. * Defines the IDisposable interface in order to be cleanable from resources.
  77034. */
  77035. export interface ISpriteMap extends IDisposable {
  77036. /**
  77037. * String name of the SpriteMap.
  77038. */
  77039. name: string;
  77040. /**
  77041. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77042. */
  77043. atlasJSON: ISpriteJSONAtlas;
  77044. /**
  77045. * Texture of the SpriteMap.
  77046. */
  77047. spriteSheet: Texture;
  77048. /**
  77049. * The parameters to initialize the SpriteMap with.
  77050. */
  77051. options: ISpriteMapOptions;
  77052. }
  77053. /**
  77054. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77055. */
  77056. export class SpriteMap implements ISpriteMap {
  77057. /** The Name of the spriteMap */
  77058. name: string;
  77059. /** The JSON file with the frame and meta data */
  77060. atlasJSON: ISpriteJSONAtlas;
  77061. /** The systems Sprite Sheet Texture */
  77062. spriteSheet: Texture;
  77063. /** Arguments passed with the Constructor */
  77064. options: ISpriteMapOptions;
  77065. /** Public Sprite Storage array, parsed from atlasJSON */
  77066. sprites: Array<ISpriteJSONSprite>;
  77067. /** Returns the Number of Sprites in the System */
  77068. get spriteCount(): number;
  77069. /** Returns the Position of Output Plane*/
  77070. get position(): Vector3;
  77071. /** Returns the Position of Output Plane*/
  77072. set position(v: Vector3);
  77073. /** Returns the Rotation of Output Plane*/
  77074. get rotation(): Vector3;
  77075. /** Returns the Rotation of Output Plane*/
  77076. set rotation(v: Vector3);
  77077. /** Sets the AnimationMap*/
  77078. get animationMap(): RawTexture;
  77079. /** Sets the AnimationMap*/
  77080. set animationMap(v: RawTexture);
  77081. /** Scene that the SpriteMap was created in */
  77082. private _scene;
  77083. /** Texture Buffer of Float32 that holds tile frame data*/
  77084. private _frameMap;
  77085. /** Texture Buffers of Float32 that holds tileMap data*/
  77086. private _tileMaps;
  77087. /** Texture Buffer of Float32 that holds Animation Data*/
  77088. private _animationMap;
  77089. /** Custom ShaderMaterial Central to the System*/
  77090. private _material;
  77091. /** Custom ShaderMaterial Central to the System*/
  77092. private _output;
  77093. /** Systems Time Ticker*/
  77094. private _time;
  77095. /**
  77096. * Creates a new SpriteMap
  77097. * @param name defines the SpriteMaps Name
  77098. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77099. * @param spriteSheet is the Texture that the Sprites are on.
  77100. * @param options a basic deployment configuration
  77101. * @param scene The Scene that the map is deployed on
  77102. */
  77103. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77104. /**
  77105. * Returns tileID location
  77106. * @returns Vector2 the cell position ID
  77107. */
  77108. getTileID(): Vector2;
  77109. /**
  77110. * Gets the UV location of the mouse over the SpriteMap.
  77111. * @returns Vector2 the UV position of the mouse interaction
  77112. */
  77113. getMousePosition(): Vector2;
  77114. /**
  77115. * Creates the "frame" texture Buffer
  77116. * -------------------------------------
  77117. * Structure of frames
  77118. * "filename": "Falling-Water-2.png",
  77119. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77120. * "rotated": true,
  77121. * "trimmed": true,
  77122. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77123. * "sourceSize": {"w":32,"h":32}
  77124. * @returns RawTexture of the frameMap
  77125. */
  77126. private _createFrameBuffer;
  77127. /**
  77128. * Creates the tileMap texture Buffer
  77129. * @param buffer normally and array of numbers, or a false to generate from scratch
  77130. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77131. * @returns RawTexture of the tileMap
  77132. */
  77133. private _createTileBuffer;
  77134. /**
  77135. * Modifies the data of the tileMaps
  77136. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77137. * @param pos is the iVector2 Coordinates of the Tile
  77138. * @param tile The SpriteIndex of the new Tile
  77139. */
  77140. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77141. /**
  77142. * Creates the animationMap texture Buffer
  77143. * @param buffer normally and array of numbers, or a false to generate from scratch
  77144. * @returns RawTexture of the animationMap
  77145. */
  77146. private _createTileAnimationBuffer;
  77147. /**
  77148. * Modifies the data of the animationMap
  77149. * @param cellID is the Index of the Sprite
  77150. * @param _frame is the target Animation frame
  77151. * @param toCell is the Target Index of the next frame of the animation
  77152. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77153. * @param speed is a global scalar of the time variable on the map.
  77154. */
  77155. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77156. /**
  77157. * Exports the .tilemaps file
  77158. */
  77159. saveTileMaps(): void;
  77160. /**
  77161. * Imports the .tilemaps file
  77162. * @param url of the .tilemaps file
  77163. */
  77164. loadTileMaps(url: string): void;
  77165. /**
  77166. * Release associated resources
  77167. */
  77168. dispose(): void;
  77169. }
  77170. }
  77171. declare module "babylonjs/Sprites/spritePackedManager" {
  77172. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77173. import { Scene } from "babylonjs/scene";
  77174. /**
  77175. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77176. * @see https://doc.babylonjs.com/babylon101/sprites
  77177. */
  77178. export class SpritePackedManager extends SpriteManager {
  77179. /** defines the packed manager's name */
  77180. name: string;
  77181. /**
  77182. * Creates a new sprite manager from a packed sprite sheet
  77183. * @param name defines the manager's name
  77184. * @param imgUrl defines the sprite sheet url
  77185. * @param capacity defines the maximum allowed number of sprites
  77186. * @param scene defines the hosting scene
  77187. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77188. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77189. * @param samplingMode defines the smapling mode to use with spritesheet
  77190. * @param fromPacked set to true; do not alter
  77191. */
  77192. constructor(
  77193. /** defines the packed manager's name */
  77194. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77195. }
  77196. }
  77197. declare module "babylonjs/Sprites/index" {
  77198. export * from "babylonjs/Sprites/sprite";
  77199. export * from "babylonjs/Sprites/ISprites";
  77200. export * from "babylonjs/Sprites/spriteManager";
  77201. export * from "babylonjs/Sprites/spriteMap";
  77202. export * from "babylonjs/Sprites/spritePackedManager";
  77203. export * from "babylonjs/Sprites/spriteSceneComponent";
  77204. }
  77205. declare module "babylonjs/States/index" {
  77206. export * from "babylonjs/States/alphaCullingState";
  77207. export * from "babylonjs/States/depthCullingState";
  77208. export * from "babylonjs/States/stencilState";
  77209. }
  77210. declare module "babylonjs/Misc/assetsManager" {
  77211. import { Scene } from "babylonjs/scene";
  77212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77213. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77214. import { Skeleton } from "babylonjs/Bones/skeleton";
  77215. import { Observable } from "babylonjs/Misc/observable";
  77216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77217. import { Texture } from "babylonjs/Materials/Textures/texture";
  77218. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77219. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77220. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77221. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77222. import { AssetContainer } from "babylonjs/assetContainer";
  77223. /**
  77224. * Defines the list of states available for a task inside a AssetsManager
  77225. */
  77226. export enum AssetTaskState {
  77227. /**
  77228. * Initialization
  77229. */
  77230. INIT = 0,
  77231. /**
  77232. * Running
  77233. */
  77234. RUNNING = 1,
  77235. /**
  77236. * Done
  77237. */
  77238. DONE = 2,
  77239. /**
  77240. * Error
  77241. */
  77242. ERROR = 3
  77243. }
  77244. /**
  77245. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77246. */
  77247. export abstract class AbstractAssetTask {
  77248. /**
  77249. * Task name
  77250. */ name: string;
  77251. /**
  77252. * Callback called when the task is successful
  77253. */
  77254. onSuccess: (task: any) => void;
  77255. /**
  77256. * Callback called when the task is not successful
  77257. */
  77258. onError: (task: any, message?: string, exception?: any) => void;
  77259. /**
  77260. * Creates a new AssetsManager
  77261. * @param name defines the name of the task
  77262. */
  77263. constructor(
  77264. /**
  77265. * Task name
  77266. */ name: string);
  77267. private _isCompleted;
  77268. private _taskState;
  77269. private _errorObject;
  77270. /**
  77271. * Get if the task is completed
  77272. */
  77273. get isCompleted(): boolean;
  77274. /**
  77275. * Gets the current state of the task
  77276. */
  77277. get taskState(): AssetTaskState;
  77278. /**
  77279. * Gets the current error object (if task is in error)
  77280. */
  77281. get errorObject(): {
  77282. message?: string;
  77283. exception?: any;
  77284. };
  77285. /**
  77286. * Internal only
  77287. * @hidden
  77288. */
  77289. _setErrorObject(message?: string, exception?: any): void;
  77290. /**
  77291. * Execute the current task
  77292. * @param scene defines the scene where you want your assets to be loaded
  77293. * @param onSuccess is a callback called when the task is successfully executed
  77294. * @param onError is a callback called if an error occurs
  77295. */
  77296. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77297. /**
  77298. * Execute the current task
  77299. * @param scene defines the scene where you want your assets to be loaded
  77300. * @param onSuccess is a callback called when the task is successfully executed
  77301. * @param onError is a callback called if an error occurs
  77302. */
  77303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77304. /**
  77305. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77306. * This can be used with failed tasks that have the reason for failure fixed.
  77307. */
  77308. reset(): void;
  77309. private onErrorCallback;
  77310. private onDoneCallback;
  77311. }
  77312. /**
  77313. * Define the interface used by progress events raised during assets loading
  77314. */
  77315. export interface IAssetsProgressEvent {
  77316. /**
  77317. * Defines the number of remaining tasks to process
  77318. */
  77319. remainingCount: number;
  77320. /**
  77321. * Defines the total number of tasks
  77322. */
  77323. totalCount: number;
  77324. /**
  77325. * Defines the task that was just processed
  77326. */
  77327. task: AbstractAssetTask;
  77328. }
  77329. /**
  77330. * Class used to share progress information about assets loading
  77331. */
  77332. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77333. /**
  77334. * Defines the number of remaining tasks to process
  77335. */
  77336. remainingCount: number;
  77337. /**
  77338. * Defines the total number of tasks
  77339. */
  77340. totalCount: number;
  77341. /**
  77342. * Defines the task that was just processed
  77343. */
  77344. task: AbstractAssetTask;
  77345. /**
  77346. * Creates a AssetsProgressEvent
  77347. * @param remainingCount defines the number of remaining tasks to process
  77348. * @param totalCount defines the total number of tasks
  77349. * @param task defines the task that was just processed
  77350. */
  77351. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77352. }
  77353. /**
  77354. * Define a task used by AssetsManager to load assets into a container
  77355. */
  77356. export class ContainerAssetTask extends AbstractAssetTask {
  77357. /**
  77358. * Defines the name of the task
  77359. */
  77360. name: string;
  77361. /**
  77362. * Defines the list of mesh's names you want to load
  77363. */
  77364. meshesNames: any;
  77365. /**
  77366. * Defines the root url to use as a base to load your meshes and associated resources
  77367. */
  77368. rootUrl: string;
  77369. /**
  77370. * Defines the filename or File of the scene to load from
  77371. */
  77372. sceneFilename: string | File;
  77373. /**
  77374. * Get the loaded asset container
  77375. */
  77376. loadedContainer: AssetContainer;
  77377. /**
  77378. * Gets the list of loaded meshes
  77379. */
  77380. loadedMeshes: Array<AbstractMesh>;
  77381. /**
  77382. * Gets the list of loaded particle systems
  77383. */
  77384. loadedParticleSystems: Array<IParticleSystem>;
  77385. /**
  77386. * Gets the list of loaded skeletons
  77387. */
  77388. loadedSkeletons: Array<Skeleton>;
  77389. /**
  77390. * Gets the list of loaded animation groups
  77391. */
  77392. loadedAnimationGroups: Array<AnimationGroup>;
  77393. /**
  77394. * Callback called when the task is successful
  77395. */
  77396. onSuccess: (task: ContainerAssetTask) => void;
  77397. /**
  77398. * Callback called when the task is successful
  77399. */
  77400. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77401. /**
  77402. * Creates a new ContainerAssetTask
  77403. * @param name defines the name of the task
  77404. * @param meshesNames defines the list of mesh's names you want to load
  77405. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77406. * @param sceneFilename defines the filename or File of the scene to load from
  77407. */
  77408. constructor(
  77409. /**
  77410. * Defines the name of the task
  77411. */
  77412. name: string,
  77413. /**
  77414. * Defines the list of mesh's names you want to load
  77415. */
  77416. meshesNames: any,
  77417. /**
  77418. * Defines the root url to use as a base to load your meshes and associated resources
  77419. */
  77420. rootUrl: string,
  77421. /**
  77422. * Defines the filename or File of the scene to load from
  77423. */
  77424. sceneFilename: string | File);
  77425. /**
  77426. * Execute the current task
  77427. * @param scene defines the scene where you want your assets to be loaded
  77428. * @param onSuccess is a callback called when the task is successfully executed
  77429. * @param onError is a callback called if an error occurs
  77430. */
  77431. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77432. }
  77433. /**
  77434. * Define a task used by AssetsManager to load meshes
  77435. */
  77436. export class MeshAssetTask extends AbstractAssetTask {
  77437. /**
  77438. * Defines the name of the task
  77439. */
  77440. name: string;
  77441. /**
  77442. * Defines the list of mesh's names you want to load
  77443. */
  77444. meshesNames: any;
  77445. /**
  77446. * Defines the root url to use as a base to load your meshes and associated resources
  77447. */
  77448. rootUrl: string;
  77449. /**
  77450. * Defines the filename or File of the scene to load from
  77451. */
  77452. sceneFilename: string | File;
  77453. /**
  77454. * Gets the list of loaded meshes
  77455. */
  77456. loadedMeshes: Array<AbstractMesh>;
  77457. /**
  77458. * Gets the list of loaded particle systems
  77459. */
  77460. loadedParticleSystems: Array<IParticleSystem>;
  77461. /**
  77462. * Gets the list of loaded skeletons
  77463. */
  77464. loadedSkeletons: Array<Skeleton>;
  77465. /**
  77466. * Gets the list of loaded animation groups
  77467. */
  77468. loadedAnimationGroups: Array<AnimationGroup>;
  77469. /**
  77470. * Callback called when the task is successful
  77471. */
  77472. onSuccess: (task: MeshAssetTask) => void;
  77473. /**
  77474. * Callback called when the task is successful
  77475. */
  77476. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77477. /**
  77478. * Creates a new MeshAssetTask
  77479. * @param name defines the name of the task
  77480. * @param meshesNames defines the list of mesh's names you want to load
  77481. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77482. * @param sceneFilename defines the filename or File of the scene to load from
  77483. */
  77484. constructor(
  77485. /**
  77486. * Defines the name of the task
  77487. */
  77488. name: string,
  77489. /**
  77490. * Defines the list of mesh's names you want to load
  77491. */
  77492. meshesNames: any,
  77493. /**
  77494. * Defines the root url to use as a base to load your meshes and associated resources
  77495. */
  77496. rootUrl: string,
  77497. /**
  77498. * Defines the filename or File of the scene to load from
  77499. */
  77500. sceneFilename: string | File);
  77501. /**
  77502. * Execute the current task
  77503. * @param scene defines the scene where you want your assets to be loaded
  77504. * @param onSuccess is a callback called when the task is successfully executed
  77505. * @param onError is a callback called if an error occurs
  77506. */
  77507. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77508. }
  77509. /**
  77510. * Define a task used by AssetsManager to load text content
  77511. */
  77512. export class TextFileAssetTask extends AbstractAssetTask {
  77513. /**
  77514. * Defines the name of the task
  77515. */
  77516. name: string;
  77517. /**
  77518. * Defines the location of the file to load
  77519. */
  77520. url: string;
  77521. /**
  77522. * Gets the loaded text string
  77523. */
  77524. text: string;
  77525. /**
  77526. * Callback called when the task is successful
  77527. */
  77528. onSuccess: (task: TextFileAssetTask) => void;
  77529. /**
  77530. * Callback called when the task is successful
  77531. */
  77532. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77533. /**
  77534. * Creates a new TextFileAssetTask object
  77535. * @param name defines the name of the task
  77536. * @param url defines the location of the file to load
  77537. */
  77538. constructor(
  77539. /**
  77540. * Defines the name of the task
  77541. */
  77542. name: string,
  77543. /**
  77544. * Defines the location of the file to load
  77545. */
  77546. url: string);
  77547. /**
  77548. * Execute the current task
  77549. * @param scene defines the scene where you want your assets to be loaded
  77550. * @param onSuccess is a callback called when the task is successfully executed
  77551. * @param onError is a callback called if an error occurs
  77552. */
  77553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77554. }
  77555. /**
  77556. * Define a task used by AssetsManager to load binary data
  77557. */
  77558. export class BinaryFileAssetTask extends AbstractAssetTask {
  77559. /**
  77560. * Defines the name of the task
  77561. */
  77562. name: string;
  77563. /**
  77564. * Defines the location of the file to load
  77565. */
  77566. url: string;
  77567. /**
  77568. * Gets the lodaded data (as an array buffer)
  77569. */
  77570. data: ArrayBuffer;
  77571. /**
  77572. * Callback called when the task is successful
  77573. */
  77574. onSuccess: (task: BinaryFileAssetTask) => void;
  77575. /**
  77576. * Callback called when the task is successful
  77577. */
  77578. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77579. /**
  77580. * Creates a new BinaryFileAssetTask object
  77581. * @param name defines the name of the new task
  77582. * @param url defines the location of the file to load
  77583. */
  77584. constructor(
  77585. /**
  77586. * Defines the name of the task
  77587. */
  77588. name: string,
  77589. /**
  77590. * Defines the location of the file to load
  77591. */
  77592. url: string);
  77593. /**
  77594. * Execute the current task
  77595. * @param scene defines the scene where you want your assets to be loaded
  77596. * @param onSuccess is a callback called when the task is successfully executed
  77597. * @param onError is a callback called if an error occurs
  77598. */
  77599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77600. }
  77601. /**
  77602. * Define a task used by AssetsManager to load images
  77603. */
  77604. export class ImageAssetTask extends AbstractAssetTask {
  77605. /**
  77606. * Defines the name of the task
  77607. */
  77608. name: string;
  77609. /**
  77610. * Defines the location of the image to load
  77611. */
  77612. url: string;
  77613. /**
  77614. * Gets the loaded images
  77615. */
  77616. image: HTMLImageElement;
  77617. /**
  77618. * Callback called when the task is successful
  77619. */
  77620. onSuccess: (task: ImageAssetTask) => void;
  77621. /**
  77622. * Callback called when the task is successful
  77623. */
  77624. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77625. /**
  77626. * Creates a new ImageAssetTask
  77627. * @param name defines the name of the task
  77628. * @param url defines the location of the image to load
  77629. */
  77630. constructor(
  77631. /**
  77632. * Defines the name of the task
  77633. */
  77634. name: string,
  77635. /**
  77636. * Defines the location of the image to load
  77637. */
  77638. url: string);
  77639. /**
  77640. * Execute the current task
  77641. * @param scene defines the scene where you want your assets to be loaded
  77642. * @param onSuccess is a callback called when the task is successfully executed
  77643. * @param onError is a callback called if an error occurs
  77644. */
  77645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77646. }
  77647. /**
  77648. * Defines the interface used by texture loading tasks
  77649. */
  77650. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77651. /**
  77652. * Gets the loaded texture
  77653. */
  77654. texture: TEX;
  77655. }
  77656. /**
  77657. * Define a task used by AssetsManager to load 2D textures
  77658. */
  77659. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77660. /**
  77661. * Defines the name of the task
  77662. */
  77663. name: string;
  77664. /**
  77665. * Defines the location of the file to load
  77666. */
  77667. url: string;
  77668. /**
  77669. * Defines if mipmap should not be generated (default is false)
  77670. */
  77671. noMipmap?: boolean | undefined;
  77672. /**
  77673. * Defines if texture must be inverted on Y axis (default is true)
  77674. */
  77675. invertY: boolean;
  77676. /**
  77677. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77678. */
  77679. samplingMode: number;
  77680. /**
  77681. * Gets the loaded texture
  77682. */
  77683. texture: Texture;
  77684. /**
  77685. * Callback called when the task is successful
  77686. */
  77687. onSuccess: (task: TextureAssetTask) => void;
  77688. /**
  77689. * Callback called when the task is successful
  77690. */
  77691. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77692. /**
  77693. * Creates a new TextureAssetTask object
  77694. * @param name defines the name of the task
  77695. * @param url defines the location of the file to load
  77696. * @param noMipmap defines if mipmap should not be generated (default is false)
  77697. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77698. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77699. */
  77700. constructor(
  77701. /**
  77702. * Defines the name of the task
  77703. */
  77704. name: string,
  77705. /**
  77706. * Defines the location of the file to load
  77707. */
  77708. url: string,
  77709. /**
  77710. * Defines if mipmap should not be generated (default is false)
  77711. */
  77712. noMipmap?: boolean | undefined,
  77713. /**
  77714. * Defines if texture must be inverted on Y axis (default is true)
  77715. */
  77716. invertY?: boolean,
  77717. /**
  77718. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77719. */
  77720. samplingMode?: number);
  77721. /**
  77722. * Execute the current task
  77723. * @param scene defines the scene where you want your assets to be loaded
  77724. * @param onSuccess is a callback called when the task is successfully executed
  77725. * @param onError is a callback called if an error occurs
  77726. */
  77727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77728. }
  77729. /**
  77730. * Define a task used by AssetsManager to load cube textures
  77731. */
  77732. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77733. /**
  77734. * Defines the name of the task
  77735. */
  77736. name: string;
  77737. /**
  77738. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77739. */
  77740. url: string;
  77741. /**
  77742. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77743. */
  77744. extensions?: string[] | undefined;
  77745. /**
  77746. * Defines if mipmaps should not be generated (default is false)
  77747. */
  77748. noMipmap?: boolean | undefined;
  77749. /**
  77750. * Defines the explicit list of files (undefined by default)
  77751. */
  77752. files?: string[] | undefined;
  77753. /**
  77754. * Gets the loaded texture
  77755. */
  77756. texture: CubeTexture;
  77757. /**
  77758. * Callback called when the task is successful
  77759. */
  77760. onSuccess: (task: CubeTextureAssetTask) => void;
  77761. /**
  77762. * Callback called when the task is successful
  77763. */
  77764. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77765. /**
  77766. * Creates a new CubeTextureAssetTask
  77767. * @param name defines the name of the task
  77768. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77769. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77770. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77771. * @param files defines the explicit list of files (undefined by default)
  77772. */
  77773. constructor(
  77774. /**
  77775. * Defines the name of the task
  77776. */
  77777. name: string,
  77778. /**
  77779. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77780. */
  77781. url: string,
  77782. /**
  77783. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77784. */
  77785. extensions?: string[] | undefined,
  77786. /**
  77787. * Defines if mipmaps should not be generated (default is false)
  77788. */
  77789. noMipmap?: boolean | undefined,
  77790. /**
  77791. * Defines the explicit list of files (undefined by default)
  77792. */
  77793. files?: string[] | undefined);
  77794. /**
  77795. * Execute the current task
  77796. * @param scene defines the scene where you want your assets to be loaded
  77797. * @param onSuccess is a callback called when the task is successfully executed
  77798. * @param onError is a callback called if an error occurs
  77799. */
  77800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77801. }
  77802. /**
  77803. * Define a task used by AssetsManager to load HDR cube textures
  77804. */
  77805. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77806. /**
  77807. * Defines the name of the task
  77808. */
  77809. name: string;
  77810. /**
  77811. * Defines the location of the file to load
  77812. */
  77813. url: string;
  77814. /**
  77815. * Defines the desired size (the more it increases the longer the generation will be)
  77816. */
  77817. size: number;
  77818. /**
  77819. * Defines if mipmaps should not be generated (default is false)
  77820. */
  77821. noMipmap: boolean;
  77822. /**
  77823. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77824. */
  77825. generateHarmonics: boolean;
  77826. /**
  77827. * 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)
  77828. */
  77829. gammaSpace: boolean;
  77830. /**
  77831. * Internal Use Only
  77832. */
  77833. reserved: boolean;
  77834. /**
  77835. * Gets the loaded texture
  77836. */
  77837. texture: HDRCubeTexture;
  77838. /**
  77839. * Callback called when the task is successful
  77840. */
  77841. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77842. /**
  77843. * Callback called when the task is successful
  77844. */
  77845. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77846. /**
  77847. * Creates a new HDRCubeTextureAssetTask object
  77848. * @param name defines the name of the task
  77849. * @param url defines the location of the file to load
  77850. * @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.
  77851. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77852. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77853. * @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)
  77854. * @param reserved Internal use only
  77855. */
  77856. constructor(
  77857. /**
  77858. * Defines the name of the task
  77859. */
  77860. name: string,
  77861. /**
  77862. * Defines the location of the file to load
  77863. */
  77864. url: string,
  77865. /**
  77866. * Defines the desired size (the more it increases the longer the generation will be)
  77867. */
  77868. size: number,
  77869. /**
  77870. * Defines if mipmaps should not be generated (default is false)
  77871. */
  77872. noMipmap?: boolean,
  77873. /**
  77874. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77875. */
  77876. generateHarmonics?: boolean,
  77877. /**
  77878. * 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)
  77879. */
  77880. gammaSpace?: boolean,
  77881. /**
  77882. * Internal Use Only
  77883. */
  77884. reserved?: boolean);
  77885. /**
  77886. * Execute the current task
  77887. * @param scene defines the scene where you want your assets to be loaded
  77888. * @param onSuccess is a callback called when the task is successfully executed
  77889. * @param onError is a callback called if an error occurs
  77890. */
  77891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77892. }
  77893. /**
  77894. * Define a task used by AssetsManager to load Equirectangular cube textures
  77895. */
  77896. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77897. /**
  77898. * Defines the name of the task
  77899. */
  77900. name: string;
  77901. /**
  77902. * Defines the location of the file to load
  77903. */
  77904. url: string;
  77905. /**
  77906. * Defines the desired size (the more it increases the longer the generation will be)
  77907. */
  77908. size: number;
  77909. /**
  77910. * Defines if mipmaps should not be generated (default is false)
  77911. */
  77912. noMipmap: boolean;
  77913. /**
  77914. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77915. * but the standard material would require them in Gamma space) (default is true)
  77916. */
  77917. gammaSpace: boolean;
  77918. /**
  77919. * Gets the loaded texture
  77920. */
  77921. texture: EquiRectangularCubeTexture;
  77922. /**
  77923. * Callback called when the task is successful
  77924. */
  77925. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77926. /**
  77927. * Callback called when the task is successful
  77928. */
  77929. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77930. /**
  77931. * Creates a new EquiRectangularCubeTextureAssetTask object
  77932. * @param name defines the name of the task
  77933. * @param url defines the location of the file to load
  77934. * @param size defines the desired size (the more it increases the longer the generation will be)
  77935. * If the size is omitted this implies you are using a preprocessed cubemap.
  77936. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77937. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77938. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77939. * (default is true)
  77940. */
  77941. constructor(
  77942. /**
  77943. * Defines the name of the task
  77944. */
  77945. name: string,
  77946. /**
  77947. * Defines the location of the file to load
  77948. */
  77949. url: string,
  77950. /**
  77951. * Defines the desired size (the more it increases the longer the generation will be)
  77952. */
  77953. size: number,
  77954. /**
  77955. * Defines if mipmaps should not be generated (default is false)
  77956. */
  77957. noMipmap?: boolean,
  77958. /**
  77959. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77960. * but the standard material would require them in Gamma space) (default is true)
  77961. */
  77962. gammaSpace?: boolean);
  77963. /**
  77964. * Execute the current task
  77965. * @param scene defines the scene where you want your assets to be loaded
  77966. * @param onSuccess is a callback called when the task is successfully executed
  77967. * @param onError is a callback called if an error occurs
  77968. */
  77969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77970. }
  77971. /**
  77972. * This class can be used to easily import assets into a scene
  77973. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77974. */
  77975. export class AssetsManager {
  77976. private _scene;
  77977. private _isLoading;
  77978. protected _tasks: AbstractAssetTask[];
  77979. protected _waitingTasksCount: number;
  77980. protected _totalTasksCount: number;
  77981. /**
  77982. * Callback called when all tasks are processed
  77983. */
  77984. onFinish: (tasks: AbstractAssetTask[]) => void;
  77985. /**
  77986. * Callback called when a task is successful
  77987. */
  77988. onTaskSuccess: (task: AbstractAssetTask) => void;
  77989. /**
  77990. * Callback called when a task had an error
  77991. */
  77992. onTaskError: (task: AbstractAssetTask) => void;
  77993. /**
  77994. * Callback called when a task is done (whatever the result is)
  77995. */
  77996. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77997. /**
  77998. * Observable called when all tasks are processed
  77999. */
  78000. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78001. /**
  78002. * Observable called when a task had an error
  78003. */
  78004. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78005. /**
  78006. * Observable called when all tasks were executed
  78007. */
  78008. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78009. /**
  78010. * Observable called when a task is done (whatever the result is)
  78011. */
  78012. onProgressObservable: Observable<IAssetsProgressEvent>;
  78013. /**
  78014. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78015. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78016. */
  78017. useDefaultLoadingScreen: boolean;
  78018. /**
  78019. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78020. * when all assets have been downloaded.
  78021. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78022. */
  78023. autoHideLoadingUI: boolean;
  78024. /**
  78025. * Creates a new AssetsManager
  78026. * @param scene defines the scene to work on
  78027. */
  78028. constructor(scene: Scene);
  78029. /**
  78030. * Add a ContainerAssetTask to the list of active tasks
  78031. * @param taskName defines the name of the new task
  78032. * @param meshesNames defines the name of meshes to load
  78033. * @param rootUrl defines the root url to use to locate files
  78034. * @param sceneFilename defines the filename of the scene file
  78035. * @returns a new ContainerAssetTask object
  78036. */
  78037. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78038. /**
  78039. * Add a MeshAssetTask to the list of active tasks
  78040. * @param taskName defines the name of the new task
  78041. * @param meshesNames defines the name of meshes to load
  78042. * @param rootUrl defines the root url to use to locate files
  78043. * @param sceneFilename defines the filename of the scene file
  78044. * @returns a new MeshAssetTask object
  78045. */
  78046. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78047. /**
  78048. * Add a TextFileAssetTask to the list of active tasks
  78049. * @param taskName defines the name of the new task
  78050. * @param url defines the url of the file to load
  78051. * @returns a new TextFileAssetTask object
  78052. */
  78053. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78054. /**
  78055. * Add a BinaryFileAssetTask to the list of active tasks
  78056. * @param taskName defines the name of the new task
  78057. * @param url defines the url of the file to load
  78058. * @returns a new BinaryFileAssetTask object
  78059. */
  78060. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78061. /**
  78062. * Add a ImageAssetTask to the list of active tasks
  78063. * @param taskName defines the name of the new task
  78064. * @param url defines the url of the file to load
  78065. * @returns a new ImageAssetTask object
  78066. */
  78067. addImageTask(taskName: string, url: string): ImageAssetTask;
  78068. /**
  78069. * Add a TextureAssetTask to the list of active tasks
  78070. * @param taskName defines the name of the new task
  78071. * @param url defines the url of the file to load
  78072. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78073. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78074. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78075. * @returns a new TextureAssetTask object
  78076. */
  78077. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78078. /**
  78079. * Add a CubeTextureAssetTask to the list of active tasks
  78080. * @param taskName defines the name of the new task
  78081. * @param url defines the url of the file to load
  78082. * @param extensions defines the extension to use to load the cube map (can be null)
  78083. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78084. * @param files defines the list of files to load (can be null)
  78085. * @returns a new CubeTextureAssetTask object
  78086. */
  78087. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78088. /**
  78089. *
  78090. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78091. * @param taskName defines the name of the new task
  78092. * @param url defines the url of the file to load
  78093. * @param size defines the size you want for the cubemap (can be null)
  78094. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78095. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78096. * @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)
  78097. * @param reserved Internal use only
  78098. * @returns a new HDRCubeTextureAssetTask object
  78099. */
  78100. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78101. /**
  78102. *
  78103. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78104. * @param taskName defines the name of the new task
  78105. * @param url defines the url of the file to load
  78106. * @param size defines the size you want for the cubemap (can be null)
  78107. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78108. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78109. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78110. * @returns a new EquiRectangularCubeTextureAssetTask object
  78111. */
  78112. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78113. /**
  78114. * Remove a task from the assets manager.
  78115. * @param task the task to remove
  78116. */
  78117. removeTask(task: AbstractAssetTask): void;
  78118. private _decreaseWaitingTasksCount;
  78119. private _runTask;
  78120. /**
  78121. * Reset the AssetsManager and remove all tasks
  78122. * @return the current instance of the AssetsManager
  78123. */
  78124. reset(): AssetsManager;
  78125. /**
  78126. * Start the loading process
  78127. * @return the current instance of the AssetsManager
  78128. */
  78129. load(): AssetsManager;
  78130. /**
  78131. * Start the loading process as an async operation
  78132. * @return a promise returning the list of failed tasks
  78133. */
  78134. loadAsync(): Promise<void>;
  78135. }
  78136. }
  78137. declare module "babylonjs/Misc/deferred" {
  78138. /**
  78139. * Wrapper class for promise with external resolve and reject.
  78140. */
  78141. export class Deferred<T> {
  78142. /**
  78143. * The promise associated with this deferred object.
  78144. */
  78145. readonly promise: Promise<T>;
  78146. private _resolve;
  78147. private _reject;
  78148. /**
  78149. * The resolve method of the promise associated with this deferred object.
  78150. */
  78151. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78152. /**
  78153. * The reject method of the promise associated with this deferred object.
  78154. */
  78155. get reject(): (reason?: any) => void;
  78156. /**
  78157. * Constructor for this deferred object.
  78158. */
  78159. constructor();
  78160. }
  78161. }
  78162. declare module "babylonjs/Misc/meshExploder" {
  78163. import { Mesh } from "babylonjs/Meshes/mesh";
  78164. /**
  78165. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78166. */
  78167. export class MeshExploder {
  78168. private _centerMesh;
  78169. private _meshes;
  78170. private _meshesOrigins;
  78171. private _toCenterVectors;
  78172. private _scaledDirection;
  78173. private _newPosition;
  78174. private _centerPosition;
  78175. /**
  78176. * Explodes meshes from a center mesh.
  78177. * @param meshes The meshes to explode.
  78178. * @param centerMesh The mesh to be center of explosion.
  78179. */
  78180. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78181. private _setCenterMesh;
  78182. /**
  78183. * Get class name
  78184. * @returns "MeshExploder"
  78185. */
  78186. getClassName(): string;
  78187. /**
  78188. * "Exploded meshes"
  78189. * @returns Array of meshes with the centerMesh at index 0.
  78190. */
  78191. getMeshes(): Array<Mesh>;
  78192. /**
  78193. * Explodes meshes giving a specific direction
  78194. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78195. */
  78196. explode(direction?: number): void;
  78197. }
  78198. }
  78199. declare module "babylonjs/Misc/filesInput" {
  78200. import { Engine } from "babylonjs/Engines/engine";
  78201. import { Scene } from "babylonjs/scene";
  78202. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78203. import { Nullable } from "babylonjs/types";
  78204. /**
  78205. * Class used to help managing file picking and drag'n'drop
  78206. */
  78207. export class FilesInput {
  78208. /**
  78209. * List of files ready to be loaded
  78210. */
  78211. static get FilesToLoad(): {
  78212. [key: string]: File;
  78213. };
  78214. /**
  78215. * Callback called when a file is processed
  78216. */
  78217. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78218. private _engine;
  78219. private _currentScene;
  78220. private _sceneLoadedCallback;
  78221. private _progressCallback;
  78222. private _additionalRenderLoopLogicCallback;
  78223. private _textureLoadingCallback;
  78224. private _startingProcessingFilesCallback;
  78225. private _onReloadCallback;
  78226. private _errorCallback;
  78227. private _elementToMonitor;
  78228. private _sceneFileToLoad;
  78229. private _filesToLoad;
  78230. /**
  78231. * Creates a new FilesInput
  78232. * @param engine defines the rendering engine
  78233. * @param scene defines the hosting scene
  78234. * @param sceneLoadedCallback callback called when scene is loaded
  78235. * @param progressCallback callback called to track progress
  78236. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78237. * @param textureLoadingCallback callback called when a texture is loading
  78238. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78239. * @param onReloadCallback callback called when a reload is requested
  78240. * @param errorCallback callback call if an error occurs
  78241. */
  78242. 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>);
  78243. private _dragEnterHandler;
  78244. private _dragOverHandler;
  78245. private _dropHandler;
  78246. /**
  78247. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78248. * @param elementToMonitor defines the DOM element to track
  78249. */
  78250. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78251. /** Gets the current list of files to load */
  78252. get filesToLoad(): File[];
  78253. /**
  78254. * Release all associated resources
  78255. */
  78256. dispose(): void;
  78257. private renderFunction;
  78258. private drag;
  78259. private drop;
  78260. private _traverseFolder;
  78261. private _processFiles;
  78262. /**
  78263. * Load files from a drop event
  78264. * @param event defines the drop event to use as source
  78265. */
  78266. loadFiles(event: any): void;
  78267. private _processReload;
  78268. /**
  78269. * Reload the current scene from the loaded files
  78270. */
  78271. reload(): void;
  78272. }
  78273. }
  78274. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78275. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78276. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78277. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78278. }
  78279. declare module "babylonjs/Misc/sceneOptimizer" {
  78280. import { Scene, IDisposable } from "babylonjs/scene";
  78281. import { Observable } from "babylonjs/Misc/observable";
  78282. /**
  78283. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78284. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78285. */
  78286. export class SceneOptimization {
  78287. /**
  78288. * Defines the priority of this optimization (0 by default which means first in the list)
  78289. */
  78290. priority: number;
  78291. /**
  78292. * Gets a string describing the action executed by the current optimization
  78293. * @returns description string
  78294. */
  78295. getDescription(): string;
  78296. /**
  78297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78298. * @param scene defines the current scene where to apply this optimization
  78299. * @param optimizer defines the current optimizer
  78300. * @returns true if everything that can be done was applied
  78301. */
  78302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78303. /**
  78304. * Creates the SceneOptimization object
  78305. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78306. * @param desc defines the description associated with the optimization
  78307. */
  78308. constructor(
  78309. /**
  78310. * Defines the priority of this optimization (0 by default which means first in the list)
  78311. */
  78312. priority?: number);
  78313. }
  78314. /**
  78315. * Defines an optimization used to reduce the size of render target textures
  78316. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78317. */
  78318. export class TextureOptimization extends SceneOptimization {
  78319. /**
  78320. * Defines the priority of this optimization (0 by default which means first in the list)
  78321. */
  78322. priority: number;
  78323. /**
  78324. * 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
  78325. */
  78326. maximumSize: number;
  78327. /**
  78328. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78329. */
  78330. step: number;
  78331. /**
  78332. * Gets a string describing the action executed by the current optimization
  78333. * @returns description string
  78334. */
  78335. getDescription(): string;
  78336. /**
  78337. * Creates the TextureOptimization object
  78338. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78339. * @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
  78340. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78341. */
  78342. constructor(
  78343. /**
  78344. * Defines the priority of this optimization (0 by default which means first in the list)
  78345. */
  78346. priority?: number,
  78347. /**
  78348. * 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
  78349. */
  78350. maximumSize?: number,
  78351. /**
  78352. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78353. */
  78354. step?: number);
  78355. /**
  78356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78357. * @param scene defines the current scene where to apply this optimization
  78358. * @param optimizer defines the current optimizer
  78359. * @returns true if everything that can be done was applied
  78360. */
  78361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78362. }
  78363. /**
  78364. * Defines an optimization used to increase or decrease the rendering resolution
  78365. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78366. */
  78367. export class HardwareScalingOptimization extends SceneOptimization {
  78368. /**
  78369. * Defines the priority of this optimization (0 by default which means first in the list)
  78370. */
  78371. priority: number;
  78372. /**
  78373. * Defines the maximum scale to use (2 by default)
  78374. */
  78375. maximumScale: number;
  78376. /**
  78377. * Defines the step to use between two passes (0.5 by default)
  78378. */
  78379. step: number;
  78380. private _currentScale;
  78381. private _directionOffset;
  78382. /**
  78383. * Gets a string describing the action executed by the current optimization
  78384. * @return description string
  78385. */
  78386. getDescription(): string;
  78387. /**
  78388. * Creates the HardwareScalingOptimization object
  78389. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78390. * @param maximumScale defines the maximum scale to use (2 by default)
  78391. * @param step defines the step to use between two passes (0.5 by default)
  78392. */
  78393. constructor(
  78394. /**
  78395. * Defines the priority of this optimization (0 by default which means first in the list)
  78396. */
  78397. priority?: number,
  78398. /**
  78399. * Defines the maximum scale to use (2 by default)
  78400. */
  78401. maximumScale?: number,
  78402. /**
  78403. * Defines the step to use between two passes (0.5 by default)
  78404. */
  78405. step?: number);
  78406. /**
  78407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78408. * @param scene defines the current scene where to apply this optimization
  78409. * @param optimizer defines the current optimizer
  78410. * @returns true if everything that can be done was applied
  78411. */
  78412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78413. }
  78414. /**
  78415. * Defines an optimization used to remove shadows
  78416. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78417. */
  78418. export class ShadowsOptimization extends SceneOptimization {
  78419. /**
  78420. * Gets a string describing the action executed by the current optimization
  78421. * @return description string
  78422. */
  78423. getDescription(): string;
  78424. /**
  78425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78426. * @param scene defines the current scene where to apply this optimization
  78427. * @param optimizer defines the current optimizer
  78428. * @returns true if everything that can be done was applied
  78429. */
  78430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78431. }
  78432. /**
  78433. * Defines an optimization used to turn post-processes off
  78434. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78435. */
  78436. export class PostProcessesOptimization extends SceneOptimization {
  78437. /**
  78438. * Gets a string describing the action executed by the current optimization
  78439. * @return description string
  78440. */
  78441. getDescription(): string;
  78442. /**
  78443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78444. * @param scene defines the current scene where to apply this optimization
  78445. * @param optimizer defines the current optimizer
  78446. * @returns true if everything that can be done was applied
  78447. */
  78448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78449. }
  78450. /**
  78451. * Defines an optimization used to turn lens flares off
  78452. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78453. */
  78454. export class LensFlaresOptimization extends SceneOptimization {
  78455. /**
  78456. * Gets a string describing the action executed by the current optimization
  78457. * @return description string
  78458. */
  78459. getDescription(): string;
  78460. /**
  78461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78462. * @param scene defines the current scene where to apply this optimization
  78463. * @param optimizer defines the current optimizer
  78464. * @returns true if everything that can be done was applied
  78465. */
  78466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78467. }
  78468. /**
  78469. * Defines an optimization based on user defined callback.
  78470. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78471. */
  78472. export class CustomOptimization extends SceneOptimization {
  78473. /**
  78474. * Callback called to apply the custom optimization.
  78475. */
  78476. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78477. /**
  78478. * Callback called to get custom description
  78479. */
  78480. onGetDescription: () => string;
  78481. /**
  78482. * Gets a string describing the action executed by the current optimization
  78483. * @returns description string
  78484. */
  78485. getDescription(): string;
  78486. /**
  78487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78488. * @param scene defines the current scene where to apply this optimization
  78489. * @param optimizer defines the current optimizer
  78490. * @returns true if everything that can be done was applied
  78491. */
  78492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78493. }
  78494. /**
  78495. * Defines an optimization used to turn particles off
  78496. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78497. */
  78498. export class ParticlesOptimization extends SceneOptimization {
  78499. /**
  78500. * Gets a string describing the action executed by the current optimization
  78501. * @return description string
  78502. */
  78503. getDescription(): string;
  78504. /**
  78505. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78506. * @param scene defines the current scene where to apply this optimization
  78507. * @param optimizer defines the current optimizer
  78508. * @returns true if everything that can be done was applied
  78509. */
  78510. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78511. }
  78512. /**
  78513. * Defines an optimization used to turn render targets off
  78514. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78515. */
  78516. export class RenderTargetsOptimization extends SceneOptimization {
  78517. /**
  78518. * Gets a string describing the action executed by the current optimization
  78519. * @return description string
  78520. */
  78521. getDescription(): string;
  78522. /**
  78523. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78524. * @param scene defines the current scene where to apply this optimization
  78525. * @param optimizer defines the current optimizer
  78526. * @returns true if everything that can be done was applied
  78527. */
  78528. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78529. }
  78530. /**
  78531. * Defines an optimization used to merge meshes with compatible materials
  78532. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78533. */
  78534. export class MergeMeshesOptimization extends SceneOptimization {
  78535. private static _UpdateSelectionTree;
  78536. /**
  78537. * Gets or sets a boolean which defines if optimization octree has to be updated
  78538. */
  78539. static get UpdateSelectionTree(): boolean;
  78540. /**
  78541. * Gets or sets a boolean which defines if optimization octree has to be updated
  78542. */
  78543. static set UpdateSelectionTree(value: boolean);
  78544. /**
  78545. * Gets a string describing the action executed by the current optimization
  78546. * @return description string
  78547. */
  78548. getDescription(): string;
  78549. private _canBeMerged;
  78550. /**
  78551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78552. * @param scene defines the current scene where to apply this optimization
  78553. * @param optimizer defines the current optimizer
  78554. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78555. * @returns true if everything that can be done was applied
  78556. */
  78557. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78558. }
  78559. /**
  78560. * Defines a list of options used by SceneOptimizer
  78561. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78562. */
  78563. export class SceneOptimizerOptions {
  78564. /**
  78565. * Defines the target frame rate to reach (60 by default)
  78566. */
  78567. targetFrameRate: number;
  78568. /**
  78569. * Defines the interval between two checkes (2000ms by default)
  78570. */
  78571. trackerDuration: number;
  78572. /**
  78573. * Gets the list of optimizations to apply
  78574. */
  78575. optimizations: SceneOptimization[];
  78576. /**
  78577. * Creates a new list of options used by SceneOptimizer
  78578. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78579. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78580. */
  78581. constructor(
  78582. /**
  78583. * Defines the target frame rate to reach (60 by default)
  78584. */
  78585. targetFrameRate?: number,
  78586. /**
  78587. * Defines the interval between two checkes (2000ms by default)
  78588. */
  78589. trackerDuration?: number);
  78590. /**
  78591. * Add a new optimization
  78592. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78593. * @returns the current SceneOptimizerOptions
  78594. */
  78595. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78596. /**
  78597. * Add a new custom optimization
  78598. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78599. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78600. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78601. * @returns the current SceneOptimizerOptions
  78602. */
  78603. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78604. /**
  78605. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78606. * @param targetFrameRate defines the target frame rate (60 by default)
  78607. * @returns a SceneOptimizerOptions object
  78608. */
  78609. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78610. /**
  78611. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78612. * @param targetFrameRate defines the target frame rate (60 by default)
  78613. * @returns a SceneOptimizerOptions object
  78614. */
  78615. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78616. /**
  78617. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78618. * @param targetFrameRate defines the target frame rate (60 by default)
  78619. * @returns a SceneOptimizerOptions object
  78620. */
  78621. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78622. }
  78623. /**
  78624. * Class used to run optimizations in order to reach a target frame rate
  78625. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78626. */
  78627. export class SceneOptimizer implements IDisposable {
  78628. private _isRunning;
  78629. private _options;
  78630. private _scene;
  78631. private _currentPriorityLevel;
  78632. private _targetFrameRate;
  78633. private _trackerDuration;
  78634. private _currentFrameRate;
  78635. private _sceneDisposeObserver;
  78636. private _improvementMode;
  78637. /**
  78638. * Defines an observable called when the optimizer reaches the target frame rate
  78639. */
  78640. onSuccessObservable: Observable<SceneOptimizer>;
  78641. /**
  78642. * Defines an observable called when the optimizer enables an optimization
  78643. */
  78644. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78645. /**
  78646. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78647. */
  78648. onFailureObservable: Observable<SceneOptimizer>;
  78649. /**
  78650. * Gets a boolean indicating if the optimizer is in improvement mode
  78651. */
  78652. get isInImprovementMode(): boolean;
  78653. /**
  78654. * Gets the current priority level (0 at start)
  78655. */
  78656. get currentPriorityLevel(): number;
  78657. /**
  78658. * Gets the current frame rate checked by the SceneOptimizer
  78659. */
  78660. get currentFrameRate(): number;
  78661. /**
  78662. * Gets or sets the current target frame rate (60 by default)
  78663. */
  78664. get targetFrameRate(): number;
  78665. /**
  78666. * Gets or sets the current target frame rate (60 by default)
  78667. */
  78668. set targetFrameRate(value: number);
  78669. /**
  78670. * Gets or sets the current interval between two checks (every 2000ms by default)
  78671. */
  78672. get trackerDuration(): number;
  78673. /**
  78674. * Gets or sets the current interval between two checks (every 2000ms by default)
  78675. */
  78676. set trackerDuration(value: number);
  78677. /**
  78678. * Gets the list of active optimizations
  78679. */
  78680. get optimizations(): SceneOptimization[];
  78681. /**
  78682. * Creates a new SceneOptimizer
  78683. * @param scene defines the scene to work on
  78684. * @param options defines the options to use with the SceneOptimizer
  78685. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78686. * @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)
  78687. */
  78688. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78689. /**
  78690. * Stops the current optimizer
  78691. */
  78692. stop(): void;
  78693. /**
  78694. * Reset the optimizer to initial step (current priority level = 0)
  78695. */
  78696. reset(): void;
  78697. /**
  78698. * Start the optimizer. By default it will try to reach a specific framerate
  78699. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78700. */
  78701. start(): void;
  78702. private _checkCurrentState;
  78703. /**
  78704. * Release all resources
  78705. */
  78706. dispose(): void;
  78707. /**
  78708. * Helper function to create a SceneOptimizer with one single line of code
  78709. * @param scene defines the scene to work on
  78710. * @param options defines the options to use with the SceneOptimizer
  78711. * @param onSuccess defines a callback to call on success
  78712. * @param onFailure defines a callback to call on failure
  78713. * @returns the new SceneOptimizer object
  78714. */
  78715. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78716. }
  78717. }
  78718. declare module "babylonjs/Misc/sceneSerializer" {
  78719. import { Scene } from "babylonjs/scene";
  78720. /**
  78721. * Class used to serialize a scene into a string
  78722. */
  78723. export class SceneSerializer {
  78724. /**
  78725. * Clear cache used by a previous serialization
  78726. */
  78727. static ClearCache(): void;
  78728. /**
  78729. * Serialize a scene into a JSON compatible object
  78730. * @param scene defines the scene to serialize
  78731. * @returns a JSON compatible object
  78732. */
  78733. static Serialize(scene: Scene): any;
  78734. /**
  78735. * Serialize a mesh into a JSON compatible object
  78736. * @param toSerialize defines the mesh to serialize
  78737. * @param withParents defines if parents must be serialized as well
  78738. * @param withChildren defines if children must be serialized as well
  78739. * @returns a JSON compatible object
  78740. */
  78741. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78742. }
  78743. }
  78744. declare module "babylonjs/Misc/textureTools" {
  78745. import { Texture } from "babylonjs/Materials/Textures/texture";
  78746. /**
  78747. * Class used to host texture specific utilities
  78748. */
  78749. export class TextureTools {
  78750. /**
  78751. * Uses the GPU to create a copy texture rescaled at a given size
  78752. * @param texture Texture to copy from
  78753. * @param width defines the desired width
  78754. * @param height defines the desired height
  78755. * @param useBilinearMode defines if bilinear mode has to be used
  78756. * @return the generated texture
  78757. */
  78758. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78759. }
  78760. }
  78761. declare module "babylonjs/Misc/videoRecorder" {
  78762. import { Nullable } from "babylonjs/types";
  78763. import { Engine } from "babylonjs/Engines/engine";
  78764. /**
  78765. * This represents the different options available for the video capture.
  78766. */
  78767. export interface VideoRecorderOptions {
  78768. /** Defines the mime type of the video. */
  78769. mimeType: string;
  78770. /** Defines the FPS the video should be recorded at. */
  78771. fps: number;
  78772. /** Defines the chunk size for the recording data. */
  78773. recordChunckSize: number;
  78774. /** The audio tracks to attach to the recording. */
  78775. audioTracks?: MediaStreamTrack[];
  78776. }
  78777. /**
  78778. * This can help with recording videos from BabylonJS.
  78779. * This is based on the available WebRTC functionalities of the browser.
  78780. *
  78781. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78782. */
  78783. export class VideoRecorder {
  78784. private static readonly _defaultOptions;
  78785. /**
  78786. * Returns whether or not the VideoRecorder is available in your browser.
  78787. * @param engine Defines the Babylon Engine.
  78788. * @returns true if supported otherwise false.
  78789. */
  78790. static IsSupported(engine: Engine): boolean;
  78791. private readonly _options;
  78792. private _canvas;
  78793. private _mediaRecorder;
  78794. private _recordedChunks;
  78795. private _fileName;
  78796. private _resolve;
  78797. private _reject;
  78798. /**
  78799. * True when a recording is already in progress.
  78800. */
  78801. get isRecording(): boolean;
  78802. /**
  78803. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78804. * @param engine Defines the BabylonJS Engine you wish to record.
  78805. * @param options Defines options that can be used to customize the capture.
  78806. */
  78807. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78808. /**
  78809. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78810. */
  78811. stopRecording(): void;
  78812. /**
  78813. * Starts recording the canvas for a max duration specified in parameters.
  78814. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78815. * If null no automatic download will start and you can rely on the promise to get the data back.
  78816. * @param maxDuration Defines the maximum recording time in seconds.
  78817. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78818. * @return A promise callback at the end of the recording with the video data in Blob.
  78819. */
  78820. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78821. /**
  78822. * Releases internal resources used during the recording.
  78823. */
  78824. dispose(): void;
  78825. private _handleDataAvailable;
  78826. private _handleError;
  78827. private _handleStop;
  78828. }
  78829. }
  78830. declare module "babylonjs/Misc/screenshotTools" {
  78831. import { Camera } from "babylonjs/Cameras/camera";
  78832. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78833. import { Engine } from "babylonjs/Engines/engine";
  78834. /**
  78835. * Class containing a set of static utilities functions for screenshots
  78836. */
  78837. export class ScreenshotTools {
  78838. /**
  78839. * Captures a screenshot of the current rendering
  78840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78841. * @param engine defines the rendering engine
  78842. * @param camera defines the source camera
  78843. * @param size This parameter can be set to a single number or to an object with the
  78844. * following (optional) properties: precision, width, height. If a single number is passed,
  78845. * it will be used for both width and height. If an object is passed, the screenshot size
  78846. * will be derived from the parameters. The precision property is a multiplier allowing
  78847. * rendering at a higher or lower resolution
  78848. * @param successCallback defines the callback receives a single parameter which contains the
  78849. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78850. * src parameter of an <img> to display it
  78851. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78852. * Check your browser for supported MIME types
  78853. */
  78854. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78855. /**
  78856. * Captures a screenshot of the current rendering
  78857. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78858. * @param engine defines the rendering engine
  78859. * @param camera defines the source camera
  78860. * @param size This parameter can be set to a single number or to an object with the
  78861. * following (optional) properties: precision, width, height. If a single number is passed,
  78862. * it will be used for both width and height. If an object is passed, the screenshot size
  78863. * will be derived from the parameters. The precision property is a multiplier allowing
  78864. * rendering at a higher or lower resolution
  78865. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78866. * Check your browser for supported MIME types
  78867. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78868. * to the src parameter of an <img> to display it
  78869. */
  78870. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78871. /**
  78872. * Generates an image screenshot from the specified camera.
  78873. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78874. * @param engine The engine to use for rendering
  78875. * @param camera The camera to use for rendering
  78876. * @param size This parameter can be set to a single number or to an object with the
  78877. * following (optional) properties: precision, width, height. If a single number is passed,
  78878. * it will be used for both width and height. If an object is passed, the screenshot size
  78879. * will be derived from the parameters. The precision property is a multiplier allowing
  78880. * rendering at a higher or lower resolution
  78881. * @param successCallback The callback receives a single parameter which contains the
  78882. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78883. * src parameter of an <img> to display it
  78884. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78885. * Check your browser for supported MIME types
  78886. * @param samples Texture samples (default: 1)
  78887. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78888. * @param fileName A name for for the downloaded file.
  78889. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78890. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78891. */
  78892. 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;
  78893. /**
  78894. * Generates an image screenshot from the specified camera.
  78895. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78896. * @param engine The engine to use for rendering
  78897. * @param camera The camera to use for rendering
  78898. * @param size This parameter can be set to a single number or to an object with the
  78899. * following (optional) properties: precision, width, height. If a single number is passed,
  78900. * it will be used for both width and height. If an object is passed, the screenshot size
  78901. * will be derived from the parameters. The precision property is a multiplier allowing
  78902. * rendering at a higher or lower resolution
  78903. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78904. * Check your browser for supported MIME types
  78905. * @param samples Texture samples (default: 1)
  78906. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78907. * @param fileName A name for for the downloaded file.
  78908. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78909. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78910. * to the src parameter of an <img> to display it
  78911. */
  78912. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78913. /**
  78914. * Gets height and width for screenshot size
  78915. * @private
  78916. */
  78917. private static _getScreenshotSize;
  78918. }
  78919. }
  78920. declare module "babylonjs/Misc/dataReader" {
  78921. /**
  78922. * Interface for a data buffer
  78923. */
  78924. export interface IDataBuffer {
  78925. /**
  78926. * Reads bytes from the data buffer.
  78927. * @param byteOffset The byte offset to read
  78928. * @param byteLength The byte length to read
  78929. * @returns A promise that resolves when the bytes are read
  78930. */
  78931. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78932. /**
  78933. * The byte length of the buffer.
  78934. */
  78935. readonly byteLength: number;
  78936. }
  78937. /**
  78938. * Utility class for reading from a data buffer
  78939. */
  78940. export class DataReader {
  78941. /**
  78942. * The data buffer associated with this data reader.
  78943. */
  78944. readonly buffer: IDataBuffer;
  78945. /**
  78946. * The current byte offset from the beginning of the data buffer.
  78947. */
  78948. byteOffset: number;
  78949. private _dataView;
  78950. private _dataByteOffset;
  78951. /**
  78952. * Constructor
  78953. * @param buffer The buffer to read
  78954. */
  78955. constructor(buffer: IDataBuffer);
  78956. /**
  78957. * Loads the given byte length.
  78958. * @param byteLength The byte length to load
  78959. * @returns A promise that resolves when the load is complete
  78960. */
  78961. loadAsync(byteLength: number): Promise<void>;
  78962. /**
  78963. * Read a unsigned 32-bit integer from the currently loaded data range.
  78964. * @returns The 32-bit integer read
  78965. */
  78966. readUint32(): number;
  78967. /**
  78968. * Read a byte array from the currently loaded data range.
  78969. * @param byteLength The byte length to read
  78970. * @returns The byte array read
  78971. */
  78972. readUint8Array(byteLength: number): Uint8Array;
  78973. /**
  78974. * Read a string from the currently loaded data range.
  78975. * @param byteLength The byte length to read
  78976. * @returns The string read
  78977. */
  78978. readString(byteLength: number): string;
  78979. /**
  78980. * Skips the given byte length the currently loaded data range.
  78981. * @param byteLength The byte length to skip
  78982. */
  78983. skipBytes(byteLength: number): void;
  78984. }
  78985. }
  78986. declare module "babylonjs/Misc/dataStorage" {
  78987. /**
  78988. * Class for storing data to local storage if available or in-memory storage otherwise
  78989. */
  78990. export class DataStorage {
  78991. private static _Storage;
  78992. private static _GetStorage;
  78993. /**
  78994. * Reads a string from the data storage
  78995. * @param key The key to read
  78996. * @param defaultValue The value if the key doesn't exist
  78997. * @returns The string value
  78998. */
  78999. static ReadString(key: string, defaultValue: string): string;
  79000. /**
  79001. * Writes a string to the data storage
  79002. * @param key The key to write
  79003. * @param value The value to write
  79004. */
  79005. static WriteString(key: string, value: string): void;
  79006. /**
  79007. * Reads a boolean from the data storage
  79008. * @param key The key to read
  79009. * @param defaultValue The value if the key doesn't exist
  79010. * @returns The boolean value
  79011. */
  79012. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79013. /**
  79014. * Writes a boolean to the data storage
  79015. * @param key The key to write
  79016. * @param value The value to write
  79017. */
  79018. static WriteBoolean(key: string, value: boolean): void;
  79019. /**
  79020. * Reads a number from the data storage
  79021. * @param key The key to read
  79022. * @param defaultValue The value if the key doesn't exist
  79023. * @returns The number value
  79024. */
  79025. static ReadNumber(key: string, defaultValue: number): number;
  79026. /**
  79027. * Writes a number to the data storage
  79028. * @param key The key to write
  79029. * @param value The value to write
  79030. */
  79031. static WriteNumber(key: string, value: number): void;
  79032. }
  79033. }
  79034. declare module "babylonjs/Misc/sceneRecorder" {
  79035. import { Scene } from "babylonjs/scene";
  79036. /**
  79037. * Class used to record delta files between 2 scene states
  79038. */
  79039. export class SceneRecorder {
  79040. private _trackedScene;
  79041. private _savedJSON;
  79042. /**
  79043. * Track a given scene. This means the current scene state will be considered the original state
  79044. * @param scene defines the scene to track
  79045. */
  79046. track(scene: Scene): void;
  79047. /**
  79048. * Get the delta between current state and original state
  79049. * @returns a string containing the delta
  79050. */
  79051. getDelta(): any;
  79052. private _compareArray;
  79053. private _compareObjects;
  79054. private _compareCollections;
  79055. private static GetShadowGeneratorById;
  79056. /**
  79057. * Apply a given delta to a given scene
  79058. * @param deltaJSON defines the JSON containing the delta
  79059. * @param scene defines the scene to apply the delta to
  79060. */
  79061. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79062. private static _ApplyPropertiesToEntity;
  79063. private static _ApplyDeltaForEntity;
  79064. }
  79065. }
  79066. declare module "babylonjs/Misc/trajectoryClassifier" {
  79067. import { DeepImmutable, Nullable } from "babylonjs/types";
  79068. import { Vector3 } from "babylonjs/Maths/math.vector";
  79069. /**
  79070. * A 3D trajectory consisting of an order list of vectors describing a
  79071. * path of motion through 3D space.
  79072. */
  79073. export class Trajectory {
  79074. private _points;
  79075. private readonly _segmentLength;
  79076. /**
  79077. * Serialize to JSON.
  79078. * @returns serialized JSON string
  79079. */
  79080. serialize(): string;
  79081. /**
  79082. * Deserialize from JSON.
  79083. * @param json serialized JSON string
  79084. * @returns deserialized Trajectory
  79085. */
  79086. static Deserialize(json: string): Trajectory;
  79087. /**
  79088. * Create a new empty Trajectory.
  79089. * @param segmentLength radius of discretization for Trajectory points
  79090. */
  79091. constructor(segmentLength?: number);
  79092. /**
  79093. * Get the length of the Trajectory.
  79094. * @returns length of the Trajectory
  79095. */
  79096. getLength(): number;
  79097. /**
  79098. * Append a new point to the Trajectory.
  79099. * NOTE: This implementation has many allocations.
  79100. * @param point point to append to the Trajectory
  79101. */
  79102. add(point: DeepImmutable<Vector3>): void;
  79103. /**
  79104. * Create a new Trajectory with a segment length chosen to make it
  79105. * probable that the new Trajectory will have a specified number of
  79106. * segments. This operation is imprecise.
  79107. * @param targetResolution number of segments desired
  79108. * @returns new Trajectory with approximately the requested number of segments
  79109. */
  79110. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79111. /**
  79112. * Convert Trajectory segments into tokenized representation. This
  79113. * representation is an array of numbers where each nth number is the
  79114. * index of the token which is most similar to the nth segment of the
  79115. * Trajectory.
  79116. * @param tokens list of vectors which serve as discrete tokens
  79117. * @returns list of indices of most similar token per segment
  79118. */
  79119. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79120. private static _forwardDir;
  79121. private static _inverseFromVec;
  79122. private static _upDir;
  79123. private static _fromToVec;
  79124. private static _lookMatrix;
  79125. /**
  79126. * Transform the rotation (i.e., direction) of a segment to isolate
  79127. * the relative transformation represented by the segment. This operation
  79128. * may or may not succeed due to singularities in the equations that define
  79129. * motion relativity in this context.
  79130. * @param priorVec the origin of the prior segment
  79131. * @param fromVec the origin of the current segment
  79132. * @param toVec the destination of the current segment
  79133. * @param result reference to output variable
  79134. * @returns whether or not transformation was successful
  79135. */
  79136. private static _transformSegmentDirToRef;
  79137. private static _bestMatch;
  79138. private static _score;
  79139. private static _bestScore;
  79140. /**
  79141. * Determine which token vector is most similar to the
  79142. * segment vector.
  79143. * @param segment segment vector
  79144. * @param tokens token vector list
  79145. * @returns index of the most similar token to the segment
  79146. */
  79147. private static _tokenizeSegment;
  79148. }
  79149. /**
  79150. * Class representing a set of known, named trajectories to which Trajectories can be
  79151. * added and using which Trajectories can be recognized.
  79152. */
  79153. export class TrajectoryClassifier {
  79154. private _maximumAllowableMatchCost;
  79155. private _vector3Alphabet;
  79156. private _levenshteinAlphabet;
  79157. private _nameToDescribedTrajectory;
  79158. /**
  79159. * Serialize to JSON.
  79160. * @returns JSON serialization
  79161. */
  79162. serialize(): string;
  79163. /**
  79164. * Deserialize from JSON.
  79165. * @param json JSON serialization
  79166. * @returns deserialized TrajectorySet
  79167. */
  79168. static Deserialize(json: string): TrajectoryClassifier;
  79169. /**
  79170. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79171. * VERY naive, need to be generating these things from known
  79172. * sets. Better version later, probably eliminating this one.
  79173. * @returns auto-generated TrajectorySet
  79174. */
  79175. static Generate(): TrajectoryClassifier;
  79176. private constructor();
  79177. /**
  79178. * Add a new Trajectory to the set with a given name.
  79179. * @param trajectory new Trajectory to be added
  79180. * @param classification name to which to add the Trajectory
  79181. */
  79182. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79183. /**
  79184. * Remove a known named trajectory and all Trajectories associated with it.
  79185. * @param classification name to remove
  79186. * @returns whether anything was removed
  79187. */
  79188. deleteClassification(classification: string): boolean;
  79189. /**
  79190. * Attempt to recognize a Trajectory from among all the classifications
  79191. * already known to the classifier.
  79192. * @param trajectory Trajectory to be recognized
  79193. * @returns classification of Trajectory if recognized, null otherwise
  79194. */
  79195. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79196. }
  79197. }
  79198. declare module "babylonjs/Misc/index" {
  79199. export * from "babylonjs/Misc/andOrNotEvaluator";
  79200. export * from "babylonjs/Misc/assetsManager";
  79201. export * from "babylonjs/Misc/basis";
  79202. export * from "babylonjs/Misc/dds";
  79203. export * from "babylonjs/Misc/decorators";
  79204. export * from "babylonjs/Misc/deferred";
  79205. export * from "babylonjs/Misc/environmentTextureTools";
  79206. export * from "babylonjs/Misc/meshExploder";
  79207. export * from "babylonjs/Misc/filesInput";
  79208. export * from "babylonjs/Misc/HighDynamicRange/index";
  79209. export * from "babylonjs/Misc/khronosTextureContainer";
  79210. export * from "babylonjs/Misc/observable";
  79211. export * from "babylonjs/Misc/performanceMonitor";
  79212. export * from "babylonjs/Misc/promise";
  79213. export * from "babylonjs/Misc/sceneOptimizer";
  79214. export * from "babylonjs/Misc/sceneSerializer";
  79215. export * from "babylonjs/Misc/smartArray";
  79216. export * from "babylonjs/Misc/stringDictionary";
  79217. export * from "babylonjs/Misc/tags";
  79218. export * from "babylonjs/Misc/textureTools";
  79219. export * from "babylonjs/Misc/tga";
  79220. export * from "babylonjs/Misc/tools";
  79221. export * from "babylonjs/Misc/videoRecorder";
  79222. export * from "babylonjs/Misc/virtualJoystick";
  79223. export * from "babylonjs/Misc/workerPool";
  79224. export * from "babylonjs/Misc/logger";
  79225. export * from "babylonjs/Misc/typeStore";
  79226. export * from "babylonjs/Misc/filesInputStore";
  79227. export * from "babylonjs/Misc/deepCopier";
  79228. export * from "babylonjs/Misc/pivotTools";
  79229. export * from "babylonjs/Misc/precisionDate";
  79230. export * from "babylonjs/Misc/screenshotTools";
  79231. export * from "babylonjs/Misc/typeStore";
  79232. export * from "babylonjs/Misc/webRequest";
  79233. export * from "babylonjs/Misc/iInspectable";
  79234. export * from "babylonjs/Misc/brdfTextureTools";
  79235. export * from "babylonjs/Misc/rgbdTextureTools";
  79236. export * from "babylonjs/Misc/gradients";
  79237. export * from "babylonjs/Misc/perfCounter";
  79238. export * from "babylonjs/Misc/fileRequest";
  79239. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79240. export * from "babylonjs/Misc/retryStrategy";
  79241. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79242. export * from "babylonjs/Misc/canvasGenerator";
  79243. export * from "babylonjs/Misc/fileTools";
  79244. export * from "babylonjs/Misc/stringTools";
  79245. export * from "babylonjs/Misc/dataReader";
  79246. export * from "babylonjs/Misc/minMaxReducer";
  79247. export * from "babylonjs/Misc/depthReducer";
  79248. export * from "babylonjs/Misc/dataStorage";
  79249. export * from "babylonjs/Misc/sceneRecorder";
  79250. export * from "babylonjs/Misc/khronosTextureContainer2";
  79251. export * from "babylonjs/Misc/trajectoryClassifier";
  79252. export * from "babylonjs/Misc/timer";
  79253. }
  79254. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79255. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79256. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79257. import { Observable } from "babylonjs/Misc/observable";
  79258. import { Matrix } from "babylonjs/Maths/math.vector";
  79259. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79260. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79261. /**
  79262. * An interface for all Hit test features
  79263. */
  79264. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79265. /**
  79266. * Triggered when new babylon (transformed) hit test results are available
  79267. */
  79268. onHitTestResultObservable: Observable<T[]>;
  79269. }
  79270. /**
  79271. * Options used for hit testing
  79272. */
  79273. export interface IWebXRLegacyHitTestOptions {
  79274. /**
  79275. * Only test when user interacted with the scene. Default - hit test every frame
  79276. */
  79277. testOnPointerDownOnly?: boolean;
  79278. /**
  79279. * The node to use to transform the local results to world coordinates
  79280. */
  79281. worldParentNode?: TransformNode;
  79282. }
  79283. /**
  79284. * Interface defining the babylon result of raycasting/hit-test
  79285. */
  79286. export interface IWebXRLegacyHitResult {
  79287. /**
  79288. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79289. */
  79290. transformationMatrix: Matrix;
  79291. /**
  79292. * The native hit test result
  79293. */
  79294. xrHitResult: XRHitResult | XRHitTestResult;
  79295. }
  79296. /**
  79297. * The currently-working hit-test module.
  79298. * Hit test (or Ray-casting) is used to interact with the real world.
  79299. * For further information read here - https://github.com/immersive-web/hit-test
  79300. */
  79301. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79302. /**
  79303. * options to use when constructing this feature
  79304. */
  79305. readonly options: IWebXRLegacyHitTestOptions;
  79306. private _direction;
  79307. private _mat;
  79308. private _onSelectEnabled;
  79309. private _origin;
  79310. /**
  79311. * The module's name
  79312. */
  79313. static readonly Name: string;
  79314. /**
  79315. * The (Babylon) version of this module.
  79316. * This is an integer representing the implementation version.
  79317. * This number does not correspond to the WebXR specs version
  79318. */
  79319. static readonly Version: number;
  79320. /**
  79321. * Populated with the last native XR Hit Results
  79322. */
  79323. lastNativeXRHitResults: XRHitResult[];
  79324. /**
  79325. * Triggered when new babylon (transformed) hit test results are available
  79326. */
  79327. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79328. /**
  79329. * Creates a new instance of the (legacy version) hit test feature
  79330. * @param _xrSessionManager an instance of WebXRSessionManager
  79331. * @param options options to use when constructing this feature
  79332. */
  79333. constructor(_xrSessionManager: WebXRSessionManager,
  79334. /**
  79335. * options to use when constructing this feature
  79336. */
  79337. options?: IWebXRLegacyHitTestOptions);
  79338. /**
  79339. * execute a hit test with an XR Ray
  79340. *
  79341. * @param xrSession a native xrSession that will execute this hit test
  79342. * @param xrRay the ray (position and direction) to use for ray-casting
  79343. * @param referenceSpace native XR reference space to use for the hit-test
  79344. * @param filter filter function that will filter the results
  79345. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79346. */
  79347. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79348. /**
  79349. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79350. * @param event the (select) event to use to select with
  79351. * @param referenceSpace the reference space to use for this hit test
  79352. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79353. */
  79354. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79355. /**
  79356. * attach this feature
  79357. * Will usually be called by the features manager
  79358. *
  79359. * @returns true if successful.
  79360. */
  79361. attach(): boolean;
  79362. /**
  79363. * detach this feature.
  79364. * Will usually be called by the features manager
  79365. *
  79366. * @returns true if successful.
  79367. */
  79368. detach(): boolean;
  79369. /**
  79370. * Dispose this feature and all of the resources attached
  79371. */
  79372. dispose(): void;
  79373. protected _onXRFrame(frame: XRFrame): void;
  79374. private _onHitTestResults;
  79375. private _onSelect;
  79376. }
  79377. }
  79378. declare module "babylonjs/XR/features/WebXRHitTest" {
  79379. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79380. import { Observable } from "babylonjs/Misc/observable";
  79381. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79382. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79383. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79384. /**
  79385. * Options used for hit testing (version 2)
  79386. */
  79387. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79388. /**
  79389. * Do not create a permanent hit test. Will usually be used when only
  79390. * transient inputs are needed.
  79391. */
  79392. disablePermanentHitTest?: boolean;
  79393. /**
  79394. * Enable transient (for example touch-based) hit test inspections
  79395. */
  79396. enableTransientHitTest?: boolean;
  79397. /**
  79398. * Offset ray for the permanent hit test
  79399. */
  79400. offsetRay?: Vector3;
  79401. /**
  79402. * Offset ray for the transient hit test
  79403. */
  79404. transientOffsetRay?: Vector3;
  79405. /**
  79406. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79407. */
  79408. useReferenceSpace?: boolean;
  79409. /**
  79410. * Override the default entity type(s) of the hit-test result
  79411. */
  79412. entityTypes?: XRHitTestTrackableType[];
  79413. }
  79414. /**
  79415. * Interface defining the babylon result of hit-test
  79416. */
  79417. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79418. /**
  79419. * The input source that generated this hit test (if transient)
  79420. */
  79421. inputSource?: XRInputSource;
  79422. /**
  79423. * Is this a transient hit test
  79424. */
  79425. isTransient?: boolean;
  79426. /**
  79427. * Position of the hit test result
  79428. */
  79429. position: Vector3;
  79430. /**
  79431. * Rotation of the hit test result
  79432. */
  79433. rotationQuaternion: Quaternion;
  79434. /**
  79435. * The native hit test result
  79436. */
  79437. xrHitResult: XRHitTestResult;
  79438. }
  79439. /**
  79440. * The currently-working hit-test module.
  79441. * Hit test (or Ray-casting) is used to interact with the real world.
  79442. * For further information read here - https://github.com/immersive-web/hit-test
  79443. *
  79444. * Tested on chrome (mobile) 80.
  79445. */
  79446. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79447. /**
  79448. * options to use when constructing this feature
  79449. */
  79450. readonly options: IWebXRHitTestOptions;
  79451. private _tmpMat;
  79452. private _tmpPos;
  79453. private _tmpQuat;
  79454. private _transientXrHitTestSource;
  79455. private _xrHitTestSource;
  79456. private initHitTestSource;
  79457. /**
  79458. * The module's name
  79459. */
  79460. static readonly Name: string;
  79461. /**
  79462. * The (Babylon) version of this module.
  79463. * This is an integer representing the implementation version.
  79464. * This number does not correspond to the WebXR specs version
  79465. */
  79466. static readonly Version: number;
  79467. /**
  79468. * When set to true, each hit test will have its own position/rotation objects
  79469. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79470. * the developers will clone them or copy them as they see fit.
  79471. */
  79472. autoCloneTransformation: boolean;
  79473. /**
  79474. * Triggered when new babylon (transformed) hit test results are available
  79475. * Note - this will be called when results come back from the device. It can be an empty array!!
  79476. */
  79477. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79478. /**
  79479. * Use this to temporarily pause hit test checks.
  79480. */
  79481. paused: boolean;
  79482. /**
  79483. * Creates a new instance of the hit test feature
  79484. * @param _xrSessionManager an instance of WebXRSessionManager
  79485. * @param options options to use when constructing this feature
  79486. */
  79487. constructor(_xrSessionManager: WebXRSessionManager,
  79488. /**
  79489. * options to use when constructing this feature
  79490. */
  79491. options?: IWebXRHitTestOptions);
  79492. /**
  79493. * attach this feature
  79494. * Will usually be called by the features manager
  79495. *
  79496. * @returns true if successful.
  79497. */
  79498. attach(): boolean;
  79499. /**
  79500. * detach this feature.
  79501. * Will usually be called by the features manager
  79502. *
  79503. * @returns true if successful.
  79504. */
  79505. detach(): boolean;
  79506. /**
  79507. * Dispose this feature and all of the resources attached
  79508. */
  79509. dispose(): void;
  79510. protected _onXRFrame(frame: XRFrame): void;
  79511. private _processWebXRHitTestResult;
  79512. }
  79513. }
  79514. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79515. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79516. import { Observable } from "babylonjs/Misc/observable";
  79517. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79518. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79519. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79520. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79521. /**
  79522. * Configuration options of the anchor system
  79523. */
  79524. export interface IWebXRAnchorSystemOptions {
  79525. /**
  79526. * a node that will be used to convert local to world coordinates
  79527. */
  79528. worldParentNode?: TransformNode;
  79529. /**
  79530. * If set to true a reference of the created anchors will be kept until the next session starts
  79531. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79532. */
  79533. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79534. }
  79535. /**
  79536. * A babylon container for an XR Anchor
  79537. */
  79538. export interface IWebXRAnchor {
  79539. /**
  79540. * A babylon-assigned ID for this anchor
  79541. */
  79542. id: number;
  79543. /**
  79544. * Transformation matrix to apply to an object attached to this anchor
  79545. */
  79546. transformationMatrix: Matrix;
  79547. /**
  79548. * The native anchor object
  79549. */
  79550. xrAnchor: XRAnchor;
  79551. /**
  79552. * if defined, this object will be constantly updated by the anchor's position and rotation
  79553. */
  79554. attachedNode?: TransformNode;
  79555. }
  79556. /**
  79557. * An implementation of the anchor system for WebXR.
  79558. * For further information see https://github.com/immersive-web/anchors/
  79559. */
  79560. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79561. private _options;
  79562. private _lastFrameDetected;
  79563. private _trackedAnchors;
  79564. private _referenceSpaceForFrameAnchors;
  79565. private _futureAnchors;
  79566. /**
  79567. * The module's name
  79568. */
  79569. static readonly Name: string;
  79570. /**
  79571. * The (Babylon) version of this module.
  79572. * This is an integer representing the implementation version.
  79573. * This number does not correspond to the WebXR specs version
  79574. */
  79575. static readonly Version: number;
  79576. /**
  79577. * Observers registered here will be executed when a new anchor was added to the session
  79578. */
  79579. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79580. /**
  79581. * Observers registered here will be executed when an anchor was removed from the session
  79582. */
  79583. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79584. /**
  79585. * Observers registered here will be executed when an existing anchor updates
  79586. * This can execute N times every frame
  79587. */
  79588. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79589. /**
  79590. * Set the reference space to use for anchor creation, when not using a hit test.
  79591. * Will default to the session's reference space if not defined
  79592. */
  79593. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79594. /**
  79595. * constructs a new anchor system
  79596. * @param _xrSessionManager an instance of WebXRSessionManager
  79597. * @param _options configuration object for this feature
  79598. */
  79599. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79600. private _tmpVector;
  79601. private _tmpQuaternion;
  79602. private _populateTmpTransformation;
  79603. /**
  79604. * Create a new anchor point using a hit test result at a specific point in the scene
  79605. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79606. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79607. *
  79608. * @param hitTestResult The hit test result to use for this anchor creation
  79609. * @param position an optional position offset for this anchor
  79610. * @param rotationQuaternion an optional rotation offset for this anchor
  79611. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79612. */
  79613. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79614. /**
  79615. * Add a new anchor at a specific position and rotation
  79616. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79617. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79618. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79619. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79620. *
  79621. * @param position the position in which to add an anchor
  79622. * @param rotationQuaternion an optional rotation for the anchor transformation
  79623. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79624. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79625. */
  79626. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79627. /**
  79628. * detach this feature.
  79629. * Will usually be called by the features manager
  79630. *
  79631. * @returns true if successful.
  79632. */
  79633. detach(): boolean;
  79634. /**
  79635. * Dispose this feature and all of the resources attached
  79636. */
  79637. dispose(): void;
  79638. protected _onXRFrame(frame: XRFrame): void;
  79639. /**
  79640. * avoiding using Array.find for global support.
  79641. * @param xrAnchor the plane to find in the array
  79642. */
  79643. private _findIndexInAnchorArray;
  79644. private _updateAnchorWithXRFrame;
  79645. private _createAnchorAtTransformation;
  79646. }
  79647. }
  79648. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79650. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79651. import { Observable } from "babylonjs/Misc/observable";
  79652. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79653. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79654. /**
  79655. * Options used in the plane detector module
  79656. */
  79657. export interface IWebXRPlaneDetectorOptions {
  79658. /**
  79659. * The node to use to transform the local results to world coordinates
  79660. */
  79661. worldParentNode?: TransformNode;
  79662. /**
  79663. * If set to true a reference of the created planes will be kept until the next session starts
  79664. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79665. */
  79666. doNotRemovePlanesOnSessionEnded?: boolean;
  79667. }
  79668. /**
  79669. * A babylon interface for a WebXR plane.
  79670. * A Plane is actually a polygon, built from N points in space
  79671. *
  79672. * Supported in chrome 79, not supported in canary 81 ATM
  79673. */
  79674. export interface IWebXRPlane {
  79675. /**
  79676. * a babylon-assigned ID for this polygon
  79677. */
  79678. id: number;
  79679. /**
  79680. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79681. */
  79682. polygonDefinition: Array<Vector3>;
  79683. /**
  79684. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79685. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79686. */
  79687. transformationMatrix: Matrix;
  79688. /**
  79689. * the native xr-plane object
  79690. */
  79691. xrPlane: XRPlane;
  79692. }
  79693. /**
  79694. * The plane detector is used to detect planes in the real world when in AR
  79695. * For more information see https://github.com/immersive-web/real-world-geometry/
  79696. */
  79697. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79698. private _options;
  79699. private _detectedPlanes;
  79700. private _enabled;
  79701. private _lastFrameDetected;
  79702. /**
  79703. * The module's name
  79704. */
  79705. static readonly Name: string;
  79706. /**
  79707. * The (Babylon) version of this module.
  79708. * This is an integer representing the implementation version.
  79709. * This number does not correspond to the WebXR specs version
  79710. */
  79711. static readonly Version: number;
  79712. /**
  79713. * Observers registered here will be executed when a new plane was added to the session
  79714. */
  79715. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79716. /**
  79717. * Observers registered here will be executed when a plane is no longer detected in the session
  79718. */
  79719. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79720. /**
  79721. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79722. * This can execute N times every frame
  79723. */
  79724. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79725. /**
  79726. * construct a new Plane Detector
  79727. * @param _xrSessionManager an instance of xr Session manager
  79728. * @param _options configuration to use when constructing this feature
  79729. */
  79730. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79731. /**
  79732. * detach this feature.
  79733. * Will usually be called by the features manager
  79734. *
  79735. * @returns true if successful.
  79736. */
  79737. detach(): boolean;
  79738. /**
  79739. * Dispose this feature and all of the resources attached
  79740. */
  79741. dispose(): void;
  79742. protected _onXRFrame(frame: XRFrame): void;
  79743. private _init;
  79744. private _updatePlaneWithXRPlane;
  79745. /**
  79746. * avoiding using Array.find for global support.
  79747. * @param xrPlane the plane to find in the array
  79748. */
  79749. private findIndexInPlaneArray;
  79750. }
  79751. }
  79752. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79755. import { Observable } from "babylonjs/Misc/observable";
  79756. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79757. /**
  79758. * Options interface for the background remover plugin
  79759. */
  79760. export interface IWebXRBackgroundRemoverOptions {
  79761. /**
  79762. * Further background meshes to disable when entering AR
  79763. */
  79764. backgroundMeshes?: AbstractMesh[];
  79765. /**
  79766. * flags to configure the removal of the environment helper.
  79767. * If not set, the entire background will be removed. If set, flags should be set as well.
  79768. */
  79769. environmentHelperRemovalFlags?: {
  79770. /**
  79771. * Should the skybox be removed (default false)
  79772. */
  79773. skyBox?: boolean;
  79774. /**
  79775. * Should the ground be removed (default false)
  79776. */
  79777. ground?: boolean;
  79778. };
  79779. /**
  79780. * don't disable the environment helper
  79781. */
  79782. ignoreEnvironmentHelper?: boolean;
  79783. }
  79784. /**
  79785. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79786. */
  79787. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79788. /**
  79789. * read-only options to be used in this module
  79790. */
  79791. readonly options: IWebXRBackgroundRemoverOptions;
  79792. /**
  79793. * The module's name
  79794. */
  79795. static readonly Name: string;
  79796. /**
  79797. * The (Babylon) version of this module.
  79798. * This is an integer representing the implementation version.
  79799. * This number does not correspond to the WebXR specs version
  79800. */
  79801. static readonly Version: number;
  79802. /**
  79803. * registered observers will be triggered when the background state changes
  79804. */
  79805. onBackgroundStateChangedObservable: Observable<boolean>;
  79806. /**
  79807. * constructs a new background remover module
  79808. * @param _xrSessionManager the session manager for this module
  79809. * @param options read-only options to be used in this module
  79810. */
  79811. constructor(_xrSessionManager: WebXRSessionManager,
  79812. /**
  79813. * read-only options to be used in this module
  79814. */
  79815. options?: IWebXRBackgroundRemoverOptions);
  79816. /**
  79817. * attach this feature
  79818. * Will usually be called by the features manager
  79819. *
  79820. * @returns true if successful.
  79821. */
  79822. attach(): boolean;
  79823. /**
  79824. * detach this feature.
  79825. * Will usually be called by the features manager
  79826. *
  79827. * @returns true if successful.
  79828. */
  79829. detach(): boolean;
  79830. /**
  79831. * Dispose this feature and all of the resources attached
  79832. */
  79833. dispose(): void;
  79834. protected _onXRFrame(_xrFrame: XRFrame): void;
  79835. private _setBackgroundState;
  79836. }
  79837. }
  79838. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79839. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79840. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79841. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79842. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79843. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79844. import { Nullable } from "babylonjs/types";
  79845. /**
  79846. * Options for the controller physics feature
  79847. */
  79848. export class IWebXRControllerPhysicsOptions {
  79849. /**
  79850. * Should the headset get its own impostor
  79851. */
  79852. enableHeadsetImpostor?: boolean;
  79853. /**
  79854. * Optional parameters for the headset impostor
  79855. */
  79856. headsetImpostorParams?: {
  79857. /**
  79858. * The type of impostor to create. Default is sphere
  79859. */
  79860. impostorType: number;
  79861. /**
  79862. * the size of the impostor. Defaults to 10cm
  79863. */
  79864. impostorSize?: number | {
  79865. width: number;
  79866. height: number;
  79867. depth: number;
  79868. };
  79869. /**
  79870. * Friction definitions
  79871. */
  79872. friction?: number;
  79873. /**
  79874. * Restitution
  79875. */
  79876. restitution?: number;
  79877. };
  79878. /**
  79879. * The physics properties of the future impostors
  79880. */
  79881. physicsProperties?: {
  79882. /**
  79883. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79884. * Note that this requires a physics engine that supports mesh impostors!
  79885. */
  79886. useControllerMesh?: boolean;
  79887. /**
  79888. * The type of impostor to create. Default is sphere
  79889. */
  79890. impostorType?: number;
  79891. /**
  79892. * the size of the impostor. Defaults to 10cm
  79893. */
  79894. impostorSize?: number | {
  79895. width: number;
  79896. height: number;
  79897. depth: number;
  79898. };
  79899. /**
  79900. * Friction definitions
  79901. */
  79902. friction?: number;
  79903. /**
  79904. * Restitution
  79905. */
  79906. restitution?: number;
  79907. };
  79908. /**
  79909. * the xr input to use with this pointer selection
  79910. */
  79911. xrInput: WebXRInput;
  79912. }
  79913. /**
  79914. * Add physics impostor to your webxr controllers,
  79915. * including naive calculation of their linear and angular velocity
  79916. */
  79917. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79918. private readonly _options;
  79919. private _attachController;
  79920. private _controllers;
  79921. private _debugMode;
  79922. private _delta;
  79923. private _headsetImpostor?;
  79924. private _headsetMesh?;
  79925. private _lastTimestamp;
  79926. private _tmpQuaternion;
  79927. private _tmpVector;
  79928. /**
  79929. * The module's name
  79930. */
  79931. static readonly Name: string;
  79932. /**
  79933. * The (Babylon) version of this module.
  79934. * This is an integer representing the implementation version.
  79935. * This number does not correspond to the webxr specs version
  79936. */
  79937. static readonly Version: number;
  79938. /**
  79939. * Construct a new Controller Physics Feature
  79940. * @param _xrSessionManager the corresponding xr session manager
  79941. * @param _options options to create this feature with
  79942. */
  79943. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79944. /**
  79945. * @hidden
  79946. * enable debugging - will show console outputs and the impostor mesh
  79947. */
  79948. _enablePhysicsDebug(): void;
  79949. /**
  79950. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79951. * @param xrController the controller to add
  79952. */
  79953. addController(xrController: WebXRInputSource): void;
  79954. /**
  79955. * attach this feature
  79956. * Will usually be called by the features manager
  79957. *
  79958. * @returns true if successful.
  79959. */
  79960. attach(): boolean;
  79961. /**
  79962. * detach this feature.
  79963. * Will usually be called by the features manager
  79964. *
  79965. * @returns true if successful.
  79966. */
  79967. detach(): boolean;
  79968. /**
  79969. * Get the headset impostor, if enabled
  79970. * @returns the impostor
  79971. */
  79972. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79973. /**
  79974. * Get the physics impostor of a specific controller.
  79975. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79976. * @param controller the controller or the controller id of which to get the impostor
  79977. * @returns the impostor or null
  79978. */
  79979. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79980. /**
  79981. * Update the physics properties provided in the constructor
  79982. * @param newProperties the new properties object
  79983. */
  79984. setPhysicsProperties(newProperties: {
  79985. impostorType?: number;
  79986. impostorSize?: number | {
  79987. width: number;
  79988. height: number;
  79989. depth: number;
  79990. };
  79991. friction?: number;
  79992. restitution?: number;
  79993. }): void;
  79994. protected _onXRFrame(_xrFrame: any): void;
  79995. private _detachController;
  79996. }
  79997. }
  79998. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79999. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80000. import { Observable } from "babylonjs/Misc/observable";
  80001. import { Vector3 } from "babylonjs/Maths/math.vector";
  80002. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80003. /**
  80004. * A babylon interface for a "WebXR" feature point.
  80005. * Represents the position and confidence value of a given feature point.
  80006. */
  80007. export interface IWebXRFeaturePoint {
  80008. /**
  80009. * Represents the position of the feature point in world space.
  80010. */
  80011. position: Vector3;
  80012. /**
  80013. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80014. */
  80015. confidenceValue: number;
  80016. }
  80017. /**
  80018. * The feature point system is used to detect feature points from real world geometry.
  80019. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80020. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80021. */
  80022. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80023. private _enabled;
  80024. private _featurePointCloud;
  80025. /**
  80026. * The module's name
  80027. */
  80028. static readonly Name: string;
  80029. /**
  80030. * The (Babylon) version of this module.
  80031. * This is an integer representing the implementation version.
  80032. * This number does not correspond to the WebXR specs version
  80033. */
  80034. static readonly Version: number;
  80035. /**
  80036. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80037. * Will notify the observers about which feature points have been added.
  80038. */
  80039. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80040. /**
  80041. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80042. * Will notify the observers about which feature points have been updated.
  80043. */
  80044. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80045. /**
  80046. * The current feature point cloud maintained across frames.
  80047. */
  80048. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80049. /**
  80050. * construct the feature point system
  80051. * @param _xrSessionManager an instance of xr Session manager
  80052. */
  80053. constructor(_xrSessionManager: WebXRSessionManager);
  80054. /**
  80055. * Detach this feature.
  80056. * Will usually be called by the features manager
  80057. *
  80058. * @returns true if successful.
  80059. */
  80060. detach(): boolean;
  80061. /**
  80062. * Dispose this feature and all of the resources attached
  80063. */
  80064. dispose(): void;
  80065. /**
  80066. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80067. */
  80068. protected _onXRFrame(frame: XRFrame): void;
  80069. /**
  80070. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80071. */
  80072. private _init;
  80073. }
  80074. }
  80075. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80076. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80077. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80079. import { Mesh } from "babylonjs/Meshes/mesh";
  80080. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80081. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80082. import { Nullable } from "babylonjs/types";
  80083. import { IDisposable } from "babylonjs/scene";
  80084. import { Observable } from "babylonjs/Misc/observable";
  80085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80086. /**
  80087. * Configuration interface for the hand tracking feature
  80088. */
  80089. export interface IWebXRHandTrackingOptions {
  80090. /**
  80091. * The xrInput that will be used as source for new hands
  80092. */
  80093. xrInput: WebXRInput;
  80094. /**
  80095. * Configuration object for the joint meshes
  80096. */
  80097. jointMeshes?: {
  80098. /**
  80099. * Should the meshes created be invisible (defaults to false)
  80100. */
  80101. invisible?: boolean;
  80102. /**
  80103. * A source mesh to be used to create instances. Defaults to a sphere.
  80104. * This mesh will be the source for all other (25) meshes.
  80105. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80106. */
  80107. sourceMesh?: Mesh;
  80108. /**
  80109. * This function will be called after a mesh was created for a specific joint.
  80110. * Using this function you can either manipulate the instance or return a new mesh.
  80111. * When returning a new mesh the instance created before will be disposed
  80112. */
  80113. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80114. /**
  80115. * Should the source mesh stay visible. Defaults to false
  80116. */
  80117. keepOriginalVisible?: boolean;
  80118. /**
  80119. * Scale factor for all instances (defaults to 2)
  80120. */
  80121. scaleFactor?: number;
  80122. /**
  80123. * Should each instance have its own physics impostor
  80124. */
  80125. enablePhysics?: boolean;
  80126. /**
  80127. * If enabled, override default physics properties
  80128. */
  80129. physicsProps?: {
  80130. friction?: number;
  80131. restitution?: number;
  80132. impostorType?: number;
  80133. };
  80134. /**
  80135. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80136. */
  80137. handMesh?: AbstractMesh;
  80138. };
  80139. }
  80140. /**
  80141. * Parts of the hands divided to writs and finger names
  80142. */
  80143. export const enum HandPart {
  80144. /**
  80145. * HandPart - Wrist
  80146. */
  80147. WRIST = "wrist",
  80148. /**
  80149. * HandPart - The THumb
  80150. */
  80151. THUMB = "thumb",
  80152. /**
  80153. * HandPart - Index finger
  80154. */
  80155. INDEX = "index",
  80156. /**
  80157. * HandPart - Middle finger
  80158. */
  80159. MIDDLE = "middle",
  80160. /**
  80161. * HandPart - Ring finger
  80162. */
  80163. RING = "ring",
  80164. /**
  80165. * HandPart - Little finger
  80166. */
  80167. LITTLE = "little"
  80168. }
  80169. /**
  80170. * Representing a single hand (with its corresponding native XRHand object)
  80171. */
  80172. export class WebXRHand implements IDisposable {
  80173. /** the controller to which the hand correlates */
  80174. readonly xrController: WebXRInputSource;
  80175. /** the meshes to be used to track the hand joints */
  80176. readonly trackedMeshes: AbstractMesh[];
  80177. /**
  80178. * Hand-parts definition (key is HandPart)
  80179. */
  80180. handPartsDefinition: {
  80181. [key: string]: number[];
  80182. };
  80183. /**
  80184. * Populate the HandPartsDefinition object.
  80185. * This is called as a side effect since certain browsers don't have XRHand defined.
  80186. */
  80187. private generateHandPartsDefinition;
  80188. /**
  80189. * Construct a new hand object
  80190. * @param xrController the controller to which the hand correlates
  80191. * @param trackedMeshes the meshes to be used to track the hand joints
  80192. */
  80193. constructor(
  80194. /** the controller to which the hand correlates */
  80195. xrController: WebXRInputSource,
  80196. /** the meshes to be used to track the hand joints */
  80197. trackedMeshes: AbstractMesh[]);
  80198. /**
  80199. * Update this hand from the latest xr frame
  80200. * @param xrFrame xrFrame to update from
  80201. * @param referenceSpace The current viewer reference space
  80202. * @param scaleFactor optional scale factor for the meshes
  80203. */
  80204. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80205. /**
  80206. * Get meshes of part of the hand
  80207. * @param part the part of hand to get
  80208. * @returns An array of meshes that correlate to the hand part requested
  80209. */
  80210. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80211. /**
  80212. * Dispose this Hand object
  80213. */
  80214. dispose(): void;
  80215. }
  80216. /**
  80217. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80218. */
  80219. export class WebXRHandTracking extends WebXRAbstractFeature {
  80220. /**
  80221. * options to use when constructing this feature
  80222. */
  80223. readonly options: IWebXRHandTrackingOptions;
  80224. private static _idCounter;
  80225. /**
  80226. * The module's name
  80227. */
  80228. static readonly Name: string;
  80229. /**
  80230. * The (Babylon) version of this module.
  80231. * This is an integer representing the implementation version.
  80232. * This number does not correspond to the WebXR specs version
  80233. */
  80234. static readonly Version: number;
  80235. /**
  80236. * This observable will notify registered observers when a new hand object was added and initialized
  80237. */
  80238. onHandAddedObservable: Observable<WebXRHand>;
  80239. /**
  80240. * This observable will notify its observers right before the hand object is disposed
  80241. */
  80242. onHandRemovedObservable: Observable<WebXRHand>;
  80243. private _hands;
  80244. /**
  80245. * Creates a new instance of the hit test feature
  80246. * @param _xrSessionManager an instance of WebXRSessionManager
  80247. * @param options options to use when constructing this feature
  80248. */
  80249. constructor(_xrSessionManager: WebXRSessionManager,
  80250. /**
  80251. * options to use when constructing this feature
  80252. */
  80253. options: IWebXRHandTrackingOptions);
  80254. /**
  80255. * Check if the needed objects are defined.
  80256. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80257. */
  80258. isCompatible(): boolean;
  80259. /**
  80260. * attach this feature
  80261. * Will usually be called by the features manager
  80262. *
  80263. * @returns true if successful.
  80264. */
  80265. attach(): boolean;
  80266. /**
  80267. * detach this feature.
  80268. * Will usually be called by the features manager
  80269. *
  80270. * @returns true if successful.
  80271. */
  80272. detach(): boolean;
  80273. /**
  80274. * Dispose this feature and all of the resources attached
  80275. */
  80276. dispose(): void;
  80277. /**
  80278. * Get the hand object according to the controller id
  80279. * @param controllerId the controller id to which we want to get the hand
  80280. * @returns null if not found or the WebXRHand object if found
  80281. */
  80282. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80283. /**
  80284. * Get a hand object according to the requested handedness
  80285. * @param handedness the handedness to request
  80286. * @returns null if not found or the WebXRHand object if found
  80287. */
  80288. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80289. protected _onXRFrame(_xrFrame: XRFrame): void;
  80290. private _attachHand;
  80291. private _detachHand;
  80292. }
  80293. }
  80294. declare module "babylonjs/XR/features/index" {
  80295. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80296. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80297. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80298. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80299. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80300. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80301. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80302. export * from "babylonjs/XR/features/WebXRHitTest";
  80303. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80304. export * from "babylonjs/XR/features/WebXRHandTracking";
  80305. }
  80306. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80307. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80309. import { Scene } from "babylonjs/scene";
  80310. /**
  80311. * The motion controller class for all microsoft mixed reality controllers
  80312. */
  80313. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80314. protected readonly _mapping: {
  80315. defaultButton: {
  80316. valueNodeName: string;
  80317. unpressedNodeName: string;
  80318. pressedNodeName: string;
  80319. };
  80320. defaultAxis: {
  80321. valueNodeName: string;
  80322. minNodeName: string;
  80323. maxNodeName: string;
  80324. };
  80325. buttons: {
  80326. "xr-standard-trigger": {
  80327. rootNodeName: string;
  80328. componentProperty: string;
  80329. states: string[];
  80330. };
  80331. "xr-standard-squeeze": {
  80332. rootNodeName: string;
  80333. componentProperty: string;
  80334. states: string[];
  80335. };
  80336. "xr-standard-touchpad": {
  80337. rootNodeName: string;
  80338. labelAnchorNodeName: string;
  80339. touchPointNodeName: string;
  80340. };
  80341. "xr-standard-thumbstick": {
  80342. rootNodeName: string;
  80343. componentProperty: string;
  80344. states: string[];
  80345. };
  80346. };
  80347. axes: {
  80348. "xr-standard-touchpad": {
  80349. "x-axis": {
  80350. rootNodeName: string;
  80351. };
  80352. "y-axis": {
  80353. rootNodeName: string;
  80354. };
  80355. };
  80356. "xr-standard-thumbstick": {
  80357. "x-axis": {
  80358. rootNodeName: string;
  80359. };
  80360. "y-axis": {
  80361. rootNodeName: string;
  80362. };
  80363. };
  80364. };
  80365. };
  80366. /**
  80367. * The base url used to load the left and right controller models
  80368. */
  80369. static MODEL_BASE_URL: string;
  80370. /**
  80371. * The name of the left controller model file
  80372. */
  80373. static MODEL_LEFT_FILENAME: string;
  80374. /**
  80375. * The name of the right controller model file
  80376. */
  80377. static MODEL_RIGHT_FILENAME: string;
  80378. profileId: string;
  80379. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80380. protected _getFilenameAndPath(): {
  80381. filename: string;
  80382. path: string;
  80383. };
  80384. protected _getModelLoadingConstraints(): boolean;
  80385. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80386. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80387. protected _updateModel(): void;
  80388. }
  80389. }
  80390. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80391. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80393. import { Scene } from "babylonjs/scene";
  80394. /**
  80395. * The motion controller class for oculus touch (quest, rift).
  80396. * This class supports legacy mapping as well the standard xr mapping
  80397. */
  80398. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80399. private _forceLegacyControllers;
  80400. private _modelRootNode;
  80401. /**
  80402. * The base url used to load the left and right controller models
  80403. */
  80404. static MODEL_BASE_URL: string;
  80405. /**
  80406. * The name of the left controller model file
  80407. */
  80408. static MODEL_LEFT_FILENAME: string;
  80409. /**
  80410. * The name of the right controller model file
  80411. */
  80412. static MODEL_RIGHT_FILENAME: string;
  80413. /**
  80414. * Base Url for the Quest controller model.
  80415. */
  80416. static QUEST_MODEL_BASE_URL: string;
  80417. profileId: string;
  80418. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80419. protected _getFilenameAndPath(): {
  80420. filename: string;
  80421. path: string;
  80422. };
  80423. protected _getModelLoadingConstraints(): boolean;
  80424. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80425. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80426. protected _updateModel(): void;
  80427. /**
  80428. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80429. * between the touch and touch 2.
  80430. */
  80431. private _isQuest;
  80432. }
  80433. }
  80434. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80435. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80436. import { Scene } from "babylonjs/scene";
  80437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80438. /**
  80439. * The motion controller class for the standard HTC-Vive controllers
  80440. */
  80441. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80442. private _modelRootNode;
  80443. /**
  80444. * The base url used to load the left and right controller models
  80445. */
  80446. static MODEL_BASE_URL: string;
  80447. /**
  80448. * File name for the controller model.
  80449. */
  80450. static MODEL_FILENAME: string;
  80451. profileId: string;
  80452. /**
  80453. * Create a new Vive motion controller object
  80454. * @param scene the scene to use to create this controller
  80455. * @param gamepadObject the corresponding gamepad object
  80456. * @param handedness the handedness of the controller
  80457. */
  80458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80459. protected _getFilenameAndPath(): {
  80460. filename: string;
  80461. path: string;
  80462. };
  80463. protected _getModelLoadingConstraints(): boolean;
  80464. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80466. protected _updateModel(): void;
  80467. }
  80468. }
  80469. declare module "babylonjs/XR/motionController/index" {
  80470. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80471. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80472. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80473. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80474. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80475. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80476. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80477. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80478. }
  80479. declare module "babylonjs/XR/index" {
  80480. export * from "babylonjs/XR/webXRCamera";
  80481. export * from "babylonjs/XR/webXREnterExitUI";
  80482. export * from "babylonjs/XR/webXRExperienceHelper";
  80483. export * from "babylonjs/XR/webXRInput";
  80484. export * from "babylonjs/XR/webXRInputSource";
  80485. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80486. export * from "babylonjs/XR/webXRTypes";
  80487. export * from "babylonjs/XR/webXRSessionManager";
  80488. export * from "babylonjs/XR/webXRDefaultExperience";
  80489. export * from "babylonjs/XR/webXRFeaturesManager";
  80490. export * from "babylonjs/XR/features/index";
  80491. export * from "babylonjs/XR/motionController/index";
  80492. }
  80493. declare module "babylonjs/index" {
  80494. export * from "babylonjs/abstractScene";
  80495. export * from "babylonjs/Actions/index";
  80496. export * from "babylonjs/Animations/index";
  80497. export * from "babylonjs/assetContainer";
  80498. export * from "babylonjs/Audio/index";
  80499. export * from "babylonjs/Behaviors/index";
  80500. export * from "babylonjs/Bones/index";
  80501. export * from "babylonjs/Cameras/index";
  80502. export * from "babylonjs/Collisions/index";
  80503. export * from "babylonjs/Culling/index";
  80504. export * from "babylonjs/Debug/index";
  80505. export * from "babylonjs/DeviceInput/index";
  80506. export * from "babylonjs/Engines/index";
  80507. export * from "babylonjs/Events/index";
  80508. export * from "babylonjs/Gamepads/index";
  80509. export * from "babylonjs/Gizmos/index";
  80510. export * from "babylonjs/Helpers/index";
  80511. export * from "babylonjs/Instrumentation/index";
  80512. export * from "babylonjs/Layers/index";
  80513. export * from "babylonjs/LensFlares/index";
  80514. export * from "babylonjs/Lights/index";
  80515. export * from "babylonjs/Loading/index";
  80516. export * from "babylonjs/Materials/index";
  80517. export * from "babylonjs/Maths/index";
  80518. export * from "babylonjs/Meshes/index";
  80519. export * from "babylonjs/Morph/index";
  80520. export * from "babylonjs/Navigation/index";
  80521. export * from "babylonjs/node";
  80522. export * from "babylonjs/Offline/index";
  80523. export * from "babylonjs/Particles/index";
  80524. export * from "babylonjs/Physics/index";
  80525. export * from "babylonjs/PostProcesses/index";
  80526. export * from "babylonjs/Probes/index";
  80527. export * from "babylonjs/Rendering/index";
  80528. export * from "babylonjs/scene";
  80529. export * from "babylonjs/sceneComponent";
  80530. export * from "babylonjs/Sprites/index";
  80531. export * from "babylonjs/States/index";
  80532. export * from "babylonjs/Misc/index";
  80533. export * from "babylonjs/XR/index";
  80534. export * from "babylonjs/types";
  80535. }
  80536. declare module "babylonjs/Animations/pathCursor" {
  80537. import { Vector3 } from "babylonjs/Maths/math.vector";
  80538. import { Path2 } from "babylonjs/Maths/math.path";
  80539. /**
  80540. * A cursor which tracks a point on a path
  80541. */
  80542. export class PathCursor {
  80543. private path;
  80544. /**
  80545. * Stores path cursor callbacks for when an onchange event is triggered
  80546. */
  80547. private _onchange;
  80548. /**
  80549. * The value of the path cursor
  80550. */
  80551. value: number;
  80552. /**
  80553. * The animation array of the path cursor
  80554. */
  80555. animations: Animation[];
  80556. /**
  80557. * Initializes the path cursor
  80558. * @param path The path to track
  80559. */
  80560. constructor(path: Path2);
  80561. /**
  80562. * Gets the cursor point on the path
  80563. * @returns A point on the path cursor at the cursor location
  80564. */
  80565. getPoint(): Vector3;
  80566. /**
  80567. * Moves the cursor ahead by the step amount
  80568. * @param step The amount to move the cursor forward
  80569. * @returns This path cursor
  80570. */
  80571. moveAhead(step?: number): PathCursor;
  80572. /**
  80573. * Moves the cursor behind by the step amount
  80574. * @param step The amount to move the cursor back
  80575. * @returns This path cursor
  80576. */
  80577. moveBack(step?: number): PathCursor;
  80578. /**
  80579. * Moves the cursor by the step amount
  80580. * If the step amount is greater than one, an exception is thrown
  80581. * @param step The amount to move the cursor
  80582. * @returns This path cursor
  80583. */
  80584. move(step: number): PathCursor;
  80585. /**
  80586. * Ensures that the value is limited between zero and one
  80587. * @returns This path cursor
  80588. */
  80589. private ensureLimits;
  80590. /**
  80591. * Runs onchange callbacks on change (used by the animation engine)
  80592. * @returns This path cursor
  80593. */
  80594. private raiseOnChange;
  80595. /**
  80596. * Executes a function on change
  80597. * @param f A path cursor onchange callback
  80598. * @returns This path cursor
  80599. */
  80600. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80601. }
  80602. }
  80603. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80604. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80605. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80606. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80607. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80608. }
  80609. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80610. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80611. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80612. }
  80613. declare module "babylonjs/Engines/Processors/index" {
  80614. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80615. export * from "babylonjs/Engines/Processors/Expressions/index";
  80616. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80617. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80618. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80619. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80620. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80621. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80622. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80623. }
  80624. declare module "babylonjs/Legacy/legacy" {
  80625. import * as Babylon from "babylonjs/index";
  80626. export * from "babylonjs/index";
  80627. }
  80628. declare module "babylonjs/Shaders/blur.fragment" {
  80629. /** @hidden */
  80630. export var blurPixelShader: {
  80631. name: string;
  80632. shader: string;
  80633. };
  80634. }
  80635. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80636. /** @hidden */
  80637. export var pointCloudVertexDeclaration: {
  80638. name: string;
  80639. shader: string;
  80640. };
  80641. }
  80642. declare module "babylonjs" {
  80643. export * from "babylonjs/Legacy/legacy";
  80644. }
  80645. declare module BABYLON {
  80646. /** Alias type for value that can be null */
  80647. export type Nullable<T> = T | null;
  80648. /**
  80649. * Alias type for number that are floats
  80650. * @ignorenaming
  80651. */
  80652. export type float = number;
  80653. /**
  80654. * Alias type for number that are doubles.
  80655. * @ignorenaming
  80656. */
  80657. export type double = number;
  80658. /**
  80659. * Alias type for number that are integer
  80660. * @ignorenaming
  80661. */
  80662. export type int = number;
  80663. /** Alias type for number array or Float32Array */
  80664. export type FloatArray = number[] | Float32Array;
  80665. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80666. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80667. /**
  80668. * Alias for types that can be used by a Buffer or VertexBuffer.
  80669. */
  80670. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80671. /**
  80672. * Alias type for primitive types
  80673. * @ignorenaming
  80674. */
  80675. type Primitive = undefined | null | boolean | string | number | Function;
  80676. /**
  80677. * Type modifier to make all the properties of an object Readonly
  80678. */
  80679. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80680. /**
  80681. * Type modifier to make all the properties of an object Readonly recursively
  80682. */
  80683. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80684. /**
  80685. * Type modifier to make object properties readonly.
  80686. */
  80687. export type DeepImmutableObject<T> = {
  80688. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80689. };
  80690. /** @hidden */
  80691. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80692. }
  80693. }
  80694. declare module BABYLON {
  80695. /**
  80696. * A class serves as a medium between the observable and its observers
  80697. */
  80698. export class EventState {
  80699. /**
  80700. * Create a new EventState
  80701. * @param mask defines the mask associated with this state
  80702. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80703. * @param target defines the original target of the state
  80704. * @param currentTarget defines the current target of the state
  80705. */
  80706. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80707. /**
  80708. * Initialize the current event state
  80709. * @param mask defines the mask associated with this state
  80710. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80711. * @param target defines the original target of the state
  80712. * @param currentTarget defines the current target of the state
  80713. * @returns the current event state
  80714. */
  80715. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80716. /**
  80717. * An Observer can set this property to true to prevent subsequent observers of being notified
  80718. */
  80719. skipNextObservers: boolean;
  80720. /**
  80721. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80722. */
  80723. mask: number;
  80724. /**
  80725. * The object that originally notified the event
  80726. */
  80727. target?: any;
  80728. /**
  80729. * The current object in the bubbling phase
  80730. */
  80731. currentTarget?: any;
  80732. /**
  80733. * This will be populated with the return value of the last function that was executed.
  80734. * If it is the first function in the callback chain it will be the event data.
  80735. */
  80736. lastReturnValue?: any;
  80737. /**
  80738. * User defined information that will be sent to observers
  80739. */
  80740. userInfo?: any;
  80741. }
  80742. /**
  80743. * Represent an Observer registered to a given Observable object.
  80744. */
  80745. export class Observer<T> {
  80746. /**
  80747. * Defines the callback to call when the observer is notified
  80748. */
  80749. callback: (eventData: T, eventState: EventState) => void;
  80750. /**
  80751. * Defines the mask of the observer (used to filter notifications)
  80752. */
  80753. mask: number;
  80754. /**
  80755. * Defines the current scope used to restore the JS context
  80756. */
  80757. scope: any;
  80758. /** @hidden */
  80759. _willBeUnregistered: boolean;
  80760. /**
  80761. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80762. */
  80763. unregisterOnNextCall: boolean;
  80764. /**
  80765. * Creates a new observer
  80766. * @param callback defines the callback to call when the observer is notified
  80767. * @param mask defines the mask of the observer (used to filter notifications)
  80768. * @param scope defines the current scope used to restore the JS context
  80769. */
  80770. constructor(
  80771. /**
  80772. * Defines the callback to call when the observer is notified
  80773. */
  80774. callback: (eventData: T, eventState: EventState) => void,
  80775. /**
  80776. * Defines the mask of the observer (used to filter notifications)
  80777. */
  80778. mask: number,
  80779. /**
  80780. * Defines the current scope used to restore the JS context
  80781. */
  80782. scope?: any);
  80783. }
  80784. /**
  80785. * Represent a list of observers registered to multiple Observables object.
  80786. */
  80787. export class MultiObserver<T> {
  80788. private _observers;
  80789. private _observables;
  80790. /**
  80791. * Release associated resources
  80792. */
  80793. dispose(): void;
  80794. /**
  80795. * Raise a callback when one of the observable will notify
  80796. * @param observables defines a list of observables to watch
  80797. * @param callback defines the callback to call on notification
  80798. * @param mask defines the mask used to filter notifications
  80799. * @param scope defines the current scope used to restore the JS context
  80800. * @returns the new MultiObserver
  80801. */
  80802. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80803. }
  80804. /**
  80805. * The Observable class is a simple implementation of the Observable pattern.
  80806. *
  80807. * 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.
  80808. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80809. * 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).
  80810. * 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.
  80811. */
  80812. export class Observable<T> {
  80813. private _observers;
  80814. private _eventState;
  80815. private _onObserverAdded;
  80816. /**
  80817. * Gets the list of observers
  80818. */
  80819. get observers(): Array<Observer<T>>;
  80820. /**
  80821. * Creates a new observable
  80822. * @param onObserverAdded defines a callback to call when a new observer is added
  80823. */
  80824. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80825. /**
  80826. * Create a new Observer with the specified callback
  80827. * @param callback the callback that will be executed for that Observer
  80828. * @param mask the mask used to filter observers
  80829. * @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.
  80830. * @param scope optional scope for the callback to be called from
  80831. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80832. * @returns the new observer created for the callback
  80833. */
  80834. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80835. /**
  80836. * Create a new Observer with the specified callback and unregisters after the next notification
  80837. * @param callback the callback that will be executed for that Observer
  80838. * @returns the new observer created for the callback
  80839. */
  80840. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80841. /**
  80842. * Remove an Observer from the Observable object
  80843. * @param observer the instance of the Observer to remove
  80844. * @returns false if it doesn't belong to this Observable
  80845. */
  80846. remove(observer: Nullable<Observer<T>>): boolean;
  80847. /**
  80848. * Remove a callback from the Observable object
  80849. * @param callback the callback to remove
  80850. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80851. * @returns false if it doesn't belong to this Observable
  80852. */
  80853. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80854. private _deferUnregister;
  80855. private _remove;
  80856. /**
  80857. * Moves the observable to the top of the observer list making it get called first when notified
  80858. * @param observer the observer to move
  80859. */
  80860. makeObserverTopPriority(observer: Observer<T>): void;
  80861. /**
  80862. * Moves the observable to the bottom of the observer list making it get called last when notified
  80863. * @param observer the observer to move
  80864. */
  80865. makeObserverBottomPriority(observer: Observer<T>): void;
  80866. /**
  80867. * Notify all Observers by calling their respective callback with the given data
  80868. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80869. * @param eventData defines the data to send to all observers
  80870. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80871. * @param target defines the original target of the state
  80872. * @param currentTarget defines the current target of the state
  80873. * @param userInfo defines any user info to send to observers
  80874. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80875. */
  80876. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  80877. /**
  80878. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80879. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80880. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80881. * and it is crucial that all callbacks will be executed.
  80882. * The order of the callbacks is kept, callbacks are not executed parallel.
  80883. *
  80884. * @param eventData The data to be sent to each callback
  80885. * @param mask is used to filter observers defaults to -1
  80886. * @param target defines the callback target (see EventState)
  80887. * @param currentTarget defines he current object in the bubbling phase
  80888. * @param userInfo defines any user info to send to observers
  80889. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80890. */
  80891. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  80892. /**
  80893. * Notify a specific observer
  80894. * @param observer defines the observer to notify
  80895. * @param eventData defines the data to be sent to each callback
  80896. * @param mask is used to filter observers defaults to -1
  80897. */
  80898. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80899. /**
  80900. * Gets a boolean indicating if the observable has at least one observer
  80901. * @returns true is the Observable has at least one Observer registered
  80902. */
  80903. hasObservers(): boolean;
  80904. /**
  80905. * Clear the list of observers
  80906. */
  80907. clear(): void;
  80908. /**
  80909. * Clone the current observable
  80910. * @returns a new observable
  80911. */
  80912. clone(): Observable<T>;
  80913. /**
  80914. * Does this observable handles observer registered with a given mask
  80915. * @param mask defines the mask to be tested
  80916. * @return whether or not one observer registered with the given mask is handeled
  80917. **/
  80918. hasSpecificMask(mask?: number): boolean;
  80919. }
  80920. }
  80921. declare module BABYLON {
  80922. /**
  80923. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80924. * Babylon.js
  80925. */
  80926. export class DomManagement {
  80927. /**
  80928. * Checks if the window object exists
  80929. * @returns true if the window object exists
  80930. */
  80931. static IsWindowObjectExist(): boolean;
  80932. /**
  80933. * Checks if the navigator object exists
  80934. * @returns true if the navigator object exists
  80935. */
  80936. static IsNavigatorAvailable(): boolean;
  80937. /**
  80938. * Check if the document object exists
  80939. * @returns true if the document object exists
  80940. */
  80941. static IsDocumentAvailable(): boolean;
  80942. /**
  80943. * Extracts text content from a DOM element hierarchy
  80944. * @param element defines the root element
  80945. * @returns a string
  80946. */
  80947. static GetDOMTextContent(element: HTMLElement): string;
  80948. }
  80949. }
  80950. declare module BABYLON {
  80951. /**
  80952. * Logger used througouht the application to allow configuration of
  80953. * the log level required for the messages.
  80954. */
  80955. export class Logger {
  80956. /**
  80957. * No log
  80958. */
  80959. static readonly NoneLogLevel: number;
  80960. /**
  80961. * Only message logs
  80962. */
  80963. static readonly MessageLogLevel: number;
  80964. /**
  80965. * Only warning logs
  80966. */
  80967. static readonly WarningLogLevel: number;
  80968. /**
  80969. * Only error logs
  80970. */
  80971. static readonly ErrorLogLevel: number;
  80972. /**
  80973. * All logs
  80974. */
  80975. static readonly AllLogLevel: number;
  80976. private static _LogCache;
  80977. /**
  80978. * Gets a value indicating the number of loading errors
  80979. * @ignorenaming
  80980. */
  80981. static errorsCount: number;
  80982. /**
  80983. * Callback called when a new log is added
  80984. */
  80985. static OnNewCacheEntry: (entry: string) => void;
  80986. private static _AddLogEntry;
  80987. private static _FormatMessage;
  80988. private static _LogDisabled;
  80989. private static _LogEnabled;
  80990. private static _WarnDisabled;
  80991. private static _WarnEnabled;
  80992. private static _ErrorDisabled;
  80993. private static _ErrorEnabled;
  80994. /**
  80995. * Log a message to the console
  80996. */
  80997. static Log: (message: string) => void;
  80998. /**
  80999. * Write a warning message to the console
  81000. */
  81001. static Warn: (message: string) => void;
  81002. /**
  81003. * Write an error message to the console
  81004. */
  81005. static Error: (message: string) => void;
  81006. /**
  81007. * Gets current log cache (list of logs)
  81008. */
  81009. static get LogCache(): string;
  81010. /**
  81011. * Clears the log cache
  81012. */
  81013. static ClearLogCache(): void;
  81014. /**
  81015. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81016. */
  81017. static set LogLevels(level: number);
  81018. }
  81019. }
  81020. declare module BABYLON {
  81021. /** @hidden */
  81022. export class _TypeStore {
  81023. /** @hidden */
  81024. static RegisteredTypes: {
  81025. [key: string]: Object;
  81026. };
  81027. /** @hidden */
  81028. static GetClass(fqdn: string): any;
  81029. }
  81030. }
  81031. declare module BABYLON {
  81032. /**
  81033. * Helper to manipulate strings
  81034. */
  81035. export class StringTools {
  81036. /**
  81037. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81038. * @param str Source string
  81039. * @param suffix Suffix to search for in the source string
  81040. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81041. */
  81042. static EndsWith(str: string, suffix: string): boolean;
  81043. /**
  81044. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81045. * @param str Source string
  81046. * @param suffix Suffix to search for in the source string
  81047. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81048. */
  81049. static StartsWith(str: string, suffix: string): boolean;
  81050. /**
  81051. * Decodes a buffer into a string
  81052. * @param buffer The buffer to decode
  81053. * @returns The decoded string
  81054. */
  81055. static Decode(buffer: Uint8Array | Uint16Array): string;
  81056. /**
  81057. * Encode a buffer to a base64 string
  81058. * @param buffer defines the buffer to encode
  81059. * @returns the encoded string
  81060. */
  81061. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81062. /**
  81063. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81064. * @param num the number to convert and pad
  81065. * @param length the expected length of the string
  81066. * @returns the padded string
  81067. */
  81068. static PadNumber(num: number, length: number): string;
  81069. }
  81070. }
  81071. declare module BABYLON {
  81072. /**
  81073. * Class containing a set of static utilities functions for deep copy.
  81074. */
  81075. export class DeepCopier {
  81076. /**
  81077. * Tries to copy an object by duplicating every property
  81078. * @param source defines the source object
  81079. * @param destination defines the target object
  81080. * @param doNotCopyList defines a list of properties to avoid
  81081. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81082. */
  81083. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81084. }
  81085. }
  81086. declare module BABYLON {
  81087. /**
  81088. * Class containing a set of static utilities functions for precision date
  81089. */
  81090. export class PrecisionDate {
  81091. /**
  81092. * Gets either window.performance.now() if supported or Date.now() else
  81093. */
  81094. static get Now(): number;
  81095. }
  81096. }
  81097. declare module BABYLON {
  81098. /** @hidden */
  81099. export class _DevTools {
  81100. static WarnImport(name: string): string;
  81101. }
  81102. }
  81103. declare module BABYLON {
  81104. /**
  81105. * Interface used to define the mechanism to get data from the network
  81106. */
  81107. export interface IWebRequest {
  81108. /**
  81109. * Returns client's response url
  81110. */
  81111. responseURL: string;
  81112. /**
  81113. * Returns client's status
  81114. */
  81115. status: number;
  81116. /**
  81117. * Returns client's status as a text
  81118. */
  81119. statusText: string;
  81120. }
  81121. }
  81122. declare module BABYLON {
  81123. /**
  81124. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81125. */
  81126. export class WebRequest implements IWebRequest {
  81127. private _xhr;
  81128. /**
  81129. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81130. * i.e. when loading files, where the server/service expects an Authorization header
  81131. */
  81132. static CustomRequestHeaders: {
  81133. [key: string]: string;
  81134. };
  81135. /**
  81136. * Add callback functions in this array to update all the requests before they get sent to the network
  81137. */
  81138. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81139. private _injectCustomRequestHeaders;
  81140. /**
  81141. * Gets or sets a function to be called when loading progress changes
  81142. */
  81143. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81144. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81145. /**
  81146. * Returns client's state
  81147. */
  81148. get readyState(): number;
  81149. /**
  81150. * Returns client's status
  81151. */
  81152. get status(): number;
  81153. /**
  81154. * Returns client's status as a text
  81155. */
  81156. get statusText(): string;
  81157. /**
  81158. * Returns client's response
  81159. */
  81160. get response(): any;
  81161. /**
  81162. * Returns client's response url
  81163. */
  81164. get responseURL(): string;
  81165. /**
  81166. * Returns client's response as text
  81167. */
  81168. get responseText(): string;
  81169. /**
  81170. * Gets or sets the expected response type
  81171. */
  81172. get responseType(): XMLHttpRequestResponseType;
  81173. set responseType(value: XMLHttpRequestResponseType);
  81174. /** @hidden */
  81175. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81176. /** @hidden */
  81177. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81178. /**
  81179. * Cancels any network activity
  81180. */
  81181. abort(): void;
  81182. /**
  81183. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81184. * @param body defines an optional request body
  81185. */
  81186. send(body?: Document | BodyInit | null): void;
  81187. /**
  81188. * Sets the request method, request URL
  81189. * @param method defines the method to use (GET, POST, etc..)
  81190. * @param url defines the url to connect with
  81191. */
  81192. open(method: string, url: string): void;
  81193. /**
  81194. * Sets the value of a request header.
  81195. * @param name The name of the header whose value is to be set
  81196. * @param value The value to set as the body of the header
  81197. */
  81198. setRequestHeader(name: string, value: string): void;
  81199. /**
  81200. * Get the string containing the text of a particular header's value.
  81201. * @param name The name of the header
  81202. * @returns The string containing the text of the given header name
  81203. */
  81204. getResponseHeader(name: string): Nullable<string>;
  81205. }
  81206. }
  81207. declare module BABYLON {
  81208. /**
  81209. * File request interface
  81210. */
  81211. export interface IFileRequest {
  81212. /**
  81213. * Raised when the request is complete (success or error).
  81214. */
  81215. onCompleteObservable: Observable<IFileRequest>;
  81216. /**
  81217. * Aborts the request for a file.
  81218. */
  81219. abort: () => void;
  81220. }
  81221. }
  81222. declare module BABYLON {
  81223. /**
  81224. * Define options used to create a render target texture
  81225. */
  81226. export class RenderTargetCreationOptions {
  81227. /**
  81228. * Specifies is mipmaps must be generated
  81229. */
  81230. generateMipMaps?: boolean;
  81231. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81232. generateDepthBuffer?: boolean;
  81233. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81234. generateStencilBuffer?: boolean;
  81235. /** Defines texture type (int by default) */
  81236. type?: number;
  81237. /** Defines sampling mode (trilinear by default) */
  81238. samplingMode?: number;
  81239. /** Defines format (RGBA by default) */
  81240. format?: number;
  81241. }
  81242. }
  81243. declare module BABYLON {
  81244. /** Defines the cross module used constants to avoid circular dependncies */
  81245. export class Constants {
  81246. /** Defines that alpha blending is disabled */
  81247. static readonly ALPHA_DISABLE: number;
  81248. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81249. static readonly ALPHA_ADD: number;
  81250. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81251. static readonly ALPHA_COMBINE: number;
  81252. /** Defines that alpha blending is DEST - SRC * DEST */
  81253. static readonly ALPHA_SUBTRACT: number;
  81254. /** Defines that alpha blending is SRC * DEST */
  81255. static readonly ALPHA_MULTIPLY: number;
  81256. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81257. static readonly ALPHA_MAXIMIZED: number;
  81258. /** Defines that alpha blending is SRC + DEST */
  81259. static readonly ALPHA_ONEONE: number;
  81260. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81261. static readonly ALPHA_PREMULTIPLIED: number;
  81262. /**
  81263. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81264. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81265. */
  81266. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81267. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81268. static readonly ALPHA_INTERPOLATE: number;
  81269. /**
  81270. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81271. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81272. */
  81273. static readonly ALPHA_SCREENMODE: number;
  81274. /**
  81275. * Defines that alpha blending is SRC + DST
  81276. * Alpha will be set to SRC ALPHA + DST ALPHA
  81277. */
  81278. static readonly ALPHA_ONEONE_ONEONE: number;
  81279. /**
  81280. * Defines that alpha blending is SRC * DST ALPHA + DST
  81281. * Alpha will be set to 0
  81282. */
  81283. static readonly ALPHA_ALPHATOCOLOR: number;
  81284. /**
  81285. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81286. */
  81287. static readonly ALPHA_REVERSEONEMINUS: number;
  81288. /**
  81289. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81290. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81291. */
  81292. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81293. /**
  81294. * Defines that alpha blending is SRC + DST
  81295. * Alpha will be set to SRC ALPHA
  81296. */
  81297. static readonly ALPHA_ONEONE_ONEZERO: number;
  81298. /**
  81299. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81300. * Alpha will be set to DST ALPHA
  81301. */
  81302. static readonly ALPHA_EXCLUSION: number;
  81303. /** Defines that alpha blending equation a SUM */
  81304. static readonly ALPHA_EQUATION_ADD: number;
  81305. /** Defines that alpha blending equation a SUBSTRACTION */
  81306. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81307. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81308. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81309. /** Defines that alpha blending equation a MAX operation */
  81310. static readonly ALPHA_EQUATION_MAX: number;
  81311. /** Defines that alpha blending equation a MIN operation */
  81312. static readonly ALPHA_EQUATION_MIN: number;
  81313. /**
  81314. * Defines that alpha blending equation a DARKEN operation:
  81315. * It takes the min of the src and sums the alpha channels.
  81316. */
  81317. static readonly ALPHA_EQUATION_DARKEN: number;
  81318. /** Defines that the ressource is not delayed*/
  81319. static readonly DELAYLOADSTATE_NONE: number;
  81320. /** Defines that the ressource was successfully delay loaded */
  81321. static readonly DELAYLOADSTATE_LOADED: number;
  81322. /** Defines that the ressource is currently delay loading */
  81323. static readonly DELAYLOADSTATE_LOADING: number;
  81324. /** Defines that the ressource is delayed and has not started loading */
  81325. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81326. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81327. static readonly NEVER: number;
  81328. /** 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 */
  81329. static readonly ALWAYS: number;
  81330. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81331. static readonly LESS: number;
  81332. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81333. static readonly EQUAL: number;
  81334. /** 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 */
  81335. static readonly LEQUAL: number;
  81336. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81337. static readonly GREATER: number;
  81338. /** 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 */
  81339. static readonly GEQUAL: number;
  81340. /** 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 */
  81341. static readonly NOTEQUAL: number;
  81342. /** Passed to stencilOperation to specify that stencil value must be kept */
  81343. static readonly KEEP: number;
  81344. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81345. static readonly REPLACE: number;
  81346. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81347. static readonly INCR: number;
  81348. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81349. static readonly DECR: number;
  81350. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81351. static readonly INVERT: number;
  81352. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81353. static readonly INCR_WRAP: number;
  81354. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81355. static readonly DECR_WRAP: number;
  81356. /** Texture is not repeating outside of 0..1 UVs */
  81357. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81358. /** Texture is repeating outside of 0..1 UVs */
  81359. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81360. /** Texture is repeating and mirrored */
  81361. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81362. /** ALPHA */
  81363. static readonly TEXTUREFORMAT_ALPHA: number;
  81364. /** LUMINANCE */
  81365. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81366. /** LUMINANCE_ALPHA */
  81367. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81368. /** RGB */
  81369. static readonly TEXTUREFORMAT_RGB: number;
  81370. /** RGBA */
  81371. static readonly TEXTUREFORMAT_RGBA: number;
  81372. /** RED */
  81373. static readonly TEXTUREFORMAT_RED: number;
  81374. /** RED (2nd reference) */
  81375. static readonly TEXTUREFORMAT_R: number;
  81376. /** RG */
  81377. static readonly TEXTUREFORMAT_RG: number;
  81378. /** RED_INTEGER */
  81379. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81380. /** RED_INTEGER (2nd reference) */
  81381. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81382. /** RG_INTEGER */
  81383. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81384. /** RGB_INTEGER */
  81385. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81386. /** RGBA_INTEGER */
  81387. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81388. /** UNSIGNED_BYTE */
  81389. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81390. /** UNSIGNED_BYTE (2nd reference) */
  81391. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81392. /** FLOAT */
  81393. static readonly TEXTURETYPE_FLOAT: number;
  81394. /** HALF_FLOAT */
  81395. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81396. /** BYTE */
  81397. static readonly TEXTURETYPE_BYTE: number;
  81398. /** SHORT */
  81399. static readonly TEXTURETYPE_SHORT: number;
  81400. /** UNSIGNED_SHORT */
  81401. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81402. /** INT */
  81403. static readonly TEXTURETYPE_INT: number;
  81404. /** UNSIGNED_INT */
  81405. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81406. /** UNSIGNED_SHORT_4_4_4_4 */
  81407. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81408. /** UNSIGNED_SHORT_5_5_5_1 */
  81409. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81410. /** UNSIGNED_SHORT_5_6_5 */
  81411. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81412. /** UNSIGNED_INT_2_10_10_10_REV */
  81413. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81414. /** UNSIGNED_INT_24_8 */
  81415. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81416. /** UNSIGNED_INT_10F_11F_11F_REV */
  81417. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81418. /** UNSIGNED_INT_5_9_9_9_REV */
  81419. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81420. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81421. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81422. /** nearest is mag = nearest and min = nearest and no mip */
  81423. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81424. /** mag = nearest and min = nearest and mip = none */
  81425. static readonly TEXTURE_NEAREST_NEAREST: number;
  81426. /** Bilinear is mag = linear and min = linear and no mip */
  81427. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81428. /** mag = linear and min = linear and mip = none */
  81429. static readonly TEXTURE_LINEAR_LINEAR: number;
  81430. /** Trilinear is mag = linear and min = linear and mip = linear */
  81431. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81432. /** Trilinear is mag = linear and min = linear and mip = linear */
  81433. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81434. /** mag = nearest and min = nearest and mip = nearest */
  81435. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81436. /** mag = nearest and min = linear and mip = nearest */
  81437. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81438. /** mag = nearest and min = linear and mip = linear */
  81439. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81440. /** mag = nearest and min = linear and mip = none */
  81441. static readonly TEXTURE_NEAREST_LINEAR: number;
  81442. /** nearest is mag = nearest and min = nearest and mip = linear */
  81443. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81444. /** mag = linear and min = nearest and mip = nearest */
  81445. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81446. /** mag = linear and min = nearest and mip = linear */
  81447. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81448. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81449. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81450. /** mag = linear and min = nearest and mip = none */
  81451. static readonly TEXTURE_LINEAR_NEAREST: number;
  81452. /** Explicit coordinates mode */
  81453. static readonly TEXTURE_EXPLICIT_MODE: number;
  81454. /** Spherical coordinates mode */
  81455. static readonly TEXTURE_SPHERICAL_MODE: number;
  81456. /** Planar coordinates mode */
  81457. static readonly TEXTURE_PLANAR_MODE: number;
  81458. /** Cubic coordinates mode */
  81459. static readonly TEXTURE_CUBIC_MODE: number;
  81460. /** Projection coordinates mode */
  81461. static readonly TEXTURE_PROJECTION_MODE: number;
  81462. /** Skybox coordinates mode */
  81463. static readonly TEXTURE_SKYBOX_MODE: number;
  81464. /** Inverse Cubic coordinates mode */
  81465. static readonly TEXTURE_INVCUBIC_MODE: number;
  81466. /** Equirectangular coordinates mode */
  81467. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81468. /** Equirectangular Fixed coordinates mode */
  81469. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81470. /** Equirectangular Fixed Mirrored coordinates mode */
  81471. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81472. /** Offline (baking) quality for texture filtering */
  81473. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81474. /** High quality for texture filtering */
  81475. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81476. /** Medium quality for texture filtering */
  81477. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81478. /** Low quality for texture filtering */
  81479. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81480. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81481. static readonly SCALEMODE_FLOOR: number;
  81482. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81483. static readonly SCALEMODE_NEAREST: number;
  81484. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81485. static readonly SCALEMODE_CEILING: number;
  81486. /**
  81487. * The dirty texture flag value
  81488. */
  81489. static readonly MATERIAL_TextureDirtyFlag: number;
  81490. /**
  81491. * The dirty light flag value
  81492. */
  81493. static readonly MATERIAL_LightDirtyFlag: number;
  81494. /**
  81495. * The dirty fresnel flag value
  81496. */
  81497. static readonly MATERIAL_FresnelDirtyFlag: number;
  81498. /**
  81499. * The dirty attribute flag value
  81500. */
  81501. static readonly MATERIAL_AttributesDirtyFlag: number;
  81502. /**
  81503. * The dirty misc flag value
  81504. */
  81505. static readonly MATERIAL_MiscDirtyFlag: number;
  81506. /**
  81507. * The dirty prepass flag value
  81508. */
  81509. static readonly MATERIAL_PrePassDirtyFlag: number;
  81510. /**
  81511. * The all dirty flag value
  81512. */
  81513. static readonly MATERIAL_AllDirtyFlag: number;
  81514. /**
  81515. * Returns the triangle fill mode
  81516. */
  81517. static readonly MATERIAL_TriangleFillMode: number;
  81518. /**
  81519. * Returns the wireframe mode
  81520. */
  81521. static readonly MATERIAL_WireFrameFillMode: number;
  81522. /**
  81523. * Returns the point fill mode
  81524. */
  81525. static readonly MATERIAL_PointFillMode: number;
  81526. /**
  81527. * Returns the point list draw mode
  81528. */
  81529. static readonly MATERIAL_PointListDrawMode: number;
  81530. /**
  81531. * Returns the line list draw mode
  81532. */
  81533. static readonly MATERIAL_LineListDrawMode: number;
  81534. /**
  81535. * Returns the line loop draw mode
  81536. */
  81537. static readonly MATERIAL_LineLoopDrawMode: number;
  81538. /**
  81539. * Returns the line strip draw mode
  81540. */
  81541. static readonly MATERIAL_LineStripDrawMode: number;
  81542. /**
  81543. * Returns the triangle strip draw mode
  81544. */
  81545. static readonly MATERIAL_TriangleStripDrawMode: number;
  81546. /**
  81547. * Returns the triangle fan draw mode
  81548. */
  81549. static readonly MATERIAL_TriangleFanDrawMode: number;
  81550. /**
  81551. * Stores the clock-wise side orientation
  81552. */
  81553. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81554. /**
  81555. * Stores the counter clock-wise side orientation
  81556. */
  81557. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81558. /**
  81559. * Nothing
  81560. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81561. */
  81562. static readonly ACTION_NothingTrigger: number;
  81563. /**
  81564. * On pick
  81565. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81566. */
  81567. static readonly ACTION_OnPickTrigger: number;
  81568. /**
  81569. * On left pick
  81570. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81571. */
  81572. static readonly ACTION_OnLeftPickTrigger: number;
  81573. /**
  81574. * On right pick
  81575. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81576. */
  81577. static readonly ACTION_OnRightPickTrigger: number;
  81578. /**
  81579. * On center pick
  81580. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81581. */
  81582. static readonly ACTION_OnCenterPickTrigger: number;
  81583. /**
  81584. * On pick down
  81585. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81586. */
  81587. static readonly ACTION_OnPickDownTrigger: number;
  81588. /**
  81589. * On double pick
  81590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81591. */
  81592. static readonly ACTION_OnDoublePickTrigger: number;
  81593. /**
  81594. * On pick up
  81595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81596. */
  81597. static readonly ACTION_OnPickUpTrigger: number;
  81598. /**
  81599. * On pick out.
  81600. * This trigger will only be raised if you also declared a OnPickDown
  81601. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81602. */
  81603. static readonly ACTION_OnPickOutTrigger: number;
  81604. /**
  81605. * On long press
  81606. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81607. */
  81608. static readonly ACTION_OnLongPressTrigger: number;
  81609. /**
  81610. * On pointer over
  81611. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81612. */
  81613. static readonly ACTION_OnPointerOverTrigger: number;
  81614. /**
  81615. * On pointer out
  81616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81617. */
  81618. static readonly ACTION_OnPointerOutTrigger: number;
  81619. /**
  81620. * On every frame
  81621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81622. */
  81623. static readonly ACTION_OnEveryFrameTrigger: number;
  81624. /**
  81625. * On intersection enter
  81626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81627. */
  81628. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81629. /**
  81630. * On intersection exit
  81631. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81632. */
  81633. static readonly ACTION_OnIntersectionExitTrigger: number;
  81634. /**
  81635. * On key down
  81636. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81637. */
  81638. static readonly ACTION_OnKeyDownTrigger: number;
  81639. /**
  81640. * On key up
  81641. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81642. */
  81643. static readonly ACTION_OnKeyUpTrigger: number;
  81644. /**
  81645. * Billboard mode will only apply to Y axis
  81646. */
  81647. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81648. /**
  81649. * Billboard mode will apply to all axes
  81650. */
  81651. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81652. /**
  81653. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81654. */
  81655. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81656. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81657. * Test order :
  81658. * Is the bounding sphere outside the frustum ?
  81659. * If not, are the bounding box vertices outside the frustum ?
  81660. * It not, then the cullable object is in the frustum.
  81661. */
  81662. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81663. /** Culling strategy : Bounding Sphere Only.
  81664. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81665. * It's also less accurate than the standard because some not visible objects can still be selected.
  81666. * Test : is the bounding sphere outside the frustum ?
  81667. * If not, then the cullable object is in the frustum.
  81668. */
  81669. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81670. /** Culling strategy : Optimistic Inclusion.
  81671. * This in an inclusion test first, then the standard exclusion test.
  81672. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81673. * 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.
  81674. * Anyway, it's as accurate as the standard strategy.
  81675. * Test :
  81676. * Is the cullable object bounding sphere center in the frustum ?
  81677. * If not, apply the default culling strategy.
  81678. */
  81679. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81680. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81681. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81682. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81683. * 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.
  81684. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81685. * Test :
  81686. * Is the cullable object bounding sphere center in the frustum ?
  81687. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81688. */
  81689. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81690. /**
  81691. * No logging while loading
  81692. */
  81693. static readonly SCENELOADER_NO_LOGGING: number;
  81694. /**
  81695. * Minimal logging while loading
  81696. */
  81697. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81698. /**
  81699. * Summary logging while loading
  81700. */
  81701. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81702. /**
  81703. * Detailled logging while loading
  81704. */
  81705. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81706. /**
  81707. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81708. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81709. */
  81710. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81711. /**
  81712. * Constant used to retrieve the position texture index in the textures array in the prepass
  81713. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81714. */
  81715. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81716. /**
  81717. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81718. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81719. */
  81720. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81721. /**
  81722. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81723. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81724. */
  81725. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81726. /**
  81727. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81728. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81729. */
  81730. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81731. /**
  81732. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81733. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81734. */
  81735. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81736. /**
  81737. * Constant used to retrieve albedo index in the textures array in the prepass
  81738. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81739. */
  81740. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81741. }
  81742. }
  81743. declare module BABYLON {
  81744. /**
  81745. * This represents the required contract to create a new type of texture loader.
  81746. */
  81747. export interface IInternalTextureLoader {
  81748. /**
  81749. * Defines wether the loader supports cascade loading the different faces.
  81750. */
  81751. supportCascades: boolean;
  81752. /**
  81753. * This returns if the loader support the current file information.
  81754. * @param extension defines the file extension of the file being loaded
  81755. * @param mimeType defines the optional mime type of the file being loaded
  81756. * @returns true if the loader can load the specified file
  81757. */
  81758. canLoad(extension: string, mimeType?: string): boolean;
  81759. /**
  81760. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81761. * @param data contains the texture data
  81762. * @param texture defines the BabylonJS internal texture
  81763. * @param createPolynomials will be true if polynomials have been requested
  81764. * @param onLoad defines the callback to trigger once the texture is ready
  81765. * @param onError defines the callback to trigger in case of error
  81766. */
  81767. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81768. /**
  81769. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81770. * @param data contains the texture data
  81771. * @param texture defines the BabylonJS internal texture
  81772. * @param callback defines the method to call once ready to upload
  81773. */
  81774. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81775. }
  81776. }
  81777. declare module BABYLON {
  81778. /**
  81779. * Class used to store and describe the pipeline context associated with an effect
  81780. */
  81781. export interface IPipelineContext {
  81782. /**
  81783. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81784. */
  81785. isAsync: boolean;
  81786. /**
  81787. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81788. */
  81789. isReady: boolean;
  81790. /** @hidden */
  81791. _getVertexShaderCode(): string | null;
  81792. /** @hidden */
  81793. _getFragmentShaderCode(): string | null;
  81794. /** @hidden */
  81795. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81796. }
  81797. }
  81798. declare module BABYLON {
  81799. /**
  81800. * Class used to store gfx data (like WebGLBuffer)
  81801. */
  81802. export class DataBuffer {
  81803. /**
  81804. * Gets or sets the number of objects referencing this buffer
  81805. */
  81806. references: number;
  81807. /** Gets or sets the size of the underlying buffer */
  81808. capacity: number;
  81809. /**
  81810. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81811. */
  81812. is32Bits: boolean;
  81813. /**
  81814. * Gets the underlying buffer
  81815. */
  81816. get underlyingResource(): any;
  81817. }
  81818. }
  81819. declare module BABYLON {
  81820. /** @hidden */
  81821. export interface IShaderProcessor {
  81822. attributeProcessor?: (attribute: string) => string;
  81823. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81824. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81825. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81826. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81827. lineProcessor?: (line: string, isFragment: boolean) => string;
  81828. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81829. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81830. }
  81831. }
  81832. declare module BABYLON {
  81833. /** @hidden */
  81834. export interface ProcessingOptions {
  81835. defines: string[];
  81836. indexParameters: any;
  81837. isFragment: boolean;
  81838. shouldUseHighPrecisionShader: boolean;
  81839. supportsUniformBuffers: boolean;
  81840. shadersRepository: string;
  81841. includesShadersStore: {
  81842. [key: string]: string;
  81843. };
  81844. processor?: IShaderProcessor;
  81845. version: string;
  81846. platformName: string;
  81847. lookForClosingBracketForUniformBuffer?: boolean;
  81848. }
  81849. }
  81850. declare module BABYLON {
  81851. /** @hidden */
  81852. export class ShaderCodeNode {
  81853. line: string;
  81854. children: ShaderCodeNode[];
  81855. additionalDefineKey?: string;
  81856. additionalDefineValue?: string;
  81857. isValid(preprocessors: {
  81858. [key: string]: string;
  81859. }): boolean;
  81860. process(preprocessors: {
  81861. [key: string]: string;
  81862. }, options: ProcessingOptions): string;
  81863. }
  81864. }
  81865. declare module BABYLON {
  81866. /** @hidden */
  81867. export class ShaderCodeCursor {
  81868. private _lines;
  81869. lineIndex: number;
  81870. get currentLine(): string;
  81871. get canRead(): boolean;
  81872. set lines(value: string[]);
  81873. }
  81874. }
  81875. declare module BABYLON {
  81876. /** @hidden */
  81877. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81878. process(preprocessors: {
  81879. [key: string]: string;
  81880. }, options: ProcessingOptions): string;
  81881. }
  81882. }
  81883. declare module BABYLON {
  81884. /** @hidden */
  81885. export class ShaderDefineExpression {
  81886. isTrue(preprocessors: {
  81887. [key: string]: string;
  81888. }): boolean;
  81889. private static _OperatorPriority;
  81890. private static _Stack;
  81891. static postfixToInfix(postfix: string[]): string;
  81892. static infixToPostfix(infix: string): string[];
  81893. }
  81894. }
  81895. declare module BABYLON {
  81896. /** @hidden */
  81897. export class ShaderCodeTestNode extends ShaderCodeNode {
  81898. testExpression: ShaderDefineExpression;
  81899. isValid(preprocessors: {
  81900. [key: string]: string;
  81901. }): boolean;
  81902. }
  81903. }
  81904. declare module BABYLON {
  81905. /** @hidden */
  81906. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81907. define: string;
  81908. not: boolean;
  81909. constructor(define: string, not?: boolean);
  81910. isTrue(preprocessors: {
  81911. [key: string]: string;
  81912. }): boolean;
  81913. }
  81914. }
  81915. declare module BABYLON {
  81916. /** @hidden */
  81917. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81918. leftOperand: ShaderDefineExpression;
  81919. rightOperand: ShaderDefineExpression;
  81920. isTrue(preprocessors: {
  81921. [key: string]: string;
  81922. }): boolean;
  81923. }
  81924. }
  81925. declare module BABYLON {
  81926. /** @hidden */
  81927. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81928. leftOperand: ShaderDefineExpression;
  81929. rightOperand: ShaderDefineExpression;
  81930. isTrue(preprocessors: {
  81931. [key: string]: string;
  81932. }): boolean;
  81933. }
  81934. }
  81935. declare module BABYLON {
  81936. /** @hidden */
  81937. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81938. define: string;
  81939. operand: string;
  81940. testValue: string;
  81941. constructor(define: string, operand: string, testValue: string);
  81942. isTrue(preprocessors: {
  81943. [key: string]: string;
  81944. }): boolean;
  81945. }
  81946. }
  81947. declare module BABYLON {
  81948. /**
  81949. * Class used to enable access to offline support
  81950. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81951. */
  81952. export interface IOfflineProvider {
  81953. /**
  81954. * Gets a boolean indicating if scene must be saved in the database
  81955. */
  81956. enableSceneOffline: boolean;
  81957. /**
  81958. * Gets a boolean indicating if textures must be saved in the database
  81959. */
  81960. enableTexturesOffline: boolean;
  81961. /**
  81962. * Open the offline support and make it available
  81963. * @param successCallback defines the callback to call on success
  81964. * @param errorCallback defines the callback to call on error
  81965. */
  81966. open(successCallback: () => void, errorCallback: () => void): void;
  81967. /**
  81968. * Loads an image from the offline support
  81969. * @param url defines the url to load from
  81970. * @param image defines the target DOM image
  81971. */
  81972. loadImage(url: string, image: HTMLImageElement): void;
  81973. /**
  81974. * Loads a file from offline support
  81975. * @param url defines the URL to load from
  81976. * @param sceneLoaded defines a callback to call on success
  81977. * @param progressCallBack defines a callback to call when progress changed
  81978. * @param errorCallback defines a callback to call on error
  81979. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81980. */
  81981. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81982. }
  81983. }
  81984. declare module BABYLON {
  81985. /**
  81986. * Class used to help managing file picking and drag'n'drop
  81987. * File Storage
  81988. */
  81989. export class FilesInputStore {
  81990. /**
  81991. * List of files ready to be loaded
  81992. */
  81993. static FilesToLoad: {
  81994. [key: string]: File;
  81995. };
  81996. }
  81997. }
  81998. declare module BABYLON {
  81999. /**
  82000. * Class used to define a retry strategy when error happens while loading assets
  82001. */
  82002. export class RetryStrategy {
  82003. /**
  82004. * Function used to defines an exponential back off strategy
  82005. * @param maxRetries defines the maximum number of retries (3 by default)
  82006. * @param baseInterval defines the interval between retries
  82007. * @returns the strategy function to use
  82008. */
  82009. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /**
  82014. * @ignore
  82015. * Application error to support additional information when loading a file
  82016. */
  82017. export abstract class BaseError extends Error {
  82018. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82019. }
  82020. }
  82021. declare module BABYLON {
  82022. /** @ignore */
  82023. export class LoadFileError extends BaseError {
  82024. request?: WebRequest;
  82025. file?: File;
  82026. /**
  82027. * Creates a new LoadFileError
  82028. * @param message defines the message of the error
  82029. * @param request defines the optional web request
  82030. * @param file defines the optional file
  82031. */
  82032. constructor(message: string, object?: WebRequest | File);
  82033. }
  82034. /** @ignore */
  82035. export class RequestFileError extends BaseError {
  82036. request: WebRequest;
  82037. /**
  82038. * Creates a new LoadFileError
  82039. * @param message defines the message of the error
  82040. * @param request defines the optional web request
  82041. */
  82042. constructor(message: string, request: WebRequest);
  82043. }
  82044. /** @ignore */
  82045. export class ReadFileError extends BaseError {
  82046. file: File;
  82047. /**
  82048. * Creates a new ReadFileError
  82049. * @param message defines the message of the error
  82050. * @param file defines the optional file
  82051. */
  82052. constructor(message: string, file: File);
  82053. }
  82054. /**
  82055. * @hidden
  82056. */
  82057. export class FileTools {
  82058. /**
  82059. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82060. */
  82061. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82062. /**
  82063. * Gets or sets the base URL to use to load assets
  82064. */
  82065. static BaseUrl: string;
  82066. /**
  82067. * Default behaviour for cors in the application.
  82068. * It can be a string if the expected behavior is identical in the entire app.
  82069. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82070. */
  82071. static CorsBehavior: string | ((url: string | string[]) => string);
  82072. /**
  82073. * Gets or sets a function used to pre-process url before using them to load assets
  82074. */
  82075. static PreprocessUrl: (url: string) => string;
  82076. /**
  82077. * Removes unwanted characters from an url
  82078. * @param url defines the url to clean
  82079. * @returns the cleaned url
  82080. */
  82081. private static _CleanUrl;
  82082. /**
  82083. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82084. * @param url define the url we are trying
  82085. * @param element define the dom element where to configure the cors policy
  82086. */
  82087. static SetCorsBehavior(url: string | string[], element: {
  82088. crossOrigin: string | null;
  82089. }): void;
  82090. /**
  82091. * Loads an image as an HTMLImageElement.
  82092. * @param input url string, ArrayBuffer, or Blob to load
  82093. * @param onLoad callback called when the image successfully loads
  82094. * @param onError callback called when the image fails to load
  82095. * @param offlineProvider offline provider for caching
  82096. * @param mimeType optional mime type
  82097. * @returns the HTMLImageElement of the loaded image
  82098. */
  82099. 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>;
  82100. /**
  82101. * Reads a file from a File object
  82102. * @param file defines the file to load
  82103. * @param onSuccess defines the callback to call when data is loaded
  82104. * @param onProgress defines the callback to call during loading process
  82105. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82106. * @param onError defines the callback to call when an error occurs
  82107. * @returns a file request object
  82108. */
  82109. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82110. /**
  82111. * Loads a file from a url
  82112. * @param url url to load
  82113. * @param onSuccess callback called when the file successfully loads
  82114. * @param onProgress callback called while file is loading (if the server supports this mode)
  82115. * @param offlineProvider defines the offline provider for caching
  82116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82117. * @param onError callback called when the file fails to load
  82118. * @returns a file request object
  82119. */
  82120. 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;
  82121. /**
  82122. * Loads a file
  82123. * @param url url to load
  82124. * @param onSuccess callback called when the file successfully loads
  82125. * @param onProgress callback called while file is loading (if the server supports this mode)
  82126. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82127. * @param onError callback called when the file fails to load
  82128. * @param onOpened callback called when the web request is opened
  82129. * @returns a file request object
  82130. */
  82131. 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;
  82132. /**
  82133. * Checks if the loaded document was accessed via `file:`-Protocol.
  82134. * @returns boolean
  82135. */
  82136. static IsFileURL(): boolean;
  82137. }
  82138. }
  82139. declare module BABYLON {
  82140. /** @hidden */
  82141. export class ShaderProcessor {
  82142. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82143. private static _ProcessPrecision;
  82144. private static _ExtractOperation;
  82145. private static _BuildSubExpression;
  82146. private static _BuildExpression;
  82147. private static _MoveCursorWithinIf;
  82148. private static _MoveCursor;
  82149. private static _EvaluatePreProcessors;
  82150. private static _PreparePreProcessors;
  82151. private static _ProcessShaderConversion;
  82152. private static _ProcessIncludes;
  82153. /**
  82154. * Loads a file from a url
  82155. * @param url url to load
  82156. * @param onSuccess callback called when the file successfully loads
  82157. * @param onProgress callback called while file is loading (if the server supports this mode)
  82158. * @param offlineProvider defines the offline provider for caching
  82159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82160. * @param onError callback called when the file fails to load
  82161. * @returns a file request object
  82162. * @hidden
  82163. */
  82164. 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;
  82165. }
  82166. }
  82167. declare module BABYLON {
  82168. /**
  82169. * @hidden
  82170. */
  82171. export interface IColor4Like {
  82172. r: float;
  82173. g: float;
  82174. b: float;
  82175. a: float;
  82176. }
  82177. /**
  82178. * @hidden
  82179. */
  82180. export interface IColor3Like {
  82181. r: float;
  82182. g: float;
  82183. b: float;
  82184. }
  82185. /**
  82186. * @hidden
  82187. */
  82188. export interface IVector4Like {
  82189. x: float;
  82190. y: float;
  82191. z: float;
  82192. w: float;
  82193. }
  82194. /**
  82195. * @hidden
  82196. */
  82197. export interface IVector3Like {
  82198. x: float;
  82199. y: float;
  82200. z: float;
  82201. }
  82202. /**
  82203. * @hidden
  82204. */
  82205. export interface IVector2Like {
  82206. x: float;
  82207. y: float;
  82208. }
  82209. /**
  82210. * @hidden
  82211. */
  82212. export interface IMatrixLike {
  82213. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82214. updateFlag: int;
  82215. }
  82216. /**
  82217. * @hidden
  82218. */
  82219. export interface IViewportLike {
  82220. x: float;
  82221. y: float;
  82222. width: float;
  82223. height: float;
  82224. }
  82225. /**
  82226. * @hidden
  82227. */
  82228. export interface IPlaneLike {
  82229. normal: IVector3Like;
  82230. d: float;
  82231. normalize(): void;
  82232. }
  82233. }
  82234. declare module BABYLON {
  82235. /**
  82236. * Interface used to define common properties for effect fallbacks
  82237. */
  82238. export interface IEffectFallbacks {
  82239. /**
  82240. * Removes the defines that should be removed when falling back.
  82241. * @param currentDefines defines the current define statements for the shader.
  82242. * @param effect defines the current effect we try to compile
  82243. * @returns The resulting defines with defines of the current rank removed.
  82244. */
  82245. reduce(currentDefines: string, effect: Effect): string;
  82246. /**
  82247. * Removes the fallback from the bound mesh.
  82248. */
  82249. unBindMesh(): void;
  82250. /**
  82251. * Checks to see if more fallbacks are still availible.
  82252. */
  82253. hasMoreFallbacks: boolean;
  82254. }
  82255. }
  82256. declare module BABYLON {
  82257. /**
  82258. * Class used to evalaute queries containing `and` and `or` operators
  82259. */
  82260. export class AndOrNotEvaluator {
  82261. /**
  82262. * Evaluate a query
  82263. * @param query defines the query to evaluate
  82264. * @param evaluateCallback defines the callback used to filter result
  82265. * @returns true if the query matches
  82266. */
  82267. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82268. private static _HandleParenthesisContent;
  82269. private static _SimplifyNegation;
  82270. }
  82271. }
  82272. declare module BABYLON {
  82273. /**
  82274. * Class used to store custom tags
  82275. */
  82276. export class Tags {
  82277. /**
  82278. * Adds support for tags on the given object
  82279. * @param obj defines the object to use
  82280. */
  82281. static EnableFor(obj: any): void;
  82282. /**
  82283. * Removes tags support
  82284. * @param obj defines the object to use
  82285. */
  82286. static DisableFor(obj: any): void;
  82287. /**
  82288. * Gets a boolean indicating if the given object has tags
  82289. * @param obj defines the object to use
  82290. * @returns a boolean
  82291. */
  82292. static HasTags(obj: any): boolean;
  82293. /**
  82294. * Gets the tags available on a given object
  82295. * @param obj defines the object to use
  82296. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82297. * @returns the tags
  82298. */
  82299. static GetTags(obj: any, asString?: boolean): any;
  82300. /**
  82301. * Adds tags to an object
  82302. * @param obj defines the object to use
  82303. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82304. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82305. */
  82306. static AddTagsTo(obj: any, tagsString: string): void;
  82307. /**
  82308. * @hidden
  82309. */
  82310. static _AddTagTo(obj: any, tag: string): void;
  82311. /**
  82312. * Removes specific tags from a specific object
  82313. * @param obj defines the object to use
  82314. * @param tagsString defines the tags to remove
  82315. */
  82316. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82317. /**
  82318. * @hidden
  82319. */
  82320. static _RemoveTagFrom(obj: any, tag: string): void;
  82321. /**
  82322. * Defines if tags hosted on an object match a given query
  82323. * @param obj defines the object to use
  82324. * @param tagsQuery defines the tag query
  82325. * @returns a boolean
  82326. */
  82327. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82328. }
  82329. }
  82330. declare module BABYLON {
  82331. /**
  82332. * Scalar computation library
  82333. */
  82334. export class Scalar {
  82335. /**
  82336. * Two pi constants convenient for computation.
  82337. */
  82338. static TwoPi: number;
  82339. /**
  82340. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82341. * @param a number
  82342. * @param b number
  82343. * @param epsilon (default = 1.401298E-45)
  82344. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82345. */
  82346. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82347. /**
  82348. * Returns a string : the upper case translation of the number i to hexadecimal.
  82349. * @param i number
  82350. * @returns the upper case translation of the number i to hexadecimal.
  82351. */
  82352. static ToHex(i: number): string;
  82353. /**
  82354. * Returns -1 if value is negative and +1 is value is positive.
  82355. * @param value the value
  82356. * @returns the value itself if it's equal to zero.
  82357. */
  82358. static Sign(value: number): number;
  82359. /**
  82360. * Returns the value itself if it's between min and max.
  82361. * Returns min if the value is lower than min.
  82362. * Returns max if the value is greater than max.
  82363. * @param value the value to clmap
  82364. * @param min the min value to clamp to (default: 0)
  82365. * @param max the max value to clamp to (default: 1)
  82366. * @returns the clamped value
  82367. */
  82368. static Clamp(value: number, min?: number, max?: number): number;
  82369. /**
  82370. * the log2 of value.
  82371. * @param value the value to compute log2 of
  82372. * @returns the log2 of value.
  82373. */
  82374. static Log2(value: number): number;
  82375. /**
  82376. * Loops the value, so that it is never larger than length and never smaller than 0.
  82377. *
  82378. * This is similar to the modulo operator but it works with floating point numbers.
  82379. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82380. * With t = 5 and length = 2.5, the result would be 0.0.
  82381. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82382. * @param value the value
  82383. * @param length the length
  82384. * @returns the looped value
  82385. */
  82386. static Repeat(value: number, length: number): number;
  82387. /**
  82388. * Normalize the value between 0.0 and 1.0 using min and max values
  82389. * @param value value to normalize
  82390. * @param min max to normalize between
  82391. * @param max min to normalize between
  82392. * @returns the normalized value
  82393. */
  82394. static Normalize(value: number, min: number, max: number): number;
  82395. /**
  82396. * Denormalize the value from 0.0 and 1.0 using min and max values
  82397. * @param normalized value to denormalize
  82398. * @param min max to denormalize between
  82399. * @param max min to denormalize between
  82400. * @returns the denormalized value
  82401. */
  82402. static Denormalize(normalized: number, min: number, max: number): number;
  82403. /**
  82404. * Calculates the shortest difference between two given angles given in degrees.
  82405. * @param current current angle in degrees
  82406. * @param target target angle in degrees
  82407. * @returns the delta
  82408. */
  82409. static DeltaAngle(current: number, target: number): number;
  82410. /**
  82411. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82412. * @param tx value
  82413. * @param length length
  82414. * @returns The returned value will move back and forth between 0 and length
  82415. */
  82416. static PingPong(tx: number, length: number): number;
  82417. /**
  82418. * Interpolates between min and max with smoothing at the limits.
  82419. *
  82420. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82421. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82422. * @param from from
  82423. * @param to to
  82424. * @param tx value
  82425. * @returns the smooth stepped value
  82426. */
  82427. static SmoothStep(from: number, to: number, tx: number): number;
  82428. /**
  82429. * Moves a value current towards target.
  82430. *
  82431. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82432. * Negative values of maxDelta pushes the value away from target.
  82433. * @param current current value
  82434. * @param target target value
  82435. * @param maxDelta max distance to move
  82436. * @returns resulting value
  82437. */
  82438. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82439. /**
  82440. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82441. *
  82442. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82443. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82444. * @param current current value
  82445. * @param target target value
  82446. * @param maxDelta max distance to move
  82447. * @returns resulting angle
  82448. */
  82449. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82450. /**
  82451. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82452. * @param start start value
  82453. * @param end target value
  82454. * @param amount amount to lerp between
  82455. * @returns the lerped value
  82456. */
  82457. static Lerp(start: number, end: number, amount: number): number;
  82458. /**
  82459. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82460. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82461. * @param start start value
  82462. * @param end target value
  82463. * @param amount amount to lerp between
  82464. * @returns the lerped value
  82465. */
  82466. static LerpAngle(start: number, end: number, amount: number): number;
  82467. /**
  82468. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82469. * @param a start value
  82470. * @param b target value
  82471. * @param value value between a and b
  82472. * @returns the inverseLerp value
  82473. */
  82474. static InverseLerp(a: number, b: number, value: number): number;
  82475. /**
  82476. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82477. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82478. * @param value1 spline value
  82479. * @param tangent1 spline value
  82480. * @param value2 spline value
  82481. * @param tangent2 spline value
  82482. * @param amount input value
  82483. * @returns hermite result
  82484. */
  82485. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82486. /**
  82487. * Returns a random float number between and min and max values
  82488. * @param min min value of random
  82489. * @param max max value of random
  82490. * @returns random value
  82491. */
  82492. static RandomRange(min: number, max: number): number;
  82493. /**
  82494. * This function returns percentage of a number in a given range.
  82495. *
  82496. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82497. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82498. * @param number to convert to percentage
  82499. * @param min min range
  82500. * @param max max range
  82501. * @returns the percentage
  82502. */
  82503. static RangeToPercent(number: number, min: number, max: number): number;
  82504. /**
  82505. * This function returns number that corresponds to the percentage in a given range.
  82506. *
  82507. * PercentToRange(0.34,0,100) will return 34.
  82508. * @param percent to convert to number
  82509. * @param min min range
  82510. * @param max max range
  82511. * @returns the number
  82512. */
  82513. static PercentToRange(percent: number, min: number, max: number): number;
  82514. /**
  82515. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82516. * @param angle The angle to normalize in radian.
  82517. * @return The converted angle.
  82518. */
  82519. static NormalizeRadians(angle: number): number;
  82520. }
  82521. }
  82522. declare module BABYLON {
  82523. /**
  82524. * Constant used to convert a value to gamma space
  82525. * @ignorenaming
  82526. */
  82527. export const ToGammaSpace: number;
  82528. /**
  82529. * Constant used to convert a value to linear space
  82530. * @ignorenaming
  82531. */
  82532. export const ToLinearSpace = 2.2;
  82533. /**
  82534. * Constant used to define the minimal number value in Babylon.js
  82535. * @ignorenaming
  82536. */
  82537. let Epsilon: number;
  82538. }
  82539. declare module BABYLON {
  82540. /**
  82541. * Class used to represent a viewport on screen
  82542. */
  82543. export class Viewport {
  82544. /** viewport left coordinate */
  82545. x: number;
  82546. /** viewport top coordinate */
  82547. y: number;
  82548. /**viewport width */
  82549. width: number;
  82550. /** viewport height */
  82551. height: number;
  82552. /**
  82553. * Creates a Viewport object located at (x, y) and sized (width, height)
  82554. * @param x defines viewport left coordinate
  82555. * @param y defines viewport top coordinate
  82556. * @param width defines the viewport width
  82557. * @param height defines the viewport height
  82558. */
  82559. constructor(
  82560. /** viewport left coordinate */
  82561. x: number,
  82562. /** viewport top coordinate */
  82563. y: number,
  82564. /**viewport width */
  82565. width: number,
  82566. /** viewport height */
  82567. height: number);
  82568. /**
  82569. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82570. * @param renderWidth defines the rendering width
  82571. * @param renderHeight defines the rendering height
  82572. * @returns a new Viewport
  82573. */
  82574. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82575. /**
  82576. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82577. * @param renderWidth defines the rendering width
  82578. * @param renderHeight defines the rendering height
  82579. * @param ref defines the target viewport
  82580. * @returns the current viewport
  82581. */
  82582. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82583. /**
  82584. * Returns a new Viewport copied from the current one
  82585. * @returns a new Viewport
  82586. */
  82587. clone(): Viewport;
  82588. }
  82589. }
  82590. declare module BABYLON {
  82591. /**
  82592. * Class containing a set of static utilities functions for arrays.
  82593. */
  82594. export class ArrayTools {
  82595. /**
  82596. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82597. * @param size the number of element to construct and put in the array
  82598. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82599. * @returns a new array filled with new objects
  82600. */
  82601. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82602. }
  82603. }
  82604. declare module BABYLON {
  82605. /**
  82606. * Represents a plane by the equation ax + by + cz + d = 0
  82607. */
  82608. export class Plane {
  82609. private static _TmpMatrix;
  82610. /**
  82611. * Normal of the plane (a,b,c)
  82612. */
  82613. normal: Vector3;
  82614. /**
  82615. * d component of the plane
  82616. */
  82617. d: number;
  82618. /**
  82619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82620. * @param a a component of the plane
  82621. * @param b b component of the plane
  82622. * @param c c component of the plane
  82623. * @param d d component of the plane
  82624. */
  82625. constructor(a: number, b: number, c: number, d: number);
  82626. /**
  82627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82628. */
  82629. asArray(): number[];
  82630. /**
  82631. * @returns a new plane copied from the current Plane.
  82632. */
  82633. clone(): Plane;
  82634. /**
  82635. * @returns the string "Plane".
  82636. */
  82637. getClassName(): string;
  82638. /**
  82639. * @returns the Plane hash code.
  82640. */
  82641. getHashCode(): number;
  82642. /**
  82643. * Normalize the current Plane in place.
  82644. * @returns the updated Plane.
  82645. */
  82646. normalize(): Plane;
  82647. /**
  82648. * Applies a transformation the plane and returns the result
  82649. * @param transformation the transformation matrix to be applied to the plane
  82650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82651. */
  82652. transform(transformation: DeepImmutable<Matrix>): Plane;
  82653. /**
  82654. * Compute the dot product between the point and the plane normal
  82655. * @param point point to calculate the dot product with
  82656. * @returns the dot product (float) of the point coordinates and the plane normal.
  82657. */
  82658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82659. /**
  82660. * Updates the current Plane from the plane defined by the three given points.
  82661. * @param point1 one of the points used to contruct the plane
  82662. * @param point2 one of the points used to contruct the plane
  82663. * @param point3 one of the points used to contruct the plane
  82664. * @returns the updated Plane.
  82665. */
  82666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82667. /**
  82668. * Checks if the plane is facing a given direction
  82669. * @param direction the direction to check if the plane is facing
  82670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82671. * @returns True is the vector "direction" is the same side than the plane normal.
  82672. */
  82673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82674. /**
  82675. * Calculates the distance to a point
  82676. * @param point point to calculate distance to
  82677. * @returns the signed distance (float) from the given point to the Plane.
  82678. */
  82679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82680. /**
  82681. * Creates a plane from an array
  82682. * @param array the array to create a plane from
  82683. * @returns a new Plane from the given array.
  82684. */
  82685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82686. /**
  82687. * Creates a plane from three points
  82688. * @param point1 point used to create the plane
  82689. * @param point2 point used to create the plane
  82690. * @param point3 point used to create the plane
  82691. * @returns a new Plane defined by the three given points.
  82692. */
  82693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82694. /**
  82695. * Creates a plane from an origin point and a normal
  82696. * @param origin origin of the plane to be constructed
  82697. * @param normal normal of the plane to be constructed
  82698. * @returns a new Plane the normal vector to this plane at the given origin point.
  82699. * Note : the vector "normal" is updated because normalized.
  82700. */
  82701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82702. /**
  82703. * Calculates the distance from a plane and a point
  82704. * @param origin origin of the plane to be constructed
  82705. * @param normal normal of the plane to be constructed
  82706. * @param point point to calculate distance to
  82707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82708. */
  82709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82710. }
  82711. }
  82712. declare module BABYLON {
  82713. /** @hidden */
  82714. export class PerformanceConfigurator {
  82715. /** @hidden */
  82716. static MatrixUse64Bits: boolean;
  82717. /** @hidden */
  82718. static MatrixTrackPrecisionChange: boolean;
  82719. /** @hidden */
  82720. static MatrixCurrentType: any;
  82721. /** @hidden */
  82722. static MatrixTrackedMatrices: Array<any> | null;
  82723. /** @hidden */
  82724. static SetMatrixPrecision(use64bits: boolean): void;
  82725. }
  82726. }
  82727. declare module BABYLON {
  82728. /**
  82729. * Class representing a vector containing 2 coordinates
  82730. */
  82731. export class Vector2 {
  82732. /** defines the first coordinate */
  82733. x: number;
  82734. /** defines the second coordinate */
  82735. y: number;
  82736. /**
  82737. * Creates a new Vector2 from the given x and y coordinates
  82738. * @param x defines the first coordinate
  82739. * @param y defines the second coordinate
  82740. */
  82741. constructor(
  82742. /** defines the first coordinate */
  82743. x?: number,
  82744. /** defines the second coordinate */
  82745. y?: number);
  82746. /**
  82747. * Gets a string with the Vector2 coordinates
  82748. * @returns a string with the Vector2 coordinates
  82749. */
  82750. toString(): string;
  82751. /**
  82752. * Gets class name
  82753. * @returns the string "Vector2"
  82754. */
  82755. getClassName(): string;
  82756. /**
  82757. * Gets current vector hash code
  82758. * @returns the Vector2 hash code as a number
  82759. */
  82760. getHashCode(): number;
  82761. /**
  82762. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82763. * @param array defines the source array
  82764. * @param index defines the offset in source array
  82765. * @returns the current Vector2
  82766. */
  82767. toArray(array: FloatArray, index?: number): Vector2;
  82768. /**
  82769. * Update the current vector from an array
  82770. * @param array defines the destination array
  82771. * @param index defines the offset in the destination array
  82772. * @returns the current Vector3
  82773. */
  82774. fromArray(array: FloatArray, index?: number): Vector2;
  82775. /**
  82776. * Copy the current vector to an array
  82777. * @returns a new array with 2 elements: the Vector2 coordinates.
  82778. */
  82779. asArray(): number[];
  82780. /**
  82781. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82782. * @param source defines the source Vector2
  82783. * @returns the current updated Vector2
  82784. */
  82785. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82786. /**
  82787. * Sets the Vector2 coordinates with the given floats
  82788. * @param x defines the first coordinate
  82789. * @param y defines the second coordinate
  82790. * @returns the current updated Vector2
  82791. */
  82792. copyFromFloats(x: number, y: number): Vector2;
  82793. /**
  82794. * Sets the Vector2 coordinates with the given floats
  82795. * @param x defines the first coordinate
  82796. * @param y defines the second coordinate
  82797. * @returns the current updated Vector2
  82798. */
  82799. set(x: number, y: number): Vector2;
  82800. /**
  82801. * Add another vector with the current one
  82802. * @param otherVector defines the other vector
  82803. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82804. */
  82805. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82806. /**
  82807. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82808. * @param otherVector defines the other vector
  82809. * @param result defines the target vector
  82810. * @returns the unmodified current Vector2
  82811. */
  82812. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82813. /**
  82814. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82815. * @param otherVector defines the other vector
  82816. * @returns the current updated Vector2
  82817. */
  82818. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82819. /**
  82820. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82821. * @param otherVector defines the other vector
  82822. * @returns a new Vector2
  82823. */
  82824. addVector3(otherVector: Vector3): Vector2;
  82825. /**
  82826. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82827. * @param otherVector defines the other vector
  82828. * @returns a new Vector2
  82829. */
  82830. subtract(otherVector: Vector2): Vector2;
  82831. /**
  82832. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82833. * @param otherVector defines the other vector
  82834. * @param result defines the target vector
  82835. * @returns the unmodified current Vector2
  82836. */
  82837. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82838. /**
  82839. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82840. * @param otherVector defines the other vector
  82841. * @returns the current updated Vector2
  82842. */
  82843. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82844. /**
  82845. * Multiplies in place the current Vector2 coordinates by the given ones
  82846. * @param otherVector defines the other vector
  82847. * @returns the current updated Vector2
  82848. */
  82849. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82850. /**
  82851. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82852. * @param otherVector defines the other vector
  82853. * @returns a new Vector2
  82854. */
  82855. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82856. /**
  82857. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82858. * @param otherVector defines the other vector
  82859. * @param result defines the target vector
  82860. * @returns the unmodified current Vector2
  82861. */
  82862. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82863. /**
  82864. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82865. * @param x defines the first coordinate
  82866. * @param y defines the second coordinate
  82867. * @returns a new Vector2
  82868. */
  82869. multiplyByFloats(x: number, y: number): Vector2;
  82870. /**
  82871. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82872. * @param otherVector defines the other vector
  82873. * @returns a new Vector2
  82874. */
  82875. divide(otherVector: Vector2): Vector2;
  82876. /**
  82877. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82878. * @param otherVector defines the other vector
  82879. * @param result defines the target vector
  82880. * @returns the unmodified current Vector2
  82881. */
  82882. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82883. /**
  82884. * Divides the current Vector2 coordinates by the given ones
  82885. * @param otherVector defines the other vector
  82886. * @returns the current updated Vector2
  82887. */
  82888. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82889. /**
  82890. * Gets a new Vector2 with current Vector2 negated coordinates
  82891. * @returns a new Vector2
  82892. */
  82893. negate(): Vector2;
  82894. /**
  82895. * Negate this vector in place
  82896. * @returns this
  82897. */
  82898. negateInPlace(): Vector2;
  82899. /**
  82900. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82901. * @param result defines the Vector3 object where to store the result
  82902. * @returns the current Vector2
  82903. */
  82904. negateToRef(result: Vector2): Vector2;
  82905. /**
  82906. * Multiply the Vector2 coordinates by scale
  82907. * @param scale defines the scaling factor
  82908. * @returns the current updated Vector2
  82909. */
  82910. scaleInPlace(scale: number): Vector2;
  82911. /**
  82912. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82913. * @param scale defines the scaling factor
  82914. * @returns a new Vector2
  82915. */
  82916. scale(scale: number): Vector2;
  82917. /**
  82918. * Scale the current Vector2 values by a factor to a given Vector2
  82919. * @param scale defines the scale factor
  82920. * @param result defines the Vector2 object where to store the result
  82921. * @returns the unmodified current Vector2
  82922. */
  82923. scaleToRef(scale: number, result: Vector2): Vector2;
  82924. /**
  82925. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82926. * @param scale defines the scale factor
  82927. * @param result defines the Vector2 object where to store the result
  82928. * @returns the unmodified current Vector2
  82929. */
  82930. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82931. /**
  82932. * Gets a boolean if two vectors are equals
  82933. * @param otherVector defines the other vector
  82934. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82935. */
  82936. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82937. /**
  82938. * Gets a boolean if two vectors are equals (using an epsilon value)
  82939. * @param otherVector defines the other vector
  82940. * @param epsilon defines the minimal distance to consider equality
  82941. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82942. */
  82943. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82944. /**
  82945. * Gets a new Vector2 from current Vector2 floored values
  82946. * @returns a new Vector2
  82947. */
  82948. floor(): Vector2;
  82949. /**
  82950. * Gets a new Vector2 from current Vector2 floored values
  82951. * @returns a new Vector2
  82952. */
  82953. fract(): Vector2;
  82954. /**
  82955. * Gets the length of the vector
  82956. * @returns the vector length (float)
  82957. */
  82958. length(): number;
  82959. /**
  82960. * Gets the vector squared length
  82961. * @returns the vector squared length (float)
  82962. */
  82963. lengthSquared(): number;
  82964. /**
  82965. * Normalize the vector
  82966. * @returns the current updated Vector2
  82967. */
  82968. normalize(): Vector2;
  82969. /**
  82970. * Gets a new Vector2 copied from the Vector2
  82971. * @returns a new Vector2
  82972. */
  82973. clone(): Vector2;
  82974. /**
  82975. * Gets a new Vector2(0, 0)
  82976. * @returns a new Vector2
  82977. */
  82978. static Zero(): Vector2;
  82979. /**
  82980. * Gets a new Vector2(1, 1)
  82981. * @returns a new Vector2
  82982. */
  82983. static One(): Vector2;
  82984. /**
  82985. * Gets a new Vector2 set from the given index element of the given array
  82986. * @param array defines the data source
  82987. * @param offset defines the offset in the data source
  82988. * @returns a new Vector2
  82989. */
  82990. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82991. /**
  82992. * Sets "result" from the given index element of the given array
  82993. * @param array defines the data source
  82994. * @param offset defines the offset in the data source
  82995. * @param result defines the target vector
  82996. */
  82997. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82998. /**
  82999. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83000. * @param value1 defines 1st point of control
  83001. * @param value2 defines 2nd point of control
  83002. * @param value3 defines 3rd point of control
  83003. * @param value4 defines 4th point of control
  83004. * @param amount defines the interpolation factor
  83005. * @returns a new Vector2
  83006. */
  83007. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83008. /**
  83009. * 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".
  83010. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83011. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83012. * @param value defines the value to clamp
  83013. * @param min defines the lower limit
  83014. * @param max defines the upper limit
  83015. * @returns a new Vector2
  83016. */
  83017. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83018. /**
  83019. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83020. * @param value1 defines the 1st control point
  83021. * @param tangent1 defines the outgoing tangent
  83022. * @param value2 defines the 2nd control point
  83023. * @param tangent2 defines the incoming tangent
  83024. * @param amount defines the interpolation factor
  83025. * @returns a new Vector2
  83026. */
  83027. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83028. /**
  83029. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83030. * @param start defines the start vector
  83031. * @param end defines the end vector
  83032. * @param amount defines the interpolation factor
  83033. * @returns a new Vector2
  83034. */
  83035. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83036. /**
  83037. * Gets the dot product of the vector "left" and the vector "right"
  83038. * @param left defines first vector
  83039. * @param right defines second vector
  83040. * @returns the dot product (float)
  83041. */
  83042. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83043. /**
  83044. * Returns a new Vector2 equal to the normalized given vector
  83045. * @param vector defines the vector to normalize
  83046. * @returns a new Vector2
  83047. */
  83048. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83049. /**
  83050. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83051. * @param left defines 1st vector
  83052. * @param right defines 2nd vector
  83053. * @returns a new Vector2
  83054. */
  83055. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83056. /**
  83057. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83058. * @param left defines 1st vector
  83059. * @param right defines 2nd vector
  83060. * @returns a new Vector2
  83061. */
  83062. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83063. /**
  83064. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83065. * @param vector defines the vector to transform
  83066. * @param transformation defines the matrix to apply
  83067. * @returns a new Vector2
  83068. */
  83069. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83070. /**
  83071. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83072. * @param vector defines the vector to transform
  83073. * @param transformation defines the matrix to apply
  83074. * @param result defines the target vector
  83075. */
  83076. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83077. /**
  83078. * Determines if a given vector is included in a triangle
  83079. * @param p defines the vector to test
  83080. * @param p0 defines 1st triangle point
  83081. * @param p1 defines 2nd triangle point
  83082. * @param p2 defines 3rd triangle point
  83083. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83084. */
  83085. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83086. /**
  83087. * Gets the distance between the vectors "value1" and "value2"
  83088. * @param value1 defines first vector
  83089. * @param value2 defines second vector
  83090. * @returns the distance between vectors
  83091. */
  83092. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83093. /**
  83094. * Returns the squared distance between the vectors "value1" and "value2"
  83095. * @param value1 defines first vector
  83096. * @param value2 defines second vector
  83097. * @returns the squared distance between vectors
  83098. */
  83099. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83100. /**
  83101. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83102. * @param value1 defines first vector
  83103. * @param value2 defines second vector
  83104. * @returns a new Vector2
  83105. */
  83106. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83107. /**
  83108. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83109. * @param p defines the middle point
  83110. * @param segA defines one point of the segment
  83111. * @param segB defines the other point of the segment
  83112. * @returns the shortest distance
  83113. */
  83114. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83115. }
  83116. /**
  83117. * Class used to store (x,y,z) vector representation
  83118. * A Vector3 is the main object used in 3D geometry
  83119. * It can represent etiher the coordinates of a point the space, either a direction
  83120. * Reminder: js uses a left handed forward facing system
  83121. */
  83122. export class Vector3 {
  83123. private static _UpReadOnly;
  83124. private static _ZeroReadOnly;
  83125. /** @hidden */
  83126. _x: number;
  83127. /** @hidden */
  83128. _y: number;
  83129. /** @hidden */
  83130. _z: number;
  83131. /** @hidden */
  83132. _isDirty: boolean;
  83133. /** Gets or sets the x coordinate */
  83134. get x(): number;
  83135. set x(value: number);
  83136. /** Gets or sets the y coordinate */
  83137. get y(): number;
  83138. set y(value: number);
  83139. /** Gets or sets the z coordinate */
  83140. get z(): number;
  83141. set z(value: number);
  83142. /**
  83143. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83144. * @param x defines the first coordinates (on X axis)
  83145. * @param y defines the second coordinates (on Y axis)
  83146. * @param z defines the third coordinates (on Z axis)
  83147. */
  83148. constructor(x?: number, y?: number, z?: number);
  83149. /**
  83150. * Creates a string representation of the Vector3
  83151. * @returns a string with the Vector3 coordinates.
  83152. */
  83153. toString(): string;
  83154. /**
  83155. * Gets the class name
  83156. * @returns the string "Vector3"
  83157. */
  83158. getClassName(): string;
  83159. /**
  83160. * Creates the Vector3 hash code
  83161. * @returns a number which tends to be unique between Vector3 instances
  83162. */
  83163. getHashCode(): number;
  83164. /**
  83165. * Creates an array containing three elements : the coordinates of the Vector3
  83166. * @returns a new array of numbers
  83167. */
  83168. asArray(): number[];
  83169. /**
  83170. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83171. * @param array defines the destination array
  83172. * @param index defines the offset in the destination array
  83173. * @returns the current Vector3
  83174. */
  83175. toArray(array: FloatArray, index?: number): Vector3;
  83176. /**
  83177. * Update the current vector from an array
  83178. * @param array defines the destination array
  83179. * @param index defines the offset in the destination array
  83180. * @returns the current Vector3
  83181. */
  83182. fromArray(array: FloatArray, index?: number): Vector3;
  83183. /**
  83184. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83185. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83186. */
  83187. toQuaternion(): Quaternion;
  83188. /**
  83189. * Adds the given vector to the current Vector3
  83190. * @param otherVector defines the second operand
  83191. * @returns the current updated Vector3
  83192. */
  83193. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83194. /**
  83195. * Adds the given coordinates to the current Vector3
  83196. * @param x defines the x coordinate of the operand
  83197. * @param y defines the y coordinate of the operand
  83198. * @param z defines the z coordinate of the operand
  83199. * @returns the current updated Vector3
  83200. */
  83201. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83202. /**
  83203. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83204. * @param otherVector defines the second operand
  83205. * @returns the resulting Vector3
  83206. */
  83207. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83208. /**
  83209. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83210. * @param otherVector defines the second operand
  83211. * @param result defines the Vector3 object where to store the result
  83212. * @returns the current Vector3
  83213. */
  83214. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83215. /**
  83216. * Subtract the given vector from the current Vector3
  83217. * @param otherVector defines the second operand
  83218. * @returns the current updated Vector3
  83219. */
  83220. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83221. /**
  83222. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83223. * @param otherVector defines the second operand
  83224. * @returns the resulting Vector3
  83225. */
  83226. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83227. /**
  83228. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83229. * @param otherVector defines the second operand
  83230. * @param result defines the Vector3 object where to store the result
  83231. * @returns the current Vector3
  83232. */
  83233. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83234. /**
  83235. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83236. * @param x defines the x coordinate of the operand
  83237. * @param y defines the y coordinate of the operand
  83238. * @param z defines the z coordinate of the operand
  83239. * @returns the resulting Vector3
  83240. */
  83241. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83242. /**
  83243. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83244. * @param x defines the x coordinate of the operand
  83245. * @param y defines the y coordinate of the operand
  83246. * @param z defines the z coordinate of the operand
  83247. * @param result defines the Vector3 object where to store the result
  83248. * @returns the current Vector3
  83249. */
  83250. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83251. /**
  83252. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83253. * @returns a new Vector3
  83254. */
  83255. negate(): Vector3;
  83256. /**
  83257. * Negate this vector in place
  83258. * @returns this
  83259. */
  83260. negateInPlace(): Vector3;
  83261. /**
  83262. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83263. * @param result defines the Vector3 object where to store the result
  83264. * @returns the current Vector3
  83265. */
  83266. negateToRef(result: Vector3): Vector3;
  83267. /**
  83268. * Multiplies the Vector3 coordinates by the float "scale"
  83269. * @param scale defines the multiplier factor
  83270. * @returns the current updated Vector3
  83271. */
  83272. scaleInPlace(scale: number): Vector3;
  83273. /**
  83274. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83275. * @param scale defines the multiplier factor
  83276. * @returns a new Vector3
  83277. */
  83278. scale(scale: number): Vector3;
  83279. /**
  83280. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83281. * @param scale defines the multiplier factor
  83282. * @param result defines the Vector3 object where to store the result
  83283. * @returns the current Vector3
  83284. */
  83285. scaleToRef(scale: number, result: Vector3): Vector3;
  83286. /**
  83287. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83288. * @param scale defines the scale factor
  83289. * @param result defines the Vector3 object where to store the result
  83290. * @returns the unmodified current Vector3
  83291. */
  83292. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83293. /**
  83294. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83295. * @param origin defines the origin of the projection ray
  83296. * @param plane defines the plane to project to
  83297. * @returns the projected vector3
  83298. */
  83299. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83300. /**
  83301. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83302. * @param origin defines the origin of the projection ray
  83303. * @param plane defines the plane to project to
  83304. * @param result defines the Vector3 where to store the result
  83305. */
  83306. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83307. /**
  83308. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83309. * @param otherVector defines the second operand
  83310. * @returns true if both vectors are equals
  83311. */
  83312. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83313. /**
  83314. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83315. * @param otherVector defines the second operand
  83316. * @param epsilon defines the minimal distance to define values as equals
  83317. * @returns true if both vectors are distant less than epsilon
  83318. */
  83319. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83320. /**
  83321. * Returns true if the current Vector3 coordinates equals the given floats
  83322. * @param x defines the x coordinate of the operand
  83323. * @param y defines the y coordinate of the operand
  83324. * @param z defines the z coordinate of the operand
  83325. * @returns true if both vectors are equals
  83326. */
  83327. equalsToFloats(x: number, y: number, z: number): boolean;
  83328. /**
  83329. * Multiplies the current Vector3 coordinates by the given ones
  83330. * @param otherVector defines the second operand
  83331. * @returns the current updated Vector3
  83332. */
  83333. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83334. /**
  83335. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83336. * @param otherVector defines the second operand
  83337. * @returns the new Vector3
  83338. */
  83339. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83340. /**
  83341. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83342. * @param otherVector defines the second operand
  83343. * @param result defines the Vector3 object where to store the result
  83344. * @returns the current Vector3
  83345. */
  83346. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83347. /**
  83348. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83349. * @param x defines the x coordinate of the operand
  83350. * @param y defines the y coordinate of the operand
  83351. * @param z defines the z coordinate of the operand
  83352. * @returns the new Vector3
  83353. */
  83354. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83355. /**
  83356. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83357. * @param otherVector defines the second operand
  83358. * @returns the new Vector3
  83359. */
  83360. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83361. /**
  83362. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83363. * @param otherVector defines the second operand
  83364. * @param result defines the Vector3 object where to store the result
  83365. * @returns the current Vector3
  83366. */
  83367. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83368. /**
  83369. * Divides the current Vector3 coordinates by the given ones.
  83370. * @param otherVector defines the second operand
  83371. * @returns the current updated Vector3
  83372. */
  83373. divideInPlace(otherVector: Vector3): Vector3;
  83374. /**
  83375. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83376. * @param other defines the second operand
  83377. * @returns the current updated Vector3
  83378. */
  83379. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83380. /**
  83381. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83382. * @param other defines the second operand
  83383. * @returns the current updated Vector3
  83384. */
  83385. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83386. /**
  83387. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83388. * @param x defines the x coordinate of the operand
  83389. * @param y defines the y coordinate of the operand
  83390. * @param z defines the z coordinate of the operand
  83391. * @returns the current updated Vector3
  83392. */
  83393. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83394. /**
  83395. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83396. * @param x defines the x coordinate of the operand
  83397. * @param y defines the y coordinate of the operand
  83398. * @param z defines the z coordinate of the operand
  83399. * @returns the current updated Vector3
  83400. */
  83401. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83402. /**
  83403. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83404. * Check if is non uniform within a certain amount of decimal places to account for this
  83405. * @param epsilon the amount the values can differ
  83406. * @returns if the the vector is non uniform to a certain number of decimal places
  83407. */
  83408. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83409. /**
  83410. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83411. */
  83412. get isNonUniform(): boolean;
  83413. /**
  83414. * Gets a new Vector3 from current Vector3 floored values
  83415. * @returns a new Vector3
  83416. */
  83417. floor(): Vector3;
  83418. /**
  83419. * Gets a new Vector3 from current Vector3 floored values
  83420. * @returns a new Vector3
  83421. */
  83422. fract(): Vector3;
  83423. /**
  83424. * Gets the length of the Vector3
  83425. * @returns the length of the Vector3
  83426. */
  83427. length(): number;
  83428. /**
  83429. * Gets the squared length of the Vector3
  83430. * @returns squared length of the Vector3
  83431. */
  83432. lengthSquared(): number;
  83433. /**
  83434. * Normalize the current Vector3.
  83435. * Please note that this is an in place operation.
  83436. * @returns the current updated Vector3
  83437. */
  83438. normalize(): Vector3;
  83439. /**
  83440. * Reorders the x y z properties of the vector in place
  83441. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83442. * @returns the current updated vector
  83443. */
  83444. reorderInPlace(order: string): this;
  83445. /**
  83446. * Rotates the vector around 0,0,0 by a quaternion
  83447. * @param quaternion the rotation quaternion
  83448. * @param result vector to store the result
  83449. * @returns the resulting vector
  83450. */
  83451. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83452. /**
  83453. * Rotates a vector around a given point
  83454. * @param quaternion the rotation quaternion
  83455. * @param point the point to rotate around
  83456. * @param result vector to store the result
  83457. * @returns the resulting vector
  83458. */
  83459. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83460. /**
  83461. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83462. * The cross product is then orthogonal to both current and "other"
  83463. * @param other defines the right operand
  83464. * @returns the cross product
  83465. */
  83466. cross(other: Vector3): Vector3;
  83467. /**
  83468. * Normalize the current Vector3 with the given input length.
  83469. * Please note that this is an in place operation.
  83470. * @param len the length of the vector
  83471. * @returns the current updated Vector3
  83472. */
  83473. normalizeFromLength(len: number): Vector3;
  83474. /**
  83475. * Normalize the current Vector3 to a new vector
  83476. * @returns the new Vector3
  83477. */
  83478. normalizeToNew(): Vector3;
  83479. /**
  83480. * Normalize the current Vector3 to the reference
  83481. * @param reference define the Vector3 to update
  83482. * @returns the updated Vector3
  83483. */
  83484. normalizeToRef(reference: Vector3): Vector3;
  83485. /**
  83486. * Creates a new Vector3 copied from the current Vector3
  83487. * @returns the new Vector3
  83488. */
  83489. clone(): Vector3;
  83490. /**
  83491. * Copies the given vector coordinates to the current Vector3 ones
  83492. * @param source defines the source Vector3
  83493. * @returns the current updated Vector3
  83494. */
  83495. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83496. /**
  83497. * Copies the given floats to the current Vector3 coordinates
  83498. * @param x defines the x coordinate of the operand
  83499. * @param y defines the y coordinate of the operand
  83500. * @param z defines the z coordinate of the operand
  83501. * @returns the current updated Vector3
  83502. */
  83503. copyFromFloats(x: number, y: number, z: number): Vector3;
  83504. /**
  83505. * Copies the given floats to the current Vector3 coordinates
  83506. * @param x defines the x coordinate of the operand
  83507. * @param y defines the y coordinate of the operand
  83508. * @param z defines the z coordinate of the operand
  83509. * @returns the current updated Vector3
  83510. */
  83511. set(x: number, y: number, z: number): Vector3;
  83512. /**
  83513. * Copies the given float to the current Vector3 coordinates
  83514. * @param v defines the x, y and z coordinates of the operand
  83515. * @returns the current updated Vector3
  83516. */
  83517. setAll(v: number): Vector3;
  83518. /**
  83519. * Get the clip factor between two vectors
  83520. * @param vector0 defines the first operand
  83521. * @param vector1 defines the second operand
  83522. * @param axis defines the axis to use
  83523. * @param size defines the size along the axis
  83524. * @returns the clip factor
  83525. */
  83526. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83527. /**
  83528. * Get angle between two vectors
  83529. * @param vector0 angle between vector0 and vector1
  83530. * @param vector1 angle between vector0 and vector1
  83531. * @param normal direction of the normal
  83532. * @return the angle between vector0 and vector1
  83533. */
  83534. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83535. /**
  83536. * Returns a new Vector3 set from the index "offset" of the given array
  83537. * @param array defines the source array
  83538. * @param offset defines the offset in the source array
  83539. * @returns the new Vector3
  83540. */
  83541. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83542. /**
  83543. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83544. * @param array defines the source array
  83545. * @param offset defines the offset in the source array
  83546. * @returns the new Vector3
  83547. * @deprecated Please use FromArray instead.
  83548. */
  83549. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83550. /**
  83551. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83552. * @param array defines the source array
  83553. * @param offset defines the offset in the source array
  83554. * @param result defines the Vector3 where to store the result
  83555. */
  83556. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83557. /**
  83558. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83559. * @param array defines the source array
  83560. * @param offset defines the offset in the source array
  83561. * @param result defines the Vector3 where to store the result
  83562. * @deprecated Please use FromArrayToRef instead.
  83563. */
  83564. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83565. /**
  83566. * Sets the given vector "result" with the given floats.
  83567. * @param x defines the x coordinate of the source
  83568. * @param y defines the y coordinate of the source
  83569. * @param z defines the z coordinate of the source
  83570. * @param result defines the Vector3 where to store the result
  83571. */
  83572. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83573. /**
  83574. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83575. * @returns a new empty Vector3
  83576. */
  83577. static Zero(): Vector3;
  83578. /**
  83579. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83580. * @returns a new unit Vector3
  83581. */
  83582. static One(): Vector3;
  83583. /**
  83584. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83585. * @returns a new up Vector3
  83586. */
  83587. static Up(): Vector3;
  83588. /**
  83589. * Gets a up Vector3 that must not be updated
  83590. */
  83591. static get UpReadOnly(): DeepImmutable<Vector3>;
  83592. /**
  83593. * Gets a zero Vector3 that must not be updated
  83594. */
  83595. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83596. /**
  83597. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83598. * @returns a new down Vector3
  83599. */
  83600. static Down(): Vector3;
  83601. /**
  83602. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83603. * @param rightHandedSystem is the scene right-handed (negative z)
  83604. * @returns a new forward Vector3
  83605. */
  83606. static Forward(rightHandedSystem?: boolean): Vector3;
  83607. /**
  83608. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83609. * @param rightHandedSystem is the scene right-handed (negative-z)
  83610. * @returns a new forward Vector3
  83611. */
  83612. static Backward(rightHandedSystem?: boolean): Vector3;
  83613. /**
  83614. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83615. * @returns a new right Vector3
  83616. */
  83617. static Right(): Vector3;
  83618. /**
  83619. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83620. * @returns a new left Vector3
  83621. */
  83622. static Left(): Vector3;
  83623. /**
  83624. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83625. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83626. * @param vector defines the Vector3 to transform
  83627. * @param transformation defines the transformation matrix
  83628. * @returns the transformed Vector3
  83629. */
  83630. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83631. /**
  83632. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83633. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83634. * @param vector defines the Vector3 to transform
  83635. * @param transformation defines the transformation matrix
  83636. * @param result defines the Vector3 where to store the result
  83637. */
  83638. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83639. /**
  83640. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83641. * This method computes tranformed coordinates only, not transformed direction vectors
  83642. * @param x define the x coordinate of the source vector
  83643. * @param y define the y coordinate of the source vector
  83644. * @param z define the z coordinate of the source vector
  83645. * @param transformation defines the transformation matrix
  83646. * @param result defines the Vector3 where to store the result
  83647. */
  83648. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83649. /**
  83650. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83651. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83652. * @param vector defines the Vector3 to transform
  83653. * @param transformation defines the transformation matrix
  83654. * @returns the new Vector3
  83655. */
  83656. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83657. /**
  83658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83659. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83660. * @param vector defines the Vector3 to transform
  83661. * @param transformation defines the transformation matrix
  83662. * @param result defines the Vector3 where to store the result
  83663. */
  83664. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83665. /**
  83666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83667. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83668. * @param x define the x coordinate of the source vector
  83669. * @param y define the y coordinate of the source vector
  83670. * @param z define the z coordinate of the source vector
  83671. * @param transformation defines the transformation matrix
  83672. * @param result defines the Vector3 where to store the result
  83673. */
  83674. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83675. /**
  83676. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83677. * @param value1 defines the first control point
  83678. * @param value2 defines the second control point
  83679. * @param value3 defines the third control point
  83680. * @param value4 defines the fourth control point
  83681. * @param amount defines the amount on the spline to use
  83682. * @returns the new Vector3
  83683. */
  83684. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83685. /**
  83686. * 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"
  83687. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83688. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83689. * @param value defines the current value
  83690. * @param min defines the lower range value
  83691. * @param max defines the upper range value
  83692. * @returns the new Vector3
  83693. */
  83694. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83695. /**
  83696. * 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"
  83697. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83698. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83699. * @param value defines the current value
  83700. * @param min defines the lower range value
  83701. * @param max defines the upper range value
  83702. * @param result defines the Vector3 where to store the result
  83703. */
  83704. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83705. /**
  83706. * Checks if a given vector is inside a specific range
  83707. * @param v defines the vector to test
  83708. * @param min defines the minimum range
  83709. * @param max defines the maximum range
  83710. */
  83711. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83712. /**
  83713. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83714. * @param value1 defines the first control point
  83715. * @param tangent1 defines the first tangent vector
  83716. * @param value2 defines the second control point
  83717. * @param tangent2 defines the second tangent vector
  83718. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83719. * @returns the new Vector3
  83720. */
  83721. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83722. /**
  83723. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83724. * @param start defines the start value
  83725. * @param end defines the end value
  83726. * @param amount max defines amount between both (between 0 and 1)
  83727. * @returns the new Vector3
  83728. */
  83729. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83730. /**
  83731. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83732. * @param start defines the start value
  83733. * @param end defines the end value
  83734. * @param amount max defines amount between both (between 0 and 1)
  83735. * @param result defines the Vector3 where to store the result
  83736. */
  83737. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83738. /**
  83739. * Returns the dot product (float) between the vectors "left" and "right"
  83740. * @param left defines the left operand
  83741. * @param right defines the right operand
  83742. * @returns the dot product
  83743. */
  83744. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83745. /**
  83746. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83747. * The cross product is then orthogonal to both "left" and "right"
  83748. * @param left defines the left operand
  83749. * @param right defines the right operand
  83750. * @returns the cross product
  83751. */
  83752. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83753. /**
  83754. * Sets the given vector "result" with the cross product of "left" and "right"
  83755. * The cross product is then orthogonal to both "left" and "right"
  83756. * @param left defines the left operand
  83757. * @param right defines the right operand
  83758. * @param result defines the Vector3 where to store the result
  83759. */
  83760. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83761. /**
  83762. * Returns a new Vector3 as the normalization of the given vector
  83763. * @param vector defines the Vector3 to normalize
  83764. * @returns the new Vector3
  83765. */
  83766. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83767. /**
  83768. * Sets the given vector "result" with the normalization of the given first vector
  83769. * @param vector defines the Vector3 to normalize
  83770. * @param result defines the Vector3 where to store the result
  83771. */
  83772. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83773. /**
  83774. * Project a Vector3 onto screen space
  83775. * @param vector defines the Vector3 to project
  83776. * @param world defines the world matrix to use
  83777. * @param transform defines the transform (view x projection) matrix to use
  83778. * @param viewport defines the screen viewport to use
  83779. * @returns the new Vector3
  83780. */
  83781. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83782. /** @hidden */
  83783. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83784. /**
  83785. * Unproject from screen space to object space
  83786. * @param source defines the screen space Vector3 to use
  83787. * @param viewportWidth defines the current width of the viewport
  83788. * @param viewportHeight defines the current height of the viewport
  83789. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83790. * @param transform defines the transform (view x projection) matrix to use
  83791. * @returns the new Vector3
  83792. */
  83793. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83794. /**
  83795. * Unproject from screen space to object space
  83796. * @param source defines the screen space Vector3 to use
  83797. * @param viewportWidth defines the current width of the viewport
  83798. * @param viewportHeight defines the current height of the viewport
  83799. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83800. * @param view defines the view matrix to use
  83801. * @param projection defines the projection matrix to use
  83802. * @returns the new Vector3
  83803. */
  83804. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83805. /**
  83806. * Unproject from screen space to object space
  83807. * @param source defines the screen space Vector3 to use
  83808. * @param viewportWidth defines the current width of the viewport
  83809. * @param viewportHeight defines the current height of the viewport
  83810. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83811. * @param view defines the view matrix to use
  83812. * @param projection defines the projection matrix to use
  83813. * @param result defines the Vector3 where to store the result
  83814. */
  83815. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83816. /**
  83817. * Unproject from screen space to object space
  83818. * @param sourceX defines the screen space x coordinate to use
  83819. * @param sourceY defines the screen space y coordinate to use
  83820. * @param sourceZ defines the screen space z coordinate to use
  83821. * @param viewportWidth defines the current width of the viewport
  83822. * @param viewportHeight defines the current height of the viewport
  83823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83824. * @param view defines the view matrix to use
  83825. * @param projection defines the projection matrix to use
  83826. * @param result defines the Vector3 where to store the result
  83827. */
  83828. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83829. /**
  83830. * Gets the minimal coordinate values between two Vector3
  83831. * @param left defines the first operand
  83832. * @param right defines the second operand
  83833. * @returns the new Vector3
  83834. */
  83835. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83836. /**
  83837. * Gets the maximal coordinate values between two Vector3
  83838. * @param left defines the first operand
  83839. * @param right defines the second operand
  83840. * @returns the new Vector3
  83841. */
  83842. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83843. /**
  83844. * Returns the distance between the vectors "value1" and "value2"
  83845. * @param value1 defines the first operand
  83846. * @param value2 defines the second operand
  83847. * @returns the distance
  83848. */
  83849. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83850. /**
  83851. * Returns the squared distance between the vectors "value1" and "value2"
  83852. * @param value1 defines the first operand
  83853. * @param value2 defines the second operand
  83854. * @returns the squared distance
  83855. */
  83856. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83857. /**
  83858. * Returns a new Vector3 located at the center between "value1" and "value2"
  83859. * @param value1 defines the first operand
  83860. * @param value2 defines the second operand
  83861. * @returns the new Vector3
  83862. */
  83863. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83864. /**
  83865. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83866. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83867. * to something in order to rotate it from its local system to the given target system
  83868. * Note: axis1, axis2 and axis3 are normalized during this operation
  83869. * @param axis1 defines the first axis
  83870. * @param axis2 defines the second axis
  83871. * @param axis3 defines the third axis
  83872. * @returns a new Vector3
  83873. */
  83874. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83875. /**
  83876. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83877. * @param axis1 defines the first axis
  83878. * @param axis2 defines the second axis
  83879. * @param axis3 defines the third axis
  83880. * @param ref defines the Vector3 where to store the result
  83881. */
  83882. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83883. }
  83884. /**
  83885. * Vector4 class created for EulerAngle class conversion to Quaternion
  83886. */
  83887. export class Vector4 {
  83888. /** x value of the vector */
  83889. x: number;
  83890. /** y value of the vector */
  83891. y: number;
  83892. /** z value of the vector */
  83893. z: number;
  83894. /** w value of the vector */
  83895. w: number;
  83896. /**
  83897. * Creates a Vector4 object from the given floats.
  83898. * @param x x value of the vector
  83899. * @param y y value of the vector
  83900. * @param z z value of the vector
  83901. * @param w w value of the vector
  83902. */
  83903. constructor(
  83904. /** x value of the vector */
  83905. x: number,
  83906. /** y value of the vector */
  83907. y: number,
  83908. /** z value of the vector */
  83909. z: number,
  83910. /** w value of the vector */
  83911. w: number);
  83912. /**
  83913. * Returns the string with the Vector4 coordinates.
  83914. * @returns a string containing all the vector values
  83915. */
  83916. toString(): string;
  83917. /**
  83918. * Returns the string "Vector4".
  83919. * @returns "Vector4"
  83920. */
  83921. getClassName(): string;
  83922. /**
  83923. * Returns the Vector4 hash code.
  83924. * @returns a unique hash code
  83925. */
  83926. getHashCode(): number;
  83927. /**
  83928. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83929. * @returns the resulting array
  83930. */
  83931. asArray(): number[];
  83932. /**
  83933. * Populates the given array from the given index with the Vector4 coordinates.
  83934. * @param array array to populate
  83935. * @param index index of the array to start at (default: 0)
  83936. * @returns the Vector4.
  83937. */
  83938. toArray(array: FloatArray, index?: number): Vector4;
  83939. /**
  83940. * Update the current vector from an array
  83941. * @param array defines the destination array
  83942. * @param index defines the offset in the destination array
  83943. * @returns the current Vector3
  83944. */
  83945. fromArray(array: FloatArray, index?: number): Vector4;
  83946. /**
  83947. * Adds the given vector to the current Vector4.
  83948. * @param otherVector the vector to add
  83949. * @returns the updated Vector4.
  83950. */
  83951. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83952. /**
  83953. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83954. * @param otherVector the vector to add
  83955. * @returns the resulting vector
  83956. */
  83957. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83958. /**
  83959. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83960. * @param otherVector the vector to add
  83961. * @param result the vector to store the result
  83962. * @returns the current Vector4.
  83963. */
  83964. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83965. /**
  83966. * Subtract in place the given vector from the current Vector4.
  83967. * @param otherVector the vector to subtract
  83968. * @returns the updated Vector4.
  83969. */
  83970. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83971. /**
  83972. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83973. * @param otherVector the vector to add
  83974. * @returns the new vector with the result
  83975. */
  83976. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83977. /**
  83978. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83979. * @param otherVector the vector to subtract
  83980. * @param result the vector to store the result
  83981. * @returns the current Vector4.
  83982. */
  83983. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83984. /**
  83985. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83986. */
  83987. /**
  83988. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83989. * @param x value to subtract
  83990. * @param y value to subtract
  83991. * @param z value to subtract
  83992. * @param w value to subtract
  83993. * @returns new vector containing the result
  83994. */
  83995. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83996. /**
  83997. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83998. * @param x value to subtract
  83999. * @param y value to subtract
  84000. * @param z value to subtract
  84001. * @param w value to subtract
  84002. * @param result the vector to store the result in
  84003. * @returns the current Vector4.
  84004. */
  84005. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84006. /**
  84007. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84008. * @returns a new vector with the negated values
  84009. */
  84010. negate(): Vector4;
  84011. /**
  84012. * Negate this vector in place
  84013. * @returns this
  84014. */
  84015. negateInPlace(): Vector4;
  84016. /**
  84017. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84018. * @param result defines the Vector3 object where to store the result
  84019. * @returns the current Vector4
  84020. */
  84021. negateToRef(result: Vector4): Vector4;
  84022. /**
  84023. * Multiplies the current Vector4 coordinates by scale (float).
  84024. * @param scale the number to scale with
  84025. * @returns the updated Vector4.
  84026. */
  84027. scaleInPlace(scale: number): Vector4;
  84028. /**
  84029. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84030. * @param scale the number to scale with
  84031. * @returns a new vector with the result
  84032. */
  84033. scale(scale: number): Vector4;
  84034. /**
  84035. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84036. * @param scale the number to scale with
  84037. * @param result a vector to store the result in
  84038. * @returns the current Vector4.
  84039. */
  84040. scaleToRef(scale: number, result: Vector4): Vector4;
  84041. /**
  84042. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84043. * @param scale defines the scale factor
  84044. * @param result defines the Vector4 object where to store the result
  84045. * @returns the unmodified current Vector4
  84046. */
  84047. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84048. /**
  84049. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84050. * @param otherVector the vector to compare against
  84051. * @returns true if they are equal
  84052. */
  84053. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84054. /**
  84055. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84056. * @param otherVector vector to compare against
  84057. * @param epsilon (Default: very small number)
  84058. * @returns true if they are equal
  84059. */
  84060. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84061. /**
  84062. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84063. * @param x x value to compare against
  84064. * @param y y value to compare against
  84065. * @param z z value to compare against
  84066. * @param w w value to compare against
  84067. * @returns true if equal
  84068. */
  84069. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84070. /**
  84071. * Multiplies in place the current Vector4 by the given one.
  84072. * @param otherVector vector to multiple with
  84073. * @returns the updated Vector4.
  84074. */
  84075. multiplyInPlace(otherVector: Vector4): Vector4;
  84076. /**
  84077. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84078. * @param otherVector vector to multiple with
  84079. * @returns resulting new vector
  84080. */
  84081. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84082. /**
  84083. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84084. * @param otherVector vector to multiple with
  84085. * @param result vector to store the result
  84086. * @returns the current Vector4.
  84087. */
  84088. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84089. /**
  84090. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84091. * @param x x value multiply with
  84092. * @param y y value multiply with
  84093. * @param z z value multiply with
  84094. * @param w w value multiply with
  84095. * @returns resulting new vector
  84096. */
  84097. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84098. /**
  84099. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84100. * @param otherVector vector to devide with
  84101. * @returns resulting new vector
  84102. */
  84103. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84104. /**
  84105. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84106. * @param otherVector vector to devide with
  84107. * @param result vector to store the result
  84108. * @returns the current Vector4.
  84109. */
  84110. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84111. /**
  84112. * Divides the current Vector3 coordinates by the given ones.
  84113. * @param otherVector vector to devide with
  84114. * @returns the updated Vector3.
  84115. */
  84116. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84117. /**
  84118. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84119. * @param other defines the second operand
  84120. * @returns the current updated Vector4
  84121. */
  84122. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84123. /**
  84124. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84125. * @param other defines the second operand
  84126. * @returns the current updated Vector4
  84127. */
  84128. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84129. /**
  84130. * Gets a new Vector4 from current Vector4 floored values
  84131. * @returns a new Vector4
  84132. */
  84133. floor(): Vector4;
  84134. /**
  84135. * Gets a new Vector4 from current Vector3 floored values
  84136. * @returns a new Vector4
  84137. */
  84138. fract(): Vector4;
  84139. /**
  84140. * Returns the Vector4 length (float).
  84141. * @returns the length
  84142. */
  84143. length(): number;
  84144. /**
  84145. * Returns the Vector4 squared length (float).
  84146. * @returns the length squared
  84147. */
  84148. lengthSquared(): number;
  84149. /**
  84150. * Normalizes in place the Vector4.
  84151. * @returns the updated Vector4.
  84152. */
  84153. normalize(): Vector4;
  84154. /**
  84155. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84156. * @returns this converted to a new vector3
  84157. */
  84158. toVector3(): Vector3;
  84159. /**
  84160. * Returns a new Vector4 copied from the current one.
  84161. * @returns the new cloned vector
  84162. */
  84163. clone(): Vector4;
  84164. /**
  84165. * Updates the current Vector4 with the given one coordinates.
  84166. * @param source the source vector to copy from
  84167. * @returns the updated Vector4.
  84168. */
  84169. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84170. /**
  84171. * Updates the current Vector4 coordinates with the given floats.
  84172. * @param x float to copy from
  84173. * @param y float to copy from
  84174. * @param z float to copy from
  84175. * @param w float to copy from
  84176. * @returns the updated Vector4.
  84177. */
  84178. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84179. /**
  84180. * Updates the current Vector4 coordinates with the given floats.
  84181. * @param x float to set from
  84182. * @param y float to set from
  84183. * @param z float to set from
  84184. * @param w float to set from
  84185. * @returns the updated Vector4.
  84186. */
  84187. set(x: number, y: number, z: number, w: number): Vector4;
  84188. /**
  84189. * Copies the given float to the current Vector3 coordinates
  84190. * @param v defines the x, y, z and w coordinates of the operand
  84191. * @returns the current updated Vector3
  84192. */
  84193. setAll(v: number): Vector4;
  84194. /**
  84195. * Returns a new Vector4 set from the starting index of the given array.
  84196. * @param array the array to pull values from
  84197. * @param offset the offset into the array to start at
  84198. * @returns the new vector
  84199. */
  84200. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84201. /**
  84202. * Updates the given vector "result" from the starting index of the given array.
  84203. * @param array the array to pull values from
  84204. * @param offset the offset into the array to start at
  84205. * @param result the vector to store the result in
  84206. */
  84207. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84208. /**
  84209. * Updates the given vector "result" from the starting index of the given Float32Array.
  84210. * @param array the array to pull values from
  84211. * @param offset the offset into the array to start at
  84212. * @param result the vector to store the result in
  84213. */
  84214. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84215. /**
  84216. * Updates the given vector "result" coordinates from the given floats.
  84217. * @param x float to set from
  84218. * @param y float to set from
  84219. * @param z float to set from
  84220. * @param w float to set from
  84221. * @param result the vector to the floats in
  84222. */
  84223. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84224. /**
  84225. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84226. * @returns the new vector
  84227. */
  84228. static Zero(): Vector4;
  84229. /**
  84230. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84231. * @returns the new vector
  84232. */
  84233. static One(): Vector4;
  84234. /**
  84235. * Returns a new normalized Vector4 from the given one.
  84236. * @param vector the vector to normalize
  84237. * @returns the vector
  84238. */
  84239. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84240. /**
  84241. * Updates the given vector "result" from the normalization of the given one.
  84242. * @param vector the vector to normalize
  84243. * @param result the vector to store the result in
  84244. */
  84245. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84246. /**
  84247. * Returns a vector with the minimum values from the left and right vectors
  84248. * @param left left vector to minimize
  84249. * @param right right vector to minimize
  84250. * @returns a new vector with the minimum of the left and right vector values
  84251. */
  84252. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84253. /**
  84254. * Returns a vector with the maximum values from the left and right vectors
  84255. * @param left left vector to maximize
  84256. * @param right right vector to maximize
  84257. * @returns a new vector with the maximum of the left and right vector values
  84258. */
  84259. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84260. /**
  84261. * Returns the distance (float) between the vectors "value1" and "value2".
  84262. * @param value1 value to calulate the distance between
  84263. * @param value2 value to calulate the distance between
  84264. * @return the distance between the two vectors
  84265. */
  84266. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84267. /**
  84268. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84269. * @param value1 value to calulate the distance between
  84270. * @param value2 value to calulate the distance between
  84271. * @return the distance between the two vectors squared
  84272. */
  84273. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84274. /**
  84275. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84276. * @param value1 value to calulate the center between
  84277. * @param value2 value to calulate the center between
  84278. * @return the center between the two vectors
  84279. */
  84280. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84281. /**
  84282. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84283. * This methods computes transformed normalized direction vectors only.
  84284. * @param vector the vector to transform
  84285. * @param transformation the transformation matrix to apply
  84286. * @returns the new vector
  84287. */
  84288. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84289. /**
  84290. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84291. * This methods computes transformed normalized direction vectors only.
  84292. * @param vector the vector to transform
  84293. * @param transformation the transformation matrix to apply
  84294. * @param result the vector to store the result in
  84295. */
  84296. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84297. /**
  84298. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84299. * This methods computes transformed normalized direction vectors only.
  84300. * @param x value to transform
  84301. * @param y value to transform
  84302. * @param z value to transform
  84303. * @param w value to transform
  84304. * @param transformation the transformation matrix to apply
  84305. * @param result the vector to store the results in
  84306. */
  84307. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84308. /**
  84309. * Creates a new Vector4 from a Vector3
  84310. * @param source defines the source data
  84311. * @param w defines the 4th component (default is 0)
  84312. * @returns a new Vector4
  84313. */
  84314. static FromVector3(source: Vector3, w?: number): Vector4;
  84315. }
  84316. /**
  84317. * Class used to store quaternion data
  84318. * @see https://en.wikipedia.org/wiki/Quaternion
  84319. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84320. */
  84321. export class Quaternion {
  84322. /** @hidden */
  84323. _x: number;
  84324. /** @hidden */
  84325. _y: number;
  84326. /** @hidden */
  84327. _z: number;
  84328. /** @hidden */
  84329. _w: number;
  84330. /** @hidden */
  84331. _isDirty: boolean;
  84332. /** Gets or sets the x coordinate */
  84333. get x(): number;
  84334. set x(value: number);
  84335. /** Gets or sets the y coordinate */
  84336. get y(): number;
  84337. set y(value: number);
  84338. /** Gets or sets the z coordinate */
  84339. get z(): number;
  84340. set z(value: number);
  84341. /** Gets or sets the w coordinate */
  84342. get w(): number;
  84343. set w(value: number);
  84344. /**
  84345. * Creates a new Quaternion from the given floats
  84346. * @param x defines the first component (0 by default)
  84347. * @param y defines the second component (0 by default)
  84348. * @param z defines the third component (0 by default)
  84349. * @param w defines the fourth component (1.0 by default)
  84350. */
  84351. constructor(x?: number, y?: number, z?: number, w?: number);
  84352. /**
  84353. * Gets a string representation for the current quaternion
  84354. * @returns a string with the Quaternion coordinates
  84355. */
  84356. toString(): string;
  84357. /**
  84358. * Gets the class name of the quaternion
  84359. * @returns the string "Quaternion"
  84360. */
  84361. getClassName(): string;
  84362. /**
  84363. * Gets a hash code for this quaternion
  84364. * @returns the quaternion hash code
  84365. */
  84366. getHashCode(): number;
  84367. /**
  84368. * Copy the quaternion to an array
  84369. * @returns a new array populated with 4 elements from the quaternion coordinates
  84370. */
  84371. asArray(): number[];
  84372. /**
  84373. * Check if two quaternions are equals
  84374. * @param otherQuaternion defines the second operand
  84375. * @return true if the current quaternion and the given one coordinates are strictly equals
  84376. */
  84377. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84378. /**
  84379. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84380. * @param otherQuaternion defines the other quaternion
  84381. * @param epsilon defines the minimal distance to consider equality
  84382. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84383. */
  84384. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84385. /**
  84386. * Clone the current quaternion
  84387. * @returns a new quaternion copied from the current one
  84388. */
  84389. clone(): Quaternion;
  84390. /**
  84391. * Copy a quaternion to the current one
  84392. * @param other defines the other quaternion
  84393. * @returns the updated current quaternion
  84394. */
  84395. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84396. /**
  84397. * Updates the current quaternion with the given float coordinates
  84398. * @param x defines the x coordinate
  84399. * @param y defines the y coordinate
  84400. * @param z defines the z coordinate
  84401. * @param w defines the w coordinate
  84402. * @returns the updated current quaternion
  84403. */
  84404. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84405. /**
  84406. * Updates the current quaternion from the given float coordinates
  84407. * @param x defines the x coordinate
  84408. * @param y defines the y coordinate
  84409. * @param z defines the z coordinate
  84410. * @param w defines the w coordinate
  84411. * @returns the updated current quaternion
  84412. */
  84413. set(x: number, y: number, z: number, w: number): Quaternion;
  84414. /**
  84415. * Adds two quaternions
  84416. * @param other defines the second operand
  84417. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84418. */
  84419. add(other: DeepImmutable<Quaternion>): Quaternion;
  84420. /**
  84421. * Add a quaternion to the current one
  84422. * @param other defines the quaternion to add
  84423. * @returns the current quaternion
  84424. */
  84425. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84426. /**
  84427. * Subtract two quaternions
  84428. * @param other defines the second operand
  84429. * @returns a new quaternion as the subtraction result of the given one from the current one
  84430. */
  84431. subtract(other: Quaternion): Quaternion;
  84432. /**
  84433. * Multiplies the current quaternion by a scale factor
  84434. * @param value defines the scale factor
  84435. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84436. */
  84437. scale(value: number): Quaternion;
  84438. /**
  84439. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84440. * @param scale defines the scale factor
  84441. * @param result defines the Quaternion object where to store the result
  84442. * @returns the unmodified current quaternion
  84443. */
  84444. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84445. /**
  84446. * Multiplies in place the current quaternion by a scale factor
  84447. * @param value defines the scale factor
  84448. * @returns the current modified quaternion
  84449. */
  84450. scaleInPlace(value: number): Quaternion;
  84451. /**
  84452. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84453. * @param scale defines the scale factor
  84454. * @param result defines the Quaternion object where to store the result
  84455. * @returns the unmodified current quaternion
  84456. */
  84457. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84458. /**
  84459. * Multiplies two quaternions
  84460. * @param q1 defines the second operand
  84461. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84462. */
  84463. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84464. /**
  84465. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84466. * @param q1 defines the second operand
  84467. * @param result defines the target quaternion
  84468. * @returns the current quaternion
  84469. */
  84470. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84471. /**
  84472. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84473. * @param q1 defines the second operand
  84474. * @returns the currentupdated quaternion
  84475. */
  84476. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84477. /**
  84478. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84479. * @param ref defines the target quaternion
  84480. * @returns the current quaternion
  84481. */
  84482. conjugateToRef(ref: Quaternion): Quaternion;
  84483. /**
  84484. * Conjugates in place (1-q) the current quaternion
  84485. * @returns the current updated quaternion
  84486. */
  84487. conjugateInPlace(): Quaternion;
  84488. /**
  84489. * Conjugates in place (1-q) the current quaternion
  84490. * @returns a new quaternion
  84491. */
  84492. conjugate(): Quaternion;
  84493. /**
  84494. * Gets length of current quaternion
  84495. * @returns the quaternion length (float)
  84496. */
  84497. length(): number;
  84498. /**
  84499. * Normalize in place the current quaternion
  84500. * @returns the current updated quaternion
  84501. */
  84502. normalize(): Quaternion;
  84503. /**
  84504. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84505. * @param order is a reserved parameter and is ignored for now
  84506. * @returns a new Vector3 containing the Euler angles
  84507. */
  84508. toEulerAngles(order?: string): Vector3;
  84509. /**
  84510. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84511. * @param result defines the vector which will be filled with the Euler angles
  84512. * @returns the current unchanged quaternion
  84513. */
  84514. toEulerAnglesToRef(result: Vector3): Quaternion;
  84515. /**
  84516. * Updates the given rotation matrix with the current quaternion values
  84517. * @param result defines the target matrix
  84518. * @returns the current unchanged quaternion
  84519. */
  84520. toRotationMatrix(result: Matrix): Quaternion;
  84521. /**
  84522. * Updates the current quaternion from the given rotation matrix values
  84523. * @param matrix defines the source matrix
  84524. * @returns the current updated quaternion
  84525. */
  84526. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84527. /**
  84528. * Creates a new quaternion from a rotation matrix
  84529. * @param matrix defines the source matrix
  84530. * @returns a new quaternion created from the given rotation matrix values
  84531. */
  84532. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84533. /**
  84534. * Updates the given quaternion with the given rotation matrix values
  84535. * @param matrix defines the source matrix
  84536. * @param result defines the target quaternion
  84537. */
  84538. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84539. /**
  84540. * Returns the dot product (float) between the quaternions "left" and "right"
  84541. * @param left defines the left operand
  84542. * @param right defines the right operand
  84543. * @returns the dot product
  84544. */
  84545. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84546. /**
  84547. * Checks if the two quaternions are close to each other
  84548. * @param quat0 defines the first quaternion to check
  84549. * @param quat1 defines the second quaternion to check
  84550. * @returns true if the two quaternions are close to each other
  84551. */
  84552. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84553. /**
  84554. * Creates an empty quaternion
  84555. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84556. */
  84557. static Zero(): Quaternion;
  84558. /**
  84559. * Inverse a given quaternion
  84560. * @param q defines the source quaternion
  84561. * @returns a new quaternion as the inverted current quaternion
  84562. */
  84563. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84564. /**
  84565. * Inverse a given quaternion
  84566. * @param q defines the source quaternion
  84567. * @param result the quaternion the result will be stored in
  84568. * @returns the result quaternion
  84569. */
  84570. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84571. /**
  84572. * Creates an identity quaternion
  84573. * @returns the identity quaternion
  84574. */
  84575. static Identity(): Quaternion;
  84576. /**
  84577. * Gets a boolean indicating if the given quaternion is identity
  84578. * @param quaternion defines the quaternion to check
  84579. * @returns true if the quaternion is identity
  84580. */
  84581. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84582. /**
  84583. * Creates a quaternion from a rotation around an axis
  84584. * @param axis defines the axis to use
  84585. * @param angle defines the angle to use
  84586. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84587. */
  84588. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84589. /**
  84590. * Creates a rotation around an axis and stores it into the given quaternion
  84591. * @param axis defines the axis to use
  84592. * @param angle defines the angle to use
  84593. * @param result defines the target quaternion
  84594. * @returns the target quaternion
  84595. */
  84596. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84597. /**
  84598. * Creates a new quaternion from data stored into an array
  84599. * @param array defines the data source
  84600. * @param offset defines the offset in the source array where the data starts
  84601. * @returns a new quaternion
  84602. */
  84603. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84604. /**
  84605. * Updates the given quaternion "result" from the starting index of the given array.
  84606. * @param array the array to pull values from
  84607. * @param offset the offset into the array to start at
  84608. * @param result the quaternion to store the result in
  84609. */
  84610. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84611. /**
  84612. * Create a quaternion from Euler rotation angles
  84613. * @param x Pitch
  84614. * @param y Yaw
  84615. * @param z Roll
  84616. * @returns the new Quaternion
  84617. */
  84618. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84619. /**
  84620. * Updates a quaternion from Euler rotation angles
  84621. * @param x Pitch
  84622. * @param y Yaw
  84623. * @param z Roll
  84624. * @param result the quaternion to store the result
  84625. * @returns the updated quaternion
  84626. */
  84627. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84628. /**
  84629. * Create a quaternion from Euler rotation vector
  84630. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84631. * @returns the new Quaternion
  84632. */
  84633. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84634. /**
  84635. * Updates a quaternion from Euler rotation vector
  84636. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84637. * @param result the quaternion to store the result
  84638. * @returns the updated quaternion
  84639. */
  84640. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84641. /**
  84642. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84643. * @param yaw defines the rotation around Y axis
  84644. * @param pitch defines the rotation around X axis
  84645. * @param roll defines the rotation around Z axis
  84646. * @returns the new quaternion
  84647. */
  84648. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84649. /**
  84650. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84651. * @param yaw defines the rotation around Y axis
  84652. * @param pitch defines the rotation around X axis
  84653. * @param roll defines the rotation around Z axis
  84654. * @param result defines the target quaternion
  84655. */
  84656. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84657. /**
  84658. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84659. * @param alpha defines the rotation around first axis
  84660. * @param beta defines the rotation around second axis
  84661. * @param gamma defines the rotation around third axis
  84662. * @returns the new quaternion
  84663. */
  84664. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84665. /**
  84666. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84667. * @param alpha defines the rotation around first axis
  84668. * @param beta defines the rotation around second axis
  84669. * @param gamma defines the rotation around third axis
  84670. * @param result defines the target quaternion
  84671. */
  84672. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84673. /**
  84674. * 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)
  84675. * @param axis1 defines the first axis
  84676. * @param axis2 defines the second axis
  84677. * @param axis3 defines the third axis
  84678. * @returns the new quaternion
  84679. */
  84680. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84681. /**
  84682. * 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
  84683. * @param axis1 defines the first axis
  84684. * @param axis2 defines the second axis
  84685. * @param axis3 defines the third axis
  84686. * @param ref defines the target quaternion
  84687. */
  84688. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84689. /**
  84690. * Interpolates between two quaternions
  84691. * @param left defines first quaternion
  84692. * @param right defines second quaternion
  84693. * @param amount defines the gradient to use
  84694. * @returns the new interpolated quaternion
  84695. */
  84696. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84697. /**
  84698. * Interpolates between two quaternions and stores it into a target quaternion
  84699. * @param left defines first quaternion
  84700. * @param right defines second quaternion
  84701. * @param amount defines the gradient to use
  84702. * @param result defines the target quaternion
  84703. */
  84704. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84705. /**
  84706. * Interpolate between two quaternions using Hermite interpolation
  84707. * @param value1 defines first quaternion
  84708. * @param tangent1 defines the incoming tangent
  84709. * @param value2 defines second quaternion
  84710. * @param tangent2 defines the outgoing tangent
  84711. * @param amount defines the target quaternion
  84712. * @returns the new interpolated quaternion
  84713. */
  84714. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84715. }
  84716. /**
  84717. * Class used to store matrix data (4x4)
  84718. */
  84719. export class Matrix {
  84720. /**
  84721. * Gets the precision of matrix computations
  84722. */
  84723. static get Use64Bits(): boolean;
  84724. private static _updateFlagSeed;
  84725. private static _identityReadOnly;
  84726. private _isIdentity;
  84727. private _isIdentityDirty;
  84728. private _isIdentity3x2;
  84729. private _isIdentity3x2Dirty;
  84730. /**
  84731. * Gets the update flag of the matrix which is an unique number for the matrix.
  84732. * It will be incremented every time the matrix data change.
  84733. * You can use it to speed the comparison between two versions of the same matrix.
  84734. */
  84735. updateFlag: number;
  84736. private readonly _m;
  84737. /**
  84738. * Gets the internal data of the matrix
  84739. */
  84740. get m(): DeepImmutable<Float32Array | Array<number>>;
  84741. /** @hidden */
  84742. _markAsUpdated(): void;
  84743. /** @hidden */
  84744. private _updateIdentityStatus;
  84745. /**
  84746. * Creates an empty matrix (filled with zeros)
  84747. */
  84748. constructor();
  84749. /**
  84750. * Check if the current matrix is identity
  84751. * @returns true is the matrix is the identity matrix
  84752. */
  84753. isIdentity(): boolean;
  84754. /**
  84755. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84756. * @returns true is the matrix is the identity matrix
  84757. */
  84758. isIdentityAs3x2(): boolean;
  84759. /**
  84760. * Gets the determinant of the matrix
  84761. * @returns the matrix determinant
  84762. */
  84763. determinant(): number;
  84764. /**
  84765. * Returns the matrix as a Float32Array or Array<number>
  84766. * @returns the matrix underlying array
  84767. */
  84768. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84769. /**
  84770. * Returns the matrix as a Float32Array or Array<number>
  84771. * @returns the matrix underlying array.
  84772. */
  84773. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84774. /**
  84775. * Inverts the current matrix in place
  84776. * @returns the current inverted matrix
  84777. */
  84778. invert(): Matrix;
  84779. /**
  84780. * Sets all the matrix elements to zero
  84781. * @returns the current matrix
  84782. */
  84783. reset(): Matrix;
  84784. /**
  84785. * Adds the current matrix with a second one
  84786. * @param other defines the matrix to add
  84787. * @returns a new matrix as the addition of the current matrix and the given one
  84788. */
  84789. add(other: DeepImmutable<Matrix>): Matrix;
  84790. /**
  84791. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84792. * @param other defines the matrix to add
  84793. * @param result defines the target matrix
  84794. * @returns the current matrix
  84795. */
  84796. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84797. /**
  84798. * Adds in place the given matrix to the current matrix
  84799. * @param other defines the second operand
  84800. * @returns the current updated matrix
  84801. */
  84802. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84803. /**
  84804. * Sets the given matrix to the current inverted Matrix
  84805. * @param other defines the target matrix
  84806. * @returns the unmodified current matrix
  84807. */
  84808. invertToRef(other: Matrix): Matrix;
  84809. /**
  84810. * add a value at the specified position in the current Matrix
  84811. * @param index the index of the value within the matrix. between 0 and 15.
  84812. * @param value the value to be added
  84813. * @returns the current updated matrix
  84814. */
  84815. addAtIndex(index: number, value: number): Matrix;
  84816. /**
  84817. * mutiply the specified position in the current Matrix by a value
  84818. * @param index the index of the value within the matrix. between 0 and 15.
  84819. * @param value the value to be added
  84820. * @returns the current updated matrix
  84821. */
  84822. multiplyAtIndex(index: number, value: number): Matrix;
  84823. /**
  84824. * Inserts the translation vector (using 3 floats) in the current matrix
  84825. * @param x defines the 1st component of the translation
  84826. * @param y defines the 2nd component of the translation
  84827. * @param z defines the 3rd component of the translation
  84828. * @returns the current updated matrix
  84829. */
  84830. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84831. /**
  84832. * Adds the translation vector (using 3 floats) in the current matrix
  84833. * @param x defines the 1st component of the translation
  84834. * @param y defines the 2nd component of the translation
  84835. * @param z defines the 3rd component of the translation
  84836. * @returns the current updated matrix
  84837. */
  84838. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84839. /**
  84840. * Inserts the translation vector in the current matrix
  84841. * @param vector3 defines the translation to insert
  84842. * @returns the current updated matrix
  84843. */
  84844. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84845. /**
  84846. * Gets the translation value of the current matrix
  84847. * @returns a new Vector3 as the extracted translation from the matrix
  84848. */
  84849. getTranslation(): Vector3;
  84850. /**
  84851. * Fill a Vector3 with the extracted translation from the matrix
  84852. * @param result defines the Vector3 where to store the translation
  84853. * @returns the current matrix
  84854. */
  84855. getTranslationToRef(result: Vector3): Matrix;
  84856. /**
  84857. * Remove rotation and scaling part from the matrix
  84858. * @returns the updated matrix
  84859. */
  84860. removeRotationAndScaling(): Matrix;
  84861. /**
  84862. * Multiply two matrices
  84863. * @param other defines the second operand
  84864. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84865. */
  84866. multiply(other: DeepImmutable<Matrix>): Matrix;
  84867. /**
  84868. * Copy the current matrix from the given one
  84869. * @param other defines the source matrix
  84870. * @returns the current updated matrix
  84871. */
  84872. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84873. /**
  84874. * Populates the given array from the starting index with the current matrix values
  84875. * @param array defines the target array
  84876. * @param offset defines the offset in the target array where to start storing values
  84877. * @returns the current matrix
  84878. */
  84879. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84880. /**
  84881. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84882. * @param other defines the second operand
  84883. * @param result defines the matrix where to store the multiplication
  84884. * @returns the current matrix
  84885. */
  84886. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84887. /**
  84888. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84889. * @param other defines the second operand
  84890. * @param result defines the array where to store the multiplication
  84891. * @param offset defines the offset in the target array where to start storing values
  84892. * @returns the current matrix
  84893. */
  84894. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84895. /**
  84896. * Check equality between this matrix and a second one
  84897. * @param value defines the second matrix to compare
  84898. * @returns true is the current matrix and the given one values are strictly equal
  84899. */
  84900. equals(value: DeepImmutable<Matrix>): boolean;
  84901. /**
  84902. * Clone the current matrix
  84903. * @returns a new matrix from the current matrix
  84904. */
  84905. clone(): Matrix;
  84906. /**
  84907. * Returns the name of the current matrix class
  84908. * @returns the string "Matrix"
  84909. */
  84910. getClassName(): string;
  84911. /**
  84912. * Gets the hash code of the current matrix
  84913. * @returns the hash code
  84914. */
  84915. getHashCode(): number;
  84916. /**
  84917. * Decomposes the current Matrix into a translation, rotation and scaling components
  84918. * @param scale defines the scale vector3 given as a reference to update
  84919. * @param rotation defines the rotation quaternion given as a reference to update
  84920. * @param translation defines the translation vector3 given as a reference to update
  84921. * @returns true if operation was successful
  84922. */
  84923. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84924. /**
  84925. * Gets specific row of the matrix
  84926. * @param index defines the number of the row to get
  84927. * @returns the index-th row of the current matrix as a new Vector4
  84928. */
  84929. getRow(index: number): Nullable<Vector4>;
  84930. /**
  84931. * Sets the index-th row of the current matrix to the vector4 values
  84932. * @param index defines the number of the row to set
  84933. * @param row defines the target vector4
  84934. * @returns the updated current matrix
  84935. */
  84936. setRow(index: number, row: Vector4): Matrix;
  84937. /**
  84938. * Compute the transpose of the matrix
  84939. * @returns the new transposed matrix
  84940. */
  84941. transpose(): Matrix;
  84942. /**
  84943. * Compute the transpose of the matrix and store it in a given matrix
  84944. * @param result defines the target matrix
  84945. * @returns the current matrix
  84946. */
  84947. transposeToRef(result: Matrix): Matrix;
  84948. /**
  84949. * Sets the index-th row of the current matrix with the given 4 x float values
  84950. * @param index defines the row index
  84951. * @param x defines the x component to set
  84952. * @param y defines the y component to set
  84953. * @param z defines the z component to set
  84954. * @param w defines the w component to set
  84955. * @returns the updated current matrix
  84956. */
  84957. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84958. /**
  84959. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84960. * @param scale defines the scale factor
  84961. * @returns a new matrix
  84962. */
  84963. scale(scale: number): Matrix;
  84964. /**
  84965. * Scale the current matrix values by a factor to a given result matrix
  84966. * @param scale defines the scale factor
  84967. * @param result defines the matrix to store the result
  84968. * @returns the current matrix
  84969. */
  84970. scaleToRef(scale: number, result: Matrix): Matrix;
  84971. /**
  84972. * Scale the current matrix values by a factor and add the result to a given matrix
  84973. * @param scale defines the scale factor
  84974. * @param result defines the Matrix to store the result
  84975. * @returns the current matrix
  84976. */
  84977. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84978. /**
  84979. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84980. * @param ref matrix to store the result
  84981. */
  84982. toNormalMatrix(ref: Matrix): void;
  84983. /**
  84984. * Gets only rotation part of the current matrix
  84985. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84986. */
  84987. getRotationMatrix(): Matrix;
  84988. /**
  84989. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84990. * @param result defines the target matrix to store data to
  84991. * @returns the current matrix
  84992. */
  84993. getRotationMatrixToRef(result: Matrix): Matrix;
  84994. /**
  84995. * Toggles model matrix from being right handed to left handed in place and vice versa
  84996. */
  84997. toggleModelMatrixHandInPlace(): void;
  84998. /**
  84999. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85000. */
  85001. toggleProjectionMatrixHandInPlace(): void;
  85002. /**
  85003. * Creates a matrix from an array
  85004. * @param array defines the source array
  85005. * @param offset defines an offset in the source array
  85006. * @returns a new Matrix set from the starting index of the given array
  85007. */
  85008. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85009. /**
  85010. * Copy the content of an array into a given matrix
  85011. * @param array defines the source array
  85012. * @param offset defines an offset in the source array
  85013. * @param result defines the target matrix
  85014. */
  85015. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85016. /**
  85017. * Stores an array into a matrix after having multiplied each component by a given factor
  85018. * @param array defines the source array
  85019. * @param offset defines the offset in the source array
  85020. * @param scale defines the scaling factor
  85021. * @param result defines the target matrix
  85022. */
  85023. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85024. /**
  85025. * Gets an identity matrix that must not be updated
  85026. */
  85027. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85028. /**
  85029. * Stores a list of values (16) inside a given matrix
  85030. * @param initialM11 defines 1st value of 1st row
  85031. * @param initialM12 defines 2nd value of 1st row
  85032. * @param initialM13 defines 3rd value of 1st row
  85033. * @param initialM14 defines 4th value of 1st row
  85034. * @param initialM21 defines 1st value of 2nd row
  85035. * @param initialM22 defines 2nd value of 2nd row
  85036. * @param initialM23 defines 3rd value of 2nd row
  85037. * @param initialM24 defines 4th value of 2nd row
  85038. * @param initialM31 defines 1st value of 3rd row
  85039. * @param initialM32 defines 2nd value of 3rd row
  85040. * @param initialM33 defines 3rd value of 3rd row
  85041. * @param initialM34 defines 4th value of 3rd row
  85042. * @param initialM41 defines 1st value of 4th row
  85043. * @param initialM42 defines 2nd value of 4th row
  85044. * @param initialM43 defines 3rd value of 4th row
  85045. * @param initialM44 defines 4th value of 4th row
  85046. * @param result defines the target matrix
  85047. */
  85048. 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;
  85049. /**
  85050. * Creates new matrix from a list of values (16)
  85051. * @param initialM11 defines 1st value of 1st row
  85052. * @param initialM12 defines 2nd value of 1st row
  85053. * @param initialM13 defines 3rd value of 1st row
  85054. * @param initialM14 defines 4th value of 1st row
  85055. * @param initialM21 defines 1st value of 2nd row
  85056. * @param initialM22 defines 2nd value of 2nd row
  85057. * @param initialM23 defines 3rd value of 2nd row
  85058. * @param initialM24 defines 4th value of 2nd row
  85059. * @param initialM31 defines 1st value of 3rd row
  85060. * @param initialM32 defines 2nd value of 3rd row
  85061. * @param initialM33 defines 3rd value of 3rd row
  85062. * @param initialM34 defines 4th value of 3rd row
  85063. * @param initialM41 defines 1st value of 4th row
  85064. * @param initialM42 defines 2nd value of 4th row
  85065. * @param initialM43 defines 3rd value of 4th row
  85066. * @param initialM44 defines 4th value of 4th row
  85067. * @returns the new matrix
  85068. */
  85069. 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;
  85070. /**
  85071. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85072. * @param scale defines the scale vector3
  85073. * @param rotation defines the rotation quaternion
  85074. * @param translation defines the translation vector3
  85075. * @returns a new matrix
  85076. */
  85077. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85078. /**
  85079. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85080. * @param scale defines the scale vector3
  85081. * @param rotation defines the rotation quaternion
  85082. * @param translation defines the translation vector3
  85083. * @param result defines the target matrix
  85084. */
  85085. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85086. /**
  85087. * Creates a new identity matrix
  85088. * @returns a new identity matrix
  85089. */
  85090. static Identity(): Matrix;
  85091. /**
  85092. * Creates a new identity matrix and stores the result in a given matrix
  85093. * @param result defines the target matrix
  85094. */
  85095. static IdentityToRef(result: Matrix): void;
  85096. /**
  85097. * Creates a new zero matrix
  85098. * @returns a new zero matrix
  85099. */
  85100. static Zero(): Matrix;
  85101. /**
  85102. * Creates a new rotation matrix for "angle" radians around the X axis
  85103. * @param angle defines the angle (in radians) to use
  85104. * @return the new matrix
  85105. */
  85106. static RotationX(angle: number): Matrix;
  85107. /**
  85108. * Creates a new matrix as the invert of a given matrix
  85109. * @param source defines the source matrix
  85110. * @returns the new matrix
  85111. */
  85112. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85113. /**
  85114. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85115. * @param angle defines the angle (in radians) to use
  85116. * @param result defines the target matrix
  85117. */
  85118. static RotationXToRef(angle: number, result: Matrix): void;
  85119. /**
  85120. * Creates a new rotation matrix for "angle" radians around the Y axis
  85121. * @param angle defines the angle (in radians) to use
  85122. * @return the new matrix
  85123. */
  85124. static RotationY(angle: number): Matrix;
  85125. /**
  85126. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85127. * @param angle defines the angle (in radians) to use
  85128. * @param result defines the target matrix
  85129. */
  85130. static RotationYToRef(angle: number, result: Matrix): void;
  85131. /**
  85132. * Creates a new rotation matrix for "angle" radians around the Z axis
  85133. * @param angle defines the angle (in radians) to use
  85134. * @return the new matrix
  85135. */
  85136. static RotationZ(angle: number): Matrix;
  85137. /**
  85138. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85139. * @param angle defines the angle (in radians) to use
  85140. * @param result defines the target matrix
  85141. */
  85142. static RotationZToRef(angle: number, result: Matrix): void;
  85143. /**
  85144. * Creates a new rotation matrix for "angle" radians around the given axis
  85145. * @param axis defines the axis to use
  85146. * @param angle defines the angle (in radians) to use
  85147. * @return the new matrix
  85148. */
  85149. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85150. /**
  85151. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85152. * @param axis defines the axis to use
  85153. * @param angle defines the angle (in radians) to use
  85154. * @param result defines the target matrix
  85155. */
  85156. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85157. /**
  85158. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85159. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85160. * @param from defines the vector to align
  85161. * @param to defines the vector to align to
  85162. * @param result defines the target matrix
  85163. */
  85164. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85165. /**
  85166. * Creates a rotation matrix
  85167. * @param yaw defines the yaw angle in radians (Y axis)
  85168. * @param pitch defines the pitch angle in radians (X axis)
  85169. * @param roll defines the roll angle in radians (Z axis)
  85170. * @returns the new rotation matrix
  85171. */
  85172. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85173. /**
  85174. * Creates a rotation matrix and stores it in a given matrix
  85175. * @param yaw defines the yaw angle in radians (Y axis)
  85176. * @param pitch defines the pitch angle in radians (X axis)
  85177. * @param roll defines the roll angle in radians (Z axis)
  85178. * @param result defines the target matrix
  85179. */
  85180. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85181. /**
  85182. * Creates a scaling matrix
  85183. * @param x defines the scale factor on X axis
  85184. * @param y defines the scale factor on Y axis
  85185. * @param z defines the scale factor on Z axis
  85186. * @returns the new matrix
  85187. */
  85188. static Scaling(x: number, y: number, z: number): Matrix;
  85189. /**
  85190. * Creates a scaling matrix and stores it in a given matrix
  85191. * @param x defines the scale factor on X axis
  85192. * @param y defines the scale factor on Y axis
  85193. * @param z defines the scale factor on Z axis
  85194. * @param result defines the target matrix
  85195. */
  85196. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85197. /**
  85198. * Creates a translation matrix
  85199. * @param x defines the translation on X axis
  85200. * @param y defines the translation on Y axis
  85201. * @param z defines the translationon Z axis
  85202. * @returns the new matrix
  85203. */
  85204. static Translation(x: number, y: number, z: number): Matrix;
  85205. /**
  85206. * Creates a translation matrix and stores it in a given matrix
  85207. * @param x defines the translation on X axis
  85208. * @param y defines the translation on Y axis
  85209. * @param z defines the translationon Z axis
  85210. * @param result defines the target matrix
  85211. */
  85212. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85213. /**
  85214. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85215. * @param startValue defines the start value
  85216. * @param endValue defines the end value
  85217. * @param gradient defines the gradient factor
  85218. * @returns the new matrix
  85219. */
  85220. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85221. /**
  85222. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85223. * @param startValue defines the start value
  85224. * @param endValue defines the end value
  85225. * @param gradient defines the gradient factor
  85226. * @param result defines the Matrix object where to store data
  85227. */
  85228. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85229. /**
  85230. * Builds a new matrix whose values are computed by:
  85231. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85232. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85233. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85234. * @param startValue defines the first matrix
  85235. * @param endValue defines the second matrix
  85236. * @param gradient defines the gradient between the two matrices
  85237. * @returns the new matrix
  85238. */
  85239. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85240. /**
  85241. * Update a matrix to values which are computed by:
  85242. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85243. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85244. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85245. * @param startValue defines the first matrix
  85246. * @param endValue defines the second matrix
  85247. * @param gradient defines the gradient between the two matrices
  85248. * @param result defines the target matrix
  85249. */
  85250. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85251. /**
  85252. * 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"
  85253. * This function works in left handed mode
  85254. * @param eye defines the final position of the entity
  85255. * @param target defines where the entity should look at
  85256. * @param up defines the up vector for the entity
  85257. * @returns the new matrix
  85258. */
  85259. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85260. /**
  85261. * 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".
  85262. * This function works in left handed mode
  85263. * @param eye defines the final position of the entity
  85264. * @param target defines where the entity should look at
  85265. * @param up defines the up vector for the entity
  85266. * @param result defines the target matrix
  85267. */
  85268. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85269. /**
  85270. * 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"
  85271. * This function works in right handed mode
  85272. * @param eye defines the final position of the entity
  85273. * @param target defines where the entity should look at
  85274. * @param up defines the up vector for the entity
  85275. * @returns the new matrix
  85276. */
  85277. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85278. /**
  85279. * 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".
  85280. * This function works in right handed mode
  85281. * @param eye defines the final position of the entity
  85282. * @param target defines where the entity should look at
  85283. * @param up defines the up vector for the entity
  85284. * @param result defines the target matrix
  85285. */
  85286. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85287. /**
  85288. * Create a left-handed orthographic projection matrix
  85289. * @param width defines the viewport width
  85290. * @param height defines the viewport height
  85291. * @param znear defines the near clip plane
  85292. * @param zfar defines the far clip plane
  85293. * @returns a new matrix as a left-handed orthographic projection matrix
  85294. */
  85295. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85296. /**
  85297. * Store a left-handed orthographic projection to a given matrix
  85298. * @param width defines the viewport width
  85299. * @param height defines the viewport height
  85300. * @param znear defines the near clip plane
  85301. * @param zfar defines the far clip plane
  85302. * @param result defines the target matrix
  85303. */
  85304. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85305. /**
  85306. * Create a left-handed orthographic projection matrix
  85307. * @param left defines the viewport left coordinate
  85308. * @param right defines the viewport right coordinate
  85309. * @param bottom defines the viewport bottom coordinate
  85310. * @param top defines the viewport top coordinate
  85311. * @param znear defines the near clip plane
  85312. * @param zfar defines the far clip plane
  85313. * @returns a new matrix as a left-handed orthographic projection matrix
  85314. */
  85315. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85316. /**
  85317. * Stores a left-handed orthographic projection into a given matrix
  85318. * @param left defines the viewport left coordinate
  85319. * @param right defines the viewport right coordinate
  85320. * @param bottom defines the viewport bottom coordinate
  85321. * @param top defines the viewport top coordinate
  85322. * @param znear defines the near clip plane
  85323. * @param zfar defines the far clip plane
  85324. * @param result defines the target matrix
  85325. */
  85326. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85327. /**
  85328. * Creates a right-handed orthographic projection matrix
  85329. * @param left defines the viewport left coordinate
  85330. * @param right defines the viewport right coordinate
  85331. * @param bottom defines the viewport bottom coordinate
  85332. * @param top defines the viewport top coordinate
  85333. * @param znear defines the near clip plane
  85334. * @param zfar defines the far clip plane
  85335. * @returns a new matrix as a right-handed orthographic projection matrix
  85336. */
  85337. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85338. /**
  85339. * Stores a right-handed orthographic projection into a given matrix
  85340. * @param left defines the viewport left coordinate
  85341. * @param right defines the viewport right coordinate
  85342. * @param bottom defines the viewport bottom coordinate
  85343. * @param top defines the viewport top coordinate
  85344. * @param znear defines the near clip plane
  85345. * @param zfar defines the far clip plane
  85346. * @param result defines the target matrix
  85347. */
  85348. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85349. /**
  85350. * Creates a left-handed perspective projection matrix
  85351. * @param width defines the viewport width
  85352. * @param height defines the viewport height
  85353. * @param znear defines the near clip plane
  85354. * @param zfar defines the far clip plane
  85355. * @returns a new matrix as a left-handed perspective projection matrix
  85356. */
  85357. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85358. /**
  85359. * Creates a left-handed perspective projection matrix
  85360. * @param fov defines the horizontal field of view
  85361. * @param aspect defines the aspect ratio
  85362. * @param znear defines the near clip plane
  85363. * @param zfar defines the far clip plane
  85364. * @returns a new matrix as a left-handed perspective projection matrix
  85365. */
  85366. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85367. /**
  85368. * Stores a left-handed perspective projection into a given matrix
  85369. * @param fov defines the horizontal field of view
  85370. * @param aspect defines the aspect ratio
  85371. * @param znear defines the near clip plane
  85372. * @param zfar defines the far clip plane
  85373. * @param result defines the target matrix
  85374. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85375. */
  85376. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85377. /**
  85378. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85379. * @param fov defines the horizontal field of view
  85380. * @param aspect defines the aspect ratio
  85381. * @param znear defines the near clip plane
  85382. * @param zfar not used as infinity is used as far clip
  85383. * @param result defines the target matrix
  85384. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85385. */
  85386. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85387. /**
  85388. * Creates a right-handed perspective projection matrix
  85389. * @param fov defines the horizontal field of view
  85390. * @param aspect defines the aspect ratio
  85391. * @param znear defines the near clip plane
  85392. * @param zfar defines the far clip plane
  85393. * @returns a new matrix as a right-handed perspective projection matrix
  85394. */
  85395. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85396. /**
  85397. * Stores a right-handed perspective projection into a given matrix
  85398. * @param fov defines the horizontal field of view
  85399. * @param aspect defines the aspect ratio
  85400. * @param znear defines the near clip plane
  85401. * @param zfar defines the far clip plane
  85402. * @param result defines the target matrix
  85403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85404. */
  85405. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85406. /**
  85407. * Stores a right-handed perspective projection into a given matrix
  85408. * @param fov defines the horizontal field of view
  85409. * @param aspect defines the aspect ratio
  85410. * @param znear defines the near clip plane
  85411. * @param zfar not used as infinity is used as far clip
  85412. * @param result defines the target matrix
  85413. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85414. */
  85415. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85416. /**
  85417. * Stores a perspective projection for WebVR info a given matrix
  85418. * @param fov defines the field of view
  85419. * @param znear defines the near clip plane
  85420. * @param zfar defines the far clip plane
  85421. * @param result defines the target matrix
  85422. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85423. */
  85424. static PerspectiveFovWebVRToRef(fov: {
  85425. upDegrees: number;
  85426. downDegrees: number;
  85427. leftDegrees: number;
  85428. rightDegrees: number;
  85429. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85430. /**
  85431. * Computes a complete transformation matrix
  85432. * @param viewport defines the viewport to use
  85433. * @param world defines the world matrix
  85434. * @param view defines the view matrix
  85435. * @param projection defines the projection matrix
  85436. * @param zmin defines the near clip plane
  85437. * @param zmax defines the far clip plane
  85438. * @returns the transformation matrix
  85439. */
  85440. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85441. /**
  85442. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85443. * @param matrix defines the matrix to use
  85444. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85445. */
  85446. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85447. /**
  85448. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85449. * @param matrix defines the matrix to use
  85450. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85451. */
  85452. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85453. /**
  85454. * Compute the transpose of a given matrix
  85455. * @param matrix defines the matrix to transpose
  85456. * @returns the new matrix
  85457. */
  85458. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85459. /**
  85460. * Compute the transpose of a matrix and store it in a target matrix
  85461. * @param matrix defines the matrix to transpose
  85462. * @param result defines the target matrix
  85463. */
  85464. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85465. /**
  85466. * Computes a reflection matrix from a plane
  85467. * @param plane defines the reflection plane
  85468. * @returns a new matrix
  85469. */
  85470. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85471. /**
  85472. * Computes a reflection matrix from a plane
  85473. * @param plane defines the reflection plane
  85474. * @param result defines the target matrix
  85475. */
  85476. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85477. /**
  85478. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85479. * @param xaxis defines the value of the 1st axis
  85480. * @param yaxis defines the value of the 2nd axis
  85481. * @param zaxis defines the value of the 3rd axis
  85482. * @param result defines the target matrix
  85483. */
  85484. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85485. /**
  85486. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85487. * @param quat defines the quaternion to use
  85488. * @param result defines the target matrix
  85489. */
  85490. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85491. }
  85492. /**
  85493. * @hidden
  85494. */
  85495. export class TmpVectors {
  85496. static Vector2: Vector2[];
  85497. static Vector3: Vector3[];
  85498. static Vector4: Vector4[];
  85499. static Quaternion: Quaternion[];
  85500. static Matrix: Matrix[];
  85501. }
  85502. }
  85503. declare module BABYLON {
  85504. /**
  85505. * Defines potential orientation for back face culling
  85506. */
  85507. export enum Orientation {
  85508. /**
  85509. * Clockwise
  85510. */
  85511. CW = 0,
  85512. /** Counter clockwise */
  85513. CCW = 1
  85514. }
  85515. /** Class used to represent a Bezier curve */
  85516. export class BezierCurve {
  85517. /**
  85518. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85519. * @param t defines the time
  85520. * @param x1 defines the left coordinate on X axis
  85521. * @param y1 defines the left coordinate on Y axis
  85522. * @param x2 defines the right coordinate on X axis
  85523. * @param y2 defines the right coordinate on Y axis
  85524. * @returns the interpolated value
  85525. */
  85526. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85527. }
  85528. /**
  85529. * Defines angle representation
  85530. */
  85531. export class Angle {
  85532. private _radians;
  85533. /**
  85534. * Creates an Angle object of "radians" radians (float).
  85535. * @param radians the angle in radians
  85536. */
  85537. constructor(radians: number);
  85538. /**
  85539. * Get value in degrees
  85540. * @returns the Angle value in degrees (float)
  85541. */
  85542. degrees(): number;
  85543. /**
  85544. * Get value in radians
  85545. * @returns the Angle value in radians (float)
  85546. */
  85547. radians(): number;
  85548. /**
  85549. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85550. * @param a defines first point as the origin
  85551. * @param b defines point
  85552. * @returns a new Angle
  85553. */
  85554. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85555. /**
  85556. * Gets a new Angle object from the given float in radians
  85557. * @param radians defines the angle value in radians
  85558. * @returns a new Angle
  85559. */
  85560. static FromRadians(radians: number): Angle;
  85561. /**
  85562. * Gets a new Angle object from the given float in degrees
  85563. * @param degrees defines the angle value in degrees
  85564. * @returns a new Angle
  85565. */
  85566. static FromDegrees(degrees: number): Angle;
  85567. }
  85568. /**
  85569. * This represents an arc in a 2d space.
  85570. */
  85571. export class Arc2 {
  85572. /** Defines the start point of the arc */
  85573. startPoint: Vector2;
  85574. /** Defines the mid point of the arc */
  85575. midPoint: Vector2;
  85576. /** Defines the end point of the arc */
  85577. endPoint: Vector2;
  85578. /**
  85579. * Defines the center point of the arc.
  85580. */
  85581. centerPoint: Vector2;
  85582. /**
  85583. * Defines the radius of the arc.
  85584. */
  85585. radius: number;
  85586. /**
  85587. * Defines the angle of the arc (from mid point to end point).
  85588. */
  85589. angle: Angle;
  85590. /**
  85591. * Defines the start angle of the arc (from start point to middle point).
  85592. */
  85593. startAngle: Angle;
  85594. /**
  85595. * Defines the orientation of the arc (clock wise/counter clock wise).
  85596. */
  85597. orientation: Orientation;
  85598. /**
  85599. * Creates an Arc object from the three given points : start, middle and end.
  85600. * @param startPoint Defines the start point of the arc
  85601. * @param midPoint Defines the midlle point of the arc
  85602. * @param endPoint Defines the end point of the arc
  85603. */
  85604. constructor(
  85605. /** Defines the start point of the arc */
  85606. startPoint: Vector2,
  85607. /** Defines the mid point of the arc */
  85608. midPoint: Vector2,
  85609. /** Defines the end point of the arc */
  85610. endPoint: Vector2);
  85611. }
  85612. /**
  85613. * Represents a 2D path made up of multiple 2D points
  85614. */
  85615. export class Path2 {
  85616. private _points;
  85617. private _length;
  85618. /**
  85619. * If the path start and end point are the same
  85620. */
  85621. closed: boolean;
  85622. /**
  85623. * Creates a Path2 object from the starting 2D coordinates x and y.
  85624. * @param x the starting points x value
  85625. * @param y the starting points y value
  85626. */
  85627. constructor(x: number, y: number);
  85628. /**
  85629. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85630. * @param x the added points x value
  85631. * @param y the added points y value
  85632. * @returns the updated Path2.
  85633. */
  85634. addLineTo(x: number, y: number): Path2;
  85635. /**
  85636. * 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.
  85637. * @param midX middle point x value
  85638. * @param midY middle point y value
  85639. * @param endX end point x value
  85640. * @param endY end point y value
  85641. * @param numberOfSegments (default: 36)
  85642. * @returns the updated Path2.
  85643. */
  85644. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85645. /**
  85646. * Closes the Path2.
  85647. * @returns the Path2.
  85648. */
  85649. close(): Path2;
  85650. /**
  85651. * Gets the sum of the distance between each sequential point in the path
  85652. * @returns the Path2 total length (float).
  85653. */
  85654. length(): number;
  85655. /**
  85656. * Gets the points which construct the path
  85657. * @returns the Path2 internal array of points.
  85658. */
  85659. getPoints(): Vector2[];
  85660. /**
  85661. * Retreives the point at the distance aways from the starting point
  85662. * @param normalizedLengthPosition the length along the path to retreive the point from
  85663. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85664. */
  85665. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85666. /**
  85667. * Creates a new path starting from an x and y position
  85668. * @param x starting x value
  85669. * @param y starting y value
  85670. * @returns a new Path2 starting at the coordinates (x, y).
  85671. */
  85672. static StartingAt(x: number, y: number): Path2;
  85673. }
  85674. /**
  85675. * Represents a 3D path made up of multiple 3D points
  85676. */
  85677. export class Path3D {
  85678. /**
  85679. * an array of Vector3, the curve axis of the Path3D
  85680. */
  85681. path: Vector3[];
  85682. private _curve;
  85683. private _distances;
  85684. private _tangents;
  85685. private _normals;
  85686. private _binormals;
  85687. private _raw;
  85688. private _alignTangentsWithPath;
  85689. private readonly _pointAtData;
  85690. /**
  85691. * new Path3D(path, normal, raw)
  85692. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85693. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85694. * @param path an array of Vector3, the curve axis of the Path3D
  85695. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85696. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85697. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85698. */
  85699. constructor(
  85700. /**
  85701. * an array of Vector3, the curve axis of the Path3D
  85702. */
  85703. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85704. /**
  85705. * Returns the Path3D array of successive Vector3 designing its curve.
  85706. * @returns the Path3D array of successive Vector3 designing its curve.
  85707. */
  85708. getCurve(): Vector3[];
  85709. /**
  85710. * Returns the Path3D array of successive Vector3 designing its curve.
  85711. * @returns the Path3D array of successive Vector3 designing its curve.
  85712. */
  85713. getPoints(): Vector3[];
  85714. /**
  85715. * @returns the computed length (float) of the path.
  85716. */
  85717. length(): number;
  85718. /**
  85719. * Returns an array populated with tangent vectors on each Path3D curve point.
  85720. * @returns an array populated with tangent vectors on each Path3D curve point.
  85721. */
  85722. getTangents(): Vector3[];
  85723. /**
  85724. * Returns an array populated with normal vectors on each Path3D curve point.
  85725. * @returns an array populated with normal vectors on each Path3D curve point.
  85726. */
  85727. getNormals(): Vector3[];
  85728. /**
  85729. * Returns an array populated with binormal vectors on each Path3D curve point.
  85730. * @returns an array populated with binormal vectors on each Path3D curve point.
  85731. */
  85732. getBinormals(): Vector3[];
  85733. /**
  85734. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85735. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85736. */
  85737. getDistances(): number[];
  85738. /**
  85739. * Returns an interpolated point along this path
  85740. * @param position the position of the point along this path, from 0.0 to 1.0
  85741. * @returns a new Vector3 as the point
  85742. */
  85743. getPointAt(position: number): Vector3;
  85744. /**
  85745. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85746. * @param position the position of the point along this path, from 0.0 to 1.0
  85747. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85748. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85749. */
  85750. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85751. /**
  85752. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85753. * @param position the position of the point along this path, from 0.0 to 1.0
  85754. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85755. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85756. */
  85757. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85758. /**
  85759. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85760. * @param position the position of the point along this path, from 0.0 to 1.0
  85761. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85762. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85763. */
  85764. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85765. /**
  85766. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85767. * @param position the position of the point along this path, from 0.0 to 1.0
  85768. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85769. */
  85770. getDistanceAt(position: number): number;
  85771. /**
  85772. * Returns the array index of the previous point of an interpolated point along this path
  85773. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85774. * @returns the array index
  85775. */
  85776. getPreviousPointIndexAt(position: number): number;
  85777. /**
  85778. * 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)
  85779. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85780. * @returns the sub position
  85781. */
  85782. getSubPositionAt(position: number): number;
  85783. /**
  85784. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85785. * @param target the vector of which to get the closest position to
  85786. * @returns the position of the closest virtual point on this path to the target vector
  85787. */
  85788. getClosestPositionTo(target: Vector3): number;
  85789. /**
  85790. * Returns a sub path (slice) of this path
  85791. * @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
  85792. * @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
  85793. * @returns a sub path (slice) of this path
  85794. */
  85795. slice(start?: number, end?: number): Path3D;
  85796. /**
  85797. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85798. * @param path path which all values are copied into the curves points
  85799. * @param firstNormal which should be projected onto the curve
  85800. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85801. * @returns the same object updated.
  85802. */
  85803. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85804. private _compute;
  85805. private _getFirstNonNullVector;
  85806. private _getLastNonNullVector;
  85807. private _normalVector;
  85808. /**
  85809. * Updates the point at data for an interpolated point along this curve
  85810. * @param position the position of the point along this curve, from 0.0 to 1.0
  85811. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85812. * @returns the (updated) point at data
  85813. */
  85814. private _updatePointAtData;
  85815. /**
  85816. * Updates the point at data from the specified parameters
  85817. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85818. * @param point the interpolated point
  85819. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85820. */
  85821. private _setPointAtData;
  85822. /**
  85823. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85824. */
  85825. private _updateInterpolationMatrix;
  85826. }
  85827. /**
  85828. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85829. * A Curve3 is designed from a series of successive Vector3.
  85830. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85831. */
  85832. export class Curve3 {
  85833. private _points;
  85834. private _length;
  85835. /**
  85836. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85837. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85838. * @param v1 (Vector3) the control point
  85839. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85840. * @param nbPoints (integer) the wanted number of points in the curve
  85841. * @returns the created Curve3
  85842. */
  85843. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85844. /**
  85845. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85846. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85847. * @param v1 (Vector3) the first control point
  85848. * @param v2 (Vector3) the second control point
  85849. * @param v3 (Vector3) the end point of the Cubic Bezier
  85850. * @param nbPoints (integer) the wanted number of points in the curve
  85851. * @returns the created Curve3
  85852. */
  85853. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85854. /**
  85855. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85856. * @param p1 (Vector3) the origin point of the Hermite Spline
  85857. * @param t1 (Vector3) the tangent vector at the origin point
  85858. * @param p2 (Vector3) the end point of the Hermite Spline
  85859. * @param t2 (Vector3) the tangent vector at the end point
  85860. * @param nbPoints (integer) the wanted number of points in the curve
  85861. * @returns the created Curve3
  85862. */
  85863. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85864. /**
  85865. * Returns a Curve3 object along a CatmullRom Spline curve :
  85866. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85867. * @param nbPoints (integer) the wanted number of points between each curve control points
  85868. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85869. * @returns the created Curve3
  85870. */
  85871. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85872. /**
  85873. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85874. * A Curve3 is designed from a series of successive Vector3.
  85875. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85876. * @param points points which make up the curve
  85877. */
  85878. constructor(points: Vector3[]);
  85879. /**
  85880. * @returns the Curve3 stored array of successive Vector3
  85881. */
  85882. getPoints(): Vector3[];
  85883. /**
  85884. * @returns the computed length (float) of the curve.
  85885. */
  85886. length(): number;
  85887. /**
  85888. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85889. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85890. * curveA and curveB keep unchanged.
  85891. * @param curve the curve to continue from this curve
  85892. * @returns the newly constructed curve
  85893. */
  85894. continue(curve: DeepImmutable<Curve3>): Curve3;
  85895. private _computeLength;
  85896. }
  85897. }
  85898. declare module BABYLON {
  85899. /**
  85900. * This represents the main contract an easing function should follow.
  85901. * Easing functions are used throughout the animation system.
  85902. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85903. */
  85904. export interface IEasingFunction {
  85905. /**
  85906. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85907. * of the easing function.
  85908. * The link below provides some of the most common examples of easing functions.
  85909. * @see https://easings.net/
  85910. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85911. * @returns the corresponding value on the curve defined by the easing function
  85912. */
  85913. ease(gradient: number): number;
  85914. }
  85915. /**
  85916. * Base class used for every default easing function.
  85917. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85918. */
  85919. export class EasingFunction implements IEasingFunction {
  85920. /**
  85921. * Interpolation follows the mathematical formula associated with the easing function.
  85922. */
  85923. static readonly EASINGMODE_EASEIN: number;
  85924. /**
  85925. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85926. */
  85927. static readonly EASINGMODE_EASEOUT: number;
  85928. /**
  85929. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85930. */
  85931. static readonly EASINGMODE_EASEINOUT: number;
  85932. private _easingMode;
  85933. /**
  85934. * Sets the easing mode of the current function.
  85935. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85936. */
  85937. setEasingMode(easingMode: number): void;
  85938. /**
  85939. * Gets the current easing mode.
  85940. * @returns the easing mode
  85941. */
  85942. getEasingMode(): number;
  85943. /**
  85944. * @hidden
  85945. */
  85946. easeInCore(gradient: number): number;
  85947. /**
  85948. * Given an input gradient between 0 and 1, this returns the corresponding value
  85949. * of the easing function.
  85950. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85951. * @returns the corresponding value on the curve defined by the easing function
  85952. */
  85953. ease(gradient: number): number;
  85954. }
  85955. /**
  85956. * Easing function with a circle shape (see link below).
  85957. * @see https://easings.net/#easeInCirc
  85958. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85959. */
  85960. export class CircleEase extends EasingFunction implements IEasingFunction {
  85961. /** @hidden */
  85962. easeInCore(gradient: number): number;
  85963. }
  85964. /**
  85965. * Easing function with a ease back shape (see link below).
  85966. * @see https://easings.net/#easeInBack
  85967. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85968. */
  85969. export class BackEase extends EasingFunction implements IEasingFunction {
  85970. /** Defines the amplitude of the function */
  85971. amplitude: number;
  85972. /**
  85973. * Instantiates a back ease easing
  85974. * @see https://easings.net/#easeInBack
  85975. * @param amplitude Defines the amplitude of the function
  85976. */
  85977. constructor(
  85978. /** Defines the amplitude of the function */
  85979. amplitude?: number);
  85980. /** @hidden */
  85981. easeInCore(gradient: number): number;
  85982. }
  85983. /**
  85984. * Easing function with a bouncing shape (see link below).
  85985. * @see https://easings.net/#easeInBounce
  85986. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85987. */
  85988. export class BounceEase extends EasingFunction implements IEasingFunction {
  85989. /** Defines the number of bounces */
  85990. bounces: number;
  85991. /** Defines the amplitude of the bounce */
  85992. bounciness: number;
  85993. /**
  85994. * Instantiates a bounce easing
  85995. * @see https://easings.net/#easeInBounce
  85996. * @param bounces Defines the number of bounces
  85997. * @param bounciness Defines the amplitude of the bounce
  85998. */
  85999. constructor(
  86000. /** Defines the number of bounces */
  86001. bounces?: number,
  86002. /** Defines the amplitude of the bounce */
  86003. bounciness?: number);
  86004. /** @hidden */
  86005. easeInCore(gradient: number): number;
  86006. }
  86007. /**
  86008. * Easing function with a power of 3 shape (see link below).
  86009. * @see https://easings.net/#easeInCubic
  86010. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86011. */
  86012. export class CubicEase extends EasingFunction implements IEasingFunction {
  86013. /** @hidden */
  86014. easeInCore(gradient: number): number;
  86015. }
  86016. /**
  86017. * Easing function with an elastic shape (see link below).
  86018. * @see https://easings.net/#easeInElastic
  86019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86020. */
  86021. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86022. /** Defines the number of oscillations*/
  86023. oscillations: number;
  86024. /** Defines the amplitude of the oscillations*/
  86025. springiness: number;
  86026. /**
  86027. * Instantiates an elastic easing function
  86028. * @see https://easings.net/#easeInElastic
  86029. * @param oscillations Defines the number of oscillations
  86030. * @param springiness Defines the amplitude of the oscillations
  86031. */
  86032. constructor(
  86033. /** Defines the number of oscillations*/
  86034. oscillations?: number,
  86035. /** Defines the amplitude of the oscillations*/
  86036. springiness?: number);
  86037. /** @hidden */
  86038. easeInCore(gradient: number): number;
  86039. }
  86040. /**
  86041. * Easing function with an exponential shape (see link below).
  86042. * @see https://easings.net/#easeInExpo
  86043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86044. */
  86045. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86046. /** Defines the exponent of the function */
  86047. exponent: number;
  86048. /**
  86049. * Instantiates an exponential easing function
  86050. * @see https://easings.net/#easeInExpo
  86051. * @param exponent Defines the exponent of the function
  86052. */
  86053. constructor(
  86054. /** Defines the exponent of the function */
  86055. exponent?: number);
  86056. /** @hidden */
  86057. easeInCore(gradient: number): number;
  86058. }
  86059. /**
  86060. * Easing function with a power shape (see link below).
  86061. * @see https://easings.net/#easeInQuad
  86062. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86063. */
  86064. export class PowerEase extends EasingFunction implements IEasingFunction {
  86065. /** Defines the power of the function */
  86066. power: number;
  86067. /**
  86068. * Instantiates an power base easing function
  86069. * @see https://easings.net/#easeInQuad
  86070. * @param power Defines the power of the function
  86071. */
  86072. constructor(
  86073. /** Defines the power of the function */
  86074. power?: number);
  86075. /** @hidden */
  86076. easeInCore(gradient: number): number;
  86077. }
  86078. /**
  86079. * Easing function with a power of 2 shape (see link below).
  86080. * @see https://easings.net/#easeInQuad
  86081. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86082. */
  86083. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86084. /** @hidden */
  86085. easeInCore(gradient: number): number;
  86086. }
  86087. /**
  86088. * Easing function with a power of 4 shape (see link below).
  86089. * @see https://easings.net/#easeInQuart
  86090. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86091. */
  86092. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86093. /** @hidden */
  86094. easeInCore(gradient: number): number;
  86095. }
  86096. /**
  86097. * Easing function with a power of 5 shape (see link below).
  86098. * @see https://easings.net/#easeInQuint
  86099. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86100. */
  86101. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86102. /** @hidden */
  86103. easeInCore(gradient: number): number;
  86104. }
  86105. /**
  86106. * Easing function with a sin shape (see link below).
  86107. * @see https://easings.net/#easeInSine
  86108. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86109. */
  86110. export class SineEase extends EasingFunction implements IEasingFunction {
  86111. /** @hidden */
  86112. easeInCore(gradient: number): number;
  86113. }
  86114. /**
  86115. * Easing function with a bezier shape (see link below).
  86116. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86117. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86118. */
  86119. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86120. /** Defines the x component of the start tangent in the bezier curve */
  86121. x1: number;
  86122. /** Defines the y component of the start tangent in the bezier curve */
  86123. y1: number;
  86124. /** Defines the x component of the end tangent in the bezier curve */
  86125. x2: number;
  86126. /** Defines the y component of the end tangent in the bezier curve */
  86127. y2: number;
  86128. /**
  86129. * Instantiates a bezier function
  86130. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86131. * @param x1 Defines the x component of the start tangent in the bezier curve
  86132. * @param y1 Defines the y component of the start tangent in the bezier curve
  86133. * @param x2 Defines the x component of the end tangent in the bezier curve
  86134. * @param y2 Defines the y component of the end tangent in the bezier curve
  86135. */
  86136. constructor(
  86137. /** Defines the x component of the start tangent in the bezier curve */
  86138. x1?: number,
  86139. /** Defines the y component of the start tangent in the bezier curve */
  86140. y1?: number,
  86141. /** Defines the x component of the end tangent in the bezier curve */
  86142. x2?: number,
  86143. /** Defines the y component of the end tangent in the bezier curve */
  86144. y2?: number);
  86145. /** @hidden */
  86146. easeInCore(gradient: number): number;
  86147. }
  86148. }
  86149. declare module BABYLON {
  86150. /**
  86151. * Class used to hold a RBG color
  86152. */
  86153. export class Color3 {
  86154. /**
  86155. * Defines the red component (between 0 and 1, default is 0)
  86156. */
  86157. r: number;
  86158. /**
  86159. * Defines the green component (between 0 and 1, default is 0)
  86160. */
  86161. g: number;
  86162. /**
  86163. * Defines the blue component (between 0 and 1, default is 0)
  86164. */
  86165. b: number;
  86166. /**
  86167. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86168. * @param r defines the red component (between 0 and 1, default is 0)
  86169. * @param g defines the green component (between 0 and 1, default is 0)
  86170. * @param b defines the blue component (between 0 and 1, default is 0)
  86171. */
  86172. constructor(
  86173. /**
  86174. * Defines the red component (between 0 and 1, default is 0)
  86175. */
  86176. r?: number,
  86177. /**
  86178. * Defines the green component (between 0 and 1, default is 0)
  86179. */
  86180. g?: number,
  86181. /**
  86182. * Defines the blue component (between 0 and 1, default is 0)
  86183. */
  86184. b?: number);
  86185. /**
  86186. * Creates a string with the Color3 current values
  86187. * @returns the string representation of the Color3 object
  86188. */
  86189. toString(): string;
  86190. /**
  86191. * Returns the string "Color3"
  86192. * @returns "Color3"
  86193. */
  86194. getClassName(): string;
  86195. /**
  86196. * Compute the Color3 hash code
  86197. * @returns an unique number that can be used to hash Color3 objects
  86198. */
  86199. getHashCode(): number;
  86200. /**
  86201. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86202. * @param array defines the array where to store the r,g,b components
  86203. * @param index defines an optional index in the target array to define where to start storing values
  86204. * @returns the current Color3 object
  86205. */
  86206. toArray(array: FloatArray, index?: number): Color3;
  86207. /**
  86208. * Update the current color with values stored in an array from the starting index of the given array
  86209. * @param array defines the source array
  86210. * @param offset defines an offset in the source array
  86211. * @returns the current Color3 object
  86212. */
  86213. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86214. /**
  86215. * Returns a new Color4 object from the current Color3 and the given alpha
  86216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86217. * @returns a new Color4 object
  86218. */
  86219. toColor4(alpha?: number): Color4;
  86220. /**
  86221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86222. * @returns the new array
  86223. */
  86224. asArray(): number[];
  86225. /**
  86226. * Returns the luminance value
  86227. * @returns a float value
  86228. */
  86229. toLuminance(): number;
  86230. /**
  86231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86232. * @param otherColor defines the second operand
  86233. * @returns the new Color3 object
  86234. */
  86235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86236. /**
  86237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86238. * @param otherColor defines the second operand
  86239. * @param result defines the Color3 object where to store the result
  86240. * @returns the current Color3
  86241. */
  86242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86243. /**
  86244. * Determines equality between Color3 objects
  86245. * @param otherColor defines the second operand
  86246. * @returns true if the rgb values are equal to the given ones
  86247. */
  86248. equals(otherColor: DeepImmutable<Color3>): boolean;
  86249. /**
  86250. * Determines equality between the current Color3 object and a set of r,b,g values
  86251. * @param r defines the red component to check
  86252. * @param g defines the green component to check
  86253. * @param b defines the blue component to check
  86254. * @returns true if the rgb values are equal to the given ones
  86255. */
  86256. equalsFloats(r: number, g: number, b: number): boolean;
  86257. /**
  86258. * Multiplies in place each rgb value by scale
  86259. * @param scale defines the scaling factor
  86260. * @returns the updated Color3
  86261. */
  86262. scale(scale: number): Color3;
  86263. /**
  86264. * Multiplies the rgb values by scale and stores the result into "result"
  86265. * @param scale defines the scaling factor
  86266. * @param result defines the Color3 object where to store the result
  86267. * @returns the unmodified current Color3
  86268. */
  86269. scaleToRef(scale: number, result: Color3): Color3;
  86270. /**
  86271. * Scale the current Color3 values by a factor and add the result to a given Color3
  86272. * @param scale defines the scale factor
  86273. * @param result defines color to store the result into
  86274. * @returns the unmodified current Color3
  86275. */
  86276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86277. /**
  86278. * Clamps the rgb values by the min and max values and stores the result into "result"
  86279. * @param min defines minimum clamping value (default is 0)
  86280. * @param max defines maximum clamping value (default is 1)
  86281. * @param result defines color to store the result into
  86282. * @returns the original Color3
  86283. */
  86284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86285. /**
  86286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86287. * @param otherColor defines the second operand
  86288. * @returns the new Color3
  86289. */
  86290. add(otherColor: DeepImmutable<Color3>): Color3;
  86291. /**
  86292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86293. * @param otherColor defines the second operand
  86294. * @param result defines Color3 object to store the result into
  86295. * @returns the unmodified current Color3
  86296. */
  86297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86298. /**
  86299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86300. * @param otherColor defines the second operand
  86301. * @returns the new Color3
  86302. */
  86303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86304. /**
  86305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86306. * @param otherColor defines the second operand
  86307. * @param result defines Color3 object to store the result into
  86308. * @returns the unmodified current Color3
  86309. */
  86310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86311. /**
  86312. * Copy the current object
  86313. * @returns a new Color3 copied the current one
  86314. */
  86315. clone(): Color3;
  86316. /**
  86317. * Copies the rgb values from the source in the current Color3
  86318. * @param source defines the source Color3 object
  86319. * @returns the updated Color3 object
  86320. */
  86321. copyFrom(source: DeepImmutable<Color3>): Color3;
  86322. /**
  86323. * Updates the Color3 rgb values from the given floats
  86324. * @param r defines the red component to read from
  86325. * @param g defines the green component to read from
  86326. * @param b defines the blue component to read from
  86327. * @returns the current Color3 object
  86328. */
  86329. copyFromFloats(r: number, g: number, b: number): Color3;
  86330. /**
  86331. * Updates the Color3 rgb values from the given floats
  86332. * @param r defines the red component to read from
  86333. * @param g defines the green component to read from
  86334. * @param b defines the blue component to read from
  86335. * @returns the current Color3 object
  86336. */
  86337. set(r: number, g: number, b: number): Color3;
  86338. /**
  86339. * Compute the Color3 hexadecimal code as a string
  86340. * @returns a string containing the hexadecimal representation of the Color3 object
  86341. */
  86342. toHexString(): string;
  86343. /**
  86344. * Computes a new Color3 converted from the current one to linear space
  86345. * @returns a new Color3 object
  86346. */
  86347. toLinearSpace(): Color3;
  86348. /**
  86349. * Converts current color in rgb space to HSV values
  86350. * @returns a new color3 representing the HSV values
  86351. */
  86352. toHSV(): Color3;
  86353. /**
  86354. * Converts current color in rgb space to HSV values
  86355. * @param result defines the Color3 where to store the HSV values
  86356. */
  86357. toHSVToRef(result: Color3): void;
  86358. /**
  86359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86360. * @param convertedColor defines the Color3 object where to store the linear space version
  86361. * @returns the unmodified Color3
  86362. */
  86363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86364. /**
  86365. * Computes a new Color3 converted from the current one to gamma space
  86366. * @returns a new Color3 object
  86367. */
  86368. toGammaSpace(): Color3;
  86369. /**
  86370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86371. * @param convertedColor defines the Color3 object where to store the gamma space version
  86372. * @returns the unmodified Color3
  86373. */
  86374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86375. private static _BlackReadOnly;
  86376. /**
  86377. * Convert Hue, saturation and value to a Color3 (RGB)
  86378. * @param hue defines the hue
  86379. * @param saturation defines the saturation
  86380. * @param value defines the value
  86381. * @param result defines the Color3 where to store the RGB values
  86382. */
  86383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86384. /**
  86385. * Creates a new Color3 from the string containing valid hexadecimal values
  86386. * @param hex defines a string containing valid hexadecimal values
  86387. * @returns a new Color3 object
  86388. */
  86389. static FromHexString(hex: string): Color3;
  86390. /**
  86391. * Creates a new Color3 from the starting index of the given array
  86392. * @param array defines the source array
  86393. * @param offset defines an offset in the source array
  86394. * @returns a new Color3 object
  86395. */
  86396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86397. /**
  86398. * Creates a new Color3 from the starting index element of the given array
  86399. * @param array defines the source array to read from
  86400. * @param offset defines the offset in the source array
  86401. * @param result defines the target Color3 object
  86402. */
  86403. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86404. /**
  86405. * Creates a new Color3 from integer values (< 256)
  86406. * @param r defines the red component to read from (value between 0 and 255)
  86407. * @param g defines the green component to read from (value between 0 and 255)
  86408. * @param b defines the blue component to read from (value between 0 and 255)
  86409. * @returns a new Color3 object
  86410. */
  86411. static FromInts(r: number, g: number, b: number): Color3;
  86412. /**
  86413. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86414. * @param start defines the start Color3 value
  86415. * @param end defines the end Color3 value
  86416. * @param amount defines the gradient value between start and end
  86417. * @returns a new Color3 object
  86418. */
  86419. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86420. /**
  86421. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86422. * @param left defines the start value
  86423. * @param right defines the end value
  86424. * @param amount defines the gradient factor
  86425. * @param result defines the Color3 object where to store the result
  86426. */
  86427. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86428. /**
  86429. * Returns a Color3 value containing a red color
  86430. * @returns a new Color3 object
  86431. */
  86432. static Red(): Color3;
  86433. /**
  86434. * Returns a Color3 value containing a green color
  86435. * @returns a new Color3 object
  86436. */
  86437. static Green(): Color3;
  86438. /**
  86439. * Returns a Color3 value containing a blue color
  86440. * @returns a new Color3 object
  86441. */
  86442. static Blue(): Color3;
  86443. /**
  86444. * Returns a Color3 value containing a black color
  86445. * @returns a new Color3 object
  86446. */
  86447. static Black(): Color3;
  86448. /**
  86449. * Gets a Color3 value containing a black color that must not be updated
  86450. */
  86451. static get BlackReadOnly(): DeepImmutable<Color3>;
  86452. /**
  86453. * Returns a Color3 value containing a white color
  86454. * @returns a new Color3 object
  86455. */
  86456. static White(): Color3;
  86457. /**
  86458. * Returns a Color3 value containing a purple color
  86459. * @returns a new Color3 object
  86460. */
  86461. static Purple(): Color3;
  86462. /**
  86463. * Returns a Color3 value containing a magenta color
  86464. * @returns a new Color3 object
  86465. */
  86466. static Magenta(): Color3;
  86467. /**
  86468. * Returns a Color3 value containing a yellow color
  86469. * @returns a new Color3 object
  86470. */
  86471. static Yellow(): Color3;
  86472. /**
  86473. * Returns a Color3 value containing a gray color
  86474. * @returns a new Color3 object
  86475. */
  86476. static Gray(): Color3;
  86477. /**
  86478. * Returns a Color3 value containing a teal color
  86479. * @returns a new Color3 object
  86480. */
  86481. static Teal(): Color3;
  86482. /**
  86483. * Returns a Color3 value containing a random color
  86484. * @returns a new Color3 object
  86485. */
  86486. static Random(): Color3;
  86487. }
  86488. /**
  86489. * Class used to hold a RBGA color
  86490. */
  86491. export class Color4 {
  86492. /**
  86493. * Defines the red component (between 0 and 1, default is 0)
  86494. */
  86495. r: number;
  86496. /**
  86497. * Defines the green component (between 0 and 1, default is 0)
  86498. */
  86499. g: number;
  86500. /**
  86501. * Defines the blue component (between 0 and 1, default is 0)
  86502. */
  86503. b: number;
  86504. /**
  86505. * Defines the alpha component (between 0 and 1, default is 1)
  86506. */
  86507. a: number;
  86508. /**
  86509. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86510. * @param r defines the red component (between 0 and 1, default is 0)
  86511. * @param g defines the green component (between 0 and 1, default is 0)
  86512. * @param b defines the blue component (between 0 and 1, default is 0)
  86513. * @param a defines the alpha component (between 0 and 1, default is 1)
  86514. */
  86515. constructor(
  86516. /**
  86517. * Defines the red component (between 0 and 1, default is 0)
  86518. */
  86519. r?: number,
  86520. /**
  86521. * Defines the green component (between 0 and 1, default is 0)
  86522. */
  86523. g?: number,
  86524. /**
  86525. * Defines the blue component (between 0 and 1, default is 0)
  86526. */
  86527. b?: number,
  86528. /**
  86529. * Defines the alpha component (between 0 and 1, default is 1)
  86530. */
  86531. a?: number);
  86532. /**
  86533. * Adds in place the given Color4 values to the current Color4 object
  86534. * @param right defines the second operand
  86535. * @returns the current updated Color4 object
  86536. */
  86537. addInPlace(right: DeepImmutable<Color4>): Color4;
  86538. /**
  86539. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86540. * @returns the new array
  86541. */
  86542. asArray(): number[];
  86543. /**
  86544. * Stores from the starting index in the given array the Color4 successive values
  86545. * @param array defines the array where to store the r,g,b components
  86546. * @param index defines an optional index in the target array to define where to start storing values
  86547. * @returns the current Color4 object
  86548. */
  86549. toArray(array: number[], index?: number): Color4;
  86550. /**
  86551. * Update the current color with values stored in an array from the starting index of the given array
  86552. * @param array defines the source array
  86553. * @param offset defines an offset in the source array
  86554. * @returns the current Color4 object
  86555. */
  86556. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86557. /**
  86558. * Determines equality between Color4 objects
  86559. * @param otherColor defines the second operand
  86560. * @returns true if the rgba values are equal to the given ones
  86561. */
  86562. equals(otherColor: DeepImmutable<Color4>): boolean;
  86563. /**
  86564. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86565. * @param right defines the second operand
  86566. * @returns a new Color4 object
  86567. */
  86568. add(right: DeepImmutable<Color4>): Color4;
  86569. /**
  86570. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86571. * @param right defines the second operand
  86572. * @returns a new Color4 object
  86573. */
  86574. subtract(right: DeepImmutable<Color4>): Color4;
  86575. /**
  86576. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86577. * @param right defines the second operand
  86578. * @param result defines the Color4 object where to store the result
  86579. * @returns the current Color4 object
  86580. */
  86581. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86582. /**
  86583. * Creates a new Color4 with the current Color4 values multiplied by scale
  86584. * @param scale defines the scaling factor to apply
  86585. * @returns a new Color4 object
  86586. */
  86587. scale(scale: number): Color4;
  86588. /**
  86589. * Multiplies the current Color4 values by scale and stores the result in "result"
  86590. * @param scale defines the scaling factor to apply
  86591. * @param result defines the Color4 object where to store the result
  86592. * @returns the current unmodified Color4
  86593. */
  86594. scaleToRef(scale: number, result: Color4): Color4;
  86595. /**
  86596. * Scale the current Color4 values by a factor and add the result to a given Color4
  86597. * @param scale defines the scale factor
  86598. * @param result defines the Color4 object where to store the result
  86599. * @returns the unmodified current Color4
  86600. */
  86601. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86602. /**
  86603. * Clamps the rgb values by the min and max values and stores the result into "result"
  86604. * @param min defines minimum clamping value (default is 0)
  86605. * @param max defines maximum clamping value (default is 1)
  86606. * @param result defines color to store the result into.
  86607. * @returns the cuurent Color4
  86608. */
  86609. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86610. /**
  86611. * Multipy an Color4 value by another and return a new Color4 object
  86612. * @param color defines the Color4 value to multiply by
  86613. * @returns a new Color4 object
  86614. */
  86615. multiply(color: Color4): Color4;
  86616. /**
  86617. * Multipy a Color4 value by another and push the result in a reference value
  86618. * @param color defines the Color4 value to multiply by
  86619. * @param result defines the Color4 to fill the result in
  86620. * @returns the result Color4
  86621. */
  86622. multiplyToRef(color: Color4, result: Color4): Color4;
  86623. /**
  86624. * Creates a string with the Color4 current values
  86625. * @returns the string representation of the Color4 object
  86626. */
  86627. toString(): string;
  86628. /**
  86629. * Returns the string "Color4"
  86630. * @returns "Color4"
  86631. */
  86632. getClassName(): string;
  86633. /**
  86634. * Compute the Color4 hash code
  86635. * @returns an unique number that can be used to hash Color4 objects
  86636. */
  86637. getHashCode(): number;
  86638. /**
  86639. * Creates a new Color4 copied from the current one
  86640. * @returns a new Color4 object
  86641. */
  86642. clone(): Color4;
  86643. /**
  86644. * Copies the given Color4 values into the current one
  86645. * @param source defines the source Color4 object
  86646. * @returns the current updated Color4 object
  86647. */
  86648. copyFrom(source: Color4): Color4;
  86649. /**
  86650. * Copies the given float values into the current one
  86651. * @param r defines the red component to read from
  86652. * @param g defines the green component to read from
  86653. * @param b defines the blue component to read from
  86654. * @param a defines the alpha component to read from
  86655. * @returns the current updated Color4 object
  86656. */
  86657. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86658. /**
  86659. * Copies the given float values into the current one
  86660. * @param r defines the red component to read from
  86661. * @param g defines the green component to read from
  86662. * @param b defines the blue component to read from
  86663. * @param a defines the alpha component to read from
  86664. * @returns the current updated Color4 object
  86665. */
  86666. set(r: number, g: number, b: number, a: number): Color4;
  86667. /**
  86668. * Compute the Color4 hexadecimal code as a string
  86669. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86670. * @returns a string containing the hexadecimal representation of the Color4 object
  86671. */
  86672. toHexString(returnAsColor3?: boolean): string;
  86673. /**
  86674. * Computes a new Color4 converted from the current one to linear space
  86675. * @returns a new Color4 object
  86676. */
  86677. toLinearSpace(): Color4;
  86678. /**
  86679. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86680. * @param convertedColor defines the Color4 object where to store the linear space version
  86681. * @returns the unmodified Color4
  86682. */
  86683. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86684. /**
  86685. * Computes a new Color4 converted from the current one to gamma space
  86686. * @returns a new Color4 object
  86687. */
  86688. toGammaSpace(): Color4;
  86689. /**
  86690. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86691. * @param convertedColor defines the Color4 object where to store the gamma space version
  86692. * @returns the unmodified Color4
  86693. */
  86694. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86695. /**
  86696. * Creates a new Color4 from the string containing valid hexadecimal values
  86697. * @param hex defines a string containing valid hexadecimal values
  86698. * @returns a new Color4 object
  86699. */
  86700. static FromHexString(hex: string): Color4;
  86701. /**
  86702. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86703. * @param left defines the start value
  86704. * @param right defines the end value
  86705. * @param amount defines the gradient factor
  86706. * @returns a new Color4 object
  86707. */
  86708. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86709. /**
  86710. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86711. * @param left defines the start value
  86712. * @param right defines the end value
  86713. * @param amount defines the gradient factor
  86714. * @param result defines the Color4 object where to store data
  86715. */
  86716. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86717. /**
  86718. * Creates a new Color4 from a Color3 and an alpha value
  86719. * @param color3 defines the source Color3 to read from
  86720. * @param alpha defines the alpha component (1.0 by default)
  86721. * @returns a new Color4 object
  86722. */
  86723. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86724. /**
  86725. * Creates a new Color4 from the starting index element of the given array
  86726. * @param array defines the source array to read from
  86727. * @param offset defines the offset in the source array
  86728. * @returns a new Color4 object
  86729. */
  86730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86731. /**
  86732. * Creates a new Color4 from the starting index element of the given array
  86733. * @param array defines the source array to read from
  86734. * @param offset defines the offset in the source array
  86735. * @param result defines the target Color4 object
  86736. */
  86737. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86738. /**
  86739. * Creates a new Color3 from integer values (< 256)
  86740. * @param r defines the red component to read from (value between 0 and 255)
  86741. * @param g defines the green component to read from (value between 0 and 255)
  86742. * @param b defines the blue component to read from (value between 0 and 255)
  86743. * @param a defines the alpha component to read from (value between 0 and 255)
  86744. * @returns a new Color3 object
  86745. */
  86746. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86747. /**
  86748. * Check the content of a given array and convert it to an array containing RGBA data
  86749. * If the original array was already containing count * 4 values then it is returned directly
  86750. * @param colors defines the array to check
  86751. * @param count defines the number of RGBA data to expect
  86752. * @returns an array containing count * 4 values (RGBA)
  86753. */
  86754. static CheckColors4(colors: number[], count: number): number[];
  86755. }
  86756. /**
  86757. * @hidden
  86758. */
  86759. export class TmpColors {
  86760. static Color3: Color3[];
  86761. static Color4: Color4[];
  86762. }
  86763. }
  86764. declare module BABYLON {
  86765. /**
  86766. * Defines an interface which represents an animation key frame
  86767. */
  86768. export interface IAnimationKey {
  86769. /**
  86770. * Frame of the key frame
  86771. */
  86772. frame: number;
  86773. /**
  86774. * Value at the specifies key frame
  86775. */
  86776. value: any;
  86777. /**
  86778. * The input tangent for the cubic hermite spline
  86779. */
  86780. inTangent?: any;
  86781. /**
  86782. * The output tangent for the cubic hermite spline
  86783. */
  86784. outTangent?: any;
  86785. /**
  86786. * The animation interpolation type
  86787. */
  86788. interpolation?: AnimationKeyInterpolation;
  86789. }
  86790. /**
  86791. * Enum for the animation key frame interpolation type
  86792. */
  86793. export enum AnimationKeyInterpolation {
  86794. /**
  86795. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86796. */
  86797. STEP = 1
  86798. }
  86799. }
  86800. declare module BABYLON {
  86801. /**
  86802. * Represents the range of an animation
  86803. */
  86804. export class AnimationRange {
  86805. /**The name of the animation range**/
  86806. name: string;
  86807. /**The starting frame of the animation */
  86808. from: number;
  86809. /**The ending frame of the animation*/
  86810. to: number;
  86811. /**
  86812. * Initializes the range of an animation
  86813. * @param name The name of the animation range
  86814. * @param from The starting frame of the animation
  86815. * @param to The ending frame of the animation
  86816. */
  86817. constructor(
  86818. /**The name of the animation range**/
  86819. name: string,
  86820. /**The starting frame of the animation */
  86821. from: number,
  86822. /**The ending frame of the animation*/
  86823. to: number);
  86824. /**
  86825. * Makes a copy of the animation range
  86826. * @returns A copy of the animation range
  86827. */
  86828. clone(): AnimationRange;
  86829. }
  86830. }
  86831. declare module BABYLON {
  86832. /**
  86833. * Composed of a frame, and an action function
  86834. */
  86835. export class AnimationEvent {
  86836. /** The frame for which the event is triggered **/
  86837. frame: number;
  86838. /** The event to perform when triggered **/
  86839. action: (currentFrame: number) => void;
  86840. /** Specifies if the event should be triggered only once**/
  86841. onlyOnce?: boolean | undefined;
  86842. /**
  86843. * Specifies if the animation event is done
  86844. */
  86845. isDone: boolean;
  86846. /**
  86847. * Initializes the animation event
  86848. * @param frame The frame for which the event is triggered
  86849. * @param action The event to perform when triggered
  86850. * @param onlyOnce Specifies if the event should be triggered only once
  86851. */
  86852. constructor(
  86853. /** The frame for which the event is triggered **/
  86854. frame: number,
  86855. /** The event to perform when triggered **/
  86856. action: (currentFrame: number) => void,
  86857. /** Specifies if the event should be triggered only once**/
  86858. onlyOnce?: boolean | undefined);
  86859. /** @hidden */
  86860. _clone(): AnimationEvent;
  86861. }
  86862. }
  86863. declare module BABYLON {
  86864. /**
  86865. * Interface used to define a behavior
  86866. */
  86867. export interface Behavior<T> {
  86868. /** gets or sets behavior's name */
  86869. name: string;
  86870. /**
  86871. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86872. */
  86873. init(): void;
  86874. /**
  86875. * Called when the behavior is attached to a target
  86876. * @param target defines the target where the behavior is attached to
  86877. */
  86878. attach(target: T): void;
  86879. /**
  86880. * Called when the behavior is detached from its target
  86881. */
  86882. detach(): void;
  86883. }
  86884. /**
  86885. * Interface implemented by classes supporting behaviors
  86886. */
  86887. export interface IBehaviorAware<T> {
  86888. /**
  86889. * Attach a behavior
  86890. * @param behavior defines the behavior to attach
  86891. * @returns the current host
  86892. */
  86893. addBehavior(behavior: Behavior<T>): T;
  86894. /**
  86895. * Remove a behavior from the current object
  86896. * @param behavior defines the behavior to detach
  86897. * @returns the current host
  86898. */
  86899. removeBehavior(behavior: Behavior<T>): T;
  86900. /**
  86901. * Gets a behavior using its name to search
  86902. * @param name defines the name to search
  86903. * @returns the behavior or null if not found
  86904. */
  86905. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86906. }
  86907. }
  86908. declare module BABYLON {
  86909. /**
  86910. * Defines an array and its length.
  86911. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86912. */
  86913. export interface ISmartArrayLike<T> {
  86914. /**
  86915. * The data of the array.
  86916. */
  86917. data: Array<T>;
  86918. /**
  86919. * The active length of the array.
  86920. */
  86921. length: number;
  86922. }
  86923. /**
  86924. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86925. */
  86926. export class SmartArray<T> implements ISmartArrayLike<T> {
  86927. /**
  86928. * The full set of data from the array.
  86929. */
  86930. data: Array<T>;
  86931. /**
  86932. * The active length of the array.
  86933. */
  86934. length: number;
  86935. protected _id: number;
  86936. /**
  86937. * Instantiates a Smart Array.
  86938. * @param capacity defines the default capacity of the array.
  86939. */
  86940. constructor(capacity: number);
  86941. /**
  86942. * Pushes a value at the end of the active data.
  86943. * @param value defines the object to push in the array.
  86944. */
  86945. push(value: T): void;
  86946. /**
  86947. * Iterates over the active data and apply the lambda to them.
  86948. * @param func defines the action to apply on each value.
  86949. */
  86950. forEach(func: (content: T) => void): void;
  86951. /**
  86952. * Sorts the full sets of data.
  86953. * @param compareFn defines the comparison function to apply.
  86954. */
  86955. sort(compareFn: (a: T, b: T) => number): void;
  86956. /**
  86957. * Resets the active data to an empty array.
  86958. */
  86959. reset(): void;
  86960. /**
  86961. * Releases all the data from the array as well as the array.
  86962. */
  86963. dispose(): void;
  86964. /**
  86965. * Concats the active data with a given array.
  86966. * @param array defines the data to concatenate with.
  86967. */
  86968. concat(array: any): void;
  86969. /**
  86970. * Returns the position of a value in the active data.
  86971. * @param value defines the value to find the index for
  86972. * @returns the index if found in the active data otherwise -1
  86973. */
  86974. indexOf(value: T): number;
  86975. /**
  86976. * Returns whether an element is part of the active data.
  86977. * @param value defines the value to look for
  86978. * @returns true if found in the active data otherwise false
  86979. */
  86980. contains(value: T): boolean;
  86981. private static _GlobalId;
  86982. }
  86983. /**
  86984. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86985. * The data in this array can only be present once
  86986. */
  86987. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86988. private _duplicateId;
  86989. /**
  86990. * Pushes a value at the end of the active data.
  86991. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86992. * @param value defines the object to push in the array.
  86993. */
  86994. push(value: T): void;
  86995. /**
  86996. * Pushes a value at the end of the active data.
  86997. * If the data is already present, it won t be added again
  86998. * @param value defines the object to push in the array.
  86999. * @returns true if added false if it was already present
  87000. */
  87001. pushNoDuplicate(value: T): boolean;
  87002. /**
  87003. * Resets the active data to an empty array.
  87004. */
  87005. reset(): void;
  87006. /**
  87007. * Concats the active data with a given array.
  87008. * This ensures no dupplicate will be present in the result.
  87009. * @param array defines the data to concatenate with.
  87010. */
  87011. concatWithNoDuplicate(array: any): void;
  87012. }
  87013. }
  87014. declare module BABYLON {
  87015. /**
  87016. * @ignore
  87017. * This is a list of all the different input types that are available in the application.
  87018. * Fo instance: ArcRotateCameraGamepadInput...
  87019. */
  87020. export var CameraInputTypes: {};
  87021. /**
  87022. * This is the contract to implement in order to create a new input class.
  87023. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87024. */
  87025. export interface ICameraInput<TCamera extends Camera> {
  87026. /**
  87027. * Defines the camera the input is attached to.
  87028. */
  87029. camera: Nullable<TCamera>;
  87030. /**
  87031. * Gets the class name of the current intput.
  87032. * @returns the class name
  87033. */
  87034. getClassName(): string;
  87035. /**
  87036. * Get the friendly name associated with the input class.
  87037. * @returns the input friendly name
  87038. */
  87039. getSimpleName(): string;
  87040. /**
  87041. * Attach the input controls to a specific dom element to get the input from.
  87042. * @param element Defines the element the controls should be listened from
  87043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87044. */
  87045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87046. /**
  87047. * Detach the current controls from the specified dom element.
  87048. * @param element Defines the element to stop listening the inputs from
  87049. */
  87050. detachControl(element: Nullable<HTMLElement>): void;
  87051. /**
  87052. * Update the current camera state depending on the inputs that have been used this frame.
  87053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87054. */
  87055. checkInputs?: () => void;
  87056. }
  87057. /**
  87058. * Represents a map of input types to input instance or input index to input instance.
  87059. */
  87060. export interface CameraInputsMap<TCamera extends Camera> {
  87061. /**
  87062. * Accessor to the input by input type.
  87063. */
  87064. [name: string]: ICameraInput<TCamera>;
  87065. /**
  87066. * Accessor to the input by input index.
  87067. */
  87068. [idx: number]: ICameraInput<TCamera>;
  87069. }
  87070. /**
  87071. * This represents the input manager used within a camera.
  87072. * It helps dealing with all the different kind of input attached to a camera.
  87073. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87074. */
  87075. export class CameraInputsManager<TCamera extends Camera> {
  87076. /**
  87077. * Defines the list of inputs attahed to the camera.
  87078. */
  87079. attached: CameraInputsMap<TCamera>;
  87080. /**
  87081. * Defines the dom element the camera is collecting inputs from.
  87082. * This is null if the controls have not been attached.
  87083. */
  87084. attachedElement: Nullable<HTMLElement>;
  87085. /**
  87086. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87087. */
  87088. noPreventDefault: boolean;
  87089. /**
  87090. * Defined the camera the input manager belongs to.
  87091. */
  87092. camera: TCamera;
  87093. /**
  87094. * Update the current camera state depending on the inputs that have been used this frame.
  87095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87096. */
  87097. checkInputs: () => void;
  87098. /**
  87099. * Instantiate a new Camera Input Manager.
  87100. * @param camera Defines the camera the input manager blongs to
  87101. */
  87102. constructor(camera: TCamera);
  87103. /**
  87104. * Add an input method to a camera
  87105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87106. * @param input camera input method
  87107. */
  87108. add(input: ICameraInput<TCamera>): void;
  87109. /**
  87110. * Remove a specific input method from a camera
  87111. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87112. * @param inputToRemove camera input method
  87113. */
  87114. remove(inputToRemove: ICameraInput<TCamera>): void;
  87115. /**
  87116. * Remove a specific input type from a camera
  87117. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87118. * @param inputType the type of the input to remove
  87119. */
  87120. removeByType(inputType: string): void;
  87121. private _addCheckInputs;
  87122. /**
  87123. * Attach the input controls to the currently attached dom element to listen the events from.
  87124. * @param input Defines the input to attach
  87125. */
  87126. attachInput(input: ICameraInput<TCamera>): void;
  87127. /**
  87128. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87129. * @param element Defines the dom element to collect the events from
  87130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87131. */
  87132. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87133. /**
  87134. * Detach the current manager inputs controls from a specific dom element.
  87135. * @param element Defines the dom element to collect the events from
  87136. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87137. */
  87138. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87139. /**
  87140. * Rebuild the dynamic inputCheck function from the current list of
  87141. * defined inputs in the manager.
  87142. */
  87143. rebuildInputCheck(): void;
  87144. /**
  87145. * Remove all attached input methods from a camera
  87146. */
  87147. clear(): void;
  87148. /**
  87149. * Serialize the current input manager attached to a camera.
  87150. * This ensures than once parsed,
  87151. * the input associated to the camera will be identical to the current ones
  87152. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87153. */
  87154. serialize(serializedCamera: any): void;
  87155. /**
  87156. * Parses an input manager serialized JSON to restore the previous list of inputs
  87157. * and states associated to a camera.
  87158. * @param parsedCamera Defines the JSON to parse
  87159. */
  87160. parse(parsedCamera: any): void;
  87161. }
  87162. }
  87163. declare module BABYLON {
  87164. /**
  87165. * Class used to store data that will be store in GPU memory
  87166. */
  87167. export class Buffer {
  87168. private _engine;
  87169. private _buffer;
  87170. /** @hidden */
  87171. _data: Nullable<DataArray>;
  87172. private _updatable;
  87173. private _instanced;
  87174. private _divisor;
  87175. /**
  87176. * Gets the byte stride.
  87177. */
  87178. readonly byteStride: number;
  87179. /**
  87180. * Constructor
  87181. * @param engine the engine
  87182. * @param data the data to use for this buffer
  87183. * @param updatable whether the data is updatable
  87184. * @param stride the stride (optional)
  87185. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87186. * @param instanced whether the buffer is instanced (optional)
  87187. * @param useBytes set to true if the stride in in bytes (optional)
  87188. * @param divisor sets an optional divisor for instances (1 by default)
  87189. */
  87190. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87191. /**
  87192. * Create a new VertexBuffer based on the current buffer
  87193. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87194. * @param offset defines offset in the buffer (0 by default)
  87195. * @param size defines the size in floats of attributes (position is 3 for instance)
  87196. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87197. * @param instanced defines if the vertex buffer contains indexed data
  87198. * @param useBytes defines if the offset and stride are in bytes *
  87199. * @param divisor sets an optional divisor for instances (1 by default)
  87200. * @returns the new vertex buffer
  87201. */
  87202. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87203. /**
  87204. * Gets a boolean indicating if the Buffer is updatable?
  87205. * @returns true if the buffer is updatable
  87206. */
  87207. isUpdatable(): boolean;
  87208. /**
  87209. * Gets current buffer's data
  87210. * @returns a DataArray or null
  87211. */
  87212. getData(): Nullable<DataArray>;
  87213. /**
  87214. * Gets underlying native buffer
  87215. * @returns underlying native buffer
  87216. */
  87217. getBuffer(): Nullable<DataBuffer>;
  87218. /**
  87219. * Gets the stride in float32 units (i.e. byte stride / 4).
  87220. * May not be an integer if the byte stride is not divisible by 4.
  87221. * @returns the stride in float32 units
  87222. * @deprecated Please use byteStride instead.
  87223. */
  87224. getStrideSize(): number;
  87225. /**
  87226. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87227. * @param data defines the data to store
  87228. */
  87229. create(data?: Nullable<DataArray>): void;
  87230. /** @hidden */
  87231. _rebuild(): void;
  87232. /**
  87233. * Update current buffer data
  87234. * @param data defines the data to store
  87235. */
  87236. update(data: DataArray): void;
  87237. /**
  87238. * Updates the data directly.
  87239. * @param data the new data
  87240. * @param offset the new offset
  87241. * @param vertexCount the vertex count (optional)
  87242. * @param useBytes set to true if the offset is in bytes
  87243. */
  87244. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87245. /**
  87246. * Release all resources
  87247. */
  87248. dispose(): void;
  87249. }
  87250. /**
  87251. * Specialized buffer used to store vertex data
  87252. */
  87253. export class VertexBuffer {
  87254. /** @hidden */
  87255. _buffer: Buffer;
  87256. private _kind;
  87257. private _size;
  87258. private _ownsBuffer;
  87259. private _instanced;
  87260. private _instanceDivisor;
  87261. /**
  87262. * The byte type.
  87263. */
  87264. static readonly BYTE: number;
  87265. /**
  87266. * The unsigned byte type.
  87267. */
  87268. static readonly UNSIGNED_BYTE: number;
  87269. /**
  87270. * The short type.
  87271. */
  87272. static readonly SHORT: number;
  87273. /**
  87274. * The unsigned short type.
  87275. */
  87276. static readonly UNSIGNED_SHORT: number;
  87277. /**
  87278. * The integer type.
  87279. */
  87280. static readonly INT: number;
  87281. /**
  87282. * The unsigned integer type.
  87283. */
  87284. static readonly UNSIGNED_INT: number;
  87285. /**
  87286. * The float type.
  87287. */
  87288. static readonly FLOAT: number;
  87289. /**
  87290. * Gets or sets the instance divisor when in instanced mode
  87291. */
  87292. get instanceDivisor(): number;
  87293. set instanceDivisor(value: number);
  87294. /**
  87295. * Gets the byte stride.
  87296. */
  87297. readonly byteStride: number;
  87298. /**
  87299. * Gets the byte offset.
  87300. */
  87301. readonly byteOffset: number;
  87302. /**
  87303. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87304. */
  87305. readonly normalized: boolean;
  87306. /**
  87307. * Gets the data type of each component in the array.
  87308. */
  87309. readonly type: number;
  87310. /**
  87311. * Constructor
  87312. * @param engine the engine
  87313. * @param data the data to use for this vertex buffer
  87314. * @param kind the vertex buffer kind
  87315. * @param updatable whether the data is updatable
  87316. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87317. * @param stride the stride (optional)
  87318. * @param instanced whether the buffer is instanced (optional)
  87319. * @param offset the offset of the data (optional)
  87320. * @param size the number of components (optional)
  87321. * @param type the type of the component (optional)
  87322. * @param normalized whether the data contains normalized data (optional)
  87323. * @param useBytes set to true if stride and offset are in bytes (optional)
  87324. * @param divisor defines the instance divisor to use (1 by default)
  87325. */
  87326. 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);
  87327. /** @hidden */
  87328. _rebuild(): void;
  87329. /**
  87330. * Returns the kind of the VertexBuffer (string)
  87331. * @returns a string
  87332. */
  87333. getKind(): string;
  87334. /**
  87335. * Gets a boolean indicating if the VertexBuffer is updatable?
  87336. * @returns true if the buffer is updatable
  87337. */
  87338. isUpdatable(): boolean;
  87339. /**
  87340. * Gets current buffer's data
  87341. * @returns a DataArray or null
  87342. */
  87343. getData(): Nullable<DataArray>;
  87344. /**
  87345. * Gets underlying native buffer
  87346. * @returns underlying native buffer
  87347. */
  87348. getBuffer(): Nullable<DataBuffer>;
  87349. /**
  87350. * Gets the stride in float32 units (i.e. byte stride / 4).
  87351. * May not be an integer if the byte stride is not divisible by 4.
  87352. * @returns the stride in float32 units
  87353. * @deprecated Please use byteStride instead.
  87354. */
  87355. getStrideSize(): number;
  87356. /**
  87357. * Returns the offset as a multiple of the type byte length.
  87358. * @returns the offset in bytes
  87359. * @deprecated Please use byteOffset instead.
  87360. */
  87361. getOffset(): number;
  87362. /**
  87363. * Returns the number of components per vertex attribute (integer)
  87364. * @returns the size in float
  87365. */
  87366. getSize(): number;
  87367. /**
  87368. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87369. * @returns true if this buffer is instanced
  87370. */
  87371. getIsInstanced(): boolean;
  87372. /**
  87373. * Returns the instancing divisor, zero for non-instanced (integer).
  87374. * @returns a number
  87375. */
  87376. getInstanceDivisor(): number;
  87377. /**
  87378. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87379. * @param data defines the data to store
  87380. */
  87381. create(data?: DataArray): void;
  87382. /**
  87383. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87384. * This function will create a new buffer if the current one is not updatable
  87385. * @param data defines the data to store
  87386. */
  87387. update(data: DataArray): void;
  87388. /**
  87389. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87390. * Returns the directly updated WebGLBuffer.
  87391. * @param data the new data
  87392. * @param offset the new offset
  87393. * @param useBytes set to true if the offset is in bytes
  87394. */
  87395. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87396. /**
  87397. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87398. */
  87399. dispose(): void;
  87400. /**
  87401. * Enumerates each value of this vertex buffer as numbers.
  87402. * @param count the number of values to enumerate
  87403. * @param callback the callback function called for each value
  87404. */
  87405. forEach(count: number, callback: (value: number, index: number) => void): void;
  87406. /**
  87407. * Positions
  87408. */
  87409. static readonly PositionKind: string;
  87410. /**
  87411. * Normals
  87412. */
  87413. static readonly NormalKind: string;
  87414. /**
  87415. * Tangents
  87416. */
  87417. static readonly TangentKind: string;
  87418. /**
  87419. * Texture coordinates
  87420. */
  87421. static readonly UVKind: string;
  87422. /**
  87423. * Texture coordinates 2
  87424. */
  87425. static readonly UV2Kind: string;
  87426. /**
  87427. * Texture coordinates 3
  87428. */
  87429. static readonly UV3Kind: string;
  87430. /**
  87431. * Texture coordinates 4
  87432. */
  87433. static readonly UV4Kind: string;
  87434. /**
  87435. * Texture coordinates 5
  87436. */
  87437. static readonly UV5Kind: string;
  87438. /**
  87439. * Texture coordinates 6
  87440. */
  87441. static readonly UV6Kind: string;
  87442. /**
  87443. * Colors
  87444. */
  87445. static readonly ColorKind: string;
  87446. /**
  87447. * Matrix indices (for bones)
  87448. */
  87449. static readonly MatricesIndicesKind: string;
  87450. /**
  87451. * Matrix weights (for bones)
  87452. */
  87453. static readonly MatricesWeightsKind: string;
  87454. /**
  87455. * Additional matrix indices (for bones)
  87456. */
  87457. static readonly MatricesIndicesExtraKind: string;
  87458. /**
  87459. * Additional matrix weights (for bones)
  87460. */
  87461. static readonly MatricesWeightsExtraKind: string;
  87462. /**
  87463. * Deduces the stride given a kind.
  87464. * @param kind The kind string to deduce
  87465. * @returns The deduced stride
  87466. */
  87467. static DeduceStride(kind: string): number;
  87468. /**
  87469. * Gets the byte length of the given type.
  87470. * @param type the type
  87471. * @returns the number of bytes
  87472. */
  87473. static GetTypeByteLength(type: number): number;
  87474. /**
  87475. * Enumerates each value of the given parameters as numbers.
  87476. * @param data the data to enumerate
  87477. * @param byteOffset the byte offset of the data
  87478. * @param byteStride the byte stride of the data
  87479. * @param componentCount the number of components per element
  87480. * @param componentType the type of the component
  87481. * @param count the number of values to enumerate
  87482. * @param normalized whether the data is normalized
  87483. * @param callback the callback function called for each value
  87484. */
  87485. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87486. private static _GetFloatValue;
  87487. }
  87488. }
  87489. declare module BABYLON {
  87490. /**
  87491. * The options Interface for creating a Capsule Mesh
  87492. */
  87493. export interface ICreateCapsuleOptions {
  87494. /** The Orientation of the capsule. Default : Vector3.Up() */
  87495. orientation?: Vector3;
  87496. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87497. subdivisions: number;
  87498. /** Number of cylindrical segments on the capsule. */
  87499. tessellation: number;
  87500. /** Height or Length of the capsule. */
  87501. height: number;
  87502. /** Radius of the capsule. */
  87503. radius: number;
  87504. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87505. capSubdivisions: number;
  87506. /** Overwrite for the top radius. */
  87507. radiusTop?: number;
  87508. /** Overwrite for the bottom radius. */
  87509. radiusBottom?: number;
  87510. /** Overwrite for the top capSubdivisions. */
  87511. topCapSubdivisions?: number;
  87512. /** Overwrite for the bottom capSubdivisions. */
  87513. bottomCapSubdivisions?: number;
  87514. }
  87515. /**
  87516. * Class containing static functions to help procedurally build meshes
  87517. */
  87518. export class CapsuleBuilder {
  87519. /**
  87520. * Creates a capsule or a pill mesh
  87521. * @param name defines the name of the mesh
  87522. * @param options The constructors options.
  87523. * @param scene The scene the mesh is scoped to.
  87524. * @returns Capsule Mesh
  87525. */
  87526. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87527. }
  87528. }
  87529. declare module BABYLON {
  87530. /**
  87531. * @hidden
  87532. */
  87533. export class IntersectionInfo {
  87534. bu: Nullable<number>;
  87535. bv: Nullable<number>;
  87536. distance: number;
  87537. faceId: number;
  87538. subMeshId: number;
  87539. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87540. }
  87541. }
  87542. declare module BABYLON {
  87543. /**
  87544. * Class used to store bounding sphere information
  87545. */
  87546. export class BoundingSphere {
  87547. /**
  87548. * Gets the center of the bounding sphere in local space
  87549. */
  87550. readonly center: Vector3;
  87551. /**
  87552. * Radius of the bounding sphere in local space
  87553. */
  87554. radius: number;
  87555. /**
  87556. * Gets the center of the bounding sphere in world space
  87557. */
  87558. readonly centerWorld: Vector3;
  87559. /**
  87560. * Radius of the bounding sphere in world space
  87561. */
  87562. radiusWorld: number;
  87563. /**
  87564. * Gets the minimum vector in local space
  87565. */
  87566. readonly minimum: Vector3;
  87567. /**
  87568. * Gets the maximum vector in local space
  87569. */
  87570. readonly maximum: Vector3;
  87571. private _worldMatrix;
  87572. private static readonly TmpVector3;
  87573. /**
  87574. * Creates a new bounding sphere
  87575. * @param min defines the minimum vector (in local space)
  87576. * @param max defines the maximum vector (in local space)
  87577. * @param worldMatrix defines the new world matrix
  87578. */
  87579. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87580. /**
  87581. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87582. * @param min defines the new minimum vector (in local space)
  87583. * @param max defines the new maximum vector (in local space)
  87584. * @param worldMatrix defines the new world matrix
  87585. */
  87586. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87587. /**
  87588. * Scale the current bounding sphere by applying a scale factor
  87589. * @param factor defines the scale factor to apply
  87590. * @returns the current bounding box
  87591. */
  87592. scale(factor: number): BoundingSphere;
  87593. /**
  87594. * Gets the world matrix of the bounding box
  87595. * @returns a matrix
  87596. */
  87597. getWorldMatrix(): DeepImmutable<Matrix>;
  87598. /** @hidden */
  87599. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87600. /**
  87601. * Tests if the bounding sphere is intersecting the frustum planes
  87602. * @param frustumPlanes defines the frustum planes to test
  87603. * @returns true if there is an intersection
  87604. */
  87605. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87606. /**
  87607. * Tests if the bounding sphere center is in between the frustum planes.
  87608. * Used for optimistic fast inclusion.
  87609. * @param frustumPlanes defines the frustum planes to test
  87610. * @returns true if the sphere center is in between the frustum planes
  87611. */
  87612. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87613. /**
  87614. * Tests if a point is inside the bounding sphere
  87615. * @param point defines the point to test
  87616. * @returns true if the point is inside the bounding sphere
  87617. */
  87618. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87619. /**
  87620. * Checks if two sphere intersct
  87621. * @param sphere0 sphere 0
  87622. * @param sphere1 sphere 1
  87623. * @returns true if the speres intersect
  87624. */
  87625. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87626. }
  87627. }
  87628. declare module BABYLON {
  87629. /**
  87630. * Class used to store bounding box information
  87631. */
  87632. export class BoundingBox implements ICullable {
  87633. /**
  87634. * Gets the 8 vectors representing the bounding box in local space
  87635. */
  87636. readonly vectors: Vector3[];
  87637. /**
  87638. * Gets the center of the bounding box in local space
  87639. */
  87640. readonly center: Vector3;
  87641. /**
  87642. * Gets the center of the bounding box in world space
  87643. */
  87644. readonly centerWorld: Vector3;
  87645. /**
  87646. * Gets the extend size in local space
  87647. */
  87648. readonly extendSize: Vector3;
  87649. /**
  87650. * Gets the extend size in world space
  87651. */
  87652. readonly extendSizeWorld: Vector3;
  87653. /**
  87654. * Gets the OBB (object bounding box) directions
  87655. */
  87656. readonly directions: Vector3[];
  87657. /**
  87658. * Gets the 8 vectors representing the bounding box in world space
  87659. */
  87660. readonly vectorsWorld: Vector3[];
  87661. /**
  87662. * Gets the minimum vector in world space
  87663. */
  87664. readonly minimumWorld: Vector3;
  87665. /**
  87666. * Gets the maximum vector in world space
  87667. */
  87668. readonly maximumWorld: Vector3;
  87669. /**
  87670. * Gets the minimum vector in local space
  87671. */
  87672. readonly minimum: Vector3;
  87673. /**
  87674. * Gets the maximum vector in local space
  87675. */
  87676. readonly maximum: Vector3;
  87677. private _worldMatrix;
  87678. private static readonly TmpVector3;
  87679. /**
  87680. * @hidden
  87681. */
  87682. _tag: number;
  87683. /**
  87684. * Creates a new bounding box
  87685. * @param min defines the minimum vector (in local space)
  87686. * @param max defines the maximum vector (in local space)
  87687. * @param worldMatrix defines the new world matrix
  87688. */
  87689. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87690. /**
  87691. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87692. * @param min defines the new minimum vector (in local space)
  87693. * @param max defines the new maximum vector (in local space)
  87694. * @param worldMatrix defines the new world matrix
  87695. */
  87696. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87697. /**
  87698. * Scale the current bounding box by applying a scale factor
  87699. * @param factor defines the scale factor to apply
  87700. * @returns the current bounding box
  87701. */
  87702. scale(factor: number): BoundingBox;
  87703. /**
  87704. * Gets the world matrix of the bounding box
  87705. * @returns a matrix
  87706. */
  87707. getWorldMatrix(): DeepImmutable<Matrix>;
  87708. /** @hidden */
  87709. _update(world: DeepImmutable<Matrix>): void;
  87710. /**
  87711. * Tests if the bounding box is intersecting the frustum planes
  87712. * @param frustumPlanes defines the frustum planes to test
  87713. * @returns true if there is an intersection
  87714. */
  87715. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87716. /**
  87717. * Tests if the bounding box is entirely inside the frustum planes
  87718. * @param frustumPlanes defines the frustum planes to test
  87719. * @returns true if there is an inclusion
  87720. */
  87721. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87722. /**
  87723. * Tests if a point is inside the bounding box
  87724. * @param point defines the point to test
  87725. * @returns true if the point is inside the bounding box
  87726. */
  87727. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87728. /**
  87729. * Tests if the bounding box intersects with a bounding sphere
  87730. * @param sphere defines the sphere to test
  87731. * @returns true if there is an intersection
  87732. */
  87733. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87734. /**
  87735. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87736. * @param min defines the min vector to use
  87737. * @param max defines the max vector to use
  87738. * @returns true if there is an intersection
  87739. */
  87740. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87741. /**
  87742. * Tests if two bounding boxes are intersections
  87743. * @param box0 defines the first box to test
  87744. * @param box1 defines the second box to test
  87745. * @returns true if there is an intersection
  87746. */
  87747. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87748. /**
  87749. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87750. * @param minPoint defines the minimum vector of the bounding box
  87751. * @param maxPoint defines the maximum vector of the bounding box
  87752. * @param sphereCenter defines the sphere center
  87753. * @param sphereRadius defines the sphere radius
  87754. * @returns true if there is an intersection
  87755. */
  87756. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87757. /**
  87758. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87759. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87760. * @param frustumPlanes defines the frustum planes to test
  87761. * @return true if there is an inclusion
  87762. */
  87763. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87764. /**
  87765. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87766. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87767. * @param frustumPlanes defines the frustum planes to test
  87768. * @return true if there is an intersection
  87769. */
  87770. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87771. }
  87772. }
  87773. declare module BABYLON {
  87774. /** @hidden */
  87775. export class Collider {
  87776. /** Define if a collision was found */
  87777. collisionFound: boolean;
  87778. /**
  87779. * Define last intersection point in local space
  87780. */
  87781. intersectionPoint: Vector3;
  87782. /**
  87783. * Define last collided mesh
  87784. */
  87785. collidedMesh: Nullable<AbstractMesh>;
  87786. private _collisionPoint;
  87787. private _planeIntersectionPoint;
  87788. private _tempVector;
  87789. private _tempVector2;
  87790. private _tempVector3;
  87791. private _tempVector4;
  87792. private _edge;
  87793. private _baseToVertex;
  87794. private _destinationPoint;
  87795. private _slidePlaneNormal;
  87796. private _displacementVector;
  87797. /** @hidden */
  87798. _radius: Vector3;
  87799. /** @hidden */
  87800. _retry: number;
  87801. private _velocity;
  87802. private _basePoint;
  87803. private _epsilon;
  87804. /** @hidden */
  87805. _velocityWorldLength: number;
  87806. /** @hidden */
  87807. _basePointWorld: Vector3;
  87808. private _velocityWorld;
  87809. private _normalizedVelocity;
  87810. /** @hidden */
  87811. _initialVelocity: Vector3;
  87812. /** @hidden */
  87813. _initialPosition: Vector3;
  87814. private _nearestDistance;
  87815. private _collisionMask;
  87816. get collisionMask(): number;
  87817. set collisionMask(mask: number);
  87818. /**
  87819. * Gets the plane normal used to compute the sliding response (in local space)
  87820. */
  87821. get slidePlaneNormal(): Vector3;
  87822. /** @hidden */
  87823. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87824. /** @hidden */
  87825. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87826. /** @hidden */
  87827. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87828. /** @hidden */
  87829. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87830. /** @hidden */
  87831. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87832. /** @hidden */
  87833. _getResponse(pos: Vector3, vel: Vector3): void;
  87834. }
  87835. }
  87836. declare module BABYLON {
  87837. /**
  87838. * Interface for cullable objects
  87839. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87840. */
  87841. export interface ICullable {
  87842. /**
  87843. * Checks if the object or part of the object is in the frustum
  87844. * @param frustumPlanes Camera near/planes
  87845. * @returns true if the object is in frustum otherwise false
  87846. */
  87847. isInFrustum(frustumPlanes: Plane[]): boolean;
  87848. /**
  87849. * Checks if a cullable object (mesh...) is in the camera frustum
  87850. * Unlike isInFrustum this cheks the full bounding box
  87851. * @param frustumPlanes Camera near/planes
  87852. * @returns true if the object is in frustum otherwise false
  87853. */
  87854. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87855. }
  87856. /**
  87857. * Info for a bounding data of a mesh
  87858. */
  87859. export class BoundingInfo implements ICullable {
  87860. /**
  87861. * Bounding box for the mesh
  87862. */
  87863. readonly boundingBox: BoundingBox;
  87864. /**
  87865. * Bounding sphere for the mesh
  87866. */
  87867. readonly boundingSphere: BoundingSphere;
  87868. private _isLocked;
  87869. private static readonly TmpVector3;
  87870. /**
  87871. * Constructs bounding info
  87872. * @param minimum min vector of the bounding box/sphere
  87873. * @param maximum max vector of the bounding box/sphere
  87874. * @param worldMatrix defines the new world matrix
  87875. */
  87876. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87877. /**
  87878. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87879. * @param min defines the new minimum vector (in local space)
  87880. * @param max defines the new maximum vector (in local space)
  87881. * @param worldMatrix defines the new world matrix
  87882. */
  87883. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87884. /**
  87885. * min vector of the bounding box/sphere
  87886. */
  87887. get minimum(): Vector3;
  87888. /**
  87889. * max vector of the bounding box/sphere
  87890. */
  87891. get maximum(): Vector3;
  87892. /**
  87893. * If the info is locked and won't be updated to avoid perf overhead
  87894. */
  87895. get isLocked(): boolean;
  87896. set isLocked(value: boolean);
  87897. /**
  87898. * Updates the bounding sphere and box
  87899. * @param world world matrix to be used to update
  87900. */
  87901. update(world: DeepImmutable<Matrix>): void;
  87902. /**
  87903. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87904. * @param center New center of the bounding info
  87905. * @param extend New extend of the bounding info
  87906. * @returns the current bounding info
  87907. */
  87908. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87909. /**
  87910. * Scale the current bounding info by applying a scale factor
  87911. * @param factor defines the scale factor to apply
  87912. * @returns the current bounding info
  87913. */
  87914. scale(factor: number): BoundingInfo;
  87915. /**
  87916. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87917. * @param frustumPlanes defines the frustum to test
  87918. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87919. * @returns true if the bounding info is in the frustum planes
  87920. */
  87921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87922. /**
  87923. * Gets the world distance between the min and max points of the bounding box
  87924. */
  87925. get diagonalLength(): number;
  87926. /**
  87927. * Checks if a cullable object (mesh...) is in the camera frustum
  87928. * Unlike isInFrustum this cheks the full bounding box
  87929. * @param frustumPlanes Camera near/planes
  87930. * @returns true if the object is in frustum otherwise false
  87931. */
  87932. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87933. /** @hidden */
  87934. _checkCollision(collider: Collider): boolean;
  87935. /**
  87936. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87937. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87938. * @param point the point to check intersection with
  87939. * @returns if the point intersects
  87940. */
  87941. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87942. /**
  87943. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87944. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87945. * @param boundingInfo the bounding info to check intersection with
  87946. * @param precise if the intersection should be done using OBB
  87947. * @returns if the bounding info intersects
  87948. */
  87949. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87950. }
  87951. }
  87952. declare module BABYLON {
  87953. /**
  87954. * Extracts minimum and maximum values from a list of indexed positions
  87955. * @param positions defines the positions to use
  87956. * @param indices defines the indices to the positions
  87957. * @param indexStart defines the start index
  87958. * @param indexCount defines the end index
  87959. * @param bias defines bias value to add to the result
  87960. * @return minimum and maximum values
  87961. */
  87962. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87963. minimum: Vector3;
  87964. maximum: Vector3;
  87965. };
  87966. /**
  87967. * Extracts minimum and maximum values from a list of positions
  87968. * @param positions defines the positions to use
  87969. * @param start defines the start index in the positions array
  87970. * @param count defines the number of positions to handle
  87971. * @param bias defines bias value to add to the result
  87972. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87973. * @return minimum and maximum values
  87974. */
  87975. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87976. minimum: Vector3;
  87977. maximum: Vector3;
  87978. };
  87979. }
  87980. declare module BABYLON {
  87981. /** @hidden */
  87982. export class WebGLDataBuffer extends DataBuffer {
  87983. private _buffer;
  87984. constructor(resource: WebGLBuffer);
  87985. get underlyingResource(): any;
  87986. }
  87987. }
  87988. declare module BABYLON {
  87989. /** @hidden */
  87990. export class WebGLPipelineContext implements IPipelineContext {
  87991. engine: ThinEngine;
  87992. program: Nullable<WebGLProgram>;
  87993. context?: WebGLRenderingContext;
  87994. vertexShader?: WebGLShader;
  87995. fragmentShader?: WebGLShader;
  87996. isParallelCompiled: boolean;
  87997. onCompiled?: () => void;
  87998. transformFeedback?: WebGLTransformFeedback | null;
  87999. vertexCompilationError: Nullable<string>;
  88000. fragmentCompilationError: Nullable<string>;
  88001. programLinkError: Nullable<string>;
  88002. programValidationError: Nullable<string>;
  88003. get isAsync(): boolean;
  88004. get isReady(): boolean;
  88005. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88006. _getVertexShaderCode(): string | null;
  88007. _getFragmentShaderCode(): string | null;
  88008. }
  88009. }
  88010. declare module BABYLON {
  88011. interface ThinEngine {
  88012. /**
  88013. * Create an uniform buffer
  88014. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88015. * @param elements defines the content of the uniform buffer
  88016. * @returns the webGL uniform buffer
  88017. */
  88018. createUniformBuffer(elements: FloatArray): DataBuffer;
  88019. /**
  88020. * Create a dynamic uniform buffer
  88021. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88022. * @param elements defines the content of the uniform buffer
  88023. * @returns the webGL uniform buffer
  88024. */
  88025. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88026. /**
  88027. * Update an existing uniform buffer
  88028. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88029. * @param uniformBuffer defines the target uniform buffer
  88030. * @param elements defines the content to update
  88031. * @param offset defines the offset in the uniform buffer where update should start
  88032. * @param count defines the size of the data to update
  88033. */
  88034. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88035. /**
  88036. * Bind an uniform buffer to the current webGL context
  88037. * @param buffer defines the buffer to bind
  88038. */
  88039. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88040. /**
  88041. * Bind a buffer to the current webGL context at a given location
  88042. * @param buffer defines the buffer to bind
  88043. * @param location defines the index where to bind the buffer
  88044. */
  88045. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88046. /**
  88047. * Bind a specific block at a given index in a specific shader program
  88048. * @param pipelineContext defines the pipeline context to use
  88049. * @param blockName defines the block name
  88050. * @param index defines the index where to bind the block
  88051. */
  88052. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88053. }
  88054. }
  88055. declare module BABYLON {
  88056. /**
  88057. * Uniform buffer objects.
  88058. *
  88059. * Handles blocks of uniform on the GPU.
  88060. *
  88061. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88062. *
  88063. * For more information, please refer to :
  88064. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88065. */
  88066. export class UniformBuffer {
  88067. private _engine;
  88068. private _buffer;
  88069. private _data;
  88070. private _bufferData;
  88071. private _dynamic?;
  88072. private _uniformLocations;
  88073. private _uniformSizes;
  88074. private _uniformLocationPointer;
  88075. private _needSync;
  88076. private _noUBO;
  88077. private _currentEffect;
  88078. /** @hidden */
  88079. _alreadyBound: boolean;
  88080. private static _MAX_UNIFORM_SIZE;
  88081. private static _tempBuffer;
  88082. /**
  88083. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88084. * This is dynamic to allow compat with webgl 1 and 2.
  88085. * You will need to pass the name of the uniform as well as the value.
  88086. */
  88087. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88088. /**
  88089. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88090. * This is dynamic to allow compat with webgl 1 and 2.
  88091. * You will need to pass the name of the uniform as well as the value.
  88092. */
  88093. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88094. /**
  88095. * Lambda to Update a single float in a uniform buffer.
  88096. * This is dynamic to allow compat with webgl 1 and 2.
  88097. * You will need to pass the name of the uniform as well as the value.
  88098. */
  88099. updateFloat: (name: string, x: number) => void;
  88100. /**
  88101. * Lambda to Update a vec2 of float in a uniform buffer.
  88102. * This is dynamic to allow compat with webgl 1 and 2.
  88103. * You will need to pass the name of the uniform as well as the value.
  88104. */
  88105. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88106. /**
  88107. * Lambda to Update a vec3 of float in a uniform buffer.
  88108. * This is dynamic to allow compat with webgl 1 and 2.
  88109. * You will need to pass the name of the uniform as well as the value.
  88110. */
  88111. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88112. /**
  88113. * Lambda to Update a vec4 of float in a uniform buffer.
  88114. * This is dynamic to allow compat with webgl 1 and 2.
  88115. * You will need to pass the name of the uniform as well as the value.
  88116. */
  88117. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88118. /**
  88119. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88120. * This is dynamic to allow compat with webgl 1 and 2.
  88121. * You will need to pass the name of the uniform as well as the value.
  88122. */
  88123. updateMatrix: (name: string, mat: Matrix) => void;
  88124. /**
  88125. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88126. * This is dynamic to allow compat with webgl 1 and 2.
  88127. * You will need to pass the name of the uniform as well as the value.
  88128. */
  88129. updateVector3: (name: string, vector: Vector3) => void;
  88130. /**
  88131. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88132. * This is dynamic to allow compat with webgl 1 and 2.
  88133. * You will need to pass the name of the uniform as well as the value.
  88134. */
  88135. updateVector4: (name: string, vector: Vector4) => void;
  88136. /**
  88137. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88138. * This is dynamic to allow compat with webgl 1 and 2.
  88139. * You will need to pass the name of the uniform as well as the value.
  88140. */
  88141. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88142. /**
  88143. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88144. * This is dynamic to allow compat with webgl 1 and 2.
  88145. * You will need to pass the name of the uniform as well as the value.
  88146. */
  88147. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88148. /**
  88149. * Instantiates a new Uniform buffer objects.
  88150. *
  88151. * Handles blocks of uniform on the GPU.
  88152. *
  88153. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88154. *
  88155. * For more information, please refer to :
  88156. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88157. * @param engine Define the engine the buffer is associated with
  88158. * @param data Define the data contained in the buffer
  88159. * @param dynamic Define if the buffer is updatable
  88160. */
  88161. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88162. /**
  88163. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88164. * or just falling back on setUniformXXX calls.
  88165. */
  88166. get useUbo(): boolean;
  88167. /**
  88168. * Indicates if the WebGL underlying uniform buffer is in sync
  88169. * with the javascript cache data.
  88170. */
  88171. get isSync(): boolean;
  88172. /**
  88173. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88174. * Also, a dynamic UniformBuffer will disable cache verification and always
  88175. * update the underlying WebGL uniform buffer to the GPU.
  88176. * @returns if Dynamic, otherwise false
  88177. */
  88178. isDynamic(): boolean;
  88179. /**
  88180. * The data cache on JS side.
  88181. * @returns the underlying data as a float array
  88182. */
  88183. getData(): Float32Array;
  88184. /**
  88185. * The underlying WebGL Uniform buffer.
  88186. * @returns the webgl buffer
  88187. */
  88188. getBuffer(): Nullable<DataBuffer>;
  88189. /**
  88190. * std140 layout specifies how to align data within an UBO structure.
  88191. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88192. * for specs.
  88193. */
  88194. private _fillAlignment;
  88195. /**
  88196. * Adds an uniform in the buffer.
  88197. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88198. * for the layout to be correct !
  88199. * @param name Name of the uniform, as used in the uniform block in the shader.
  88200. * @param size Data size, or data directly.
  88201. */
  88202. addUniform(name: string, size: number | number[]): void;
  88203. /**
  88204. * Adds a Matrix 4x4 to the uniform buffer.
  88205. * @param name Name of the uniform, as used in the uniform block in the shader.
  88206. * @param mat A 4x4 matrix.
  88207. */
  88208. addMatrix(name: string, mat: Matrix): void;
  88209. /**
  88210. * Adds a vec2 to the uniform buffer.
  88211. * @param name Name of the uniform, as used in the uniform block in the shader.
  88212. * @param x Define the x component value of the vec2
  88213. * @param y Define the y component value of the vec2
  88214. */
  88215. addFloat2(name: string, x: number, y: number): void;
  88216. /**
  88217. * Adds a vec3 to the uniform buffer.
  88218. * @param name Name of the uniform, as used in the uniform block in the shader.
  88219. * @param x Define the x component value of the vec3
  88220. * @param y Define the y component value of the vec3
  88221. * @param z Define the z component value of the vec3
  88222. */
  88223. addFloat3(name: string, x: number, y: number, z: number): void;
  88224. /**
  88225. * Adds a vec3 to the uniform buffer.
  88226. * @param name Name of the uniform, as used in the uniform block in the shader.
  88227. * @param color Define the vec3 from a Color
  88228. */
  88229. addColor3(name: string, color: Color3): void;
  88230. /**
  88231. * Adds a vec4 to the uniform buffer.
  88232. * @param name Name of the uniform, as used in the uniform block in the shader.
  88233. * @param color Define the rgb components from a Color
  88234. * @param alpha Define the a component of the vec4
  88235. */
  88236. addColor4(name: string, color: Color3, alpha: number): void;
  88237. /**
  88238. * Adds a vec3 to the uniform buffer.
  88239. * @param name Name of the uniform, as used in the uniform block in the shader.
  88240. * @param vector Define the vec3 components from a Vector
  88241. */
  88242. addVector3(name: string, vector: Vector3): void;
  88243. /**
  88244. * Adds a Matrix 3x3 to the uniform buffer.
  88245. * @param name Name of the uniform, as used in the uniform block in the shader.
  88246. */
  88247. addMatrix3x3(name: string): void;
  88248. /**
  88249. * Adds a Matrix 2x2 to the uniform buffer.
  88250. * @param name Name of the uniform, as used in the uniform block in the shader.
  88251. */
  88252. addMatrix2x2(name: string): void;
  88253. /**
  88254. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88255. */
  88256. create(): void;
  88257. /** @hidden */
  88258. _rebuild(): void;
  88259. /**
  88260. * Updates the WebGL Uniform Buffer on the GPU.
  88261. * If the `dynamic` flag is set to true, no cache comparison is done.
  88262. * Otherwise, the buffer will be updated only if the cache differs.
  88263. */
  88264. update(): void;
  88265. /**
  88266. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88267. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88268. * @param data Define the flattened data
  88269. * @param size Define the size of the data.
  88270. */
  88271. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88272. private _valueCache;
  88273. private _cacheMatrix;
  88274. private _updateMatrix3x3ForUniform;
  88275. private _updateMatrix3x3ForEffect;
  88276. private _updateMatrix2x2ForEffect;
  88277. private _updateMatrix2x2ForUniform;
  88278. private _updateFloatForEffect;
  88279. private _updateFloatForUniform;
  88280. private _updateFloat2ForEffect;
  88281. private _updateFloat2ForUniform;
  88282. private _updateFloat3ForEffect;
  88283. private _updateFloat3ForUniform;
  88284. private _updateFloat4ForEffect;
  88285. private _updateFloat4ForUniform;
  88286. private _updateMatrixForEffect;
  88287. private _updateMatrixForUniform;
  88288. private _updateVector3ForEffect;
  88289. private _updateVector3ForUniform;
  88290. private _updateVector4ForEffect;
  88291. private _updateVector4ForUniform;
  88292. private _updateColor3ForEffect;
  88293. private _updateColor3ForUniform;
  88294. private _updateColor4ForEffect;
  88295. private _updateColor4ForUniform;
  88296. /**
  88297. * Sets a sampler uniform on the effect.
  88298. * @param name Define the name of the sampler.
  88299. * @param texture Define the texture to set in the sampler
  88300. */
  88301. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88302. /**
  88303. * Directly updates the value of the uniform in the cache AND on the GPU.
  88304. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88305. * @param data Define the flattened data
  88306. */
  88307. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88308. /**
  88309. * Binds this uniform buffer to an effect.
  88310. * @param effect Define the effect to bind the buffer to
  88311. * @param name Name of the uniform block in the shader.
  88312. */
  88313. bindToEffect(effect: Effect, name: string): void;
  88314. /**
  88315. * Disposes the uniform buffer.
  88316. */
  88317. dispose(): void;
  88318. }
  88319. }
  88320. declare module BABYLON {
  88321. /**
  88322. * Enum that determines the text-wrapping mode to use.
  88323. */
  88324. export enum InspectableType {
  88325. /**
  88326. * Checkbox for booleans
  88327. */
  88328. Checkbox = 0,
  88329. /**
  88330. * Sliders for numbers
  88331. */
  88332. Slider = 1,
  88333. /**
  88334. * Vector3
  88335. */
  88336. Vector3 = 2,
  88337. /**
  88338. * Quaternions
  88339. */
  88340. Quaternion = 3,
  88341. /**
  88342. * Color3
  88343. */
  88344. Color3 = 4,
  88345. /**
  88346. * String
  88347. */
  88348. String = 5
  88349. }
  88350. /**
  88351. * Interface used to define custom inspectable properties.
  88352. * This interface is used by the inspector to display custom property grids
  88353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88354. */
  88355. export interface IInspectable {
  88356. /**
  88357. * Gets the label to display
  88358. */
  88359. label: string;
  88360. /**
  88361. * Gets the name of the property to edit
  88362. */
  88363. propertyName: string;
  88364. /**
  88365. * Gets the type of the editor to use
  88366. */
  88367. type: InspectableType;
  88368. /**
  88369. * Gets the minimum value of the property when using in "slider" mode
  88370. */
  88371. min?: number;
  88372. /**
  88373. * Gets the maximum value of the property when using in "slider" mode
  88374. */
  88375. max?: number;
  88376. /**
  88377. * Gets the setp to use when using in "slider" mode
  88378. */
  88379. step?: number;
  88380. }
  88381. }
  88382. declare module BABYLON {
  88383. /**
  88384. * Class used to provide helper for timing
  88385. */
  88386. export class TimingTools {
  88387. /**
  88388. * Polyfill for setImmediate
  88389. * @param action defines the action to execute after the current execution block
  88390. */
  88391. static SetImmediate(action: () => void): void;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /**
  88396. * Class used to enable instatition of objects by class name
  88397. */
  88398. export class InstantiationTools {
  88399. /**
  88400. * Use this object to register external classes like custom textures or material
  88401. * to allow the laoders to instantiate them
  88402. */
  88403. static RegisteredExternalClasses: {
  88404. [key: string]: Object;
  88405. };
  88406. /**
  88407. * Tries to instantiate a new object from a given class name
  88408. * @param className defines the class name to instantiate
  88409. * @returns the new object or null if the system was not able to do the instantiation
  88410. */
  88411. static Instantiate(className: string): any;
  88412. }
  88413. }
  88414. declare module BABYLON {
  88415. /**
  88416. * Define options used to create a depth texture
  88417. */
  88418. export class DepthTextureCreationOptions {
  88419. /** Specifies whether or not a stencil should be allocated in the texture */
  88420. generateStencil?: boolean;
  88421. /** Specifies whether or not bilinear filtering is enable on the texture */
  88422. bilinearFiltering?: boolean;
  88423. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88424. comparisonFunction?: number;
  88425. /** Specifies if the created texture is a cube texture */
  88426. isCube?: boolean;
  88427. }
  88428. }
  88429. declare module BABYLON {
  88430. interface ThinEngine {
  88431. /**
  88432. * Creates a depth stencil cube texture.
  88433. * This is only available in WebGL 2.
  88434. * @param size The size of face edge in the cube texture.
  88435. * @param options The options defining the cube texture.
  88436. * @returns The cube texture
  88437. */
  88438. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88439. /**
  88440. * Creates a cube texture
  88441. * @param rootUrl defines the url where the files to load is located
  88442. * @param scene defines the current scene
  88443. * @param files defines the list of files to load (1 per face)
  88444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88445. * @param onLoad defines an optional callback raised when the texture is loaded
  88446. * @param onError defines an optional callback raised if there is an issue to load the texture
  88447. * @param format defines the format of the data
  88448. * @param forcedExtension defines the extension to use to pick the right loader
  88449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88452. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88453. * @returns the cube texture as an InternalTexture
  88454. */
  88455. 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;
  88456. /**
  88457. * Creates a cube texture
  88458. * @param rootUrl defines the url where the files to load is located
  88459. * @param scene defines the current scene
  88460. * @param files defines the list of files to load (1 per face)
  88461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88462. * @param onLoad defines an optional callback raised when the texture is loaded
  88463. * @param onError defines an optional callback raised if there is an issue to load the texture
  88464. * @param format defines the format of the data
  88465. * @param forcedExtension defines the extension to use to pick the right loader
  88466. * @returns the cube texture as an InternalTexture
  88467. */
  88468. 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;
  88469. /**
  88470. * Creates a cube texture
  88471. * @param rootUrl defines the url where the files to load is located
  88472. * @param scene defines the current scene
  88473. * @param files defines the list of files to load (1 per face)
  88474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88475. * @param onLoad defines an optional callback raised when the texture is loaded
  88476. * @param onError defines an optional callback raised if there is an issue to load the texture
  88477. * @param format defines the format of the data
  88478. * @param forcedExtension defines the extension to use to pick the right loader
  88479. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88482. * @returns the cube texture as an InternalTexture
  88483. */
  88484. 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;
  88485. /** @hidden */
  88486. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88487. /** @hidden */
  88488. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88489. /** @hidden */
  88490. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88491. /** @hidden */
  88492. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88493. /**
  88494. * @hidden
  88495. */
  88496. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88497. }
  88498. }
  88499. declare module BABYLON {
  88500. /**
  88501. * Class for creating a cube texture
  88502. */
  88503. export class CubeTexture extends BaseTexture {
  88504. private _delayedOnLoad;
  88505. /**
  88506. * Observable triggered once the texture has been loaded.
  88507. */
  88508. onLoadObservable: Observable<CubeTexture>;
  88509. /**
  88510. * The url of the texture
  88511. */
  88512. url: string;
  88513. /**
  88514. * Gets or sets the center of the bounding box associated with the cube texture.
  88515. * It must define where the camera used to render the texture was set
  88516. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88517. */
  88518. boundingBoxPosition: Vector3;
  88519. private _boundingBoxSize;
  88520. /**
  88521. * Gets or sets the size of the bounding box associated with the cube texture
  88522. * When defined, the cubemap will switch to local mode
  88523. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88524. * @example https://www.babylonjs-playground.com/#RNASML
  88525. */
  88526. set boundingBoxSize(value: Vector3);
  88527. /**
  88528. * Returns the bounding box size
  88529. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88530. */
  88531. get boundingBoxSize(): Vector3;
  88532. protected _rotationY: number;
  88533. /**
  88534. * Sets texture matrix rotation angle around Y axis in radians.
  88535. */
  88536. set rotationY(value: number);
  88537. /**
  88538. * Gets texture matrix rotation angle around Y axis radians.
  88539. */
  88540. get rotationY(): number;
  88541. /**
  88542. * Are mip maps generated for this texture or not.
  88543. */
  88544. get noMipmap(): boolean;
  88545. private _noMipmap;
  88546. private _files;
  88547. protected _forcedExtension: Nullable<string>;
  88548. private _extensions;
  88549. private _textureMatrix;
  88550. private _format;
  88551. private _createPolynomials;
  88552. /**
  88553. * Creates a cube texture from an array of image urls
  88554. * @param files defines an array of image urls
  88555. * @param scene defines the hosting scene
  88556. * @param noMipmap specifies if mip maps are not used
  88557. * @returns a cube texture
  88558. */
  88559. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88560. /**
  88561. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88562. * @param url defines the url of the prefiltered texture
  88563. * @param scene defines the scene the texture is attached to
  88564. * @param forcedExtension defines the extension of the file if different from the url
  88565. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88566. * @return the prefiltered texture
  88567. */
  88568. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88569. /**
  88570. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88571. * as prefiltered data.
  88572. * @param rootUrl defines the url of the texture or the root name of the six images
  88573. * @param null defines the scene or engine the texture is attached to
  88574. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88575. * @param noMipmap defines if mipmaps should be created or not
  88576. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88577. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88578. * @param onError defines a callback triggered in case of error during load
  88579. * @param format defines the internal format to use for the texture once loaded
  88580. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88581. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88582. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88583. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88584. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88585. * @return the cube texture
  88586. */
  88587. 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);
  88588. /**
  88589. * Get the current class name of the texture useful for serialization or dynamic coding.
  88590. * @returns "CubeTexture"
  88591. */
  88592. getClassName(): string;
  88593. /**
  88594. * Update the url (and optional buffer) of this texture if url was null during construction.
  88595. * @param url the url of the texture
  88596. * @param forcedExtension defines the extension to use
  88597. * @param onLoad callback called when the texture is loaded (defaults to null)
  88598. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88599. */
  88600. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88601. /**
  88602. * Delays loading of the cube texture
  88603. * @param forcedExtension defines the extension to use
  88604. */
  88605. delayLoad(forcedExtension?: string): void;
  88606. /**
  88607. * Returns the reflection texture matrix
  88608. * @returns the reflection texture matrix
  88609. */
  88610. getReflectionTextureMatrix(): Matrix;
  88611. /**
  88612. * Sets the reflection texture matrix
  88613. * @param value Reflection texture matrix
  88614. */
  88615. setReflectionTextureMatrix(value: Matrix): void;
  88616. /**
  88617. * Parses text to create a cube texture
  88618. * @param parsedTexture define the serialized text to read from
  88619. * @param scene defines the hosting scene
  88620. * @param rootUrl defines the root url of the cube texture
  88621. * @returns a cube texture
  88622. */
  88623. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88624. /**
  88625. * Makes a clone, or deep copy, of the cube texture
  88626. * @returns a new cube texture
  88627. */
  88628. clone(): CubeTexture;
  88629. }
  88630. }
  88631. declare module BABYLON {
  88632. /**
  88633. * Manages the defines for the Material
  88634. */
  88635. export class MaterialDefines {
  88636. /** @hidden */
  88637. protected _keys: string[];
  88638. private _isDirty;
  88639. /** @hidden */
  88640. _renderId: number;
  88641. /** @hidden */
  88642. _areLightsDirty: boolean;
  88643. /** @hidden */
  88644. _areLightsDisposed: boolean;
  88645. /** @hidden */
  88646. _areAttributesDirty: boolean;
  88647. /** @hidden */
  88648. _areTexturesDirty: boolean;
  88649. /** @hidden */
  88650. _areFresnelDirty: boolean;
  88651. /** @hidden */
  88652. _areMiscDirty: boolean;
  88653. /** @hidden */
  88654. _arePrePassDirty: boolean;
  88655. /** @hidden */
  88656. _areImageProcessingDirty: boolean;
  88657. /** @hidden */
  88658. _normals: boolean;
  88659. /** @hidden */
  88660. _uvs: boolean;
  88661. /** @hidden */
  88662. _needNormals: boolean;
  88663. /** @hidden */
  88664. _needUVs: boolean;
  88665. [id: string]: any;
  88666. /**
  88667. * Specifies if the material needs to be re-calculated
  88668. */
  88669. get isDirty(): boolean;
  88670. /**
  88671. * Marks the material to indicate that it has been re-calculated
  88672. */
  88673. markAsProcessed(): void;
  88674. /**
  88675. * Marks the material to indicate that it needs to be re-calculated
  88676. */
  88677. markAsUnprocessed(): void;
  88678. /**
  88679. * Marks the material to indicate all of its defines need to be re-calculated
  88680. */
  88681. markAllAsDirty(): void;
  88682. /**
  88683. * Marks the material to indicate that image processing needs to be re-calculated
  88684. */
  88685. markAsImageProcessingDirty(): void;
  88686. /**
  88687. * Marks the material to indicate the lights need to be re-calculated
  88688. * @param disposed Defines whether the light is dirty due to dispose or not
  88689. */
  88690. markAsLightDirty(disposed?: boolean): void;
  88691. /**
  88692. * Marks the attribute state as changed
  88693. */
  88694. markAsAttributesDirty(): void;
  88695. /**
  88696. * Marks the texture state as changed
  88697. */
  88698. markAsTexturesDirty(): void;
  88699. /**
  88700. * Marks the fresnel state as changed
  88701. */
  88702. markAsFresnelDirty(): void;
  88703. /**
  88704. * Marks the misc state as changed
  88705. */
  88706. markAsMiscDirty(): void;
  88707. /**
  88708. * Marks the prepass state as changed
  88709. */
  88710. markAsPrePassDirty(): void;
  88711. /**
  88712. * Rebuilds the material defines
  88713. */
  88714. rebuild(): void;
  88715. /**
  88716. * Specifies if two material defines are equal
  88717. * @param other - A material define instance to compare to
  88718. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88719. */
  88720. isEqual(other: MaterialDefines): boolean;
  88721. /**
  88722. * Clones this instance's defines to another instance
  88723. * @param other - material defines to clone values to
  88724. */
  88725. cloneTo(other: MaterialDefines): void;
  88726. /**
  88727. * Resets the material define values
  88728. */
  88729. reset(): void;
  88730. /**
  88731. * Converts the material define values to a string
  88732. * @returns - String of material define information
  88733. */
  88734. toString(): string;
  88735. }
  88736. }
  88737. declare module BABYLON {
  88738. /**
  88739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88741. * 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;
  88742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88743. */
  88744. export class ColorCurves {
  88745. private _dirty;
  88746. private _tempColor;
  88747. private _globalCurve;
  88748. private _highlightsCurve;
  88749. private _midtonesCurve;
  88750. private _shadowsCurve;
  88751. private _positiveCurve;
  88752. private _negativeCurve;
  88753. private _globalHue;
  88754. private _globalDensity;
  88755. private _globalSaturation;
  88756. private _globalExposure;
  88757. /**
  88758. * Gets the global Hue value.
  88759. * 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).
  88760. */
  88761. get globalHue(): number;
  88762. /**
  88763. * Sets the global Hue value.
  88764. * 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).
  88765. */
  88766. set globalHue(value: number);
  88767. /**
  88768. * Gets the global Density value.
  88769. * 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.
  88770. * Values less than zero provide a filter of opposite hue.
  88771. */
  88772. get globalDensity(): number;
  88773. /**
  88774. * Sets the global Density value.
  88775. * 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.
  88776. * Values less than zero provide a filter of opposite hue.
  88777. */
  88778. set globalDensity(value: number);
  88779. /**
  88780. * Gets the global Saturation value.
  88781. * 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.
  88782. */
  88783. get globalSaturation(): number;
  88784. /**
  88785. * Sets the global Saturation value.
  88786. * 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.
  88787. */
  88788. set globalSaturation(value: number);
  88789. /**
  88790. * Gets the global Exposure value.
  88791. * 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.
  88792. */
  88793. get globalExposure(): number;
  88794. /**
  88795. * Sets the global Exposure value.
  88796. * 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.
  88797. */
  88798. set globalExposure(value: number);
  88799. private _highlightsHue;
  88800. private _highlightsDensity;
  88801. private _highlightsSaturation;
  88802. private _highlightsExposure;
  88803. /**
  88804. * Gets the highlights Hue value.
  88805. * 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).
  88806. */
  88807. get highlightsHue(): number;
  88808. /**
  88809. * Sets the highlights Hue value.
  88810. * 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).
  88811. */
  88812. set highlightsHue(value: number);
  88813. /**
  88814. * Gets the highlights Density value.
  88815. * 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.
  88816. * Values less than zero provide a filter of opposite hue.
  88817. */
  88818. get highlightsDensity(): number;
  88819. /**
  88820. * Sets the highlights Density value.
  88821. * 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.
  88822. * Values less than zero provide a filter of opposite hue.
  88823. */
  88824. set highlightsDensity(value: number);
  88825. /**
  88826. * Gets the highlights Saturation value.
  88827. * 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.
  88828. */
  88829. get highlightsSaturation(): number;
  88830. /**
  88831. * Sets the highlights Saturation value.
  88832. * 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.
  88833. */
  88834. set highlightsSaturation(value: number);
  88835. /**
  88836. * Gets the highlights Exposure value.
  88837. * 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.
  88838. */
  88839. get highlightsExposure(): number;
  88840. /**
  88841. * Sets the highlights Exposure value.
  88842. * 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.
  88843. */
  88844. set highlightsExposure(value: number);
  88845. private _midtonesHue;
  88846. private _midtonesDensity;
  88847. private _midtonesSaturation;
  88848. private _midtonesExposure;
  88849. /**
  88850. * Gets the midtones Hue value.
  88851. * 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).
  88852. */
  88853. get midtonesHue(): number;
  88854. /**
  88855. * Sets the midtones Hue value.
  88856. * 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).
  88857. */
  88858. set midtonesHue(value: number);
  88859. /**
  88860. * Gets the midtones Density value.
  88861. * 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.
  88862. * Values less than zero provide a filter of opposite hue.
  88863. */
  88864. get midtonesDensity(): number;
  88865. /**
  88866. * Sets the midtones Density value.
  88867. * 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.
  88868. * Values less than zero provide a filter of opposite hue.
  88869. */
  88870. set midtonesDensity(value: number);
  88871. /**
  88872. * Gets the midtones Saturation value.
  88873. * 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.
  88874. */
  88875. get midtonesSaturation(): number;
  88876. /**
  88877. * Sets the midtones Saturation value.
  88878. * 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.
  88879. */
  88880. set midtonesSaturation(value: number);
  88881. /**
  88882. * Gets the midtones Exposure value.
  88883. * 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.
  88884. */
  88885. get midtonesExposure(): number;
  88886. /**
  88887. * Sets the midtones Exposure value.
  88888. * 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.
  88889. */
  88890. set midtonesExposure(value: number);
  88891. private _shadowsHue;
  88892. private _shadowsDensity;
  88893. private _shadowsSaturation;
  88894. private _shadowsExposure;
  88895. /**
  88896. * Gets the shadows Hue value.
  88897. * 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).
  88898. */
  88899. get shadowsHue(): number;
  88900. /**
  88901. * Sets the shadows Hue value.
  88902. * 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).
  88903. */
  88904. set shadowsHue(value: number);
  88905. /**
  88906. * Gets the shadows Density value.
  88907. * 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.
  88908. * Values less than zero provide a filter of opposite hue.
  88909. */
  88910. get shadowsDensity(): number;
  88911. /**
  88912. * Sets the shadows Density value.
  88913. * 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.
  88914. * Values less than zero provide a filter of opposite hue.
  88915. */
  88916. set shadowsDensity(value: number);
  88917. /**
  88918. * Gets the shadows Saturation value.
  88919. * 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.
  88920. */
  88921. get shadowsSaturation(): number;
  88922. /**
  88923. * Sets the shadows Saturation value.
  88924. * 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.
  88925. */
  88926. set shadowsSaturation(value: number);
  88927. /**
  88928. * Gets the shadows Exposure value.
  88929. * 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.
  88930. */
  88931. get shadowsExposure(): number;
  88932. /**
  88933. * Sets the shadows Exposure value.
  88934. * 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.
  88935. */
  88936. set shadowsExposure(value: number);
  88937. /**
  88938. * Returns the class name
  88939. * @returns The class name
  88940. */
  88941. getClassName(): string;
  88942. /**
  88943. * Binds the color curves to the shader.
  88944. * @param colorCurves The color curve to bind
  88945. * @param effect The effect to bind to
  88946. * @param positiveUniform The positive uniform shader parameter
  88947. * @param neutralUniform The neutral uniform shader parameter
  88948. * @param negativeUniform The negative uniform shader parameter
  88949. */
  88950. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88951. /**
  88952. * Prepare the list of uniforms associated with the ColorCurves effects.
  88953. * @param uniformsList The list of uniforms used in the effect
  88954. */
  88955. static PrepareUniforms(uniformsList: string[]): void;
  88956. /**
  88957. * Returns color grading data based on a hue, density, saturation and exposure value.
  88958. * @param filterHue The hue of the color filter.
  88959. * @param filterDensity The density of the color filter.
  88960. * @param saturation The saturation.
  88961. * @param exposure The exposure.
  88962. * @param result The result data container.
  88963. */
  88964. private getColorGradingDataToRef;
  88965. /**
  88966. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88967. * @param value The input slider value in range [-100,100].
  88968. * @returns Adjusted value.
  88969. */
  88970. private static applyColorGradingSliderNonlinear;
  88971. /**
  88972. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88973. * @param hue The hue (H) input.
  88974. * @param saturation The saturation (S) input.
  88975. * @param brightness The brightness (B) input.
  88976. * @result An RGBA color represented as Vector4.
  88977. */
  88978. private static fromHSBToRef;
  88979. /**
  88980. * Returns a value clamped between min and max
  88981. * @param value The value to clamp
  88982. * @param min The minimum of value
  88983. * @param max The maximum of value
  88984. * @returns The clamped value.
  88985. */
  88986. private static clamp;
  88987. /**
  88988. * Clones the current color curve instance.
  88989. * @return The cloned curves
  88990. */
  88991. clone(): ColorCurves;
  88992. /**
  88993. * Serializes the current color curve instance to a json representation.
  88994. * @return a JSON representation
  88995. */
  88996. serialize(): any;
  88997. /**
  88998. * Parses the color curve from a json representation.
  88999. * @param source the JSON source to parse
  89000. * @return The parsed curves
  89001. */
  89002. static Parse(source: any): ColorCurves;
  89003. }
  89004. }
  89005. declare module BABYLON {
  89006. /**
  89007. * Interface to follow in your material defines to integrate easily the
  89008. * Image proccessing functions.
  89009. * @hidden
  89010. */
  89011. export interface IImageProcessingConfigurationDefines {
  89012. IMAGEPROCESSING: boolean;
  89013. VIGNETTE: boolean;
  89014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89015. VIGNETTEBLENDMODEOPAQUE: boolean;
  89016. TONEMAPPING: boolean;
  89017. TONEMAPPING_ACES: boolean;
  89018. CONTRAST: boolean;
  89019. EXPOSURE: boolean;
  89020. COLORCURVES: boolean;
  89021. COLORGRADING: boolean;
  89022. COLORGRADING3D: boolean;
  89023. SAMPLER3DGREENDEPTH: boolean;
  89024. SAMPLER3DBGRMAP: boolean;
  89025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89026. }
  89027. /**
  89028. * @hidden
  89029. */
  89030. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89031. IMAGEPROCESSING: boolean;
  89032. VIGNETTE: boolean;
  89033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89034. VIGNETTEBLENDMODEOPAQUE: boolean;
  89035. TONEMAPPING: boolean;
  89036. TONEMAPPING_ACES: boolean;
  89037. CONTRAST: boolean;
  89038. COLORCURVES: boolean;
  89039. COLORGRADING: boolean;
  89040. COLORGRADING3D: boolean;
  89041. SAMPLER3DGREENDEPTH: boolean;
  89042. SAMPLER3DBGRMAP: boolean;
  89043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89044. EXPOSURE: boolean;
  89045. constructor();
  89046. }
  89047. /**
  89048. * This groups together the common properties used for image processing either in direct forward pass
  89049. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89050. * or not.
  89051. */
  89052. export class ImageProcessingConfiguration {
  89053. /**
  89054. * Default tone mapping applied in BabylonJS.
  89055. */
  89056. static readonly TONEMAPPING_STANDARD: number;
  89057. /**
  89058. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89059. * to other engines rendering to increase portability.
  89060. */
  89061. static readonly TONEMAPPING_ACES: number;
  89062. /**
  89063. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89064. */
  89065. colorCurves: Nullable<ColorCurves>;
  89066. private _colorCurvesEnabled;
  89067. /**
  89068. * Gets wether the color curves effect is enabled.
  89069. */
  89070. get colorCurvesEnabled(): boolean;
  89071. /**
  89072. * Sets wether the color curves effect is enabled.
  89073. */
  89074. set colorCurvesEnabled(value: boolean);
  89075. private _colorGradingTexture;
  89076. /**
  89077. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89078. */
  89079. get colorGradingTexture(): Nullable<BaseTexture>;
  89080. /**
  89081. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89082. */
  89083. set colorGradingTexture(value: Nullable<BaseTexture>);
  89084. private _colorGradingEnabled;
  89085. /**
  89086. * Gets wether the color grading effect is enabled.
  89087. */
  89088. get colorGradingEnabled(): boolean;
  89089. /**
  89090. * Sets wether the color grading effect is enabled.
  89091. */
  89092. set colorGradingEnabled(value: boolean);
  89093. private _colorGradingWithGreenDepth;
  89094. /**
  89095. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89096. */
  89097. get colorGradingWithGreenDepth(): boolean;
  89098. /**
  89099. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89100. */
  89101. set colorGradingWithGreenDepth(value: boolean);
  89102. private _colorGradingBGR;
  89103. /**
  89104. * Gets wether the color grading texture contains BGR values.
  89105. */
  89106. get colorGradingBGR(): boolean;
  89107. /**
  89108. * Sets wether the color grading texture contains BGR values.
  89109. */
  89110. set colorGradingBGR(value: boolean);
  89111. /** @hidden */
  89112. _exposure: number;
  89113. /**
  89114. * Gets the Exposure used in the effect.
  89115. */
  89116. get exposure(): number;
  89117. /**
  89118. * Sets the Exposure used in the effect.
  89119. */
  89120. set exposure(value: number);
  89121. private _toneMappingEnabled;
  89122. /**
  89123. * Gets wether the tone mapping effect is enabled.
  89124. */
  89125. get toneMappingEnabled(): boolean;
  89126. /**
  89127. * Sets wether the tone mapping effect is enabled.
  89128. */
  89129. set toneMappingEnabled(value: boolean);
  89130. private _toneMappingType;
  89131. /**
  89132. * Gets the type of tone mapping effect.
  89133. */
  89134. get toneMappingType(): number;
  89135. /**
  89136. * Sets the type of tone mapping effect used in BabylonJS.
  89137. */
  89138. set toneMappingType(value: number);
  89139. protected _contrast: number;
  89140. /**
  89141. * Gets the contrast used in the effect.
  89142. */
  89143. get contrast(): number;
  89144. /**
  89145. * Sets the contrast used in the effect.
  89146. */
  89147. set contrast(value: number);
  89148. /**
  89149. * Vignette stretch size.
  89150. */
  89151. vignetteStretch: number;
  89152. /**
  89153. * Vignette centre X Offset.
  89154. */
  89155. vignetteCentreX: number;
  89156. /**
  89157. * Vignette centre Y Offset.
  89158. */
  89159. vignetteCentreY: number;
  89160. /**
  89161. * Vignette weight or intensity of the vignette effect.
  89162. */
  89163. vignetteWeight: number;
  89164. /**
  89165. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89166. * if vignetteEnabled is set to true.
  89167. */
  89168. vignetteColor: Color4;
  89169. /**
  89170. * Camera field of view used by the Vignette effect.
  89171. */
  89172. vignetteCameraFov: number;
  89173. private _vignetteBlendMode;
  89174. /**
  89175. * Gets the vignette blend mode allowing different kind of effect.
  89176. */
  89177. get vignetteBlendMode(): number;
  89178. /**
  89179. * Sets the vignette blend mode allowing different kind of effect.
  89180. */
  89181. set vignetteBlendMode(value: number);
  89182. private _vignetteEnabled;
  89183. /**
  89184. * Gets wether the vignette effect is enabled.
  89185. */
  89186. get vignetteEnabled(): boolean;
  89187. /**
  89188. * Sets wether the vignette effect is enabled.
  89189. */
  89190. set vignetteEnabled(value: boolean);
  89191. private _applyByPostProcess;
  89192. /**
  89193. * Gets wether the image processing is applied through a post process or not.
  89194. */
  89195. get applyByPostProcess(): boolean;
  89196. /**
  89197. * Sets wether the image processing is applied through a post process or not.
  89198. */
  89199. set applyByPostProcess(value: boolean);
  89200. private _isEnabled;
  89201. /**
  89202. * Gets wether the image processing is enabled or not.
  89203. */
  89204. get isEnabled(): boolean;
  89205. /**
  89206. * Sets wether the image processing is enabled or not.
  89207. */
  89208. set isEnabled(value: boolean);
  89209. /**
  89210. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89211. */
  89212. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89213. /**
  89214. * Method called each time the image processing information changes requires to recompile the effect.
  89215. */
  89216. protected _updateParameters(): void;
  89217. /**
  89218. * Gets the current class name.
  89219. * @return "ImageProcessingConfiguration"
  89220. */
  89221. getClassName(): string;
  89222. /**
  89223. * Prepare the list of uniforms associated with the Image Processing effects.
  89224. * @param uniforms The list of uniforms used in the effect
  89225. * @param defines the list of defines currently in use
  89226. */
  89227. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89228. /**
  89229. * Prepare the list of samplers associated with the Image Processing effects.
  89230. * @param samplersList The list of uniforms used in the effect
  89231. * @param defines the list of defines currently in use
  89232. */
  89233. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89234. /**
  89235. * Prepare the list of defines associated to the shader.
  89236. * @param defines the list of defines to complete
  89237. * @param forPostProcess Define if we are currently in post process mode or not
  89238. */
  89239. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89240. /**
  89241. * Returns true if all the image processing information are ready.
  89242. * @returns True if ready, otherwise, false
  89243. */
  89244. isReady(): boolean;
  89245. /**
  89246. * Binds the image processing to the shader.
  89247. * @param effect The effect to bind to
  89248. * @param overrideAspectRatio Override the aspect ratio of the effect
  89249. */
  89250. bind(effect: Effect, overrideAspectRatio?: number): void;
  89251. /**
  89252. * Clones the current image processing instance.
  89253. * @return The cloned image processing
  89254. */
  89255. clone(): ImageProcessingConfiguration;
  89256. /**
  89257. * Serializes the current image processing instance to a json representation.
  89258. * @return a JSON representation
  89259. */
  89260. serialize(): any;
  89261. /**
  89262. * Parses the image processing from a json representation.
  89263. * @param source the JSON source to parse
  89264. * @return The parsed image processing
  89265. */
  89266. static Parse(source: any): ImageProcessingConfiguration;
  89267. private static _VIGNETTEMODE_MULTIPLY;
  89268. private static _VIGNETTEMODE_OPAQUE;
  89269. /**
  89270. * Used to apply the vignette as a mix with the pixel color.
  89271. */
  89272. static get VIGNETTEMODE_MULTIPLY(): number;
  89273. /**
  89274. * Used to apply the vignette as a replacement of the pixel color.
  89275. */
  89276. static get VIGNETTEMODE_OPAQUE(): number;
  89277. }
  89278. }
  89279. declare module BABYLON {
  89280. /** @hidden */
  89281. export var postprocessVertexShader: {
  89282. name: string;
  89283. shader: string;
  89284. };
  89285. }
  89286. declare module BABYLON {
  89287. /**
  89288. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89289. */
  89290. export type RenderTargetTextureSize = number | {
  89291. width: number;
  89292. height: number;
  89293. layers?: number;
  89294. };
  89295. interface ThinEngine {
  89296. /**
  89297. * Creates a new render target texture
  89298. * @param size defines the size of the texture
  89299. * @param options defines the options used to create the texture
  89300. * @returns a new render target texture stored in an InternalTexture
  89301. */
  89302. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89303. /**
  89304. * Creates a depth stencil texture.
  89305. * This is only available in WebGL 2 or with the depth texture extension available.
  89306. * @param size The size of face edge in the texture.
  89307. * @param options The options defining the texture.
  89308. * @returns The texture
  89309. */
  89310. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89311. /** @hidden */
  89312. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89313. }
  89314. }
  89315. declare module BABYLON {
  89316. /**
  89317. * Defines the kind of connection point for node based material
  89318. */
  89319. export enum NodeMaterialBlockConnectionPointTypes {
  89320. /** Float */
  89321. Float = 1,
  89322. /** Int */
  89323. Int = 2,
  89324. /** Vector2 */
  89325. Vector2 = 4,
  89326. /** Vector3 */
  89327. Vector3 = 8,
  89328. /** Vector4 */
  89329. Vector4 = 16,
  89330. /** Color3 */
  89331. Color3 = 32,
  89332. /** Color4 */
  89333. Color4 = 64,
  89334. /** Matrix */
  89335. Matrix = 128,
  89336. /** Custom object */
  89337. Object = 256,
  89338. /** Detect type based on connection */
  89339. AutoDetect = 1024,
  89340. /** Output type that will be defined by input type */
  89341. BasedOnInput = 2048
  89342. }
  89343. }
  89344. declare module BABYLON {
  89345. /**
  89346. * Enum used to define the target of a block
  89347. */
  89348. export enum NodeMaterialBlockTargets {
  89349. /** Vertex shader */
  89350. Vertex = 1,
  89351. /** Fragment shader */
  89352. Fragment = 2,
  89353. /** Neutral */
  89354. Neutral = 4,
  89355. /** Vertex and Fragment */
  89356. VertexAndFragment = 3
  89357. }
  89358. }
  89359. declare module BABYLON {
  89360. /**
  89361. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89362. */
  89363. export enum NodeMaterialBlockConnectionPointMode {
  89364. /** Value is an uniform */
  89365. Uniform = 0,
  89366. /** Value is a mesh attribute */
  89367. Attribute = 1,
  89368. /** Value is a varying between vertex and fragment shaders */
  89369. Varying = 2,
  89370. /** Mode is undefined */
  89371. Undefined = 3
  89372. }
  89373. }
  89374. declare module BABYLON {
  89375. /**
  89376. * Enum used to define system values e.g. values automatically provided by the system
  89377. */
  89378. export enum NodeMaterialSystemValues {
  89379. /** World */
  89380. World = 1,
  89381. /** View */
  89382. View = 2,
  89383. /** Projection */
  89384. Projection = 3,
  89385. /** ViewProjection */
  89386. ViewProjection = 4,
  89387. /** WorldView */
  89388. WorldView = 5,
  89389. /** WorldViewProjection */
  89390. WorldViewProjection = 6,
  89391. /** CameraPosition */
  89392. CameraPosition = 7,
  89393. /** Fog Color */
  89394. FogColor = 8,
  89395. /** Delta time */
  89396. DeltaTime = 9
  89397. }
  89398. }
  89399. declare module BABYLON {
  89400. /** Defines supported spaces */
  89401. export enum Space {
  89402. /** Local (object) space */
  89403. LOCAL = 0,
  89404. /** World space */
  89405. WORLD = 1,
  89406. /** Bone space */
  89407. BONE = 2
  89408. }
  89409. /** Defines the 3 main axes */
  89410. export class Axis {
  89411. /** X axis */
  89412. static X: Vector3;
  89413. /** Y axis */
  89414. static Y: Vector3;
  89415. /** Z axis */
  89416. static Z: Vector3;
  89417. }
  89418. }
  89419. declare module BABYLON {
  89420. /**
  89421. * Represents a camera frustum
  89422. */
  89423. export class Frustum {
  89424. /**
  89425. * Gets the planes representing the frustum
  89426. * @param transform matrix to be applied to the returned planes
  89427. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89428. */
  89429. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89430. /**
  89431. * Gets the near frustum plane transformed by the transform matrix
  89432. * @param transform transformation matrix to be applied to the resulting frustum plane
  89433. * @param frustumPlane the resuling frustum plane
  89434. */
  89435. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89436. /**
  89437. * Gets the far frustum plane transformed by the transform matrix
  89438. * @param transform transformation matrix to be applied to the resulting frustum plane
  89439. * @param frustumPlane the resuling frustum plane
  89440. */
  89441. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89442. /**
  89443. * Gets the left frustum plane transformed by the transform matrix
  89444. * @param transform transformation matrix to be applied to the resulting frustum plane
  89445. * @param frustumPlane the resuling frustum plane
  89446. */
  89447. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89448. /**
  89449. * Gets the right frustum plane transformed by the transform matrix
  89450. * @param transform transformation matrix to be applied to the resulting frustum plane
  89451. * @param frustumPlane the resuling frustum plane
  89452. */
  89453. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89454. /**
  89455. * Gets the top frustum plane transformed by the transform matrix
  89456. * @param transform transformation matrix to be applied to the resulting frustum plane
  89457. * @param frustumPlane the resuling frustum plane
  89458. */
  89459. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89460. /**
  89461. * Gets the bottom frustum plane transformed by the transform matrix
  89462. * @param transform transformation matrix to be applied to the resulting frustum plane
  89463. * @param frustumPlane the resuling frustum plane
  89464. */
  89465. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89466. /**
  89467. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89468. * @param transform transformation matrix to be applied to the resulting frustum planes
  89469. * @param frustumPlanes the resuling frustum planes
  89470. */
  89471. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89472. }
  89473. }
  89474. declare module BABYLON {
  89475. /**
  89476. * Interface for the size containing width and height
  89477. */
  89478. export interface ISize {
  89479. /**
  89480. * Width
  89481. */
  89482. width: number;
  89483. /**
  89484. * Heighht
  89485. */
  89486. height: number;
  89487. }
  89488. /**
  89489. * Size containing widht and height
  89490. */
  89491. export class Size implements ISize {
  89492. /**
  89493. * Width
  89494. */
  89495. width: number;
  89496. /**
  89497. * Height
  89498. */
  89499. height: number;
  89500. /**
  89501. * Creates a Size object from the given width and height (floats).
  89502. * @param width width of the new size
  89503. * @param height height of the new size
  89504. */
  89505. constructor(width: number, height: number);
  89506. /**
  89507. * Returns a string with the Size width and height
  89508. * @returns a string with the Size width and height
  89509. */
  89510. toString(): string;
  89511. /**
  89512. * "Size"
  89513. * @returns the string "Size"
  89514. */
  89515. getClassName(): string;
  89516. /**
  89517. * Returns the Size hash code.
  89518. * @returns a hash code for a unique width and height
  89519. */
  89520. getHashCode(): number;
  89521. /**
  89522. * Updates the current size from the given one.
  89523. * @param src the given size
  89524. */
  89525. copyFrom(src: Size): void;
  89526. /**
  89527. * Updates in place the current Size from the given floats.
  89528. * @param width width of the new size
  89529. * @param height height of the new size
  89530. * @returns the updated Size.
  89531. */
  89532. copyFromFloats(width: number, height: number): Size;
  89533. /**
  89534. * Updates in place the current Size from the given floats.
  89535. * @param width width to set
  89536. * @param height height to set
  89537. * @returns the updated Size.
  89538. */
  89539. set(width: number, height: number): Size;
  89540. /**
  89541. * Multiplies the width and height by numbers
  89542. * @param w factor to multiple the width by
  89543. * @param h factor to multiple the height by
  89544. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89545. */
  89546. multiplyByFloats(w: number, h: number): Size;
  89547. /**
  89548. * Clones the size
  89549. * @returns a new Size copied from the given one.
  89550. */
  89551. clone(): Size;
  89552. /**
  89553. * True if the current Size and the given one width and height are strictly equal.
  89554. * @param other the other size to compare against
  89555. * @returns True if the current Size and the given one width and height are strictly equal.
  89556. */
  89557. equals(other: Size): boolean;
  89558. /**
  89559. * The surface of the Size : width * height (float).
  89560. */
  89561. get surface(): number;
  89562. /**
  89563. * Create a new size of zero
  89564. * @returns a new Size set to (0.0, 0.0)
  89565. */
  89566. static Zero(): Size;
  89567. /**
  89568. * Sums the width and height of two sizes
  89569. * @param otherSize size to add to this size
  89570. * @returns a new Size set as the addition result of the current Size and the given one.
  89571. */
  89572. add(otherSize: Size): Size;
  89573. /**
  89574. * Subtracts the width and height of two
  89575. * @param otherSize size to subtract to this size
  89576. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89577. */
  89578. subtract(otherSize: Size): Size;
  89579. /**
  89580. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89581. * @param start starting size to lerp between
  89582. * @param end end size to lerp between
  89583. * @param amount amount to lerp between the start and end values
  89584. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89585. */
  89586. static Lerp(start: Size, end: Size, amount: number): Size;
  89587. }
  89588. }
  89589. declare module BABYLON {
  89590. /**
  89591. * Contains position and normal vectors for a vertex
  89592. */
  89593. export class PositionNormalVertex {
  89594. /** the position of the vertex (defaut: 0,0,0) */
  89595. position: Vector3;
  89596. /** the normal of the vertex (defaut: 0,1,0) */
  89597. normal: Vector3;
  89598. /**
  89599. * Creates a PositionNormalVertex
  89600. * @param position the position of the vertex (defaut: 0,0,0)
  89601. * @param normal the normal of the vertex (defaut: 0,1,0)
  89602. */
  89603. constructor(
  89604. /** the position of the vertex (defaut: 0,0,0) */
  89605. position?: Vector3,
  89606. /** the normal of the vertex (defaut: 0,1,0) */
  89607. normal?: Vector3);
  89608. /**
  89609. * Clones the PositionNormalVertex
  89610. * @returns the cloned PositionNormalVertex
  89611. */
  89612. clone(): PositionNormalVertex;
  89613. }
  89614. /**
  89615. * Contains position, normal and uv vectors for a vertex
  89616. */
  89617. export class PositionNormalTextureVertex {
  89618. /** the position of the vertex (defaut: 0,0,0) */
  89619. position: Vector3;
  89620. /** the normal of the vertex (defaut: 0,1,0) */
  89621. normal: Vector3;
  89622. /** the uv of the vertex (default: 0,0) */
  89623. uv: Vector2;
  89624. /**
  89625. * Creates a PositionNormalTextureVertex
  89626. * @param position the position of the vertex (defaut: 0,0,0)
  89627. * @param normal the normal of the vertex (defaut: 0,1,0)
  89628. * @param uv the uv of the vertex (default: 0,0)
  89629. */
  89630. constructor(
  89631. /** the position of the vertex (defaut: 0,0,0) */
  89632. position?: Vector3,
  89633. /** the normal of the vertex (defaut: 0,1,0) */
  89634. normal?: Vector3,
  89635. /** the uv of the vertex (default: 0,0) */
  89636. uv?: Vector2);
  89637. /**
  89638. * Clones the PositionNormalTextureVertex
  89639. * @returns the cloned PositionNormalTextureVertex
  89640. */
  89641. clone(): PositionNormalTextureVertex;
  89642. }
  89643. }
  89644. declare module BABYLON {
  89645. /**
  89646. * Enum defining the type of animations supported by InputBlock
  89647. */
  89648. export enum AnimatedInputBlockTypes {
  89649. /** No animation */
  89650. None = 0,
  89651. /** Time based animation. Will only work for floats */
  89652. Time = 1
  89653. }
  89654. }
  89655. declare module BABYLON {
  89656. /**
  89657. * Interface describing all the common properties and methods a shadow light needs to implement.
  89658. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89659. * as well as binding the different shadow properties to the effects.
  89660. */
  89661. export interface IShadowLight extends Light {
  89662. /**
  89663. * The light id in the scene (used in scene.findLighById for instance)
  89664. */
  89665. id: string;
  89666. /**
  89667. * The position the shdow will be casted from.
  89668. */
  89669. position: Vector3;
  89670. /**
  89671. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89672. */
  89673. direction: Vector3;
  89674. /**
  89675. * The transformed position. Position of the light in world space taking parenting in account.
  89676. */
  89677. transformedPosition: Vector3;
  89678. /**
  89679. * The transformed direction. Direction of the light in world space taking parenting in account.
  89680. */
  89681. transformedDirection: Vector3;
  89682. /**
  89683. * The friendly name of the light in the scene.
  89684. */
  89685. name: string;
  89686. /**
  89687. * Defines the shadow projection clipping minimum z value.
  89688. */
  89689. shadowMinZ: number;
  89690. /**
  89691. * Defines the shadow projection clipping maximum z value.
  89692. */
  89693. shadowMaxZ: number;
  89694. /**
  89695. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89696. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89697. */
  89698. computeTransformedInformation(): boolean;
  89699. /**
  89700. * Gets the scene the light belongs to.
  89701. * @returns The scene
  89702. */
  89703. getScene(): Scene;
  89704. /**
  89705. * Callback defining a custom Projection Matrix Builder.
  89706. * This can be used to override the default projection matrix computation.
  89707. */
  89708. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89709. /**
  89710. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89711. * @param matrix The materix to updated with the projection information
  89712. * @param viewMatrix The transform matrix of the light
  89713. * @param renderList The list of mesh to render in the map
  89714. * @returns The current light
  89715. */
  89716. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89717. /**
  89718. * Gets the current depth scale used in ESM.
  89719. * @returns The scale
  89720. */
  89721. getDepthScale(): number;
  89722. /**
  89723. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89724. * @returns true if a cube texture needs to be use
  89725. */
  89726. needCube(): boolean;
  89727. /**
  89728. * Detects if the projection matrix requires to be recomputed this frame.
  89729. * @returns true if it requires to be recomputed otherwise, false.
  89730. */
  89731. needProjectionMatrixCompute(): boolean;
  89732. /**
  89733. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89734. */
  89735. forceProjectionMatrixCompute(): void;
  89736. /**
  89737. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89738. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89739. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89740. */
  89741. getShadowDirection(faceIndex?: number): Vector3;
  89742. /**
  89743. * Gets the minZ used for shadow according to both the scene and the light.
  89744. * @param activeCamera The camera we are returning the min for
  89745. * @returns the depth min z
  89746. */
  89747. getDepthMinZ(activeCamera: Camera): number;
  89748. /**
  89749. * Gets the maxZ used for shadow according to both the scene and the light.
  89750. * @param activeCamera The camera we are returning the max for
  89751. * @returns the depth max z
  89752. */
  89753. getDepthMaxZ(activeCamera: Camera): number;
  89754. }
  89755. /**
  89756. * Base implementation IShadowLight
  89757. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89758. */
  89759. export abstract class ShadowLight extends Light implements IShadowLight {
  89760. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89761. protected _position: Vector3;
  89762. protected _setPosition(value: Vector3): void;
  89763. /**
  89764. * Sets the position the shadow will be casted from. Also use as the light position for both
  89765. * point and spot lights.
  89766. */
  89767. get position(): Vector3;
  89768. /**
  89769. * Sets the position the shadow will be casted from. Also use as the light position for both
  89770. * point and spot lights.
  89771. */
  89772. set position(value: Vector3);
  89773. protected _direction: Vector3;
  89774. protected _setDirection(value: Vector3): void;
  89775. /**
  89776. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89777. * Also use as the light direction on spot and directional lights.
  89778. */
  89779. get direction(): Vector3;
  89780. /**
  89781. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89782. * Also use as the light direction on spot and directional lights.
  89783. */
  89784. set direction(value: Vector3);
  89785. protected _shadowMinZ: number;
  89786. /**
  89787. * Gets the shadow projection clipping minimum z value.
  89788. */
  89789. get shadowMinZ(): number;
  89790. /**
  89791. * Sets the shadow projection clipping minimum z value.
  89792. */
  89793. set shadowMinZ(value: number);
  89794. protected _shadowMaxZ: number;
  89795. /**
  89796. * Sets the shadow projection clipping maximum z value.
  89797. */
  89798. get shadowMaxZ(): number;
  89799. /**
  89800. * Gets the shadow projection clipping maximum z value.
  89801. */
  89802. set shadowMaxZ(value: number);
  89803. /**
  89804. * Callback defining a custom Projection Matrix Builder.
  89805. * This can be used to override the default projection matrix computation.
  89806. */
  89807. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89808. /**
  89809. * The transformed position. Position of the light in world space taking parenting in account.
  89810. */
  89811. transformedPosition: Vector3;
  89812. /**
  89813. * The transformed direction. Direction of the light in world space taking parenting in account.
  89814. */
  89815. transformedDirection: Vector3;
  89816. private _needProjectionMatrixCompute;
  89817. /**
  89818. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89819. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89820. */
  89821. computeTransformedInformation(): boolean;
  89822. /**
  89823. * Return the depth scale used for the shadow map.
  89824. * @returns the depth scale.
  89825. */
  89826. getDepthScale(): number;
  89827. /**
  89828. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89829. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89830. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89831. */
  89832. getShadowDirection(faceIndex?: number): Vector3;
  89833. /**
  89834. * Returns the ShadowLight absolute position in the World.
  89835. * @returns the position vector in world space
  89836. */
  89837. getAbsolutePosition(): Vector3;
  89838. /**
  89839. * Sets the ShadowLight direction toward the passed target.
  89840. * @param target The point to target in local space
  89841. * @returns the updated ShadowLight direction
  89842. */
  89843. setDirectionToTarget(target: Vector3): Vector3;
  89844. /**
  89845. * Returns the light rotation in euler definition.
  89846. * @returns the x y z rotation in local space.
  89847. */
  89848. getRotation(): Vector3;
  89849. /**
  89850. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89851. * @returns true if a cube texture needs to be use
  89852. */
  89853. needCube(): boolean;
  89854. /**
  89855. * Detects if the projection matrix requires to be recomputed this frame.
  89856. * @returns true if it requires to be recomputed otherwise, false.
  89857. */
  89858. needProjectionMatrixCompute(): boolean;
  89859. /**
  89860. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89861. */
  89862. forceProjectionMatrixCompute(): void;
  89863. /** @hidden */
  89864. _initCache(): void;
  89865. /** @hidden */
  89866. _isSynchronized(): boolean;
  89867. /**
  89868. * Computes the world matrix of the node
  89869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89870. * @returns the world matrix
  89871. */
  89872. computeWorldMatrix(force?: boolean): Matrix;
  89873. /**
  89874. * Gets the minZ used for shadow according to both the scene and the light.
  89875. * @param activeCamera The camera we are returning the min for
  89876. * @returns the depth min z
  89877. */
  89878. getDepthMinZ(activeCamera: Camera): number;
  89879. /**
  89880. * Gets the maxZ used for shadow according to both the scene and the light.
  89881. * @param activeCamera The camera we are returning the max for
  89882. * @returns the depth max z
  89883. */
  89884. getDepthMaxZ(activeCamera: Camera): number;
  89885. /**
  89886. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89887. * @param matrix The materix to updated with the projection information
  89888. * @param viewMatrix The transform matrix of the light
  89889. * @param renderList The list of mesh to render in the map
  89890. * @returns The current light
  89891. */
  89892. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89893. }
  89894. }
  89895. declare module BABYLON {
  89896. /** @hidden */
  89897. export var packingFunctions: {
  89898. name: string;
  89899. shader: string;
  89900. };
  89901. }
  89902. declare module BABYLON {
  89903. /** @hidden */
  89904. export var bayerDitherFunctions: {
  89905. name: string;
  89906. shader: string;
  89907. };
  89908. }
  89909. declare module BABYLON {
  89910. /** @hidden */
  89911. export var shadowMapFragmentDeclaration: {
  89912. name: string;
  89913. shader: string;
  89914. };
  89915. }
  89916. declare module BABYLON {
  89917. /** @hidden */
  89918. export var clipPlaneFragmentDeclaration: {
  89919. name: string;
  89920. shader: string;
  89921. };
  89922. }
  89923. declare module BABYLON {
  89924. /** @hidden */
  89925. export var clipPlaneFragment: {
  89926. name: string;
  89927. shader: string;
  89928. };
  89929. }
  89930. declare module BABYLON {
  89931. /** @hidden */
  89932. export var shadowMapFragment: {
  89933. name: string;
  89934. shader: string;
  89935. };
  89936. }
  89937. declare module BABYLON {
  89938. /** @hidden */
  89939. export var shadowMapPixelShader: {
  89940. name: string;
  89941. shader: string;
  89942. };
  89943. }
  89944. declare module BABYLON {
  89945. /** @hidden */
  89946. export var bonesDeclaration: {
  89947. name: string;
  89948. shader: string;
  89949. };
  89950. }
  89951. declare module BABYLON {
  89952. /** @hidden */
  89953. export var morphTargetsVertexGlobalDeclaration: {
  89954. name: string;
  89955. shader: string;
  89956. };
  89957. }
  89958. declare module BABYLON {
  89959. /** @hidden */
  89960. export var morphTargetsVertexDeclaration: {
  89961. name: string;
  89962. shader: string;
  89963. };
  89964. }
  89965. declare module BABYLON {
  89966. /** @hidden */
  89967. export var instancesDeclaration: {
  89968. name: string;
  89969. shader: string;
  89970. };
  89971. }
  89972. declare module BABYLON {
  89973. /** @hidden */
  89974. export var helperFunctions: {
  89975. name: string;
  89976. shader: string;
  89977. };
  89978. }
  89979. declare module BABYLON {
  89980. /** @hidden */
  89981. export var shadowMapVertexDeclaration: {
  89982. name: string;
  89983. shader: string;
  89984. };
  89985. }
  89986. declare module BABYLON {
  89987. /** @hidden */
  89988. export var clipPlaneVertexDeclaration: {
  89989. name: string;
  89990. shader: string;
  89991. };
  89992. }
  89993. declare module BABYLON {
  89994. /** @hidden */
  89995. export var morphTargetsVertex: {
  89996. name: string;
  89997. shader: string;
  89998. };
  89999. }
  90000. declare module BABYLON {
  90001. /** @hidden */
  90002. export var instancesVertex: {
  90003. name: string;
  90004. shader: string;
  90005. };
  90006. }
  90007. declare module BABYLON {
  90008. /** @hidden */
  90009. export var bonesVertex: {
  90010. name: string;
  90011. shader: string;
  90012. };
  90013. }
  90014. declare module BABYLON {
  90015. /** @hidden */
  90016. export var shadowMapVertexNormalBias: {
  90017. name: string;
  90018. shader: string;
  90019. };
  90020. }
  90021. declare module BABYLON {
  90022. /** @hidden */
  90023. export var shadowMapVertexMetric: {
  90024. name: string;
  90025. shader: string;
  90026. };
  90027. }
  90028. declare module BABYLON {
  90029. /** @hidden */
  90030. export var clipPlaneVertex: {
  90031. name: string;
  90032. shader: string;
  90033. };
  90034. }
  90035. declare module BABYLON {
  90036. /** @hidden */
  90037. export var shadowMapVertexShader: {
  90038. name: string;
  90039. shader: string;
  90040. };
  90041. }
  90042. declare module BABYLON {
  90043. /** @hidden */
  90044. export var depthBoxBlurPixelShader: {
  90045. name: string;
  90046. shader: string;
  90047. };
  90048. }
  90049. declare module BABYLON {
  90050. /** @hidden */
  90051. export var shadowMapFragmentSoftTransparentShadow: {
  90052. name: string;
  90053. shader: string;
  90054. };
  90055. }
  90056. declare module BABYLON {
  90057. /**
  90058. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90059. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90060. */
  90061. export class EffectFallbacks implements IEffectFallbacks {
  90062. private _defines;
  90063. private _currentRank;
  90064. private _maxRank;
  90065. private _mesh;
  90066. /**
  90067. * Removes the fallback from the bound mesh.
  90068. */
  90069. unBindMesh(): void;
  90070. /**
  90071. * Adds a fallback on the specified property.
  90072. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90073. * @param define The name of the define in the shader
  90074. */
  90075. addFallback(rank: number, define: string): void;
  90076. /**
  90077. * Sets the mesh to use CPU skinning when needing to fallback.
  90078. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90079. * @param mesh The mesh to use the fallbacks.
  90080. */
  90081. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90082. /**
  90083. * Checks to see if more fallbacks are still availible.
  90084. */
  90085. get hasMoreFallbacks(): boolean;
  90086. /**
  90087. * Removes the defines that should be removed when falling back.
  90088. * @param currentDefines defines the current define statements for the shader.
  90089. * @param effect defines the current effect we try to compile
  90090. * @returns The resulting defines with defines of the current rank removed.
  90091. */
  90092. reduce(currentDefines: string, effect: Effect): string;
  90093. }
  90094. }
  90095. declare module BABYLON {
  90096. /**
  90097. * Interface used to define Action
  90098. */
  90099. export interface IAction {
  90100. /**
  90101. * Trigger for the action
  90102. */
  90103. trigger: number;
  90104. /** Options of the trigger */
  90105. triggerOptions: any;
  90106. /**
  90107. * Gets the trigger parameters
  90108. * @returns the trigger parameters
  90109. */
  90110. getTriggerParameter(): any;
  90111. /**
  90112. * Internal only - executes current action event
  90113. * @hidden
  90114. */
  90115. _executeCurrent(evt?: ActionEvent): void;
  90116. /**
  90117. * Serialize placeholder for child classes
  90118. * @param parent of child
  90119. * @returns the serialized object
  90120. */
  90121. serialize(parent: any): any;
  90122. /**
  90123. * Internal only
  90124. * @hidden
  90125. */
  90126. _prepare(): void;
  90127. /**
  90128. * Internal only - manager for action
  90129. * @hidden
  90130. */
  90131. _actionManager: Nullable<AbstractActionManager>;
  90132. /**
  90133. * Adds action to chain of actions, may be a DoNothingAction
  90134. * @param action defines the next action to execute
  90135. * @returns The action passed in
  90136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90137. */
  90138. then(action: IAction): IAction;
  90139. }
  90140. /**
  90141. * The action to be carried out following a trigger
  90142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90143. */
  90144. export class Action implements IAction {
  90145. /** the trigger, with or without parameters, for the action */
  90146. triggerOptions: any;
  90147. /**
  90148. * Trigger for the action
  90149. */
  90150. trigger: number;
  90151. /**
  90152. * Internal only - manager for action
  90153. * @hidden
  90154. */
  90155. _actionManager: ActionManager;
  90156. private _nextActiveAction;
  90157. private _child;
  90158. private _condition?;
  90159. private _triggerParameter;
  90160. /**
  90161. * An event triggered prior to action being executed.
  90162. */
  90163. onBeforeExecuteObservable: Observable<Action>;
  90164. /**
  90165. * Creates a new Action
  90166. * @param triggerOptions the trigger, with or without parameters, for the action
  90167. * @param condition an optional determinant of action
  90168. */
  90169. constructor(
  90170. /** the trigger, with or without parameters, for the action */
  90171. triggerOptions: any, condition?: Condition);
  90172. /**
  90173. * Internal only
  90174. * @hidden
  90175. */
  90176. _prepare(): void;
  90177. /**
  90178. * Gets the trigger parameters
  90179. * @returns the trigger parameters
  90180. */
  90181. getTriggerParameter(): any;
  90182. /**
  90183. * Internal only - executes current action event
  90184. * @hidden
  90185. */
  90186. _executeCurrent(evt?: ActionEvent): void;
  90187. /**
  90188. * Execute placeholder for child classes
  90189. * @param evt optional action event
  90190. */
  90191. execute(evt?: ActionEvent): void;
  90192. /**
  90193. * Skips to next active action
  90194. */
  90195. skipToNextActiveAction(): void;
  90196. /**
  90197. * Adds action to chain of actions, may be a DoNothingAction
  90198. * @param action defines the next action to execute
  90199. * @returns The action passed in
  90200. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90201. */
  90202. then(action: Action): Action;
  90203. /**
  90204. * Internal only
  90205. * @hidden
  90206. */
  90207. _getProperty(propertyPath: string): string;
  90208. /**
  90209. * Internal only
  90210. * @hidden
  90211. */
  90212. _getEffectiveTarget(target: any, propertyPath: string): any;
  90213. /**
  90214. * Serialize placeholder for child classes
  90215. * @param parent of child
  90216. * @returns the serialized object
  90217. */
  90218. serialize(parent: any): any;
  90219. /**
  90220. * Internal only called by serialize
  90221. * @hidden
  90222. */
  90223. protected _serialize(serializedAction: any, parent?: any): any;
  90224. /**
  90225. * Internal only
  90226. * @hidden
  90227. */
  90228. static _SerializeValueAsString: (value: any) => string;
  90229. /**
  90230. * Internal only
  90231. * @hidden
  90232. */
  90233. static _GetTargetProperty: (target: Scene | Node) => {
  90234. name: string;
  90235. targetType: string;
  90236. value: string;
  90237. };
  90238. }
  90239. }
  90240. declare module BABYLON {
  90241. /**
  90242. * A Condition applied to an Action
  90243. */
  90244. export class Condition {
  90245. /**
  90246. * Internal only - manager for action
  90247. * @hidden
  90248. */
  90249. _actionManager: ActionManager;
  90250. /**
  90251. * Internal only
  90252. * @hidden
  90253. */
  90254. _evaluationId: number;
  90255. /**
  90256. * Internal only
  90257. * @hidden
  90258. */
  90259. _currentResult: boolean;
  90260. /**
  90261. * Creates a new Condition
  90262. * @param actionManager the manager of the action the condition is applied to
  90263. */
  90264. constructor(actionManager: ActionManager);
  90265. /**
  90266. * Check if the current condition is valid
  90267. * @returns a boolean
  90268. */
  90269. isValid(): boolean;
  90270. /**
  90271. * Internal only
  90272. * @hidden
  90273. */
  90274. _getProperty(propertyPath: string): string;
  90275. /**
  90276. * Internal only
  90277. * @hidden
  90278. */
  90279. _getEffectiveTarget(target: any, propertyPath: string): any;
  90280. /**
  90281. * Serialize placeholder for child classes
  90282. * @returns the serialized object
  90283. */
  90284. serialize(): any;
  90285. /**
  90286. * Internal only
  90287. * @hidden
  90288. */
  90289. protected _serialize(serializedCondition: any): any;
  90290. }
  90291. /**
  90292. * Defines specific conditional operators as extensions of Condition
  90293. */
  90294. export class ValueCondition extends Condition {
  90295. /** path to specify the property of the target the conditional operator uses */
  90296. propertyPath: string;
  90297. /** the value compared by the conditional operator against the current value of the property */
  90298. value: any;
  90299. /** the conditional operator, default ValueCondition.IsEqual */
  90300. operator: number;
  90301. /**
  90302. * Internal only
  90303. * @hidden
  90304. */
  90305. private static _IsEqual;
  90306. /**
  90307. * Internal only
  90308. * @hidden
  90309. */
  90310. private static _IsDifferent;
  90311. /**
  90312. * Internal only
  90313. * @hidden
  90314. */
  90315. private static _IsGreater;
  90316. /**
  90317. * Internal only
  90318. * @hidden
  90319. */
  90320. private static _IsLesser;
  90321. /**
  90322. * returns the number for IsEqual
  90323. */
  90324. static get IsEqual(): number;
  90325. /**
  90326. * Returns the number for IsDifferent
  90327. */
  90328. static get IsDifferent(): number;
  90329. /**
  90330. * Returns the number for IsGreater
  90331. */
  90332. static get IsGreater(): number;
  90333. /**
  90334. * Returns the number for IsLesser
  90335. */
  90336. static get IsLesser(): number;
  90337. /**
  90338. * Internal only The action manager for the condition
  90339. * @hidden
  90340. */
  90341. _actionManager: ActionManager;
  90342. /**
  90343. * Internal only
  90344. * @hidden
  90345. */
  90346. private _target;
  90347. /**
  90348. * Internal only
  90349. * @hidden
  90350. */
  90351. private _effectiveTarget;
  90352. /**
  90353. * Internal only
  90354. * @hidden
  90355. */
  90356. private _property;
  90357. /**
  90358. * Creates a new ValueCondition
  90359. * @param actionManager manager for the action the condition applies to
  90360. * @param target for the action
  90361. * @param propertyPath path to specify the property of the target the conditional operator uses
  90362. * @param value the value compared by the conditional operator against the current value of the property
  90363. * @param operator the conditional operator, default ValueCondition.IsEqual
  90364. */
  90365. constructor(actionManager: ActionManager, target: any,
  90366. /** path to specify the property of the target the conditional operator uses */
  90367. propertyPath: string,
  90368. /** the value compared by the conditional operator against the current value of the property */
  90369. value: any,
  90370. /** the conditional operator, default ValueCondition.IsEqual */
  90371. operator?: number);
  90372. /**
  90373. * Compares the given value with the property value for the specified conditional operator
  90374. * @returns the result of the comparison
  90375. */
  90376. isValid(): boolean;
  90377. /**
  90378. * Serialize the ValueCondition into a JSON compatible object
  90379. * @returns serialization object
  90380. */
  90381. serialize(): any;
  90382. /**
  90383. * Gets the name of the conditional operator for the ValueCondition
  90384. * @param operator the conditional operator
  90385. * @returns the name
  90386. */
  90387. static GetOperatorName(operator: number): string;
  90388. }
  90389. /**
  90390. * Defines a predicate condition as an extension of Condition
  90391. */
  90392. export class PredicateCondition extends Condition {
  90393. /** defines the predicate function used to validate the condition */
  90394. predicate: () => boolean;
  90395. /**
  90396. * Internal only - manager for action
  90397. * @hidden
  90398. */
  90399. _actionManager: ActionManager;
  90400. /**
  90401. * Creates a new PredicateCondition
  90402. * @param actionManager manager for the action the condition applies to
  90403. * @param predicate defines the predicate function used to validate the condition
  90404. */
  90405. constructor(actionManager: ActionManager,
  90406. /** defines the predicate function used to validate the condition */
  90407. predicate: () => boolean);
  90408. /**
  90409. * @returns the validity of the predicate condition
  90410. */
  90411. isValid(): boolean;
  90412. }
  90413. /**
  90414. * Defines a state condition as an extension of Condition
  90415. */
  90416. export class StateCondition extends Condition {
  90417. /** Value to compare with target state */
  90418. value: string;
  90419. /**
  90420. * Internal only - manager for action
  90421. * @hidden
  90422. */
  90423. _actionManager: ActionManager;
  90424. /**
  90425. * Internal only
  90426. * @hidden
  90427. */
  90428. private _target;
  90429. /**
  90430. * Creates a new StateCondition
  90431. * @param actionManager manager for the action the condition applies to
  90432. * @param target of the condition
  90433. * @param value to compare with target state
  90434. */
  90435. constructor(actionManager: ActionManager, target: any,
  90436. /** Value to compare with target state */
  90437. value: string);
  90438. /**
  90439. * Gets a boolean indicating if the current condition is met
  90440. * @returns the validity of the state
  90441. */
  90442. isValid(): boolean;
  90443. /**
  90444. * Serialize the StateCondition into a JSON compatible object
  90445. * @returns serialization object
  90446. */
  90447. serialize(): any;
  90448. }
  90449. }
  90450. declare module BABYLON {
  90451. /**
  90452. * This defines an action responsible to toggle a boolean once triggered.
  90453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90454. */
  90455. export class SwitchBooleanAction extends Action {
  90456. /**
  90457. * The path to the boolean property in the target object
  90458. */
  90459. propertyPath: string;
  90460. private _target;
  90461. private _effectiveTarget;
  90462. private _property;
  90463. /**
  90464. * Instantiate the action
  90465. * @param triggerOptions defines the trigger options
  90466. * @param target defines the object containing the boolean
  90467. * @param propertyPath defines the path to the boolean property in the target object
  90468. * @param condition defines the trigger related conditions
  90469. */
  90470. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90471. /** @hidden */
  90472. _prepare(): void;
  90473. /**
  90474. * Execute the action toggle the boolean value.
  90475. */
  90476. execute(): void;
  90477. /**
  90478. * Serializes the actions and its related information.
  90479. * @param parent defines the object to serialize in
  90480. * @returns the serialized object
  90481. */
  90482. serialize(parent: any): any;
  90483. }
  90484. /**
  90485. * This defines an action responsible to set a the state field of the target
  90486. * to a desired value once triggered.
  90487. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90488. */
  90489. export class SetStateAction extends Action {
  90490. /**
  90491. * The value to store in the state field.
  90492. */
  90493. value: string;
  90494. private _target;
  90495. /**
  90496. * Instantiate the action
  90497. * @param triggerOptions defines the trigger options
  90498. * @param target defines the object containing the state property
  90499. * @param value defines the value to store in the state field
  90500. * @param condition defines the trigger related conditions
  90501. */
  90502. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90503. /**
  90504. * Execute the action and store the value on the target state property.
  90505. */
  90506. execute(): void;
  90507. /**
  90508. * Serializes the actions and its related information.
  90509. * @param parent defines the object to serialize in
  90510. * @returns the serialized object
  90511. */
  90512. serialize(parent: any): any;
  90513. }
  90514. /**
  90515. * This defines an action responsible to set a property of the target
  90516. * to a desired value once triggered.
  90517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90518. */
  90519. export class SetValueAction extends Action {
  90520. /**
  90521. * The path of the property to set in the target.
  90522. */
  90523. propertyPath: string;
  90524. /**
  90525. * The value to set in the property
  90526. */
  90527. value: any;
  90528. private _target;
  90529. private _effectiveTarget;
  90530. private _property;
  90531. /**
  90532. * Instantiate the action
  90533. * @param triggerOptions defines the trigger options
  90534. * @param target defines the object containing the property
  90535. * @param propertyPath defines the path of the property to set in the target
  90536. * @param value defines the value to set in the property
  90537. * @param condition defines the trigger related conditions
  90538. */
  90539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90540. /** @hidden */
  90541. _prepare(): void;
  90542. /**
  90543. * Execute the action and set the targetted property to the desired value.
  90544. */
  90545. execute(): void;
  90546. /**
  90547. * Serializes the actions and its related information.
  90548. * @param parent defines the object to serialize in
  90549. * @returns the serialized object
  90550. */
  90551. serialize(parent: any): any;
  90552. }
  90553. /**
  90554. * This defines an action responsible to increment the target value
  90555. * to a desired value once triggered.
  90556. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90557. */
  90558. export class IncrementValueAction extends Action {
  90559. /**
  90560. * The path of the property to increment in the target.
  90561. */
  90562. propertyPath: string;
  90563. /**
  90564. * The value we should increment the property by.
  90565. */
  90566. value: any;
  90567. private _target;
  90568. private _effectiveTarget;
  90569. private _property;
  90570. /**
  90571. * Instantiate the action
  90572. * @param triggerOptions defines the trigger options
  90573. * @param target defines the object containing the property
  90574. * @param propertyPath defines the path of the property to increment in the target
  90575. * @param value defines the value value we should increment the property by
  90576. * @param condition defines the trigger related conditions
  90577. */
  90578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90579. /** @hidden */
  90580. _prepare(): void;
  90581. /**
  90582. * Execute the action and increment the target of the value amount.
  90583. */
  90584. execute(): void;
  90585. /**
  90586. * Serializes the actions and its related information.
  90587. * @param parent defines the object to serialize in
  90588. * @returns the serialized object
  90589. */
  90590. serialize(parent: any): any;
  90591. }
  90592. /**
  90593. * This defines an action responsible to start an animation once triggered.
  90594. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90595. */
  90596. export class PlayAnimationAction extends Action {
  90597. /**
  90598. * Where the animation should start (animation frame)
  90599. */
  90600. from: number;
  90601. /**
  90602. * Where the animation should stop (animation frame)
  90603. */
  90604. to: number;
  90605. /**
  90606. * Define if the animation should loop or stop after the first play.
  90607. */
  90608. loop?: boolean;
  90609. private _target;
  90610. /**
  90611. * Instantiate the action
  90612. * @param triggerOptions defines the trigger options
  90613. * @param target defines the target animation or animation name
  90614. * @param from defines from where the animation should start (animation frame)
  90615. * @param end defines where the animation should stop (animation frame)
  90616. * @param loop defines if the animation should loop or stop after the first play
  90617. * @param condition defines the trigger related conditions
  90618. */
  90619. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90620. /** @hidden */
  90621. _prepare(): void;
  90622. /**
  90623. * Execute the action and play the animation.
  90624. */
  90625. execute(): void;
  90626. /**
  90627. * Serializes the actions and its related information.
  90628. * @param parent defines the object to serialize in
  90629. * @returns the serialized object
  90630. */
  90631. serialize(parent: any): any;
  90632. }
  90633. /**
  90634. * This defines an action responsible to stop an animation once triggered.
  90635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90636. */
  90637. export class StopAnimationAction extends Action {
  90638. private _target;
  90639. /**
  90640. * Instantiate the action
  90641. * @param triggerOptions defines the trigger options
  90642. * @param target defines the target animation or animation name
  90643. * @param condition defines the trigger related conditions
  90644. */
  90645. constructor(triggerOptions: any, target: any, condition?: Condition);
  90646. /** @hidden */
  90647. _prepare(): void;
  90648. /**
  90649. * Execute the action and stop the animation.
  90650. */
  90651. execute(): void;
  90652. /**
  90653. * Serializes the actions and its related information.
  90654. * @param parent defines the object to serialize in
  90655. * @returns the serialized object
  90656. */
  90657. serialize(parent: any): any;
  90658. }
  90659. /**
  90660. * This defines an action responsible that does nothing once triggered.
  90661. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90662. */
  90663. export class DoNothingAction extends Action {
  90664. /**
  90665. * Instantiate the action
  90666. * @param triggerOptions defines the trigger options
  90667. * @param condition defines the trigger related conditions
  90668. */
  90669. constructor(triggerOptions?: any, condition?: Condition);
  90670. /**
  90671. * Execute the action and do nothing.
  90672. */
  90673. execute(): void;
  90674. /**
  90675. * Serializes the actions and its related information.
  90676. * @param parent defines the object to serialize in
  90677. * @returns the serialized object
  90678. */
  90679. serialize(parent: any): any;
  90680. }
  90681. /**
  90682. * This defines an action responsible to trigger several actions once triggered.
  90683. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90684. */
  90685. export class CombineAction extends Action {
  90686. /**
  90687. * The list of aggregated animations to run.
  90688. */
  90689. children: Action[];
  90690. /**
  90691. * Instantiate the action
  90692. * @param triggerOptions defines the trigger options
  90693. * @param children defines the list of aggregated animations to run
  90694. * @param condition defines the trigger related conditions
  90695. */
  90696. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90697. /** @hidden */
  90698. _prepare(): void;
  90699. /**
  90700. * Execute the action and executes all the aggregated actions.
  90701. */
  90702. execute(evt: ActionEvent): void;
  90703. /**
  90704. * Serializes the actions and its related information.
  90705. * @param parent defines the object to serialize in
  90706. * @returns the serialized object
  90707. */
  90708. serialize(parent: any): any;
  90709. }
  90710. /**
  90711. * This defines an action responsible to run code (external event) once triggered.
  90712. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90713. */
  90714. export class ExecuteCodeAction extends Action {
  90715. /**
  90716. * The callback function to run.
  90717. */
  90718. func: (evt: ActionEvent) => void;
  90719. /**
  90720. * Instantiate the action
  90721. * @param triggerOptions defines the trigger options
  90722. * @param func defines the callback function to run
  90723. * @param condition defines the trigger related conditions
  90724. */
  90725. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90726. /**
  90727. * Execute the action and run the attached code.
  90728. */
  90729. execute(evt: ActionEvent): void;
  90730. }
  90731. /**
  90732. * This defines an action responsible to set the parent property of the target once triggered.
  90733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90734. */
  90735. export class SetParentAction extends Action {
  90736. private _parent;
  90737. private _target;
  90738. /**
  90739. * Instantiate the action
  90740. * @param triggerOptions defines the trigger options
  90741. * @param target defines the target containing the parent property
  90742. * @param parent defines from where the animation should start (animation frame)
  90743. * @param condition defines the trigger related conditions
  90744. */
  90745. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90746. /** @hidden */
  90747. _prepare(): void;
  90748. /**
  90749. * Execute the action and set the parent property.
  90750. */
  90751. execute(): void;
  90752. /**
  90753. * Serializes the actions and its related information.
  90754. * @param parent defines the object to serialize in
  90755. * @returns the serialized object
  90756. */
  90757. serialize(parent: any): any;
  90758. }
  90759. }
  90760. declare module BABYLON {
  90761. /**
  90762. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90763. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90765. */
  90766. export class ActionManager extends AbstractActionManager {
  90767. /**
  90768. * Nothing
  90769. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90770. */
  90771. static readonly NothingTrigger: number;
  90772. /**
  90773. * On pick
  90774. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90775. */
  90776. static readonly OnPickTrigger: number;
  90777. /**
  90778. * On left pick
  90779. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90780. */
  90781. static readonly OnLeftPickTrigger: number;
  90782. /**
  90783. * On right pick
  90784. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90785. */
  90786. static readonly OnRightPickTrigger: number;
  90787. /**
  90788. * On center pick
  90789. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90790. */
  90791. static readonly OnCenterPickTrigger: number;
  90792. /**
  90793. * On pick down
  90794. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90795. */
  90796. static readonly OnPickDownTrigger: number;
  90797. /**
  90798. * On double pick
  90799. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90800. */
  90801. static readonly OnDoublePickTrigger: number;
  90802. /**
  90803. * On pick up
  90804. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90805. */
  90806. static readonly OnPickUpTrigger: number;
  90807. /**
  90808. * On pick out.
  90809. * This trigger will only be raised if you also declared a OnPickDown
  90810. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90811. */
  90812. static readonly OnPickOutTrigger: number;
  90813. /**
  90814. * On long press
  90815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90816. */
  90817. static readonly OnLongPressTrigger: number;
  90818. /**
  90819. * On pointer over
  90820. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90821. */
  90822. static readonly OnPointerOverTrigger: number;
  90823. /**
  90824. * On pointer out
  90825. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90826. */
  90827. static readonly OnPointerOutTrigger: number;
  90828. /**
  90829. * On every frame
  90830. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90831. */
  90832. static readonly OnEveryFrameTrigger: number;
  90833. /**
  90834. * On intersection enter
  90835. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90836. */
  90837. static readonly OnIntersectionEnterTrigger: number;
  90838. /**
  90839. * On intersection exit
  90840. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90841. */
  90842. static readonly OnIntersectionExitTrigger: number;
  90843. /**
  90844. * On key down
  90845. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90846. */
  90847. static readonly OnKeyDownTrigger: number;
  90848. /**
  90849. * On key up
  90850. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90851. */
  90852. static readonly OnKeyUpTrigger: number;
  90853. private _scene;
  90854. /**
  90855. * Creates a new action manager
  90856. * @param scene defines the hosting scene
  90857. */
  90858. constructor(scene: Scene);
  90859. /**
  90860. * Releases all associated resources
  90861. */
  90862. dispose(): void;
  90863. /**
  90864. * Gets hosting scene
  90865. * @returns the hosting scene
  90866. */
  90867. getScene(): Scene;
  90868. /**
  90869. * Does this action manager handles actions of any of the given triggers
  90870. * @param triggers defines the triggers to be tested
  90871. * @return a boolean indicating whether one (or more) of the triggers is handled
  90872. */
  90873. hasSpecificTriggers(triggers: number[]): boolean;
  90874. /**
  90875. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90876. * speed.
  90877. * @param triggerA defines the trigger to be tested
  90878. * @param triggerB defines the trigger to be tested
  90879. * @return a boolean indicating whether one (or more) of the triggers is handled
  90880. */
  90881. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90882. /**
  90883. * Does this action manager handles actions of a given trigger
  90884. * @param trigger defines the trigger to be tested
  90885. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90886. * @return whether the trigger is handled
  90887. */
  90888. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90889. /**
  90890. * Does this action manager has pointer triggers
  90891. */
  90892. get hasPointerTriggers(): boolean;
  90893. /**
  90894. * Does this action manager has pick triggers
  90895. */
  90896. get hasPickTriggers(): boolean;
  90897. /**
  90898. * Registers an action to this action manager
  90899. * @param action defines the action to be registered
  90900. * @return the action amended (prepared) after registration
  90901. */
  90902. registerAction(action: IAction): Nullable<IAction>;
  90903. /**
  90904. * Unregisters an action to this action manager
  90905. * @param action defines the action to be unregistered
  90906. * @return a boolean indicating whether the action has been unregistered
  90907. */
  90908. unregisterAction(action: IAction): Boolean;
  90909. /**
  90910. * Process a specific trigger
  90911. * @param trigger defines the trigger to process
  90912. * @param evt defines the event details to be processed
  90913. */
  90914. processTrigger(trigger: number, evt?: IActionEvent): void;
  90915. /** @hidden */
  90916. _getEffectiveTarget(target: any, propertyPath: string): any;
  90917. /** @hidden */
  90918. _getProperty(propertyPath: string): string;
  90919. /**
  90920. * Serialize this manager to a JSON object
  90921. * @param name defines the property name to store this manager
  90922. * @returns a JSON representation of this manager
  90923. */
  90924. serialize(name: string): any;
  90925. /**
  90926. * Creates a new ActionManager from a JSON data
  90927. * @param parsedActions defines the JSON data to read from
  90928. * @param object defines the hosting mesh
  90929. * @param scene defines the hosting scene
  90930. */
  90931. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90932. /**
  90933. * Get a trigger name by index
  90934. * @param trigger defines the trigger index
  90935. * @returns a trigger name
  90936. */
  90937. static GetTriggerName(trigger: number): string;
  90938. }
  90939. }
  90940. declare module BABYLON {
  90941. /**
  90942. * Class used to represent a sprite
  90943. * @see https://doc.babylonjs.com/babylon101/sprites
  90944. */
  90945. export class Sprite implements IAnimatable {
  90946. /** defines the name */
  90947. name: string;
  90948. /** Gets or sets the current world position */
  90949. position: Vector3;
  90950. /** Gets or sets the main color */
  90951. color: Color4;
  90952. /** Gets or sets the width */
  90953. width: number;
  90954. /** Gets or sets the height */
  90955. height: number;
  90956. /** Gets or sets rotation angle */
  90957. angle: number;
  90958. /** Gets or sets the cell index in the sprite sheet */
  90959. cellIndex: number;
  90960. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90961. cellRef: string;
  90962. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90963. invertU: boolean;
  90964. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90965. invertV: boolean;
  90966. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90967. disposeWhenFinishedAnimating: boolean;
  90968. /** Gets the list of attached animations */
  90969. animations: Nullable<Array<Animation>>;
  90970. /** Gets or sets a boolean indicating if the sprite can be picked */
  90971. isPickable: boolean;
  90972. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90973. useAlphaForPicking: boolean;
  90974. /** @hidden */
  90975. _xOffset: number;
  90976. /** @hidden */
  90977. _yOffset: number;
  90978. /** @hidden */
  90979. _xSize: number;
  90980. /** @hidden */
  90981. _ySize: number;
  90982. /**
  90983. * Gets or sets the associated action manager
  90984. */
  90985. actionManager: Nullable<ActionManager>;
  90986. /**
  90987. * An event triggered when the control has been disposed
  90988. */
  90989. onDisposeObservable: Observable<Sprite>;
  90990. private _animationStarted;
  90991. private _loopAnimation;
  90992. private _fromIndex;
  90993. private _toIndex;
  90994. private _delay;
  90995. private _direction;
  90996. private _manager;
  90997. private _time;
  90998. private _onAnimationEnd;
  90999. /**
  91000. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91001. */
  91002. isVisible: boolean;
  91003. /**
  91004. * Gets or sets the sprite size
  91005. */
  91006. get size(): number;
  91007. set size(value: number);
  91008. /**
  91009. * Returns a boolean indicating if the animation is started
  91010. */
  91011. get animationStarted(): boolean;
  91012. /**
  91013. * Gets or sets the unique id of the sprite
  91014. */
  91015. uniqueId: number;
  91016. /**
  91017. * Gets the manager of this sprite
  91018. */
  91019. get manager(): ISpriteManager;
  91020. /**
  91021. * Creates a new Sprite
  91022. * @param name defines the name
  91023. * @param manager defines the manager
  91024. */
  91025. constructor(
  91026. /** defines the name */
  91027. name: string, manager: ISpriteManager);
  91028. /**
  91029. * Returns the string "Sprite"
  91030. * @returns "Sprite"
  91031. */
  91032. getClassName(): string;
  91033. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91034. get fromIndex(): number;
  91035. set fromIndex(value: number);
  91036. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91037. get toIndex(): number;
  91038. set toIndex(value: number);
  91039. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91040. get loopAnimation(): boolean;
  91041. set loopAnimation(value: boolean);
  91042. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91043. get delay(): number;
  91044. set delay(value: number);
  91045. /**
  91046. * Starts an animation
  91047. * @param from defines the initial key
  91048. * @param to defines the end key
  91049. * @param loop defines if the animation must loop
  91050. * @param delay defines the start delay (in ms)
  91051. * @param onAnimationEnd defines a callback to call when animation ends
  91052. */
  91053. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91054. /** Stops current animation (if any) */
  91055. stopAnimation(): void;
  91056. /** @hidden */
  91057. _animate(deltaTime: number): void;
  91058. /** Release associated resources */
  91059. dispose(): void;
  91060. /**
  91061. * Serializes the sprite to a JSON object
  91062. * @returns the JSON object
  91063. */
  91064. serialize(): any;
  91065. /**
  91066. * Parses a JSON object to create a new sprite
  91067. * @param parsedSprite The JSON object to parse
  91068. * @param manager defines the hosting manager
  91069. * @returns the new sprite
  91070. */
  91071. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91072. }
  91073. }
  91074. declare module BABYLON {
  91075. /**
  91076. * Information about the result of picking within a scene
  91077. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91078. */
  91079. export class PickingInfo {
  91080. /** @hidden */
  91081. _pickingUnavailable: boolean;
  91082. /**
  91083. * If the pick collided with an object
  91084. */
  91085. hit: boolean;
  91086. /**
  91087. * Distance away where the pick collided
  91088. */
  91089. distance: number;
  91090. /**
  91091. * The location of pick collision
  91092. */
  91093. pickedPoint: Nullable<Vector3>;
  91094. /**
  91095. * The mesh corresponding the the pick collision
  91096. */
  91097. pickedMesh: Nullable<AbstractMesh>;
  91098. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91099. bu: number;
  91100. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91101. bv: number;
  91102. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91103. faceId: number;
  91104. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91105. subMeshFaceId: number;
  91106. /** Id of the the submesh that was picked */
  91107. subMeshId: number;
  91108. /** If a sprite was picked, this will be the sprite the pick collided with */
  91109. pickedSprite: Nullable<Sprite>;
  91110. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91111. thinInstanceIndex: number;
  91112. /**
  91113. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91114. */
  91115. originMesh: Nullable<AbstractMesh>;
  91116. /**
  91117. * The ray that was used to perform the picking.
  91118. */
  91119. ray: Nullable<Ray>;
  91120. /**
  91121. * Gets the normal correspodning to the face the pick collided with
  91122. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91123. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91124. * @returns The normal correspodning to the face the pick collided with
  91125. */
  91126. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91127. /**
  91128. * Gets the texture coordinates of where the pick occured
  91129. * @returns the vector containing the coordnates of the texture
  91130. */
  91131. getTextureCoordinates(): Nullable<Vector2>;
  91132. }
  91133. }
  91134. declare module BABYLON {
  91135. /**
  91136. * Class representing a ray with position and direction
  91137. */
  91138. export class Ray {
  91139. /** origin point */
  91140. origin: Vector3;
  91141. /** direction */
  91142. direction: Vector3;
  91143. /** length of the ray */
  91144. length: number;
  91145. private static readonly _TmpVector3;
  91146. private _tmpRay;
  91147. /**
  91148. * Creates a new ray
  91149. * @param origin origin point
  91150. * @param direction direction
  91151. * @param length length of the ray
  91152. */
  91153. constructor(
  91154. /** origin point */
  91155. origin: Vector3,
  91156. /** direction */
  91157. direction: Vector3,
  91158. /** length of the ray */
  91159. length?: number);
  91160. /**
  91161. * Checks if the ray intersects a box
  91162. * This does not account for the ray lenght by design to improve perfs.
  91163. * @param minimum bound of the box
  91164. * @param maximum bound of the box
  91165. * @param intersectionTreshold extra extend to be added to the box in all direction
  91166. * @returns if the box was hit
  91167. */
  91168. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91169. /**
  91170. * Checks if the ray intersects a box
  91171. * This does not account for the ray lenght by design to improve perfs.
  91172. * @param box the bounding box to check
  91173. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91174. * @returns if the box was hit
  91175. */
  91176. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91177. /**
  91178. * If the ray hits a sphere
  91179. * @param sphere the bounding sphere to check
  91180. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91181. * @returns true if it hits the sphere
  91182. */
  91183. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91184. /**
  91185. * If the ray hits a triange
  91186. * @param vertex0 triangle vertex
  91187. * @param vertex1 triangle vertex
  91188. * @param vertex2 triangle vertex
  91189. * @returns intersection information if hit
  91190. */
  91191. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91192. /**
  91193. * Checks if ray intersects a plane
  91194. * @param plane the plane to check
  91195. * @returns the distance away it was hit
  91196. */
  91197. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91198. /**
  91199. * Calculate the intercept of a ray on a given axis
  91200. * @param axis to check 'x' | 'y' | 'z'
  91201. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91202. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91203. */
  91204. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91205. /**
  91206. * Checks if ray intersects a mesh
  91207. * @param mesh the mesh to check
  91208. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91209. * @returns picking info of the intersecton
  91210. */
  91211. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91212. /**
  91213. * Checks if ray intersects a mesh
  91214. * @param meshes the meshes to check
  91215. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91216. * @param results array to store result in
  91217. * @returns Array of picking infos
  91218. */
  91219. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91220. private _comparePickingInfo;
  91221. private static smallnum;
  91222. private static rayl;
  91223. /**
  91224. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91225. * @param sega the first point of the segment to test the intersection against
  91226. * @param segb the second point of the segment to test the intersection against
  91227. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91228. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91229. */
  91230. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91231. /**
  91232. * Update the ray from viewport position
  91233. * @param x position
  91234. * @param y y position
  91235. * @param viewportWidth viewport width
  91236. * @param viewportHeight viewport height
  91237. * @param world world matrix
  91238. * @param view view matrix
  91239. * @param projection projection matrix
  91240. * @returns this ray updated
  91241. */
  91242. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91243. /**
  91244. * Creates a ray with origin and direction of 0,0,0
  91245. * @returns the new ray
  91246. */
  91247. static Zero(): Ray;
  91248. /**
  91249. * Creates a new ray from screen space and viewport
  91250. * @param x position
  91251. * @param y y position
  91252. * @param viewportWidth viewport width
  91253. * @param viewportHeight viewport height
  91254. * @param world world matrix
  91255. * @param view view matrix
  91256. * @param projection projection matrix
  91257. * @returns new ray
  91258. */
  91259. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91260. /**
  91261. * 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
  91262. * transformed to the given world matrix.
  91263. * @param origin The origin point
  91264. * @param end The end point
  91265. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91266. * @returns the new ray
  91267. */
  91268. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91269. /**
  91270. * Transforms a ray by a matrix
  91271. * @param ray ray to transform
  91272. * @param matrix matrix to apply
  91273. * @returns the resulting new ray
  91274. */
  91275. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91276. /**
  91277. * Transforms a ray by a matrix
  91278. * @param ray ray to transform
  91279. * @param matrix matrix to apply
  91280. * @param result ray to store result in
  91281. */
  91282. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91283. /**
  91284. * Unproject a ray from screen space to object space
  91285. * @param sourceX defines the screen space x coordinate to use
  91286. * @param sourceY defines the screen space y coordinate to use
  91287. * @param viewportWidth defines the current width of the viewport
  91288. * @param viewportHeight defines the current height of the viewport
  91289. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91290. * @param view defines the view matrix to use
  91291. * @param projection defines the projection matrix to use
  91292. */
  91293. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91294. }
  91295. /**
  91296. * Type used to define predicate used to select faces when a mesh intersection is detected
  91297. */
  91298. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91299. interface Scene {
  91300. /** @hidden */
  91301. _tempPickingRay: Nullable<Ray>;
  91302. /** @hidden */
  91303. _cachedRayForTransform: Ray;
  91304. /** @hidden */
  91305. _pickWithRayInverseMatrix: Matrix;
  91306. /** @hidden */
  91307. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91308. /** @hidden */
  91309. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91310. /** @hidden */
  91311. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91312. }
  91313. }
  91314. declare module BABYLON {
  91315. /**
  91316. * Groups all the scene component constants in one place to ease maintenance.
  91317. * @hidden
  91318. */
  91319. export class SceneComponentConstants {
  91320. static readonly NAME_EFFECTLAYER: string;
  91321. static readonly NAME_LAYER: string;
  91322. static readonly NAME_LENSFLARESYSTEM: string;
  91323. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91324. static readonly NAME_PARTICLESYSTEM: string;
  91325. static readonly NAME_GAMEPAD: string;
  91326. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91327. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91328. static readonly NAME_PREPASSRENDERER: string;
  91329. static readonly NAME_DEPTHRENDERER: string;
  91330. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91331. static readonly NAME_SPRITE: string;
  91332. static readonly NAME_SUBSURFACE: string;
  91333. static readonly NAME_OUTLINERENDERER: string;
  91334. static readonly NAME_PROCEDURALTEXTURE: string;
  91335. static readonly NAME_SHADOWGENERATOR: string;
  91336. static readonly NAME_OCTREE: string;
  91337. static readonly NAME_PHYSICSENGINE: string;
  91338. static readonly NAME_AUDIO: string;
  91339. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91340. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91341. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91342. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91343. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91344. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91345. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91346. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91347. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91348. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91349. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91350. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91351. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91352. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91353. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91354. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91355. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91356. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91357. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91358. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91359. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91360. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91361. static readonly STEP_AFTERRENDER_AUDIO: number;
  91362. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91363. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91364. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91365. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91366. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91367. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91368. static readonly STEP_POINTERMOVE_SPRITE: number;
  91369. static readonly STEP_POINTERDOWN_SPRITE: number;
  91370. static readonly STEP_POINTERUP_SPRITE: number;
  91371. }
  91372. /**
  91373. * This represents a scene component.
  91374. *
  91375. * This is used to decouple the dependency the scene is having on the different workloads like
  91376. * layers, post processes...
  91377. */
  91378. export interface ISceneComponent {
  91379. /**
  91380. * The name of the component. Each component must have a unique name.
  91381. */
  91382. name: string;
  91383. /**
  91384. * The scene the component belongs to.
  91385. */
  91386. scene: Scene;
  91387. /**
  91388. * Register the component to one instance of a scene.
  91389. */
  91390. register(): void;
  91391. /**
  91392. * Rebuilds the elements related to this component in case of
  91393. * context lost for instance.
  91394. */
  91395. rebuild(): void;
  91396. /**
  91397. * Disposes the component and the associated ressources.
  91398. */
  91399. dispose(): void;
  91400. }
  91401. /**
  91402. * This represents a SERIALIZABLE scene component.
  91403. *
  91404. * This extends Scene Component to add Serialization methods on top.
  91405. */
  91406. export interface ISceneSerializableComponent extends ISceneComponent {
  91407. /**
  91408. * Adds all the elements from the container to the scene
  91409. * @param container the container holding the elements
  91410. */
  91411. addFromContainer(container: AbstractScene): void;
  91412. /**
  91413. * Removes all the elements in the container from the scene
  91414. * @param container contains the elements to remove
  91415. * @param dispose if the removed element should be disposed (default: false)
  91416. */
  91417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91418. /**
  91419. * Serializes the component data to the specified json object
  91420. * @param serializationObject The object to serialize to
  91421. */
  91422. serialize(serializationObject: any): void;
  91423. }
  91424. /**
  91425. * Strong typing of a Mesh related stage step action
  91426. */
  91427. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91428. /**
  91429. * Strong typing of a Evaluate Sub Mesh related stage step action
  91430. */
  91431. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91432. /**
  91433. * Strong typing of a Active Mesh related stage step action
  91434. */
  91435. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91436. /**
  91437. * Strong typing of a Camera related stage step action
  91438. */
  91439. export type CameraStageAction = (camera: Camera) => void;
  91440. /**
  91441. * Strong typing of a Camera Frame buffer related stage step action
  91442. */
  91443. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91444. /**
  91445. * Strong typing of a Render Target related stage step action
  91446. */
  91447. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91448. /**
  91449. * Strong typing of a RenderingGroup related stage step action
  91450. */
  91451. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91452. /**
  91453. * Strong typing of a Mesh Render related stage step action
  91454. */
  91455. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91456. /**
  91457. * Strong typing of a simple stage step action
  91458. */
  91459. export type SimpleStageAction = () => void;
  91460. /**
  91461. * Strong typing of a render target action.
  91462. */
  91463. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91464. /**
  91465. * Strong typing of a pointer move action.
  91466. */
  91467. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91468. /**
  91469. * Strong typing of a pointer up/down action.
  91470. */
  91471. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91472. /**
  91473. * Representation of a stage in the scene (Basically a list of ordered steps)
  91474. * @hidden
  91475. */
  91476. export class Stage<T extends Function> extends Array<{
  91477. index: number;
  91478. component: ISceneComponent;
  91479. action: T;
  91480. }> {
  91481. /**
  91482. * Hide ctor from the rest of the world.
  91483. * @param items The items to add.
  91484. */
  91485. private constructor();
  91486. /**
  91487. * Creates a new Stage.
  91488. * @returns A new instance of a Stage
  91489. */
  91490. static Create<T extends Function>(): Stage<T>;
  91491. /**
  91492. * Registers a step in an ordered way in the targeted stage.
  91493. * @param index Defines the position to register the step in
  91494. * @param component Defines the component attached to the step
  91495. * @param action Defines the action to launch during the step
  91496. */
  91497. registerStep(index: number, component: ISceneComponent, action: T): void;
  91498. /**
  91499. * Clears all the steps from the stage.
  91500. */
  91501. clear(): void;
  91502. }
  91503. }
  91504. declare module BABYLON {
  91505. interface Scene {
  91506. /** @hidden */
  91507. _pointerOverSprite: Nullable<Sprite>;
  91508. /** @hidden */
  91509. _pickedDownSprite: Nullable<Sprite>;
  91510. /** @hidden */
  91511. _tempSpritePickingRay: Nullable<Ray>;
  91512. /**
  91513. * All of the sprite managers added to this scene
  91514. * @see https://doc.babylonjs.com/babylon101/sprites
  91515. */
  91516. spriteManagers: Array<ISpriteManager>;
  91517. /**
  91518. * An event triggered when sprites rendering is about to start
  91519. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91520. */
  91521. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91522. /**
  91523. * An event triggered when sprites rendering is done
  91524. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91525. */
  91526. onAfterSpritesRenderingObservable: Observable<Scene>;
  91527. /** @hidden */
  91528. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91529. /** Launch a ray to try to pick a sprite in the scene
  91530. * @param x position on screen
  91531. * @param y position on screen
  91532. * @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
  91533. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91535. * @returns a PickingInfo
  91536. */
  91537. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91538. /** Use the given ray to pick a sprite in the scene
  91539. * @param ray The ray (in world space) to use to pick meshes
  91540. * @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
  91541. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91542. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91543. * @returns a PickingInfo
  91544. */
  91545. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91546. /** @hidden */
  91547. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91548. /** Launch a ray to try to pick sprites in the scene
  91549. * @param x position on screen
  91550. * @param y position on screen
  91551. * @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
  91552. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91553. * @returns a PickingInfo array
  91554. */
  91555. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91556. /** Use the given ray to pick sprites in the scene
  91557. * @param ray The ray (in world space) to use to pick meshes
  91558. * @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
  91559. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91560. * @returns a PickingInfo array
  91561. */
  91562. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91563. /**
  91564. * Force the sprite under the pointer
  91565. * @param sprite defines the sprite to use
  91566. */
  91567. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91568. /**
  91569. * Gets the sprite under the pointer
  91570. * @returns a Sprite or null if no sprite is under the pointer
  91571. */
  91572. getPointerOverSprite(): Nullable<Sprite>;
  91573. }
  91574. /**
  91575. * Defines the sprite scene component responsible to manage sprites
  91576. * in a given scene.
  91577. */
  91578. export class SpriteSceneComponent implements ISceneComponent {
  91579. /**
  91580. * The component name helpfull to identify the component in the list of scene components.
  91581. */
  91582. readonly name: string;
  91583. /**
  91584. * The scene the component belongs to.
  91585. */
  91586. scene: Scene;
  91587. /** @hidden */
  91588. private _spritePredicate;
  91589. /**
  91590. * Creates a new instance of the component for the given scene
  91591. * @param scene Defines the scene to register the component in
  91592. */
  91593. constructor(scene: Scene);
  91594. /**
  91595. * Registers the component in a given scene
  91596. */
  91597. register(): void;
  91598. /**
  91599. * Rebuilds the elements related to this component in case of
  91600. * context lost for instance.
  91601. */
  91602. rebuild(): void;
  91603. /**
  91604. * Disposes the component and the associated ressources.
  91605. */
  91606. dispose(): void;
  91607. private _pickSpriteButKeepRay;
  91608. private _pointerMove;
  91609. private _pointerDown;
  91610. private _pointerUp;
  91611. }
  91612. }
  91613. declare module BABYLON {
  91614. /** @hidden */
  91615. export var fogFragmentDeclaration: {
  91616. name: string;
  91617. shader: string;
  91618. };
  91619. }
  91620. declare module BABYLON {
  91621. /** @hidden */
  91622. export var fogFragment: {
  91623. name: string;
  91624. shader: string;
  91625. };
  91626. }
  91627. declare module BABYLON {
  91628. /** @hidden */
  91629. export var imageProcessingCompatibility: {
  91630. name: string;
  91631. shader: string;
  91632. };
  91633. }
  91634. declare module BABYLON {
  91635. /** @hidden */
  91636. export var spritesPixelShader: {
  91637. name: string;
  91638. shader: string;
  91639. };
  91640. }
  91641. declare module BABYLON {
  91642. /** @hidden */
  91643. export var fogVertexDeclaration: {
  91644. name: string;
  91645. shader: string;
  91646. };
  91647. }
  91648. declare module BABYLON {
  91649. /** @hidden */
  91650. export var spritesVertexShader: {
  91651. name: string;
  91652. shader: string;
  91653. };
  91654. }
  91655. declare module BABYLON {
  91656. /**
  91657. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91658. */
  91659. export interface ISpriteManager extends IDisposable {
  91660. /**
  91661. * Gets manager's name
  91662. */
  91663. name: string;
  91664. /**
  91665. * Restricts the camera to viewing objects with the same layerMask.
  91666. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91667. */
  91668. layerMask: number;
  91669. /**
  91670. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91671. */
  91672. isPickable: boolean;
  91673. /**
  91674. * Gets the hosting scene
  91675. */
  91676. scene: Scene;
  91677. /**
  91678. * Specifies the rendering group id for this mesh (0 by default)
  91679. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91680. */
  91681. renderingGroupId: number;
  91682. /**
  91683. * Defines the list of sprites managed by the manager.
  91684. */
  91685. sprites: Array<Sprite>;
  91686. /**
  91687. * Gets or sets the spritesheet texture
  91688. */
  91689. texture: Texture;
  91690. /** Defines the default width of a cell in the spritesheet */
  91691. cellWidth: number;
  91692. /** Defines the default height of a cell in the spritesheet */
  91693. cellHeight: number;
  91694. /**
  91695. * Tests the intersection of a sprite with a specific ray.
  91696. * @param ray The ray we are sending to test the collision
  91697. * @param camera The camera space we are sending rays in
  91698. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91699. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91700. * @returns picking info or null.
  91701. */
  91702. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91703. /**
  91704. * Intersects the sprites with a ray
  91705. * @param ray defines the ray to intersect with
  91706. * @param camera defines the current active camera
  91707. * @param predicate defines a predicate used to select candidate sprites
  91708. * @returns null if no hit or a PickingInfo array
  91709. */
  91710. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91711. /**
  91712. * Renders the list of sprites on screen.
  91713. */
  91714. render(): void;
  91715. }
  91716. /**
  91717. * Class used to manage multiple sprites on the same spritesheet
  91718. * @see https://doc.babylonjs.com/babylon101/sprites
  91719. */
  91720. export class SpriteManager implements ISpriteManager {
  91721. /** defines the manager's name */
  91722. name: string;
  91723. /** Define the Url to load snippets */
  91724. static SnippetUrl: string;
  91725. /** Snippet ID if the manager was created from the snippet server */
  91726. snippetId: string;
  91727. /** Gets the list of sprites */
  91728. sprites: Sprite[];
  91729. /** Gets or sets the rendering group id (0 by default) */
  91730. renderingGroupId: number;
  91731. /** Gets or sets camera layer mask */
  91732. layerMask: number;
  91733. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91734. fogEnabled: boolean;
  91735. /** Gets or sets a boolean indicating if the sprites are pickable */
  91736. isPickable: boolean;
  91737. /** Defines the default width of a cell in the spritesheet */
  91738. cellWidth: number;
  91739. /** Defines the default height of a cell in the spritesheet */
  91740. cellHeight: number;
  91741. /** Associative array from JSON sprite data file */
  91742. private _cellData;
  91743. /** Array of sprite names from JSON sprite data file */
  91744. private _spriteMap;
  91745. /** True when packed cell data from JSON file is ready*/
  91746. private _packedAndReady;
  91747. private _textureContent;
  91748. private _useInstancing;
  91749. /**
  91750. * An event triggered when the manager is disposed.
  91751. */
  91752. onDisposeObservable: Observable<SpriteManager>;
  91753. private _onDisposeObserver;
  91754. /**
  91755. * Callback called when the manager is disposed
  91756. */
  91757. set onDispose(callback: () => void);
  91758. private _capacity;
  91759. private _fromPacked;
  91760. private _spriteTexture;
  91761. private _epsilon;
  91762. private _scene;
  91763. private _vertexData;
  91764. private _buffer;
  91765. private _vertexBuffers;
  91766. private _spriteBuffer;
  91767. private _indexBuffer;
  91768. private _effectBase;
  91769. private _effectFog;
  91770. private _vertexBufferSize;
  91771. /**
  91772. * Gets or sets the unique id of the sprite
  91773. */
  91774. uniqueId: number;
  91775. /**
  91776. * Gets the array of sprites
  91777. */
  91778. get children(): Sprite[];
  91779. /**
  91780. * Gets the hosting scene
  91781. */
  91782. get scene(): Scene;
  91783. /**
  91784. * Gets the capacity of the manager
  91785. */
  91786. get capacity(): number;
  91787. /**
  91788. * Gets or sets the spritesheet texture
  91789. */
  91790. get texture(): Texture;
  91791. set texture(value: Texture);
  91792. private _blendMode;
  91793. /**
  91794. * Blend mode use to render the particle, it can be any of
  91795. * the static Constants.ALPHA_x properties provided in this class.
  91796. * Default value is Constants.ALPHA_COMBINE
  91797. */
  91798. get blendMode(): number;
  91799. set blendMode(blendMode: number);
  91800. /** Disables writing to the depth buffer when rendering the sprites.
  91801. * It can be handy to disable depth writing when using textures without alpha channel
  91802. * and setting some specific blend modes.
  91803. */
  91804. disableDepthWrite: boolean;
  91805. /**
  91806. * Creates a new sprite manager
  91807. * @param name defines the manager's name
  91808. * @param imgUrl defines the sprite sheet url
  91809. * @param capacity defines the maximum allowed number of sprites
  91810. * @param cellSize defines the size of a sprite cell
  91811. * @param scene defines the hosting scene
  91812. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91813. * @param samplingMode defines the smapling mode to use with spritesheet
  91814. * @param fromPacked set to false; do not alter
  91815. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91816. */
  91817. constructor(
  91818. /** defines the manager's name */
  91819. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91820. /**
  91821. * Returns the string "SpriteManager"
  91822. * @returns "SpriteManager"
  91823. */
  91824. getClassName(): string;
  91825. private _makePacked;
  91826. private _appendSpriteVertex;
  91827. private _checkTextureAlpha;
  91828. /**
  91829. * Intersects the sprites with a ray
  91830. * @param ray defines the ray to intersect with
  91831. * @param camera defines the current active camera
  91832. * @param predicate defines a predicate used to select candidate sprites
  91833. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91834. * @returns null if no hit or a PickingInfo
  91835. */
  91836. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91837. /**
  91838. * Intersects the sprites with a ray
  91839. * @param ray defines the ray to intersect with
  91840. * @param camera defines the current active camera
  91841. * @param predicate defines a predicate used to select candidate sprites
  91842. * @returns null if no hit or a PickingInfo array
  91843. */
  91844. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91845. /**
  91846. * Render all child sprites
  91847. */
  91848. render(): void;
  91849. /**
  91850. * Release associated resources
  91851. */
  91852. dispose(): void;
  91853. /**
  91854. * Serializes the sprite manager to a JSON object
  91855. * @param serializeTexture defines if the texture must be serialized as well
  91856. * @returns the JSON object
  91857. */
  91858. serialize(serializeTexture?: boolean): any;
  91859. /**
  91860. * Parses a JSON object to create a new sprite manager.
  91861. * @param parsedManager The JSON object to parse
  91862. * @param scene The scene to create the sprite managerin
  91863. * @param rootUrl The root url to use to load external dependencies like texture
  91864. * @returns the new sprite manager
  91865. */
  91866. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91867. /**
  91868. * Creates a sprite manager from a snippet saved in a remote file
  91869. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91870. * @param url defines the url to load from
  91871. * @param scene defines the hosting scene
  91872. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91873. * @returns a promise that will resolve to the new sprite manager
  91874. */
  91875. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91876. /**
  91877. * Creates a sprite manager from a snippet saved by the sprite editor
  91878. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91879. * @param scene defines the hosting scene
  91880. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91881. * @returns a promise that will resolve to the new sprite manager
  91882. */
  91883. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91884. }
  91885. }
  91886. declare module BABYLON {
  91887. /** Interface used by value gradients (color, factor, ...) */
  91888. export interface IValueGradient {
  91889. /**
  91890. * Gets or sets the gradient value (between 0 and 1)
  91891. */
  91892. gradient: number;
  91893. }
  91894. /** Class used to store color4 gradient */
  91895. export class ColorGradient implements IValueGradient {
  91896. /**
  91897. * Gets or sets the gradient value (between 0 and 1)
  91898. */
  91899. gradient: number;
  91900. /**
  91901. * Gets or sets first associated color
  91902. */
  91903. color1: Color4;
  91904. /**
  91905. * Gets or sets second associated color
  91906. */
  91907. color2?: Color4 | undefined;
  91908. /**
  91909. * Creates a new color4 gradient
  91910. * @param gradient gets or sets the gradient value (between 0 and 1)
  91911. * @param color1 gets or sets first associated color
  91912. * @param color2 gets or sets first second color
  91913. */
  91914. constructor(
  91915. /**
  91916. * Gets or sets the gradient value (between 0 and 1)
  91917. */
  91918. gradient: number,
  91919. /**
  91920. * Gets or sets first associated color
  91921. */
  91922. color1: Color4,
  91923. /**
  91924. * Gets or sets second associated color
  91925. */
  91926. color2?: Color4 | undefined);
  91927. /**
  91928. * Will get a color picked randomly between color1 and color2.
  91929. * If color2 is undefined then color1 will be used
  91930. * @param result defines the target Color4 to store the result in
  91931. */
  91932. getColorToRef(result: Color4): void;
  91933. }
  91934. /** Class used to store color 3 gradient */
  91935. export class Color3Gradient implements IValueGradient {
  91936. /**
  91937. * Gets or sets the gradient value (between 0 and 1)
  91938. */
  91939. gradient: number;
  91940. /**
  91941. * Gets or sets the associated color
  91942. */
  91943. color: Color3;
  91944. /**
  91945. * Creates a new color3 gradient
  91946. * @param gradient gets or sets the gradient value (between 0 and 1)
  91947. * @param color gets or sets associated color
  91948. */
  91949. constructor(
  91950. /**
  91951. * Gets or sets the gradient value (between 0 and 1)
  91952. */
  91953. gradient: number,
  91954. /**
  91955. * Gets or sets the associated color
  91956. */
  91957. color: Color3);
  91958. }
  91959. /** Class used to store factor gradient */
  91960. export class FactorGradient implements IValueGradient {
  91961. /**
  91962. * Gets or sets the gradient value (between 0 and 1)
  91963. */
  91964. gradient: number;
  91965. /**
  91966. * Gets or sets first associated factor
  91967. */
  91968. factor1: number;
  91969. /**
  91970. * Gets or sets second associated factor
  91971. */
  91972. factor2?: number | undefined;
  91973. /**
  91974. * Creates a new factor gradient
  91975. * @param gradient gets or sets the gradient value (between 0 and 1)
  91976. * @param factor1 gets or sets first associated factor
  91977. * @param factor2 gets or sets second associated factor
  91978. */
  91979. constructor(
  91980. /**
  91981. * Gets or sets the gradient value (between 0 and 1)
  91982. */
  91983. gradient: number,
  91984. /**
  91985. * Gets or sets first associated factor
  91986. */
  91987. factor1: number,
  91988. /**
  91989. * Gets or sets second associated factor
  91990. */
  91991. factor2?: number | undefined);
  91992. /**
  91993. * Will get a number picked randomly between factor1 and factor2.
  91994. * If factor2 is undefined then factor1 will be used
  91995. * @returns the picked number
  91996. */
  91997. getFactor(): number;
  91998. }
  91999. /**
  92000. * Helper used to simplify some generic gradient tasks
  92001. */
  92002. export class GradientHelper {
  92003. /**
  92004. * Gets the current gradient from an array of IValueGradient
  92005. * @param ratio defines the current ratio to get
  92006. * @param gradients defines the array of IValueGradient
  92007. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92008. */
  92009. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92010. }
  92011. }
  92012. declare module BABYLON {
  92013. interface ThinEngine {
  92014. /**
  92015. * Creates a raw texture
  92016. * @param data defines the data to store in the texture
  92017. * @param width defines the width of the texture
  92018. * @param height defines the height of the texture
  92019. * @param format defines the format of the data
  92020. * @param generateMipMaps defines if the engine should generate the mip levels
  92021. * @param invertY defines if data must be stored with Y axis inverted
  92022. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92023. * @param compression defines the compression used (null by default)
  92024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92025. * @returns the raw texture inside an InternalTexture
  92026. */
  92027. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92028. /**
  92029. * Update a raw texture
  92030. * @param texture defines the texture to update
  92031. * @param data defines the data to store in the texture
  92032. * @param format defines the format of the data
  92033. * @param invertY defines if data must be stored with Y axis inverted
  92034. */
  92035. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92036. /**
  92037. * Update a raw texture
  92038. * @param texture defines the texture to update
  92039. * @param data defines the data to store in the texture
  92040. * @param format defines the format of the data
  92041. * @param invertY defines if data must be stored with Y axis inverted
  92042. * @param compression defines the compression used (null by default)
  92043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92044. */
  92045. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92046. /**
  92047. * Creates a new raw cube texture
  92048. * @param data defines the array of data to use to create each face
  92049. * @param size defines the size of the textures
  92050. * @param format defines the format of the data
  92051. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92052. * @param generateMipMaps defines if the engine should generate the mip levels
  92053. * @param invertY defines if data must be stored with Y axis inverted
  92054. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92055. * @param compression defines the compression used (null by default)
  92056. * @returns the cube texture as an InternalTexture
  92057. */
  92058. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92059. /**
  92060. * Update a raw cube texture
  92061. * @param texture defines the texture to udpdate
  92062. * @param data defines the data to store
  92063. * @param format defines the data format
  92064. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92065. * @param invertY defines if data must be stored with Y axis inverted
  92066. */
  92067. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92068. /**
  92069. * Update a raw cube texture
  92070. * @param texture defines the texture to udpdate
  92071. * @param data defines the data to store
  92072. * @param format defines the data format
  92073. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92074. * @param invertY defines if data must be stored with Y axis inverted
  92075. * @param compression defines the compression used (null by default)
  92076. */
  92077. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92078. /**
  92079. * Update a raw cube texture
  92080. * @param texture defines the texture to udpdate
  92081. * @param data defines the data to store
  92082. * @param format defines the data format
  92083. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92084. * @param invertY defines if data must be stored with Y axis inverted
  92085. * @param compression defines the compression used (null by default)
  92086. * @param level defines which level of the texture to update
  92087. */
  92088. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92089. /**
  92090. * Creates a new raw cube texture from a specified url
  92091. * @param url defines the url where the data is located
  92092. * @param scene defines the current scene
  92093. * @param size defines the size of the textures
  92094. * @param format defines the format of the data
  92095. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92096. * @param noMipmap defines if the engine should avoid generating the mip levels
  92097. * @param callback defines a callback used to extract texture data from loaded data
  92098. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92099. * @param onLoad defines a callback called when texture is loaded
  92100. * @param onError defines a callback called if there is an error
  92101. * @returns the cube texture as an InternalTexture
  92102. */
  92103. 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;
  92104. /**
  92105. * Creates a new raw cube texture from a specified url
  92106. * @param url defines the url where the data is located
  92107. * @param scene defines the current scene
  92108. * @param size defines the size of the textures
  92109. * @param format defines the format of the data
  92110. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92111. * @param noMipmap defines if the engine should avoid generating the mip levels
  92112. * @param callback defines a callback used to extract texture data from loaded data
  92113. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92114. * @param onLoad defines a callback called when texture is loaded
  92115. * @param onError defines a callback called if there is an error
  92116. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92117. * @param invertY defines if data must be stored with Y axis inverted
  92118. * @returns the cube texture as an InternalTexture
  92119. */
  92120. 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;
  92121. /**
  92122. * Creates a new raw 3D texture
  92123. * @param data defines the data used to create the texture
  92124. * @param width defines the width of the texture
  92125. * @param height defines the height of the texture
  92126. * @param depth defines the depth of the texture
  92127. * @param format defines the format of the texture
  92128. * @param generateMipMaps defines if the engine must generate mip levels
  92129. * @param invertY defines if data must be stored with Y axis inverted
  92130. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92131. * @param compression defines the compressed used (can be null)
  92132. * @param textureType defines the compressed used (can be null)
  92133. * @returns a new raw 3D texture (stored in an InternalTexture)
  92134. */
  92135. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92136. /**
  92137. * Update a raw 3D texture
  92138. * @param texture defines the texture to update
  92139. * @param data defines the data to store
  92140. * @param format defines the data format
  92141. * @param invertY defines if data must be stored with Y axis inverted
  92142. */
  92143. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92144. /**
  92145. * Update a raw 3D texture
  92146. * @param texture defines the texture to update
  92147. * @param data defines the data to store
  92148. * @param format defines the data format
  92149. * @param invertY defines if data must be stored with Y axis inverted
  92150. * @param compression defines the used compression (can be null)
  92151. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92152. */
  92153. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92154. /**
  92155. * Creates a new raw 2D array texture
  92156. * @param data defines the data used to create the texture
  92157. * @param width defines the width of the texture
  92158. * @param height defines the height of the texture
  92159. * @param depth defines the number of layers of the texture
  92160. * @param format defines the format of the texture
  92161. * @param generateMipMaps defines if the engine must generate mip levels
  92162. * @param invertY defines if data must be stored with Y axis inverted
  92163. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92164. * @param compression defines the compressed used (can be null)
  92165. * @param textureType defines the compressed used (can be null)
  92166. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92167. */
  92168. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92169. /**
  92170. * Update a raw 2D array texture
  92171. * @param texture defines the texture to update
  92172. * @param data defines the data to store
  92173. * @param format defines the data format
  92174. * @param invertY defines if data must be stored with Y axis inverted
  92175. */
  92176. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92177. /**
  92178. * Update a raw 2D array texture
  92179. * @param texture defines the texture to update
  92180. * @param data defines the data to store
  92181. * @param format defines the data format
  92182. * @param invertY defines if data must be stored with Y axis inverted
  92183. * @param compression defines the used compression (can be null)
  92184. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92185. */
  92186. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92187. }
  92188. }
  92189. declare module BABYLON {
  92190. /**
  92191. * Raw texture can help creating a texture directly from an array of data.
  92192. * This can be super useful if you either get the data from an uncompressed source or
  92193. * if you wish to create your texture pixel by pixel.
  92194. */
  92195. export class RawTexture extends Texture {
  92196. /**
  92197. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92198. */
  92199. format: number;
  92200. /**
  92201. * Instantiates a new RawTexture.
  92202. * Raw texture can help creating a texture directly from an array of data.
  92203. * This can be super useful if you either get the data from an uncompressed source or
  92204. * if you wish to create your texture pixel by pixel.
  92205. * @param data define the array of data to use to create the texture
  92206. * @param width define the width of the texture
  92207. * @param height define the height of the texture
  92208. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92209. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92210. * @param generateMipMaps define whether mip maps should be generated or not
  92211. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92212. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92213. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92214. */
  92215. constructor(data: ArrayBufferView, width: number, height: number,
  92216. /**
  92217. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92218. */
  92219. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92220. /**
  92221. * Updates the texture underlying data.
  92222. * @param data Define the new data of the texture
  92223. */
  92224. update(data: ArrayBufferView): void;
  92225. /**
  92226. * Creates a luminance texture from some data.
  92227. * @param data Define the texture data
  92228. * @param width Define the width of the texture
  92229. * @param height Define the height of the texture
  92230. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92231. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92232. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92233. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92234. * @returns the luminance texture
  92235. */
  92236. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92237. /**
  92238. * Creates a luminance alpha texture from some data.
  92239. * @param data Define the texture data
  92240. * @param width Define the width of the texture
  92241. * @param height Define the height of the texture
  92242. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92243. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92244. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92245. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92246. * @returns the luminance alpha texture
  92247. */
  92248. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92249. /**
  92250. * Creates an alpha texture from some data.
  92251. * @param data Define the texture data
  92252. * @param width Define the width of the texture
  92253. * @param height Define the height of the texture
  92254. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92255. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92256. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92257. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92258. * @returns the alpha texture
  92259. */
  92260. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92261. /**
  92262. * Creates a RGB texture from some data.
  92263. * @param data Define the texture data
  92264. * @param width Define the width of the texture
  92265. * @param height Define the height of the texture
  92266. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92270. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92271. * @returns the RGB alpha texture
  92272. */
  92273. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92274. /**
  92275. * Creates a RGBA texture from some data.
  92276. * @param data Define the texture data
  92277. * @param width Define the width of the texture
  92278. * @param height Define the height of the texture
  92279. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92280. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92283. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92284. * @returns the RGBA texture
  92285. */
  92286. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92287. /**
  92288. * Creates a R texture from some data.
  92289. * @param data Define the texture data
  92290. * @param width Define the width of the texture
  92291. * @param height Define the height of the texture
  92292. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92293. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92294. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92295. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92296. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92297. * @returns the R texture
  92298. */
  92299. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92300. }
  92301. }
  92302. declare module BABYLON {
  92303. interface ThinEngine {
  92304. /**
  92305. * Update a dynamic index buffer
  92306. * @param indexBuffer defines the target index buffer
  92307. * @param indices defines the data to update
  92308. * @param offset defines the offset in the target index buffer where update should start
  92309. */
  92310. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92311. /**
  92312. * Updates a dynamic vertex buffer.
  92313. * @param vertexBuffer the vertex buffer to update
  92314. * @param data the data used to update the vertex buffer
  92315. * @param byteOffset the byte offset of the data
  92316. * @param byteLength the byte length of the data
  92317. */
  92318. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92319. }
  92320. }
  92321. declare module BABYLON {
  92322. interface AbstractScene {
  92323. /**
  92324. * The list of procedural textures added to the scene
  92325. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92326. */
  92327. proceduralTextures: Array<ProceduralTexture>;
  92328. }
  92329. /**
  92330. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92331. * in a given scene.
  92332. */
  92333. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92334. /**
  92335. * The component name helpfull to identify the component in the list of scene components.
  92336. */
  92337. readonly name: string;
  92338. /**
  92339. * The scene the component belongs to.
  92340. */
  92341. scene: Scene;
  92342. /**
  92343. * Creates a new instance of the component for the given scene
  92344. * @param scene Defines the scene to register the component in
  92345. */
  92346. constructor(scene: Scene);
  92347. /**
  92348. * Registers the component in a given scene
  92349. */
  92350. register(): void;
  92351. /**
  92352. * Rebuilds the elements related to this component in case of
  92353. * context lost for instance.
  92354. */
  92355. rebuild(): void;
  92356. /**
  92357. * Disposes the component and the associated ressources.
  92358. */
  92359. dispose(): void;
  92360. private _beforeClear;
  92361. }
  92362. }
  92363. declare module BABYLON {
  92364. interface ThinEngine {
  92365. /**
  92366. * Creates a new render target cube texture
  92367. * @param size defines the size of the texture
  92368. * @param options defines the options used to create the texture
  92369. * @returns a new render target cube texture stored in an InternalTexture
  92370. */
  92371. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92372. }
  92373. }
  92374. declare module BABYLON {
  92375. /** @hidden */
  92376. export var proceduralVertexShader: {
  92377. name: string;
  92378. shader: string;
  92379. };
  92380. }
  92381. declare module BABYLON {
  92382. /**
  92383. * 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.
  92384. * This is the base class of any Procedural texture and contains most of the shareable code.
  92385. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92386. */
  92387. export class ProceduralTexture extends Texture {
  92388. /**
  92389. * Define if the texture is enabled or not (disabled texture will not render)
  92390. */
  92391. isEnabled: boolean;
  92392. /**
  92393. * Define if the texture must be cleared before rendering (default is true)
  92394. */
  92395. autoClear: boolean;
  92396. /**
  92397. * Callback called when the texture is generated
  92398. */
  92399. onGenerated: () => void;
  92400. /**
  92401. * Event raised when the texture is generated
  92402. */
  92403. onGeneratedObservable: Observable<ProceduralTexture>;
  92404. /**
  92405. * Event raised before the texture is generated
  92406. */
  92407. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92408. /**
  92409. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92410. */
  92411. nodeMaterialSource: Nullable<NodeMaterial>;
  92412. /** @hidden */
  92413. _generateMipMaps: boolean;
  92414. /** @hidden **/
  92415. _effect: Effect;
  92416. /** @hidden */
  92417. _textures: {
  92418. [key: string]: Texture;
  92419. };
  92420. /** @hidden */
  92421. protected _fallbackTexture: Nullable<Texture>;
  92422. private _size;
  92423. private _currentRefreshId;
  92424. private _frameId;
  92425. private _refreshRate;
  92426. private _vertexBuffers;
  92427. private _indexBuffer;
  92428. private _uniforms;
  92429. private _samplers;
  92430. private _fragment;
  92431. private _floats;
  92432. private _ints;
  92433. private _floatsArrays;
  92434. private _colors3;
  92435. private _colors4;
  92436. private _vectors2;
  92437. private _vectors3;
  92438. private _matrices;
  92439. private _fallbackTextureUsed;
  92440. private _fullEngine;
  92441. private _cachedDefines;
  92442. private _contentUpdateId;
  92443. private _contentData;
  92444. /**
  92445. * Instantiates a new procedural texture.
  92446. * 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.
  92447. * This is the base class of any Procedural texture and contains most of the shareable code.
  92448. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92449. * @param name Define the name of the texture
  92450. * @param size Define the size of the texture to create
  92451. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92452. * @param scene Define the scene the texture belongs to
  92453. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92454. * @param generateMipMaps Define if the texture should creates mip maps or not
  92455. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92456. * @param textureType The FBO internal texture type
  92457. */
  92458. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92459. /**
  92460. * The effect that is created when initializing the post process.
  92461. * @returns The created effect corresponding the the postprocess.
  92462. */
  92463. getEffect(): Effect;
  92464. /**
  92465. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92466. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92467. */
  92468. getContent(): Nullable<ArrayBufferView>;
  92469. private _createIndexBuffer;
  92470. /** @hidden */
  92471. _rebuild(): void;
  92472. /**
  92473. * Resets the texture in order to recreate its associated resources.
  92474. * This can be called in case of context loss
  92475. */
  92476. reset(): void;
  92477. protected _getDefines(): string;
  92478. /**
  92479. * Is the texture ready to be used ? (rendered at least once)
  92480. * @returns true if ready, otherwise, false.
  92481. */
  92482. isReady(): boolean;
  92483. /**
  92484. * Resets the refresh counter of the texture and start bak from scratch.
  92485. * Could be useful to regenerate the texture if it is setup to render only once.
  92486. */
  92487. resetRefreshCounter(): void;
  92488. /**
  92489. * Set the fragment shader to use in order to render the texture.
  92490. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92491. */
  92492. setFragment(fragment: any): void;
  92493. /**
  92494. * Define the refresh rate of the texture or the rendering frequency.
  92495. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92496. */
  92497. get refreshRate(): number;
  92498. set refreshRate(value: number);
  92499. /** @hidden */
  92500. _shouldRender(): boolean;
  92501. /**
  92502. * Get the size the texture is rendering at.
  92503. * @returns the size (on cube texture it is always squared)
  92504. */
  92505. getRenderSize(): RenderTargetTextureSize;
  92506. /**
  92507. * Resize the texture to new value.
  92508. * @param size Define the new size the texture should have
  92509. * @param generateMipMaps Define whether the new texture should create mip maps
  92510. */
  92511. resize(size: number, generateMipMaps: boolean): void;
  92512. private _checkUniform;
  92513. /**
  92514. * Set a texture in the shader program used to render.
  92515. * @param name Define the name of the uniform samplers as defined in the shader
  92516. * @param texture Define the texture to bind to this sampler
  92517. * @return the texture itself allowing "fluent" like uniform updates
  92518. */
  92519. setTexture(name: string, texture: Texture): ProceduralTexture;
  92520. /**
  92521. * Set a float in the shader.
  92522. * @param name Define the name of the uniform as defined in the shader
  92523. * @param value Define the value to give to the uniform
  92524. * @return the texture itself allowing "fluent" like uniform updates
  92525. */
  92526. setFloat(name: string, value: number): ProceduralTexture;
  92527. /**
  92528. * Set a int in the shader.
  92529. * @param name Define the name of the uniform as defined in the shader
  92530. * @param value Define the value to give to the uniform
  92531. * @return the texture itself allowing "fluent" like uniform updates
  92532. */
  92533. setInt(name: string, value: number): ProceduralTexture;
  92534. /**
  92535. * Set an array of floats in the shader.
  92536. * @param name Define the name of the uniform as defined in the shader
  92537. * @param value Define the value to give to the uniform
  92538. * @return the texture itself allowing "fluent" like uniform updates
  92539. */
  92540. setFloats(name: string, value: number[]): ProceduralTexture;
  92541. /**
  92542. * Set a vec3 in the shader from a Color3.
  92543. * @param name Define the name of the uniform as defined in the shader
  92544. * @param value Define the value to give to the uniform
  92545. * @return the texture itself allowing "fluent" like uniform updates
  92546. */
  92547. setColor3(name: string, value: Color3): ProceduralTexture;
  92548. /**
  92549. * Set a vec4 in the shader from a Color4.
  92550. * @param name Define the name of the uniform as defined in the shader
  92551. * @param value Define the value to give to the uniform
  92552. * @return the texture itself allowing "fluent" like uniform updates
  92553. */
  92554. setColor4(name: string, value: Color4): ProceduralTexture;
  92555. /**
  92556. * Set a vec2 in the shader from a Vector2.
  92557. * @param name Define the name of the uniform as defined in the shader
  92558. * @param value Define the value to give to the uniform
  92559. * @return the texture itself allowing "fluent" like uniform updates
  92560. */
  92561. setVector2(name: string, value: Vector2): ProceduralTexture;
  92562. /**
  92563. * Set a vec3 in the shader from a Vector3.
  92564. * @param name Define the name of the uniform as defined in the shader
  92565. * @param value Define the value to give to the uniform
  92566. * @return the texture itself allowing "fluent" like uniform updates
  92567. */
  92568. setVector3(name: string, value: Vector3): ProceduralTexture;
  92569. /**
  92570. * Set a mat4 in the shader from a MAtrix.
  92571. * @param name Define the name of the uniform as defined in the shader
  92572. * @param value Define the value to give to the uniform
  92573. * @return the texture itself allowing "fluent" like uniform updates
  92574. */
  92575. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92576. /**
  92577. * Render the texture to its associated render target.
  92578. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92579. */
  92580. render(useCameraPostProcess?: boolean): void;
  92581. /**
  92582. * Clone the texture.
  92583. * @returns the cloned texture
  92584. */
  92585. clone(): ProceduralTexture;
  92586. /**
  92587. * Dispose the texture and release its asoociated resources.
  92588. */
  92589. dispose(): void;
  92590. }
  92591. }
  92592. declare module BABYLON {
  92593. /**
  92594. * This represents the base class for particle system in Babylon.
  92595. * 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.
  92596. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92597. * @example https://doc.babylonjs.com/babylon101/particles
  92598. */
  92599. export class BaseParticleSystem {
  92600. /**
  92601. * Source color is added to the destination color without alpha affecting the result
  92602. */
  92603. static BLENDMODE_ONEONE: number;
  92604. /**
  92605. * Blend current color and particle color using particle’s alpha
  92606. */
  92607. static BLENDMODE_STANDARD: number;
  92608. /**
  92609. * Add current color and particle color multiplied by particle’s alpha
  92610. */
  92611. static BLENDMODE_ADD: number;
  92612. /**
  92613. * Multiply current color with particle color
  92614. */
  92615. static BLENDMODE_MULTIPLY: number;
  92616. /**
  92617. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92618. */
  92619. static BLENDMODE_MULTIPLYADD: number;
  92620. /**
  92621. * List of animations used by the particle system.
  92622. */
  92623. animations: Animation[];
  92624. /**
  92625. * Gets or sets the unique id of the particle system
  92626. */
  92627. uniqueId: number;
  92628. /**
  92629. * The id of the Particle system.
  92630. */
  92631. id: string;
  92632. /**
  92633. * The friendly name of the Particle system.
  92634. */
  92635. name: string;
  92636. /**
  92637. * Snippet ID if the particle system was created from the snippet server
  92638. */
  92639. snippetId: string;
  92640. /**
  92641. * The rendering group used by the Particle system to chose when to render.
  92642. */
  92643. renderingGroupId: number;
  92644. /**
  92645. * The emitter represents the Mesh or position we are attaching the particle system to.
  92646. */
  92647. emitter: Nullable<AbstractMesh | Vector3>;
  92648. /**
  92649. * The maximum number of particles to emit per frame
  92650. */
  92651. emitRate: number;
  92652. /**
  92653. * If you want to launch only a few particles at once, that can be done, as well.
  92654. */
  92655. manualEmitCount: number;
  92656. /**
  92657. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92658. */
  92659. updateSpeed: number;
  92660. /**
  92661. * The amount of time the particle system is running (depends of the overall update speed).
  92662. */
  92663. targetStopDuration: number;
  92664. /**
  92665. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92666. */
  92667. disposeOnStop: boolean;
  92668. /**
  92669. * Minimum power of emitting particles.
  92670. */
  92671. minEmitPower: number;
  92672. /**
  92673. * Maximum power of emitting particles.
  92674. */
  92675. maxEmitPower: number;
  92676. /**
  92677. * Minimum life time of emitting particles.
  92678. */
  92679. minLifeTime: number;
  92680. /**
  92681. * Maximum life time of emitting particles.
  92682. */
  92683. maxLifeTime: number;
  92684. /**
  92685. * Minimum Size of emitting particles.
  92686. */
  92687. minSize: number;
  92688. /**
  92689. * Maximum Size of emitting particles.
  92690. */
  92691. maxSize: number;
  92692. /**
  92693. * Minimum scale of emitting particles on X axis.
  92694. */
  92695. minScaleX: number;
  92696. /**
  92697. * Maximum scale of emitting particles on X axis.
  92698. */
  92699. maxScaleX: number;
  92700. /**
  92701. * Minimum scale of emitting particles on Y axis.
  92702. */
  92703. minScaleY: number;
  92704. /**
  92705. * Maximum scale of emitting particles on Y axis.
  92706. */
  92707. maxScaleY: number;
  92708. /**
  92709. * Gets or sets the minimal initial rotation in radians.
  92710. */
  92711. minInitialRotation: number;
  92712. /**
  92713. * Gets or sets the maximal initial rotation in radians.
  92714. */
  92715. maxInitialRotation: number;
  92716. /**
  92717. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92718. */
  92719. minAngularSpeed: number;
  92720. /**
  92721. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92722. */
  92723. maxAngularSpeed: number;
  92724. /**
  92725. * The texture used to render each particle. (this can be a spritesheet)
  92726. */
  92727. particleTexture: Nullable<BaseTexture>;
  92728. /**
  92729. * The layer mask we are rendering the particles through.
  92730. */
  92731. layerMask: number;
  92732. /**
  92733. * This can help using your own shader to render the particle system.
  92734. * The according effect will be created
  92735. */
  92736. customShader: any;
  92737. /**
  92738. * By default particle system starts as soon as they are created. This prevents the
  92739. * automatic start to happen and let you decide when to start emitting particles.
  92740. */
  92741. preventAutoStart: boolean;
  92742. private _noiseTexture;
  92743. /**
  92744. * Gets or sets a texture used to add random noise to particle positions
  92745. */
  92746. get noiseTexture(): Nullable<ProceduralTexture>;
  92747. set noiseTexture(value: Nullable<ProceduralTexture>);
  92748. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92749. noiseStrength: Vector3;
  92750. /**
  92751. * Callback triggered when the particle animation is ending.
  92752. */
  92753. onAnimationEnd: Nullable<() => void>;
  92754. /**
  92755. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92756. */
  92757. blendMode: number;
  92758. /**
  92759. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92760. * to override the particles.
  92761. */
  92762. forceDepthWrite: boolean;
  92763. /** 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 */
  92764. preWarmCycles: number;
  92765. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92766. preWarmStepOffset: number;
  92767. /**
  92768. * 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)
  92769. */
  92770. spriteCellChangeSpeed: number;
  92771. /**
  92772. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92773. */
  92774. startSpriteCellID: number;
  92775. /**
  92776. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92777. */
  92778. endSpriteCellID: number;
  92779. /**
  92780. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92781. */
  92782. spriteCellWidth: number;
  92783. /**
  92784. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92785. */
  92786. spriteCellHeight: number;
  92787. /**
  92788. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92789. */
  92790. spriteRandomStartCell: boolean;
  92791. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92792. translationPivot: Vector2;
  92793. /** @hidden */
  92794. protected _isAnimationSheetEnabled: boolean;
  92795. /**
  92796. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92797. */
  92798. beginAnimationOnStart: boolean;
  92799. /**
  92800. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92801. */
  92802. beginAnimationFrom: number;
  92803. /**
  92804. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92805. */
  92806. beginAnimationTo: number;
  92807. /**
  92808. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92809. */
  92810. beginAnimationLoop: boolean;
  92811. /**
  92812. * Gets or sets a world offset applied to all particles
  92813. */
  92814. worldOffset: Vector3;
  92815. /**
  92816. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92817. */
  92818. get isAnimationSheetEnabled(): boolean;
  92819. set isAnimationSheetEnabled(value: boolean);
  92820. /**
  92821. * Get hosting scene
  92822. * @returns the scene
  92823. */
  92824. getScene(): Nullable<Scene>;
  92825. /**
  92826. * You can use gravity if you want to give an orientation to your particles.
  92827. */
  92828. gravity: Vector3;
  92829. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92830. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92831. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92832. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92833. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92834. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92835. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92836. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92837. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92838. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92839. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92840. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92841. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92842. /**
  92843. * Defines the delay in milliseconds before starting the system (0 by default)
  92844. */
  92845. startDelay: number;
  92846. /**
  92847. * Gets the current list of drag gradients.
  92848. * You must use addDragGradient and removeDragGradient to udpate this list
  92849. * @returns the list of drag gradients
  92850. */
  92851. getDragGradients(): Nullable<Array<FactorGradient>>;
  92852. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92853. limitVelocityDamping: number;
  92854. /**
  92855. * Gets the current list of limit velocity gradients.
  92856. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92857. * @returns the list of limit velocity gradients
  92858. */
  92859. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92860. /**
  92861. * Gets the current list of color gradients.
  92862. * You must use addColorGradient and removeColorGradient to udpate this list
  92863. * @returns the list of color gradients
  92864. */
  92865. getColorGradients(): Nullable<Array<ColorGradient>>;
  92866. /**
  92867. * Gets the current list of size gradients.
  92868. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92869. * @returns the list of size gradients
  92870. */
  92871. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92872. /**
  92873. * Gets the current list of color remap gradients.
  92874. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92875. * @returns the list of color remap gradients
  92876. */
  92877. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92878. /**
  92879. * Gets the current list of alpha remap gradients.
  92880. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92881. * @returns the list of alpha remap gradients
  92882. */
  92883. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92884. /**
  92885. * Gets the current list of life time gradients.
  92886. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92887. * @returns the list of life time gradients
  92888. */
  92889. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92890. /**
  92891. * Gets the current list of angular speed gradients.
  92892. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92893. * @returns the list of angular speed gradients
  92894. */
  92895. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92896. /**
  92897. * Gets the current list of velocity gradients.
  92898. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92899. * @returns the list of velocity gradients
  92900. */
  92901. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92902. /**
  92903. * Gets the current list of start size gradients.
  92904. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92905. * @returns the list of start size gradients
  92906. */
  92907. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92908. /**
  92909. * Gets the current list of emit rate gradients.
  92910. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92911. * @returns the list of emit rate gradients
  92912. */
  92913. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92914. /**
  92915. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92916. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92917. */
  92918. get direction1(): Vector3;
  92919. set direction1(value: Vector3);
  92920. /**
  92921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92923. */
  92924. get direction2(): Vector3;
  92925. set direction2(value: Vector3);
  92926. /**
  92927. * 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.
  92928. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92929. */
  92930. get minEmitBox(): Vector3;
  92931. set minEmitBox(value: Vector3);
  92932. /**
  92933. * 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.
  92934. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92935. */
  92936. get maxEmitBox(): Vector3;
  92937. set maxEmitBox(value: Vector3);
  92938. /**
  92939. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92940. */
  92941. color1: Color4;
  92942. /**
  92943. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92944. */
  92945. color2: Color4;
  92946. /**
  92947. * Color the particle will have at the end of its lifetime
  92948. */
  92949. colorDead: Color4;
  92950. /**
  92951. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92952. */
  92953. textureMask: Color4;
  92954. /**
  92955. * The particle emitter type defines the emitter used by the particle system.
  92956. * It can be for example box, sphere, or cone...
  92957. */
  92958. particleEmitterType: IParticleEmitterType;
  92959. /** @hidden */
  92960. _isSubEmitter: boolean;
  92961. /**
  92962. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92963. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92964. */
  92965. billboardMode: number;
  92966. protected _isBillboardBased: boolean;
  92967. /**
  92968. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92969. */
  92970. get isBillboardBased(): boolean;
  92971. set isBillboardBased(value: boolean);
  92972. /**
  92973. * The scene the particle system belongs to.
  92974. */
  92975. protected _scene: Nullable<Scene>;
  92976. /**
  92977. * The engine the particle system belongs to.
  92978. */
  92979. protected _engine: ThinEngine;
  92980. /**
  92981. * Local cache of defines for image processing.
  92982. */
  92983. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92984. /**
  92985. * Default configuration related to image processing available in the standard Material.
  92986. */
  92987. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92988. /**
  92989. * Gets the image processing configuration used either in this material.
  92990. */
  92991. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92992. /**
  92993. * Sets the Default image processing configuration used either in the this material.
  92994. *
  92995. * If sets to null, the scene one is in use.
  92996. */
  92997. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92998. /**
  92999. * Attaches a new image processing configuration to the Standard Material.
  93000. * @param configuration
  93001. */
  93002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93003. /** @hidden */
  93004. protected _reset(): void;
  93005. /** @hidden */
  93006. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93007. /**
  93008. * Instantiates a particle system.
  93009. * 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.
  93010. * @param name The name of the particle system
  93011. */
  93012. constructor(name: string);
  93013. /**
  93014. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93017. * @returns the emitter
  93018. */
  93019. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93020. /**
  93021. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93022. * @param radius The radius of the hemisphere to emit from
  93023. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93024. * @returns the emitter
  93025. */
  93026. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93027. /**
  93028. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93029. * @param radius The radius of the sphere to emit from
  93030. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93031. * @returns the emitter
  93032. */
  93033. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93034. /**
  93035. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93036. * @param radius The radius of the sphere to emit from
  93037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93039. * @returns the emitter
  93040. */
  93041. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93042. /**
  93043. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93044. * @param radius The radius of the emission cylinder
  93045. * @param height The height of the emission cylinder
  93046. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93047. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93048. * @returns the emitter
  93049. */
  93050. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93051. /**
  93052. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93053. * @param radius The radius of the cylinder to emit from
  93054. * @param height The height of the emission cylinder
  93055. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93058. * @returns the emitter
  93059. */
  93060. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93061. /**
  93062. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93063. * @param radius The radius of the cone to emit from
  93064. * @param angle The base angle of the cone
  93065. * @returns the emitter
  93066. */
  93067. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93068. /**
  93069. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93072. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93073. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93074. * @returns the emitter
  93075. */
  93076. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93077. }
  93078. }
  93079. declare module BABYLON {
  93080. /**
  93081. * Type of sub emitter
  93082. */
  93083. export enum SubEmitterType {
  93084. /**
  93085. * Attached to the particle over it's lifetime
  93086. */
  93087. ATTACHED = 0,
  93088. /**
  93089. * Created when the particle dies
  93090. */
  93091. END = 1
  93092. }
  93093. /**
  93094. * Sub emitter class used to emit particles from an existing particle
  93095. */
  93096. export class SubEmitter {
  93097. /**
  93098. * the particle system to be used by the sub emitter
  93099. */
  93100. particleSystem: ParticleSystem;
  93101. /**
  93102. * Type of the submitter (Default: END)
  93103. */
  93104. type: SubEmitterType;
  93105. /**
  93106. * 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)
  93107. * Note: This only is supported when using an emitter of type Mesh
  93108. */
  93109. inheritDirection: boolean;
  93110. /**
  93111. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93112. */
  93113. inheritedVelocityAmount: number;
  93114. /**
  93115. * Creates a sub emitter
  93116. * @param particleSystem the particle system to be used by the sub emitter
  93117. */
  93118. constructor(
  93119. /**
  93120. * the particle system to be used by the sub emitter
  93121. */
  93122. particleSystem: ParticleSystem);
  93123. /**
  93124. * Clones the sub emitter
  93125. * @returns the cloned sub emitter
  93126. */
  93127. clone(): SubEmitter;
  93128. /**
  93129. * Serialize current object to a JSON object
  93130. * @returns the serialized object
  93131. */
  93132. serialize(): any;
  93133. /** @hidden */
  93134. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93135. /**
  93136. * Creates a new SubEmitter from a serialized JSON version
  93137. * @param serializationObject defines the JSON object to read from
  93138. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93139. * @param rootUrl defines the rootUrl for data loading
  93140. * @returns a new SubEmitter
  93141. */
  93142. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93143. /** Release associated resources */
  93144. dispose(): void;
  93145. }
  93146. }
  93147. declare module BABYLON {
  93148. /** @hidden */
  93149. export var imageProcessingDeclaration: {
  93150. name: string;
  93151. shader: string;
  93152. };
  93153. }
  93154. declare module BABYLON {
  93155. /** @hidden */
  93156. export var imageProcessingFunctions: {
  93157. name: string;
  93158. shader: string;
  93159. };
  93160. }
  93161. declare module BABYLON {
  93162. /** @hidden */
  93163. export var particlesPixelShader: {
  93164. name: string;
  93165. shader: string;
  93166. };
  93167. }
  93168. declare module BABYLON {
  93169. /** @hidden */
  93170. export var particlesVertexShader: {
  93171. name: string;
  93172. shader: string;
  93173. };
  93174. }
  93175. declare module BABYLON {
  93176. /**
  93177. * Interface used to define entities containing multiple clip planes
  93178. */
  93179. export interface IClipPlanesHolder {
  93180. /**
  93181. * Gets or sets the active clipplane 1
  93182. */
  93183. clipPlane: Nullable<Plane>;
  93184. /**
  93185. * Gets or sets the active clipplane 2
  93186. */
  93187. clipPlane2: Nullable<Plane>;
  93188. /**
  93189. * Gets or sets the active clipplane 3
  93190. */
  93191. clipPlane3: Nullable<Plane>;
  93192. /**
  93193. * Gets or sets the active clipplane 4
  93194. */
  93195. clipPlane4: Nullable<Plane>;
  93196. /**
  93197. * Gets or sets the active clipplane 5
  93198. */
  93199. clipPlane5: Nullable<Plane>;
  93200. /**
  93201. * Gets or sets the active clipplane 6
  93202. */
  93203. clipPlane6: Nullable<Plane>;
  93204. }
  93205. }
  93206. declare module BABYLON {
  93207. /**
  93208. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93209. *
  93210. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93211. *
  93212. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93213. */
  93214. export class ThinMaterialHelper {
  93215. /**
  93216. * Binds the clip plane information from the holder to the effect.
  93217. * @param effect The effect we are binding the data to
  93218. * @param holder The entity containing the clip plane information
  93219. */
  93220. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93221. }
  93222. }
  93223. declare module BABYLON {
  93224. interface ThinEngine {
  93225. /**
  93226. * Sets alpha constants used by some alpha blending modes
  93227. * @param r defines the red component
  93228. * @param g defines the green component
  93229. * @param b defines the blue component
  93230. * @param a defines the alpha component
  93231. */
  93232. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93233. /**
  93234. * Sets the current alpha mode
  93235. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93236. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93237. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93238. */
  93239. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93240. /**
  93241. * Gets the current alpha mode
  93242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93243. * @returns the current alpha mode
  93244. */
  93245. getAlphaMode(): number;
  93246. /**
  93247. * Sets the current alpha equation
  93248. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93249. */
  93250. setAlphaEquation(equation: number): void;
  93251. /**
  93252. * Gets the current alpha equation.
  93253. * @returns the current alpha equation
  93254. */
  93255. getAlphaEquation(): number;
  93256. }
  93257. }
  93258. declare module BABYLON {
  93259. /**
  93260. * This represents a particle system in Babylon.
  93261. * 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.
  93262. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93263. * @example https://doc.babylonjs.com/babylon101/particles
  93264. */
  93265. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93266. /**
  93267. * Billboard mode will only apply to Y axis
  93268. */
  93269. static readonly BILLBOARDMODE_Y: number;
  93270. /**
  93271. * Billboard mode will apply to all axes
  93272. */
  93273. static readonly BILLBOARDMODE_ALL: number;
  93274. /**
  93275. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93276. */
  93277. static readonly BILLBOARDMODE_STRETCHED: number;
  93278. /**
  93279. * This function can be defined to provide custom update for active particles.
  93280. * This function will be called instead of regular update (age, position, color, etc.).
  93281. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93282. */
  93283. updateFunction: (particles: Particle[]) => void;
  93284. private _emitterWorldMatrix;
  93285. /**
  93286. * This function can be defined to specify initial direction for every new particle.
  93287. * It by default use the emitterType defined function
  93288. */
  93289. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93290. /**
  93291. * This function can be defined to specify initial position for every new particle.
  93292. * It by default use the emitterType defined function
  93293. */
  93294. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93295. /**
  93296. * @hidden
  93297. */
  93298. _inheritedVelocityOffset: Vector3;
  93299. /**
  93300. * An event triggered when the system is disposed
  93301. */
  93302. onDisposeObservable: Observable<IParticleSystem>;
  93303. /**
  93304. * An event triggered when the system is stopped
  93305. */
  93306. onStoppedObservable: Observable<IParticleSystem>;
  93307. private _onDisposeObserver;
  93308. /**
  93309. * Sets a callback that will be triggered when the system is disposed
  93310. */
  93311. set onDispose(callback: () => void);
  93312. private _particles;
  93313. private _epsilon;
  93314. private _capacity;
  93315. private _stockParticles;
  93316. private _newPartsExcess;
  93317. private _vertexData;
  93318. private _vertexBuffer;
  93319. private _vertexBuffers;
  93320. private _spriteBuffer;
  93321. private _indexBuffer;
  93322. private _effect;
  93323. private _customEffect;
  93324. private _cachedDefines;
  93325. private _scaledColorStep;
  93326. private _colorDiff;
  93327. private _scaledDirection;
  93328. private _scaledGravity;
  93329. private _currentRenderId;
  93330. private _alive;
  93331. private _useInstancing;
  93332. private _started;
  93333. private _stopped;
  93334. private _actualFrame;
  93335. private _scaledUpdateSpeed;
  93336. private _vertexBufferSize;
  93337. /** @hidden */
  93338. _currentEmitRateGradient: Nullable<FactorGradient>;
  93339. /** @hidden */
  93340. _currentEmitRate1: number;
  93341. /** @hidden */
  93342. _currentEmitRate2: number;
  93343. /** @hidden */
  93344. _currentStartSizeGradient: Nullable<FactorGradient>;
  93345. /** @hidden */
  93346. _currentStartSize1: number;
  93347. /** @hidden */
  93348. _currentStartSize2: number;
  93349. private readonly _rawTextureWidth;
  93350. private _rampGradientsTexture;
  93351. private _useRampGradients;
  93352. /** Gets or sets a matrix to use to compute projection */
  93353. defaultProjectionMatrix: Matrix;
  93354. /** Gets or sets a matrix to use to compute view */
  93355. defaultViewMatrix: Matrix;
  93356. /** Gets or sets a boolean indicating that ramp gradients must be used
  93357. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93358. */
  93359. get useRampGradients(): boolean;
  93360. set useRampGradients(value: boolean);
  93361. /**
  93362. * 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.
  93363. * 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: [])
  93364. */
  93365. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93366. private _subEmitters;
  93367. /**
  93368. * @hidden
  93369. * If the particle systems emitter should be disposed when the particle system is disposed
  93370. */
  93371. _disposeEmitterOnDispose: boolean;
  93372. /**
  93373. * The current active Sub-systems, this property is used by the root particle system only.
  93374. */
  93375. activeSubSystems: Array<ParticleSystem>;
  93376. /**
  93377. * Specifies if the particles are updated in emitter local space or world space
  93378. */
  93379. isLocal: boolean;
  93380. private _rootParticleSystem;
  93381. /**
  93382. * Gets the current list of active particles
  93383. */
  93384. get particles(): Particle[];
  93385. /**
  93386. * Gets the number of particles active at the same time.
  93387. * @returns The number of active particles.
  93388. */
  93389. getActiveCount(): number;
  93390. /**
  93391. * Returns the string "ParticleSystem"
  93392. * @returns a string containing the class name
  93393. */
  93394. getClassName(): string;
  93395. /**
  93396. * Gets a boolean indicating that the system is stopping
  93397. * @returns true if the system is currently stopping
  93398. */
  93399. isStopping(): boolean;
  93400. /**
  93401. * Gets the custom effect used to render the particles
  93402. * @param blendMode Blend mode for which the effect should be retrieved
  93403. * @returns The effect
  93404. */
  93405. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93406. /**
  93407. * Sets the custom effect used to render the particles
  93408. * @param effect The effect to set
  93409. * @param blendMode Blend mode for which the effect should be set
  93410. */
  93411. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93412. /** @hidden */
  93413. private _onBeforeDrawParticlesObservable;
  93414. /**
  93415. * Observable that will be called just before the particles are drawn
  93416. */
  93417. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93418. /**
  93419. * Gets the name of the particle vertex shader
  93420. */
  93421. get vertexShaderName(): string;
  93422. /**
  93423. * Instantiates a particle system.
  93424. * 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.
  93425. * @param name The name of the particle system
  93426. * @param capacity The max number of particles alive at the same time
  93427. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93428. * @param customEffect a custom effect used to change the way particles are rendered by default
  93429. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93430. * @param epsilon Offset used to render the particles
  93431. */
  93432. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93433. private _addFactorGradient;
  93434. private _removeFactorGradient;
  93435. /**
  93436. * Adds a new life time gradient
  93437. * @param gradient defines the gradient to use (between 0 and 1)
  93438. * @param factor defines the life time factor to affect to the specified gradient
  93439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93440. * @returns the current particle system
  93441. */
  93442. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93443. /**
  93444. * Remove a specific life time gradient
  93445. * @param gradient defines the gradient to remove
  93446. * @returns the current particle system
  93447. */
  93448. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93449. /**
  93450. * Adds a new size gradient
  93451. * @param gradient defines the gradient to use (between 0 and 1)
  93452. * @param factor defines the size factor to affect to the specified gradient
  93453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93454. * @returns the current particle system
  93455. */
  93456. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93457. /**
  93458. * Remove a specific size gradient
  93459. * @param gradient defines the gradient to remove
  93460. * @returns the current particle system
  93461. */
  93462. removeSizeGradient(gradient: number): IParticleSystem;
  93463. /**
  93464. * Adds a new color remap gradient
  93465. * @param gradient defines the gradient to use (between 0 and 1)
  93466. * @param min defines the color remap minimal range
  93467. * @param max defines the color remap maximal range
  93468. * @returns the current particle system
  93469. */
  93470. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93471. /**
  93472. * Remove a specific color remap gradient
  93473. * @param gradient defines the gradient to remove
  93474. * @returns the current particle system
  93475. */
  93476. removeColorRemapGradient(gradient: number): IParticleSystem;
  93477. /**
  93478. * Adds a new alpha remap gradient
  93479. * @param gradient defines the gradient to use (between 0 and 1)
  93480. * @param min defines the alpha remap minimal range
  93481. * @param max defines the alpha remap maximal range
  93482. * @returns the current particle system
  93483. */
  93484. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93485. /**
  93486. * Remove a specific alpha remap gradient
  93487. * @param gradient defines the gradient to remove
  93488. * @returns the current particle system
  93489. */
  93490. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93491. /**
  93492. * Adds a new angular speed gradient
  93493. * @param gradient defines the gradient to use (between 0 and 1)
  93494. * @param factor defines the angular speed to affect to the specified gradient
  93495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93496. * @returns the current particle system
  93497. */
  93498. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93499. /**
  93500. * Remove a specific angular speed gradient
  93501. * @param gradient defines the gradient to remove
  93502. * @returns the current particle system
  93503. */
  93504. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93505. /**
  93506. * Adds a new velocity gradient
  93507. * @param gradient defines the gradient to use (between 0 and 1)
  93508. * @param factor defines the velocity to affect to the specified gradient
  93509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93510. * @returns the current particle system
  93511. */
  93512. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93513. /**
  93514. * Remove a specific velocity gradient
  93515. * @param gradient defines the gradient to remove
  93516. * @returns the current particle system
  93517. */
  93518. removeVelocityGradient(gradient: number): IParticleSystem;
  93519. /**
  93520. * Adds a new limit velocity gradient
  93521. * @param gradient defines the gradient to use (between 0 and 1)
  93522. * @param factor defines the limit velocity value to affect to the specified gradient
  93523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93524. * @returns the current particle system
  93525. */
  93526. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93527. /**
  93528. * Remove a specific limit velocity gradient
  93529. * @param gradient defines the gradient to remove
  93530. * @returns the current particle system
  93531. */
  93532. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93533. /**
  93534. * Adds a new drag gradient
  93535. * @param gradient defines the gradient to use (between 0 and 1)
  93536. * @param factor defines the drag value to affect to the specified gradient
  93537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93538. * @returns the current particle system
  93539. */
  93540. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93541. /**
  93542. * Remove a specific drag gradient
  93543. * @param gradient defines the gradient to remove
  93544. * @returns the current particle system
  93545. */
  93546. removeDragGradient(gradient: number): IParticleSystem;
  93547. /**
  93548. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93549. * @param gradient defines the gradient to use (between 0 and 1)
  93550. * @param factor defines the emit rate value to affect to the specified gradient
  93551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93552. * @returns the current particle system
  93553. */
  93554. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93555. /**
  93556. * Remove a specific emit rate gradient
  93557. * @param gradient defines the gradient to remove
  93558. * @returns the current particle system
  93559. */
  93560. removeEmitRateGradient(gradient: number): IParticleSystem;
  93561. /**
  93562. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93563. * @param gradient defines the gradient to use (between 0 and 1)
  93564. * @param factor defines the start size value to affect to the specified gradient
  93565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93566. * @returns the current particle system
  93567. */
  93568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93569. /**
  93570. * Remove a specific start size gradient
  93571. * @param gradient defines the gradient to remove
  93572. * @returns the current particle system
  93573. */
  93574. removeStartSizeGradient(gradient: number): IParticleSystem;
  93575. private _createRampGradientTexture;
  93576. /**
  93577. * Gets the current list of ramp gradients.
  93578. * You must use addRampGradient and removeRampGradient to udpate this list
  93579. * @returns the list of ramp gradients
  93580. */
  93581. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93582. /** Force the system to rebuild all gradients that need to be resync */
  93583. forceRefreshGradients(): void;
  93584. private _syncRampGradientTexture;
  93585. /**
  93586. * Adds a new ramp gradient used to remap particle colors
  93587. * @param gradient defines the gradient to use (between 0 and 1)
  93588. * @param color defines the color to affect to the specified gradient
  93589. * @returns the current particle system
  93590. */
  93591. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93592. /**
  93593. * Remove a specific ramp gradient
  93594. * @param gradient defines the gradient to remove
  93595. * @returns the current particle system
  93596. */
  93597. removeRampGradient(gradient: number): ParticleSystem;
  93598. /**
  93599. * Adds a new color gradient
  93600. * @param gradient defines the gradient to use (between 0 and 1)
  93601. * @param color1 defines the color to affect to the specified gradient
  93602. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93603. * @returns this particle system
  93604. */
  93605. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93606. /**
  93607. * Remove a specific color gradient
  93608. * @param gradient defines the gradient to remove
  93609. * @returns this particle system
  93610. */
  93611. removeColorGradient(gradient: number): IParticleSystem;
  93612. private _fetchR;
  93613. protected _reset(): void;
  93614. private _resetEffect;
  93615. private _createVertexBuffers;
  93616. private _createIndexBuffer;
  93617. /**
  93618. * Gets the maximum number of particles active at the same time.
  93619. * @returns The max number of active particles.
  93620. */
  93621. getCapacity(): number;
  93622. /**
  93623. * Gets whether there are still active particles in the system.
  93624. * @returns True if it is alive, otherwise false.
  93625. */
  93626. isAlive(): boolean;
  93627. /**
  93628. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93629. * @returns True if it has been started, otherwise false.
  93630. */
  93631. isStarted(): boolean;
  93632. private _prepareSubEmitterInternalArray;
  93633. /**
  93634. * Starts the particle system and begins to emit
  93635. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93636. */
  93637. start(delay?: number): void;
  93638. /**
  93639. * Stops the particle system.
  93640. * @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.
  93641. */
  93642. stop(stopSubEmitters?: boolean): void;
  93643. /**
  93644. * Remove all active particles
  93645. */
  93646. reset(): void;
  93647. /**
  93648. * @hidden (for internal use only)
  93649. */
  93650. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93651. /**
  93652. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93653. * Its lifetime will start back at 0.
  93654. */
  93655. recycleParticle: (particle: Particle) => void;
  93656. private _stopSubEmitters;
  93657. private _createParticle;
  93658. private _removeFromRoot;
  93659. private _emitFromParticle;
  93660. private _update;
  93661. /** @hidden */
  93662. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93663. /** @hidden */
  93664. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93665. /**
  93666. * Fill the defines array according to the current settings of the particle system
  93667. * @param defines Array to be updated
  93668. * @param blendMode blend mode to take into account when updating the array
  93669. */
  93670. fillDefines(defines: Array<string>, blendMode: number): void;
  93671. /**
  93672. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93673. * @param uniforms Uniforms array to fill
  93674. * @param attributes Attributes array to fill
  93675. * @param samplers Samplers array to fill
  93676. */
  93677. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93678. /** @hidden */
  93679. private _getEffect;
  93680. /**
  93681. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93682. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93683. */
  93684. animate(preWarmOnly?: boolean): void;
  93685. private _appendParticleVertices;
  93686. /**
  93687. * Rebuilds the particle system.
  93688. */
  93689. rebuild(): void;
  93690. /**
  93691. * Is this system ready to be used/rendered
  93692. * @return true if the system is ready
  93693. */
  93694. isReady(): boolean;
  93695. private _render;
  93696. /**
  93697. * Renders the particle system in its current state.
  93698. * @returns the current number of particles
  93699. */
  93700. render(): number;
  93701. /**
  93702. * Disposes the particle system and free the associated resources
  93703. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93704. */
  93705. dispose(disposeTexture?: boolean): void;
  93706. /**
  93707. * Clones the particle system.
  93708. * @param name The name of the cloned object
  93709. * @param newEmitter The new emitter to use
  93710. * @returns the cloned particle system
  93711. */
  93712. clone(name: string, newEmitter: any): ParticleSystem;
  93713. /**
  93714. * Serializes the particle system to a JSON object
  93715. * @param serializeTexture defines if the texture must be serialized as well
  93716. * @returns the JSON object
  93717. */
  93718. serialize(serializeTexture?: boolean): any;
  93719. /** @hidden */
  93720. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93721. /** @hidden */
  93722. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93723. /**
  93724. * Parses a JSON object to create a particle system.
  93725. * @param parsedParticleSystem The JSON object to parse
  93726. * @param sceneOrEngine The scene or the engine to create the particle system in
  93727. * @param rootUrl The root url to use to load external dependencies like texture
  93728. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93729. * @returns the Parsed particle system
  93730. */
  93731. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93732. }
  93733. }
  93734. declare module BABYLON {
  93735. /**
  93736. * A particle represents one of the element emitted by a particle system.
  93737. * This is mainly define by its coordinates, direction, velocity and age.
  93738. */
  93739. export class Particle {
  93740. /**
  93741. * The particle system the particle belongs to.
  93742. */
  93743. particleSystem: ParticleSystem;
  93744. private static _Count;
  93745. /**
  93746. * Unique ID of the particle
  93747. */
  93748. id: number;
  93749. /**
  93750. * The world position of the particle in the scene.
  93751. */
  93752. position: Vector3;
  93753. /**
  93754. * The world direction of the particle in the scene.
  93755. */
  93756. direction: Vector3;
  93757. /**
  93758. * The color of the particle.
  93759. */
  93760. color: Color4;
  93761. /**
  93762. * The color change of the particle per step.
  93763. */
  93764. colorStep: Color4;
  93765. /**
  93766. * Defines how long will the life of the particle be.
  93767. */
  93768. lifeTime: number;
  93769. /**
  93770. * The current age of the particle.
  93771. */
  93772. age: number;
  93773. /**
  93774. * The current size of the particle.
  93775. */
  93776. size: number;
  93777. /**
  93778. * The current scale of the particle.
  93779. */
  93780. scale: Vector2;
  93781. /**
  93782. * The current angle of the particle.
  93783. */
  93784. angle: number;
  93785. /**
  93786. * Defines how fast is the angle changing.
  93787. */
  93788. angularSpeed: number;
  93789. /**
  93790. * Defines the cell index used by the particle to be rendered from a sprite.
  93791. */
  93792. cellIndex: number;
  93793. /**
  93794. * The information required to support color remapping
  93795. */
  93796. remapData: Vector4;
  93797. /** @hidden */
  93798. _randomCellOffset?: number;
  93799. /** @hidden */
  93800. _initialDirection: Nullable<Vector3>;
  93801. /** @hidden */
  93802. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93803. /** @hidden */
  93804. _initialStartSpriteCellID: number;
  93805. /** @hidden */
  93806. _initialEndSpriteCellID: number;
  93807. /** @hidden */
  93808. _currentColorGradient: Nullable<ColorGradient>;
  93809. /** @hidden */
  93810. _currentColor1: Color4;
  93811. /** @hidden */
  93812. _currentColor2: Color4;
  93813. /** @hidden */
  93814. _currentSizeGradient: Nullable<FactorGradient>;
  93815. /** @hidden */
  93816. _currentSize1: number;
  93817. /** @hidden */
  93818. _currentSize2: number;
  93819. /** @hidden */
  93820. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93821. /** @hidden */
  93822. _currentAngularSpeed1: number;
  93823. /** @hidden */
  93824. _currentAngularSpeed2: number;
  93825. /** @hidden */
  93826. _currentVelocityGradient: Nullable<FactorGradient>;
  93827. /** @hidden */
  93828. _currentVelocity1: number;
  93829. /** @hidden */
  93830. _currentVelocity2: number;
  93831. /** @hidden */
  93832. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93833. /** @hidden */
  93834. _currentLimitVelocity1: number;
  93835. /** @hidden */
  93836. _currentLimitVelocity2: number;
  93837. /** @hidden */
  93838. _currentDragGradient: Nullable<FactorGradient>;
  93839. /** @hidden */
  93840. _currentDrag1: number;
  93841. /** @hidden */
  93842. _currentDrag2: number;
  93843. /** @hidden */
  93844. _randomNoiseCoordinates1: Vector3;
  93845. /** @hidden */
  93846. _randomNoiseCoordinates2: Vector3;
  93847. /** @hidden */
  93848. _localPosition?: Vector3;
  93849. /**
  93850. * Creates a new instance Particle
  93851. * @param particleSystem the particle system the particle belongs to
  93852. */
  93853. constructor(
  93854. /**
  93855. * The particle system the particle belongs to.
  93856. */
  93857. particleSystem: ParticleSystem);
  93858. private updateCellInfoFromSystem;
  93859. /**
  93860. * Defines how the sprite cell index is updated for the particle
  93861. */
  93862. updateCellIndex(): void;
  93863. /** @hidden */
  93864. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93865. /** @hidden */
  93866. _inheritParticleInfoToSubEmitters(): void;
  93867. /** @hidden */
  93868. _reset(): void;
  93869. /**
  93870. * Copy the properties of particle to another one.
  93871. * @param other the particle to copy the information to.
  93872. */
  93873. copyTo(other: Particle): void;
  93874. }
  93875. }
  93876. declare module BABYLON {
  93877. /**
  93878. * Particle emitter represents a volume emitting particles.
  93879. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93880. */
  93881. export interface IParticleEmitterType {
  93882. /**
  93883. * Called by the particle System when the direction is computed for the created particle.
  93884. * @param worldMatrix is the world matrix of the particle system
  93885. * @param directionToUpdate is the direction vector to update with the result
  93886. * @param particle is the particle we are computed the direction for
  93887. * @param isLocal defines if the direction should be set in local space
  93888. */
  93889. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93890. /**
  93891. * Called by the particle System when the position is computed for the created particle.
  93892. * @param worldMatrix is the world matrix of the particle system
  93893. * @param positionToUpdate is the position vector to update with the result
  93894. * @param particle is the particle we are computed the position for
  93895. * @param isLocal defines if the position should be set in local space
  93896. */
  93897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93898. /**
  93899. * Clones the current emitter and returns a copy of it
  93900. * @returns the new emitter
  93901. */
  93902. clone(): IParticleEmitterType;
  93903. /**
  93904. * Called by the GPUParticleSystem to setup the update shader
  93905. * @param effect defines the update shader
  93906. */
  93907. applyToShader(effect: Effect): void;
  93908. /**
  93909. * Returns a string to use to update the GPU particles update shader
  93910. * @returns the effect defines string
  93911. */
  93912. getEffectDefines(): string;
  93913. /**
  93914. * Returns a string representing the class name
  93915. * @returns a string containing the class name
  93916. */
  93917. getClassName(): string;
  93918. /**
  93919. * Serializes the particle system to a JSON object.
  93920. * @returns the JSON object
  93921. */
  93922. serialize(): any;
  93923. /**
  93924. * Parse properties from a JSON object
  93925. * @param serializationObject defines the JSON object
  93926. * @param scene defines the hosting scene
  93927. */
  93928. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93929. }
  93930. }
  93931. declare module BABYLON {
  93932. /**
  93933. * Particle emitter emitting particles from the inside of a box.
  93934. * It emits the particles randomly between 2 given directions.
  93935. */
  93936. export class BoxParticleEmitter implements IParticleEmitterType {
  93937. /**
  93938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93939. */
  93940. direction1: Vector3;
  93941. /**
  93942. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93943. */
  93944. direction2: Vector3;
  93945. /**
  93946. * 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.
  93947. */
  93948. minEmitBox: Vector3;
  93949. /**
  93950. * 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.
  93951. */
  93952. maxEmitBox: Vector3;
  93953. /**
  93954. * Creates a new instance BoxParticleEmitter
  93955. */
  93956. constructor();
  93957. /**
  93958. * Called by the particle System when the direction is computed for the created particle.
  93959. * @param worldMatrix is the world matrix of the particle system
  93960. * @param directionToUpdate is the direction vector to update with the result
  93961. * @param particle is the particle we are computed the direction for
  93962. * @param isLocal defines if the direction should be set in local space
  93963. */
  93964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93965. /**
  93966. * Called by the particle System when the position is computed for the created particle.
  93967. * @param worldMatrix is the world matrix of the particle system
  93968. * @param positionToUpdate is the position vector to update with the result
  93969. * @param particle is the particle we are computed the position for
  93970. * @param isLocal defines if the position should be set in local space
  93971. */
  93972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93973. /**
  93974. * Clones the current emitter and returns a copy of it
  93975. * @returns the new emitter
  93976. */
  93977. clone(): BoxParticleEmitter;
  93978. /**
  93979. * Called by the GPUParticleSystem to setup the update shader
  93980. * @param effect defines the update shader
  93981. */
  93982. applyToShader(effect: Effect): void;
  93983. /**
  93984. * Returns a string to use to update the GPU particles update shader
  93985. * @returns a string containng the defines string
  93986. */
  93987. getEffectDefines(): string;
  93988. /**
  93989. * Returns the string "BoxParticleEmitter"
  93990. * @returns a string containing the class name
  93991. */
  93992. getClassName(): string;
  93993. /**
  93994. * Serializes the particle system to a JSON object.
  93995. * @returns the JSON object
  93996. */
  93997. serialize(): any;
  93998. /**
  93999. * Parse properties from a JSON object
  94000. * @param serializationObject defines the JSON object
  94001. */
  94002. parse(serializationObject: any): void;
  94003. }
  94004. }
  94005. declare module BABYLON {
  94006. /**
  94007. * Particle emitter emitting particles from the inside of a cone.
  94008. * It emits the particles alongside the cone volume from the base to the particle.
  94009. * The emission direction might be randomized.
  94010. */
  94011. export class ConeParticleEmitter implements IParticleEmitterType {
  94012. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94013. directionRandomizer: number;
  94014. private _radius;
  94015. private _angle;
  94016. private _height;
  94017. /**
  94018. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94019. */
  94020. radiusRange: number;
  94021. /**
  94022. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94023. */
  94024. heightRange: number;
  94025. /**
  94026. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94027. */
  94028. emitFromSpawnPointOnly: boolean;
  94029. /**
  94030. * Gets or sets the radius of the emission cone
  94031. */
  94032. get radius(): number;
  94033. set radius(value: number);
  94034. /**
  94035. * Gets or sets the angle of the emission cone
  94036. */
  94037. get angle(): number;
  94038. set angle(value: number);
  94039. private _buildHeight;
  94040. /**
  94041. * Creates a new instance ConeParticleEmitter
  94042. * @param radius the radius of the emission cone (1 by default)
  94043. * @param angle the cone base angle (PI by default)
  94044. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94045. */
  94046. constructor(radius?: number, angle?: number,
  94047. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94048. directionRandomizer?: number);
  94049. /**
  94050. * Called by the particle System when the direction is computed for the created particle.
  94051. * @param worldMatrix is the world matrix of the particle system
  94052. * @param directionToUpdate is the direction vector to update with the result
  94053. * @param particle is the particle we are computed the direction for
  94054. * @param isLocal defines if the direction should be set in local space
  94055. */
  94056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94057. /**
  94058. * Called by the particle System when the position is computed for the created particle.
  94059. * @param worldMatrix is the world matrix of the particle system
  94060. * @param positionToUpdate is the position vector to update with the result
  94061. * @param particle is the particle we are computed the position for
  94062. * @param isLocal defines if the position should be set in local space
  94063. */
  94064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94065. /**
  94066. * Clones the current emitter and returns a copy of it
  94067. * @returns the new emitter
  94068. */
  94069. clone(): ConeParticleEmitter;
  94070. /**
  94071. * Called by the GPUParticleSystem to setup the update shader
  94072. * @param effect defines the update shader
  94073. */
  94074. applyToShader(effect: Effect): void;
  94075. /**
  94076. * Returns a string to use to update the GPU particles update shader
  94077. * @returns a string containng the defines string
  94078. */
  94079. getEffectDefines(): string;
  94080. /**
  94081. * Returns the string "ConeParticleEmitter"
  94082. * @returns a string containing the class name
  94083. */
  94084. getClassName(): string;
  94085. /**
  94086. * Serializes the particle system to a JSON object.
  94087. * @returns the JSON object
  94088. */
  94089. serialize(): any;
  94090. /**
  94091. * Parse properties from a JSON object
  94092. * @param serializationObject defines the JSON object
  94093. */
  94094. parse(serializationObject: any): void;
  94095. }
  94096. }
  94097. declare module BABYLON {
  94098. /**
  94099. * Particle emitter emitting particles from the inside of a cylinder.
  94100. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94101. */
  94102. export class CylinderParticleEmitter implements IParticleEmitterType {
  94103. /**
  94104. * The radius of the emission cylinder.
  94105. */
  94106. radius: number;
  94107. /**
  94108. * The height of the emission cylinder.
  94109. */
  94110. height: number;
  94111. /**
  94112. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94113. */
  94114. radiusRange: number;
  94115. /**
  94116. * How much to randomize the particle direction [0-1].
  94117. */
  94118. directionRandomizer: number;
  94119. /**
  94120. * Creates a new instance CylinderParticleEmitter
  94121. * @param radius the radius of the emission cylinder (1 by default)
  94122. * @param height the height of the emission cylinder (1 by default)
  94123. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94124. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94125. */
  94126. constructor(
  94127. /**
  94128. * The radius of the emission cylinder.
  94129. */
  94130. radius?: number,
  94131. /**
  94132. * The height of the emission cylinder.
  94133. */
  94134. height?: number,
  94135. /**
  94136. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94137. */
  94138. radiusRange?: number,
  94139. /**
  94140. * How much to randomize the particle direction [0-1].
  94141. */
  94142. directionRandomizer?: number);
  94143. /**
  94144. * Called by the particle System when the direction is computed for the created particle.
  94145. * @param worldMatrix is the world matrix of the particle system
  94146. * @param directionToUpdate is the direction vector to update with the result
  94147. * @param particle is the particle we are computed the direction for
  94148. * @param isLocal defines if the direction should be set in local space
  94149. */
  94150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94151. /**
  94152. * Called by the particle System when the position is computed for the created particle.
  94153. * @param worldMatrix is the world matrix of the particle system
  94154. * @param positionToUpdate is the position vector to update with the result
  94155. * @param particle is the particle we are computed the position for
  94156. * @param isLocal defines if the position should be set in local space
  94157. */
  94158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94159. /**
  94160. * Clones the current emitter and returns a copy of it
  94161. * @returns the new emitter
  94162. */
  94163. clone(): CylinderParticleEmitter;
  94164. /**
  94165. * Called by the GPUParticleSystem to setup the update shader
  94166. * @param effect defines the update shader
  94167. */
  94168. applyToShader(effect: Effect): void;
  94169. /**
  94170. * Returns a string to use to update the GPU particles update shader
  94171. * @returns a string containng the defines string
  94172. */
  94173. getEffectDefines(): string;
  94174. /**
  94175. * Returns the string "CylinderParticleEmitter"
  94176. * @returns a string containing the class name
  94177. */
  94178. getClassName(): string;
  94179. /**
  94180. * Serializes the particle system to a JSON object.
  94181. * @returns the JSON object
  94182. */
  94183. serialize(): any;
  94184. /**
  94185. * Parse properties from a JSON object
  94186. * @param serializationObject defines the JSON object
  94187. */
  94188. parse(serializationObject: any): void;
  94189. }
  94190. /**
  94191. * Particle emitter emitting particles from the inside of a cylinder.
  94192. * It emits the particles randomly between two vectors.
  94193. */
  94194. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94195. /**
  94196. * The min limit of the emission direction.
  94197. */
  94198. direction1: Vector3;
  94199. /**
  94200. * The max limit of the emission direction.
  94201. */
  94202. direction2: Vector3;
  94203. /**
  94204. * Creates a new instance CylinderDirectedParticleEmitter
  94205. * @param radius the radius of the emission cylinder (1 by default)
  94206. * @param height the height of the emission cylinder (1 by default)
  94207. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94208. * @param direction1 the min limit of the emission direction (up vector by default)
  94209. * @param direction2 the max limit of the emission direction (up vector by default)
  94210. */
  94211. constructor(radius?: number, height?: number, radiusRange?: number,
  94212. /**
  94213. * The min limit of the emission direction.
  94214. */
  94215. direction1?: Vector3,
  94216. /**
  94217. * The max limit of the emission direction.
  94218. */
  94219. direction2?: Vector3);
  94220. /**
  94221. * Called by the particle System when the direction is computed for the created particle.
  94222. * @param worldMatrix is the world matrix of the particle system
  94223. * @param directionToUpdate is the direction vector to update with the result
  94224. * @param particle is the particle we are computed the direction for
  94225. */
  94226. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94227. /**
  94228. * Clones the current emitter and returns a copy of it
  94229. * @returns the new emitter
  94230. */
  94231. clone(): CylinderDirectedParticleEmitter;
  94232. /**
  94233. * Called by the GPUParticleSystem to setup the update shader
  94234. * @param effect defines the update shader
  94235. */
  94236. applyToShader(effect: Effect): void;
  94237. /**
  94238. * Returns a string to use to update the GPU particles update shader
  94239. * @returns a string containng the defines string
  94240. */
  94241. getEffectDefines(): string;
  94242. /**
  94243. * Returns the string "CylinderDirectedParticleEmitter"
  94244. * @returns a string containing the class name
  94245. */
  94246. getClassName(): string;
  94247. /**
  94248. * Serializes the particle system to a JSON object.
  94249. * @returns the JSON object
  94250. */
  94251. serialize(): any;
  94252. /**
  94253. * Parse properties from a JSON object
  94254. * @param serializationObject defines the JSON object
  94255. */
  94256. parse(serializationObject: any): void;
  94257. }
  94258. }
  94259. declare module BABYLON {
  94260. /**
  94261. * Particle emitter emitting particles from the inside of a hemisphere.
  94262. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94263. */
  94264. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94265. /**
  94266. * The radius of the emission hemisphere.
  94267. */
  94268. radius: number;
  94269. /**
  94270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94271. */
  94272. radiusRange: number;
  94273. /**
  94274. * How much to randomize the particle direction [0-1].
  94275. */
  94276. directionRandomizer: number;
  94277. /**
  94278. * Creates a new instance HemisphericParticleEmitter
  94279. * @param radius the radius of the emission hemisphere (1 by default)
  94280. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94282. */
  94283. constructor(
  94284. /**
  94285. * The radius of the emission hemisphere.
  94286. */
  94287. radius?: number,
  94288. /**
  94289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94290. */
  94291. radiusRange?: number,
  94292. /**
  94293. * How much to randomize the particle direction [0-1].
  94294. */
  94295. directionRandomizer?: number);
  94296. /**
  94297. * Called by the particle System when the direction is computed for the created particle.
  94298. * @param worldMatrix is the world matrix of the particle system
  94299. * @param directionToUpdate is the direction vector to update with the result
  94300. * @param particle is the particle we are computed the direction for
  94301. * @param isLocal defines if the direction should be set in local space
  94302. */
  94303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94304. /**
  94305. * Called by the particle System when the position is computed for the created particle.
  94306. * @param worldMatrix is the world matrix of the particle system
  94307. * @param positionToUpdate is the position vector to update with the result
  94308. * @param particle is the particle we are computed the position for
  94309. * @param isLocal defines if the position should be set in local space
  94310. */
  94311. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94312. /**
  94313. * Clones the current emitter and returns a copy of it
  94314. * @returns the new emitter
  94315. */
  94316. clone(): HemisphericParticleEmitter;
  94317. /**
  94318. * Called by the GPUParticleSystem to setup the update shader
  94319. * @param effect defines the update shader
  94320. */
  94321. applyToShader(effect: Effect): void;
  94322. /**
  94323. * Returns a string to use to update the GPU particles update shader
  94324. * @returns a string containng the defines string
  94325. */
  94326. getEffectDefines(): string;
  94327. /**
  94328. * Returns the string "HemisphericParticleEmitter"
  94329. * @returns a string containing the class name
  94330. */
  94331. getClassName(): string;
  94332. /**
  94333. * Serializes the particle system to a JSON object.
  94334. * @returns the JSON object
  94335. */
  94336. serialize(): any;
  94337. /**
  94338. * Parse properties from a JSON object
  94339. * @param serializationObject defines the JSON object
  94340. */
  94341. parse(serializationObject: any): void;
  94342. }
  94343. }
  94344. declare module BABYLON {
  94345. /**
  94346. * Particle emitter emitting particles from a point.
  94347. * It emits the particles randomly between 2 given directions.
  94348. */
  94349. export class PointParticleEmitter implements IParticleEmitterType {
  94350. /**
  94351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94352. */
  94353. direction1: Vector3;
  94354. /**
  94355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94356. */
  94357. direction2: Vector3;
  94358. /**
  94359. * Creates a new instance PointParticleEmitter
  94360. */
  94361. constructor();
  94362. /**
  94363. * Called by the particle System when the direction is computed for the created particle.
  94364. * @param worldMatrix is the world matrix of the particle system
  94365. * @param directionToUpdate is the direction vector to update with the result
  94366. * @param particle is the particle we are computed the direction for
  94367. * @param isLocal defines if the direction should be set in local space
  94368. */
  94369. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94370. /**
  94371. * Called by the particle System when the position is computed for the created particle.
  94372. * @param worldMatrix is the world matrix of the particle system
  94373. * @param positionToUpdate is the position vector to update with the result
  94374. * @param particle is the particle we are computed the position for
  94375. * @param isLocal defines if the position should be set in local space
  94376. */
  94377. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94378. /**
  94379. * Clones the current emitter and returns a copy of it
  94380. * @returns the new emitter
  94381. */
  94382. clone(): PointParticleEmitter;
  94383. /**
  94384. * Called by the GPUParticleSystem to setup the update shader
  94385. * @param effect defines the update shader
  94386. */
  94387. applyToShader(effect: Effect): void;
  94388. /**
  94389. * Returns a string to use to update the GPU particles update shader
  94390. * @returns a string containng the defines string
  94391. */
  94392. getEffectDefines(): string;
  94393. /**
  94394. * Returns the string "PointParticleEmitter"
  94395. * @returns a string containing the class name
  94396. */
  94397. getClassName(): string;
  94398. /**
  94399. * Serializes the particle system to a JSON object.
  94400. * @returns the JSON object
  94401. */
  94402. serialize(): any;
  94403. /**
  94404. * Parse properties from a JSON object
  94405. * @param serializationObject defines the JSON object
  94406. */
  94407. parse(serializationObject: any): void;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. /**
  94412. * Particle emitter emitting particles from the inside of a sphere.
  94413. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94414. */
  94415. export class SphereParticleEmitter implements IParticleEmitterType {
  94416. /**
  94417. * The radius of the emission sphere.
  94418. */
  94419. radius: number;
  94420. /**
  94421. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94422. */
  94423. radiusRange: number;
  94424. /**
  94425. * How much to randomize the particle direction [0-1].
  94426. */
  94427. directionRandomizer: number;
  94428. /**
  94429. * Creates a new instance SphereParticleEmitter
  94430. * @param radius the radius of the emission sphere (1 by default)
  94431. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94432. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94433. */
  94434. constructor(
  94435. /**
  94436. * The radius of the emission sphere.
  94437. */
  94438. radius?: number,
  94439. /**
  94440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94441. */
  94442. radiusRange?: number,
  94443. /**
  94444. * How much to randomize the particle direction [0-1].
  94445. */
  94446. directionRandomizer?: number);
  94447. /**
  94448. * Called by the particle System when the direction is computed for the created particle.
  94449. * @param worldMatrix is the world matrix of the particle system
  94450. * @param directionToUpdate is the direction vector to update with the result
  94451. * @param particle is the particle we are computed the direction for
  94452. * @param isLocal defines if the direction should be set in local space
  94453. */
  94454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94455. /**
  94456. * Called by the particle System when the position is computed for the created particle.
  94457. * @param worldMatrix is the world matrix of the particle system
  94458. * @param positionToUpdate is the position vector to update with the result
  94459. * @param particle is the particle we are computed the position for
  94460. * @param isLocal defines if the position should be set in local space
  94461. */
  94462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94463. /**
  94464. * Clones the current emitter and returns a copy of it
  94465. * @returns the new emitter
  94466. */
  94467. clone(): SphereParticleEmitter;
  94468. /**
  94469. * Called by the GPUParticleSystem to setup the update shader
  94470. * @param effect defines the update shader
  94471. */
  94472. applyToShader(effect: Effect): void;
  94473. /**
  94474. * Returns a string to use to update the GPU particles update shader
  94475. * @returns a string containng the defines string
  94476. */
  94477. getEffectDefines(): string;
  94478. /**
  94479. * Returns the string "SphereParticleEmitter"
  94480. * @returns a string containing the class name
  94481. */
  94482. getClassName(): string;
  94483. /**
  94484. * Serializes the particle system to a JSON object.
  94485. * @returns the JSON object
  94486. */
  94487. serialize(): any;
  94488. /**
  94489. * Parse properties from a JSON object
  94490. * @param serializationObject defines the JSON object
  94491. */
  94492. parse(serializationObject: any): void;
  94493. }
  94494. /**
  94495. * Particle emitter emitting particles from the inside of a sphere.
  94496. * It emits the particles randomly between two vectors.
  94497. */
  94498. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94499. /**
  94500. * The min limit of the emission direction.
  94501. */
  94502. direction1: Vector3;
  94503. /**
  94504. * The max limit of the emission direction.
  94505. */
  94506. direction2: Vector3;
  94507. /**
  94508. * Creates a new instance SphereDirectedParticleEmitter
  94509. * @param radius the radius of the emission sphere (1 by default)
  94510. * @param direction1 the min limit of the emission direction (up vector by default)
  94511. * @param direction2 the max limit of the emission direction (up vector by default)
  94512. */
  94513. constructor(radius?: number,
  94514. /**
  94515. * The min limit of the emission direction.
  94516. */
  94517. direction1?: Vector3,
  94518. /**
  94519. * The max limit of the emission direction.
  94520. */
  94521. direction2?: Vector3);
  94522. /**
  94523. * Called by the particle System when the direction is computed for the created particle.
  94524. * @param worldMatrix is the world matrix of the particle system
  94525. * @param directionToUpdate is the direction vector to update with the result
  94526. * @param particle is the particle we are computed the direction for
  94527. */
  94528. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94529. /**
  94530. * Clones the current emitter and returns a copy of it
  94531. * @returns the new emitter
  94532. */
  94533. clone(): SphereDirectedParticleEmitter;
  94534. /**
  94535. * Called by the GPUParticleSystem to setup the update shader
  94536. * @param effect defines the update shader
  94537. */
  94538. applyToShader(effect: Effect): void;
  94539. /**
  94540. * Returns a string to use to update the GPU particles update shader
  94541. * @returns a string containng the defines string
  94542. */
  94543. getEffectDefines(): string;
  94544. /**
  94545. * Returns the string "SphereDirectedParticleEmitter"
  94546. * @returns a string containing the class name
  94547. */
  94548. getClassName(): string;
  94549. /**
  94550. * Serializes the particle system to a JSON object.
  94551. * @returns the JSON object
  94552. */
  94553. serialize(): any;
  94554. /**
  94555. * Parse properties from a JSON object
  94556. * @param serializationObject defines the JSON object
  94557. */
  94558. parse(serializationObject: any): void;
  94559. }
  94560. }
  94561. declare module BABYLON {
  94562. /**
  94563. * Particle emitter emitting particles from a custom list of positions.
  94564. */
  94565. export class CustomParticleEmitter implements IParticleEmitterType {
  94566. /**
  94567. * Gets or sets the position generator that will create the inital position of each particle.
  94568. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94569. */
  94570. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94571. /**
  94572. * Gets or sets the destination generator that will create the final destination of each particle.
  94573. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94574. */
  94575. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94576. /**
  94577. * Creates a new instance CustomParticleEmitter
  94578. */
  94579. constructor();
  94580. /**
  94581. * Called by the particle System when the direction is computed for the created particle.
  94582. * @param worldMatrix is the world matrix of the particle system
  94583. * @param directionToUpdate is the direction vector to update with the result
  94584. * @param particle is the particle we are computed the direction for
  94585. * @param isLocal defines if the direction should be set in local space
  94586. */
  94587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94588. /**
  94589. * Called by the particle System when the position is computed for the created particle.
  94590. * @param worldMatrix is the world matrix of the particle system
  94591. * @param positionToUpdate is the position vector to update with the result
  94592. * @param particle is the particle we are computed the position for
  94593. * @param isLocal defines if the position should be set in local space
  94594. */
  94595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94596. /**
  94597. * Clones the current emitter and returns a copy of it
  94598. * @returns the new emitter
  94599. */
  94600. clone(): CustomParticleEmitter;
  94601. /**
  94602. * Called by the GPUParticleSystem to setup the update shader
  94603. * @param effect defines the update shader
  94604. */
  94605. applyToShader(effect: Effect): void;
  94606. /**
  94607. * Returns a string to use to update the GPU particles update shader
  94608. * @returns a string containng the defines string
  94609. */
  94610. getEffectDefines(): string;
  94611. /**
  94612. * Returns the string "PointParticleEmitter"
  94613. * @returns a string containing the class name
  94614. */
  94615. getClassName(): string;
  94616. /**
  94617. * Serializes the particle system to a JSON object.
  94618. * @returns the JSON object
  94619. */
  94620. serialize(): any;
  94621. /**
  94622. * Parse properties from a JSON object
  94623. * @param serializationObject defines the JSON object
  94624. */
  94625. parse(serializationObject: any): void;
  94626. }
  94627. }
  94628. declare module BABYLON {
  94629. /**
  94630. * Particle emitter emitting particles from the inside of a box.
  94631. * It emits the particles randomly between 2 given directions.
  94632. */
  94633. export class MeshParticleEmitter implements IParticleEmitterType {
  94634. private _indices;
  94635. private _positions;
  94636. private _normals;
  94637. private _storedNormal;
  94638. private _mesh;
  94639. /**
  94640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94641. */
  94642. direction1: Vector3;
  94643. /**
  94644. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94645. */
  94646. direction2: Vector3;
  94647. /**
  94648. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94649. */
  94650. useMeshNormalsForDirection: boolean;
  94651. /** Defines the mesh to use as source */
  94652. get mesh(): Nullable<AbstractMesh>;
  94653. set mesh(value: Nullable<AbstractMesh>);
  94654. /**
  94655. * Creates a new instance MeshParticleEmitter
  94656. * @param mesh defines the mesh to use as source
  94657. */
  94658. constructor(mesh?: Nullable<AbstractMesh>);
  94659. /**
  94660. * Called by the particle System when the direction is computed for the created particle.
  94661. * @param worldMatrix is the world matrix of the particle system
  94662. * @param directionToUpdate is the direction vector to update with the result
  94663. * @param particle is the particle we are computed the direction for
  94664. * @param isLocal defines if the direction should be set in local space
  94665. */
  94666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94667. /**
  94668. * Called by the particle System when the position is computed for the created particle.
  94669. * @param worldMatrix is the world matrix of the particle system
  94670. * @param positionToUpdate is the position vector to update with the result
  94671. * @param particle is the particle we are computed the position for
  94672. * @param isLocal defines if the position should be set in local space
  94673. */
  94674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94675. /**
  94676. * Clones the current emitter and returns a copy of it
  94677. * @returns the new emitter
  94678. */
  94679. clone(): MeshParticleEmitter;
  94680. /**
  94681. * Called by the GPUParticleSystem to setup the update shader
  94682. * @param effect defines the update shader
  94683. */
  94684. applyToShader(effect: Effect): void;
  94685. /**
  94686. * Returns a string to use to update the GPU particles update shader
  94687. * @returns a string containng the defines string
  94688. */
  94689. getEffectDefines(): string;
  94690. /**
  94691. * Returns the string "BoxParticleEmitter"
  94692. * @returns a string containing the class name
  94693. */
  94694. getClassName(): string;
  94695. /**
  94696. * Serializes the particle system to a JSON object.
  94697. * @returns the JSON object
  94698. */
  94699. serialize(): any;
  94700. /**
  94701. * Parse properties from a JSON object
  94702. * @param serializationObject defines the JSON object
  94703. * @param scene defines the hosting scene
  94704. */
  94705. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * Interface representing a particle system in Babylon.js.
  94711. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94712. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94713. */
  94714. export interface IParticleSystem {
  94715. /**
  94716. * List of animations used by the particle system.
  94717. */
  94718. animations: Animation[];
  94719. /**
  94720. * The id of the Particle system.
  94721. */
  94722. id: string;
  94723. /**
  94724. * The name of the Particle system.
  94725. */
  94726. name: string;
  94727. /**
  94728. * The emitter represents the Mesh or position we are attaching the particle system to.
  94729. */
  94730. emitter: Nullable<AbstractMesh | Vector3>;
  94731. /**
  94732. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94733. */
  94734. isBillboardBased: boolean;
  94735. /**
  94736. * The rendering group used by the Particle system to chose when to render.
  94737. */
  94738. renderingGroupId: number;
  94739. /**
  94740. * The layer mask we are rendering the particles through.
  94741. */
  94742. layerMask: number;
  94743. /**
  94744. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94745. */
  94746. updateSpeed: number;
  94747. /**
  94748. * The amount of time the particle system is running (depends of the overall update speed).
  94749. */
  94750. targetStopDuration: number;
  94751. /**
  94752. * The texture used to render each particle. (this can be a spritesheet)
  94753. */
  94754. particleTexture: Nullable<BaseTexture>;
  94755. /**
  94756. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94757. */
  94758. blendMode: number;
  94759. /**
  94760. * Minimum life time of emitting particles.
  94761. */
  94762. minLifeTime: number;
  94763. /**
  94764. * Maximum life time of emitting particles.
  94765. */
  94766. maxLifeTime: number;
  94767. /**
  94768. * Minimum Size of emitting particles.
  94769. */
  94770. minSize: number;
  94771. /**
  94772. * Maximum Size of emitting particles.
  94773. */
  94774. maxSize: number;
  94775. /**
  94776. * Minimum scale of emitting particles on X axis.
  94777. */
  94778. minScaleX: number;
  94779. /**
  94780. * Maximum scale of emitting particles on X axis.
  94781. */
  94782. maxScaleX: number;
  94783. /**
  94784. * Minimum scale of emitting particles on Y axis.
  94785. */
  94786. minScaleY: number;
  94787. /**
  94788. * Maximum scale of emitting particles on Y axis.
  94789. */
  94790. maxScaleY: number;
  94791. /**
  94792. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94793. */
  94794. color1: Color4;
  94795. /**
  94796. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94797. */
  94798. color2: Color4;
  94799. /**
  94800. * Color the particle will have at the end of its lifetime.
  94801. */
  94802. colorDead: Color4;
  94803. /**
  94804. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94805. */
  94806. emitRate: number;
  94807. /**
  94808. * You can use gravity if you want to give an orientation to your particles.
  94809. */
  94810. gravity: Vector3;
  94811. /**
  94812. * Minimum power of emitting particles.
  94813. */
  94814. minEmitPower: number;
  94815. /**
  94816. * Maximum power of emitting particles.
  94817. */
  94818. maxEmitPower: number;
  94819. /**
  94820. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94821. */
  94822. minAngularSpeed: number;
  94823. /**
  94824. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94825. */
  94826. maxAngularSpeed: number;
  94827. /**
  94828. * Gets or sets the minimal initial rotation in radians.
  94829. */
  94830. minInitialRotation: number;
  94831. /**
  94832. * Gets or sets the maximal initial rotation in radians.
  94833. */
  94834. maxInitialRotation: number;
  94835. /**
  94836. * The particle emitter type defines the emitter used by the particle system.
  94837. * It can be for example box, sphere, or cone...
  94838. */
  94839. particleEmitterType: Nullable<IParticleEmitterType>;
  94840. /**
  94841. * Defines the delay in milliseconds before starting the system (0 by default)
  94842. */
  94843. startDelay: number;
  94844. /**
  94845. * 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
  94846. */
  94847. preWarmCycles: number;
  94848. /**
  94849. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94850. */
  94851. preWarmStepOffset: number;
  94852. /**
  94853. * 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)
  94854. */
  94855. spriteCellChangeSpeed: number;
  94856. /**
  94857. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94858. */
  94859. startSpriteCellID: number;
  94860. /**
  94861. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94862. */
  94863. endSpriteCellID: number;
  94864. /**
  94865. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94866. */
  94867. spriteCellWidth: number;
  94868. /**
  94869. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94870. */
  94871. spriteCellHeight: number;
  94872. /**
  94873. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94874. */
  94875. spriteRandomStartCell: boolean;
  94876. /**
  94877. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94878. */
  94879. isAnimationSheetEnabled: boolean;
  94880. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94881. translationPivot: Vector2;
  94882. /**
  94883. * Gets or sets a texture used to add random noise to particle positions
  94884. */
  94885. noiseTexture: Nullable<BaseTexture>;
  94886. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94887. noiseStrength: Vector3;
  94888. /**
  94889. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94890. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94891. */
  94892. billboardMode: number;
  94893. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94894. limitVelocityDamping: number;
  94895. /**
  94896. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94897. */
  94898. beginAnimationOnStart: boolean;
  94899. /**
  94900. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94901. */
  94902. beginAnimationFrom: number;
  94903. /**
  94904. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94905. */
  94906. beginAnimationTo: number;
  94907. /**
  94908. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94909. */
  94910. beginAnimationLoop: boolean;
  94911. /**
  94912. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94913. */
  94914. disposeOnStop: boolean;
  94915. /**
  94916. * Specifies if the particles are updated in emitter local space or world space
  94917. */
  94918. isLocal: boolean;
  94919. /** Snippet ID if the particle system was created from the snippet server */
  94920. snippetId: string;
  94921. /** Gets or sets a matrix to use to compute projection */
  94922. defaultProjectionMatrix: Matrix;
  94923. /**
  94924. * Gets the maximum number of particles active at the same time.
  94925. * @returns The max number of active particles.
  94926. */
  94927. getCapacity(): number;
  94928. /**
  94929. * Gets the number of particles active at the same time.
  94930. * @returns The number of active particles.
  94931. */
  94932. getActiveCount(): number;
  94933. /**
  94934. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94935. * @returns True if it has been started, otherwise false.
  94936. */
  94937. isStarted(): boolean;
  94938. /**
  94939. * Animates the particle system for this frame.
  94940. */
  94941. animate(): void;
  94942. /**
  94943. * Renders the particle system in its current state.
  94944. * @returns the current number of particles
  94945. */
  94946. render(): number;
  94947. /**
  94948. * Dispose the particle system and frees its associated resources.
  94949. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94950. */
  94951. dispose(disposeTexture?: boolean): void;
  94952. /**
  94953. * An event triggered when the system is disposed
  94954. */
  94955. onDisposeObservable: Observable<IParticleSystem>;
  94956. /**
  94957. * An event triggered when the system is stopped
  94958. */
  94959. onStoppedObservable: Observable<IParticleSystem>;
  94960. /**
  94961. * Clones the particle system.
  94962. * @param name The name of the cloned object
  94963. * @param newEmitter The new emitter to use
  94964. * @returns the cloned particle system
  94965. */
  94966. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94967. /**
  94968. * Serializes the particle system to a JSON object
  94969. * @param serializeTexture defines if the texture must be serialized as well
  94970. * @returns the JSON object
  94971. */
  94972. serialize(serializeTexture: boolean): any;
  94973. /**
  94974. * Rebuild the particle system
  94975. */
  94976. rebuild(): void;
  94977. /** Force the system to rebuild all gradients that need to be resync */
  94978. forceRefreshGradients(): void;
  94979. /**
  94980. * Starts the particle system and begins to emit
  94981. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94982. */
  94983. start(delay?: number): void;
  94984. /**
  94985. * Stops the particle system.
  94986. */
  94987. stop(): void;
  94988. /**
  94989. * Remove all active particles
  94990. */
  94991. reset(): void;
  94992. /**
  94993. * Gets a boolean indicating that the system is stopping
  94994. * @returns true if the system is currently stopping
  94995. */
  94996. isStopping(): boolean;
  94997. /**
  94998. * Is this system ready to be used/rendered
  94999. * @return true if the system is ready
  95000. */
  95001. isReady(): boolean;
  95002. /**
  95003. * Returns the string "ParticleSystem"
  95004. * @returns a string containing the class name
  95005. */
  95006. getClassName(): string;
  95007. /**
  95008. * Gets the custom effect used to render the particles
  95009. * @param blendMode Blend mode for which the effect should be retrieved
  95010. * @returns The effect
  95011. */
  95012. getCustomEffect(blendMode: number): Nullable<Effect>;
  95013. /**
  95014. * Sets the custom effect used to render the particles
  95015. * @param effect The effect to set
  95016. * @param blendMode Blend mode for which the effect should be set
  95017. */
  95018. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95019. /**
  95020. * Fill the defines array according to the current settings of the particle system
  95021. * @param defines Array to be updated
  95022. * @param blendMode blend mode to take into account when updating the array
  95023. */
  95024. fillDefines(defines: Array<string>, blendMode: number): void;
  95025. /**
  95026. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95027. * @param uniforms Uniforms array to fill
  95028. * @param attributes Attributes array to fill
  95029. * @param samplers Samplers array to fill
  95030. */
  95031. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95032. /**
  95033. * Observable that will be called just before the particles are drawn
  95034. */
  95035. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95036. /**
  95037. * Gets the name of the particle vertex shader
  95038. */
  95039. vertexShaderName: string;
  95040. /**
  95041. * Adds a new color gradient
  95042. * @param gradient defines the gradient to use (between 0 and 1)
  95043. * @param color1 defines the color to affect to the specified gradient
  95044. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95045. * @returns the current particle system
  95046. */
  95047. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95048. /**
  95049. * Remove a specific color gradient
  95050. * @param gradient defines the gradient to remove
  95051. * @returns the current particle system
  95052. */
  95053. removeColorGradient(gradient: number): IParticleSystem;
  95054. /**
  95055. * Adds a new size gradient
  95056. * @param gradient defines the gradient to use (between 0 and 1)
  95057. * @param factor defines the size factor to affect to the specified gradient
  95058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95059. * @returns the current particle system
  95060. */
  95061. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95062. /**
  95063. * Remove a specific size gradient
  95064. * @param gradient defines the gradient to remove
  95065. * @returns the current particle system
  95066. */
  95067. removeSizeGradient(gradient: number): IParticleSystem;
  95068. /**
  95069. * Gets the current list of color gradients.
  95070. * You must use addColorGradient and removeColorGradient to udpate this list
  95071. * @returns the list of color gradients
  95072. */
  95073. getColorGradients(): Nullable<Array<ColorGradient>>;
  95074. /**
  95075. * Gets the current list of size gradients.
  95076. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95077. * @returns the list of size gradients
  95078. */
  95079. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95080. /**
  95081. * Gets the current list of angular speed gradients.
  95082. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95083. * @returns the list of angular speed gradients
  95084. */
  95085. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95086. /**
  95087. * Adds a new angular speed gradient
  95088. * @param gradient defines the gradient to use (between 0 and 1)
  95089. * @param factor defines the angular speed to affect to the specified gradient
  95090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95091. * @returns the current particle system
  95092. */
  95093. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95094. /**
  95095. * Remove a specific angular speed gradient
  95096. * @param gradient defines the gradient to remove
  95097. * @returns the current particle system
  95098. */
  95099. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95100. /**
  95101. * Gets the current list of velocity gradients.
  95102. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95103. * @returns the list of velocity gradients
  95104. */
  95105. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95106. /**
  95107. * Adds a new velocity gradient
  95108. * @param gradient defines the gradient to use (between 0 and 1)
  95109. * @param factor defines the velocity to affect to the specified gradient
  95110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95111. * @returns the current particle system
  95112. */
  95113. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95114. /**
  95115. * Remove a specific velocity gradient
  95116. * @param gradient defines the gradient to remove
  95117. * @returns the current particle system
  95118. */
  95119. removeVelocityGradient(gradient: number): IParticleSystem;
  95120. /**
  95121. * Gets the current list of limit velocity gradients.
  95122. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95123. * @returns the list of limit velocity gradients
  95124. */
  95125. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95126. /**
  95127. * Adds a new limit velocity gradient
  95128. * @param gradient defines the gradient to use (between 0 and 1)
  95129. * @param factor defines the limit velocity to affect to the specified gradient
  95130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95131. * @returns the current particle system
  95132. */
  95133. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95134. /**
  95135. * Remove a specific limit velocity gradient
  95136. * @param gradient defines the gradient to remove
  95137. * @returns the current particle system
  95138. */
  95139. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95140. /**
  95141. * Adds a new drag gradient
  95142. * @param gradient defines the gradient to use (between 0 and 1)
  95143. * @param factor defines the drag to affect to the specified gradient
  95144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95145. * @returns the current particle system
  95146. */
  95147. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95148. /**
  95149. * Remove a specific drag gradient
  95150. * @param gradient defines the gradient to remove
  95151. * @returns the current particle system
  95152. */
  95153. removeDragGradient(gradient: number): IParticleSystem;
  95154. /**
  95155. * Gets the current list of drag gradients.
  95156. * You must use addDragGradient and removeDragGradient to udpate this list
  95157. * @returns the list of drag gradients
  95158. */
  95159. getDragGradients(): Nullable<Array<FactorGradient>>;
  95160. /**
  95161. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95162. * @param gradient defines the gradient to use (between 0 and 1)
  95163. * @param factor defines the emit rate to affect to the specified gradient
  95164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95165. * @returns the current particle system
  95166. */
  95167. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95168. /**
  95169. * Remove a specific emit rate gradient
  95170. * @param gradient defines the gradient to remove
  95171. * @returns the current particle system
  95172. */
  95173. removeEmitRateGradient(gradient: number): IParticleSystem;
  95174. /**
  95175. * Gets the current list of emit rate gradients.
  95176. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95177. * @returns the list of emit rate gradients
  95178. */
  95179. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95180. /**
  95181. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95182. * @param gradient defines the gradient to use (between 0 and 1)
  95183. * @param factor defines the start size to affect to the specified gradient
  95184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95185. * @returns the current particle system
  95186. */
  95187. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95188. /**
  95189. * Remove a specific start size gradient
  95190. * @param gradient defines the gradient to remove
  95191. * @returns the current particle system
  95192. */
  95193. removeStartSizeGradient(gradient: number): IParticleSystem;
  95194. /**
  95195. * Gets the current list of start size gradients.
  95196. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95197. * @returns the list of start size gradients
  95198. */
  95199. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95200. /**
  95201. * Adds a new life time gradient
  95202. * @param gradient defines the gradient to use (between 0 and 1)
  95203. * @param factor defines the life time factor to affect to the specified gradient
  95204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95205. * @returns the current particle system
  95206. */
  95207. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95208. /**
  95209. * Remove a specific life time gradient
  95210. * @param gradient defines the gradient to remove
  95211. * @returns the current particle system
  95212. */
  95213. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95214. /**
  95215. * Gets the current list of life time gradients.
  95216. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95217. * @returns the list of life time gradients
  95218. */
  95219. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95220. /**
  95221. * Gets the current list of color gradients.
  95222. * You must use addColorGradient and removeColorGradient to udpate this list
  95223. * @returns the list of color gradients
  95224. */
  95225. getColorGradients(): Nullable<Array<ColorGradient>>;
  95226. /**
  95227. * Adds a new ramp gradient used to remap particle colors
  95228. * @param gradient defines the gradient to use (between 0 and 1)
  95229. * @param color defines the color to affect to the specified gradient
  95230. * @returns the current particle system
  95231. */
  95232. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95233. /**
  95234. * Gets the current list of ramp gradients.
  95235. * You must use addRampGradient and removeRampGradient to udpate this list
  95236. * @returns the list of ramp gradients
  95237. */
  95238. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95239. /** Gets or sets a boolean indicating that ramp gradients must be used
  95240. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95241. */
  95242. useRampGradients: boolean;
  95243. /**
  95244. * Adds a new color remap gradient
  95245. * @param gradient defines the gradient to use (between 0 and 1)
  95246. * @param min defines the color remap minimal range
  95247. * @param max defines the color remap maximal range
  95248. * @returns the current particle system
  95249. */
  95250. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95251. /**
  95252. * Gets the current list of color remap gradients.
  95253. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95254. * @returns the list of color remap gradients
  95255. */
  95256. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95257. /**
  95258. * Adds a new alpha remap gradient
  95259. * @param gradient defines the gradient to use (between 0 and 1)
  95260. * @param min defines the alpha remap minimal range
  95261. * @param max defines the alpha remap maximal range
  95262. * @returns the current particle system
  95263. */
  95264. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95265. /**
  95266. * Gets the current list of alpha remap gradients.
  95267. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95268. * @returns the list of alpha remap gradients
  95269. */
  95270. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95271. /**
  95272. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95273. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95274. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95275. * @returns the emitter
  95276. */
  95277. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95278. /**
  95279. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95280. * @param radius The radius of the hemisphere to emit from
  95281. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95282. * @returns the emitter
  95283. */
  95284. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95285. /**
  95286. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95287. * @param radius The radius of the sphere to emit from
  95288. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95289. * @returns the emitter
  95290. */
  95291. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95292. /**
  95293. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95294. * @param radius The radius of the sphere to emit from
  95295. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95296. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95297. * @returns the emitter
  95298. */
  95299. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95300. /**
  95301. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95302. * @param radius The radius of the emission cylinder
  95303. * @param height The height of the emission cylinder
  95304. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95305. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95306. * @returns the emitter
  95307. */
  95308. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95309. /**
  95310. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95311. * @param radius The radius of the cylinder to emit from
  95312. * @param height The height of the emission cylinder
  95313. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95316. * @returns the emitter
  95317. */
  95318. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95319. /**
  95320. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95321. * @param radius The radius of the cone to emit from
  95322. * @param angle The base angle of the cone
  95323. * @returns the emitter
  95324. */
  95325. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95326. /**
  95327. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95330. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95331. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95332. * @returns the emitter
  95333. */
  95334. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95335. /**
  95336. * Get hosting scene
  95337. * @returns the scene
  95338. */
  95339. getScene(): Nullable<Scene>;
  95340. }
  95341. }
  95342. declare module BABYLON {
  95343. /**
  95344. * 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.
  95345. * @see https://doc.babylonjs.com/how_to/transformnode
  95346. */
  95347. export class TransformNode extends Node {
  95348. /**
  95349. * Object will not rotate to face the camera
  95350. */
  95351. static BILLBOARDMODE_NONE: number;
  95352. /**
  95353. * Object will rotate to face the camera but only on the x axis
  95354. */
  95355. static BILLBOARDMODE_X: number;
  95356. /**
  95357. * Object will rotate to face the camera but only on the y axis
  95358. */
  95359. static BILLBOARDMODE_Y: number;
  95360. /**
  95361. * Object will rotate to face the camera but only on the z axis
  95362. */
  95363. static BILLBOARDMODE_Z: number;
  95364. /**
  95365. * Object will rotate to face the camera
  95366. */
  95367. static BILLBOARDMODE_ALL: number;
  95368. /**
  95369. * Object will rotate to face the camera's position instead of orientation
  95370. */
  95371. static BILLBOARDMODE_USE_POSITION: number;
  95372. private static _TmpRotation;
  95373. private static _TmpScaling;
  95374. private static _TmpTranslation;
  95375. private _forward;
  95376. private _forwardInverted;
  95377. private _up;
  95378. private _right;
  95379. private _rightInverted;
  95380. private _position;
  95381. private _rotation;
  95382. private _rotationQuaternion;
  95383. protected _scaling: Vector3;
  95384. protected _isDirty: boolean;
  95385. private _transformToBoneReferal;
  95386. private _isAbsoluteSynced;
  95387. private _billboardMode;
  95388. /**
  95389. * Gets or sets the billboard mode. Default is 0.
  95390. *
  95391. * | Value | Type | Description |
  95392. * | --- | --- | --- |
  95393. * | 0 | BILLBOARDMODE_NONE | |
  95394. * | 1 | BILLBOARDMODE_X | |
  95395. * | 2 | BILLBOARDMODE_Y | |
  95396. * | 4 | BILLBOARDMODE_Z | |
  95397. * | 7 | BILLBOARDMODE_ALL | |
  95398. *
  95399. */
  95400. get billboardMode(): number;
  95401. set billboardMode(value: number);
  95402. private _preserveParentRotationForBillboard;
  95403. /**
  95404. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95405. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95406. */
  95407. get preserveParentRotationForBillboard(): boolean;
  95408. set preserveParentRotationForBillboard(value: boolean);
  95409. /**
  95410. * 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
  95411. */
  95412. scalingDeterminant: number;
  95413. private _infiniteDistance;
  95414. /**
  95415. * Gets or sets the distance of the object to max, often used by skybox
  95416. */
  95417. get infiniteDistance(): boolean;
  95418. set infiniteDistance(value: boolean);
  95419. /**
  95420. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95421. * By default the system will update normals to compensate
  95422. */
  95423. ignoreNonUniformScaling: boolean;
  95424. /**
  95425. * 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
  95426. */
  95427. reIntegrateRotationIntoRotationQuaternion: boolean;
  95428. /** @hidden */
  95429. _poseMatrix: Nullable<Matrix>;
  95430. /** @hidden */
  95431. _localMatrix: Matrix;
  95432. private _usePivotMatrix;
  95433. private _absolutePosition;
  95434. private _absoluteScaling;
  95435. private _absoluteRotationQuaternion;
  95436. private _pivotMatrix;
  95437. private _pivotMatrixInverse;
  95438. /** @hidden */
  95439. _postMultiplyPivotMatrix: boolean;
  95440. protected _isWorldMatrixFrozen: boolean;
  95441. /** @hidden */
  95442. _indexInSceneTransformNodesArray: number;
  95443. /**
  95444. * An event triggered after the world matrix is updated
  95445. */
  95446. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95447. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95448. /**
  95449. * Gets a string identifying the name of the class
  95450. * @returns "TransformNode" string
  95451. */
  95452. getClassName(): string;
  95453. /**
  95454. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95455. */
  95456. get position(): Vector3;
  95457. set position(newPosition: Vector3);
  95458. /**
  95459. * 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)).
  95460. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95461. */
  95462. get rotation(): Vector3;
  95463. set rotation(newRotation: Vector3);
  95464. /**
  95465. * 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)).
  95466. */
  95467. get scaling(): Vector3;
  95468. set scaling(newScaling: Vector3);
  95469. /**
  95470. * 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).
  95471. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95472. */
  95473. get rotationQuaternion(): Nullable<Quaternion>;
  95474. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95475. /**
  95476. * The forward direction of that transform in world space.
  95477. */
  95478. get forward(): Vector3;
  95479. /**
  95480. * The up direction of that transform in world space.
  95481. */
  95482. get up(): Vector3;
  95483. /**
  95484. * The right direction of that transform in world space.
  95485. */
  95486. get right(): Vector3;
  95487. /**
  95488. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95489. * @param matrix the matrix to copy the pose from
  95490. * @returns this TransformNode.
  95491. */
  95492. updatePoseMatrix(matrix: Matrix): TransformNode;
  95493. /**
  95494. * Returns the mesh Pose matrix.
  95495. * @returns the pose matrix
  95496. */
  95497. getPoseMatrix(): Matrix;
  95498. /** @hidden */
  95499. _isSynchronized(): boolean;
  95500. /** @hidden */
  95501. _initCache(): void;
  95502. /**
  95503. * Flag the transform node as dirty (Forcing it to update everything)
  95504. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95505. * @returns this transform node
  95506. */
  95507. markAsDirty(property: string): TransformNode;
  95508. /**
  95509. * Returns the current mesh absolute position.
  95510. * Returns a Vector3.
  95511. */
  95512. get absolutePosition(): Vector3;
  95513. /**
  95514. * Returns the current mesh absolute scaling.
  95515. * Returns a Vector3.
  95516. */
  95517. get absoluteScaling(): Vector3;
  95518. /**
  95519. * Returns the current mesh absolute rotation.
  95520. * Returns a Quaternion.
  95521. */
  95522. get absoluteRotationQuaternion(): Quaternion;
  95523. /**
  95524. * Sets a new matrix to apply before all other transformation
  95525. * @param matrix defines the transform matrix
  95526. * @returns the current TransformNode
  95527. */
  95528. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95529. /**
  95530. * Sets a new pivot matrix to the current node
  95531. * @param matrix defines the new pivot matrix to use
  95532. * @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
  95533. * @returns the current TransformNode
  95534. */
  95535. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95536. /**
  95537. * Returns the mesh pivot matrix.
  95538. * Default : Identity.
  95539. * @returns the matrix
  95540. */
  95541. getPivotMatrix(): Matrix;
  95542. /**
  95543. * Instantiate (when possible) or clone that node with its hierarchy
  95544. * @param newParent defines the new parent to use for the instance (or clone)
  95545. * @param options defines options to configure how copy is done
  95546. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95547. * @returns an instance (or a clone) of the current node with its hiearchy
  95548. */
  95549. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95550. doNotInstantiate: boolean;
  95551. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95552. /**
  95553. * Prevents the World matrix to be computed any longer
  95554. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95555. * @returns the TransformNode.
  95556. */
  95557. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95558. /**
  95559. * Allows back the World matrix computation.
  95560. * @returns the TransformNode.
  95561. */
  95562. unfreezeWorldMatrix(): this;
  95563. /**
  95564. * True if the World matrix has been frozen.
  95565. */
  95566. get isWorldMatrixFrozen(): boolean;
  95567. /**
  95568. * Retuns the mesh absolute position in the World.
  95569. * @returns a Vector3.
  95570. */
  95571. getAbsolutePosition(): Vector3;
  95572. /**
  95573. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95574. * @param absolutePosition the absolute position to set
  95575. * @returns the TransformNode.
  95576. */
  95577. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95578. /**
  95579. * Sets the mesh position in its local space.
  95580. * @param vector3 the position to set in localspace
  95581. * @returns the TransformNode.
  95582. */
  95583. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95584. /**
  95585. * Returns the mesh position in the local space from the current World matrix values.
  95586. * @returns a new Vector3.
  95587. */
  95588. getPositionExpressedInLocalSpace(): Vector3;
  95589. /**
  95590. * Translates the mesh along the passed Vector3 in its local space.
  95591. * @param vector3 the distance to translate in localspace
  95592. * @returns the TransformNode.
  95593. */
  95594. locallyTranslate(vector3: Vector3): TransformNode;
  95595. private static _lookAtVectorCache;
  95596. /**
  95597. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95598. * @param targetPoint the position (must be in same space as current mesh) to look at
  95599. * @param yawCor optional yaw (y-axis) correction in radians
  95600. * @param pitchCor optional pitch (x-axis) correction in radians
  95601. * @param rollCor optional roll (z-axis) correction in radians
  95602. * @param space the choosen space of the target
  95603. * @returns the TransformNode.
  95604. */
  95605. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95606. /**
  95607. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95608. * This Vector3 is expressed in the World space.
  95609. * @param localAxis axis to rotate
  95610. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95611. */
  95612. getDirection(localAxis: Vector3): Vector3;
  95613. /**
  95614. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95615. * localAxis is expressed in the mesh local space.
  95616. * result is computed in the Wordl space from the mesh World matrix.
  95617. * @param localAxis axis to rotate
  95618. * @param result the resulting transformnode
  95619. * @returns this TransformNode.
  95620. */
  95621. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95622. /**
  95623. * Sets this transform node rotation to the given local axis.
  95624. * @param localAxis the axis in local space
  95625. * @param yawCor optional yaw (y-axis) correction in radians
  95626. * @param pitchCor optional pitch (x-axis) correction in radians
  95627. * @param rollCor optional roll (z-axis) correction in radians
  95628. * @returns this TransformNode
  95629. */
  95630. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95631. /**
  95632. * Sets a new pivot point to the current node
  95633. * @param point defines the new pivot point to use
  95634. * @param space defines if the point is in world or local space (local by default)
  95635. * @returns the current TransformNode
  95636. */
  95637. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95638. /**
  95639. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95640. * @returns the pivot point
  95641. */
  95642. getPivotPoint(): Vector3;
  95643. /**
  95644. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95645. * @param result the vector3 to store the result
  95646. * @returns this TransformNode.
  95647. */
  95648. getPivotPointToRef(result: Vector3): TransformNode;
  95649. /**
  95650. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95651. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95652. */
  95653. getAbsolutePivotPoint(): Vector3;
  95654. /**
  95655. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95656. * @param result vector3 to store the result
  95657. * @returns this TransformNode.
  95658. */
  95659. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95660. /**
  95661. * Defines the passed node as the parent of the current node.
  95662. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95663. * @see https://doc.babylonjs.com/how_to/parenting
  95664. * @param node the node ot set as the parent
  95665. * @returns this TransformNode.
  95666. */
  95667. setParent(node: Nullable<Node>): TransformNode;
  95668. private _nonUniformScaling;
  95669. /**
  95670. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95671. */
  95672. get nonUniformScaling(): boolean;
  95673. /** @hidden */
  95674. _updateNonUniformScalingState(value: boolean): boolean;
  95675. /**
  95676. * Attach the current TransformNode to another TransformNode associated with a bone
  95677. * @param bone Bone affecting the TransformNode
  95678. * @param affectedTransformNode TransformNode associated with the bone
  95679. * @returns this object
  95680. */
  95681. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95682. /**
  95683. * Detach the transform node if its associated with a bone
  95684. * @returns this object
  95685. */
  95686. detachFromBone(): TransformNode;
  95687. private static _rotationAxisCache;
  95688. /**
  95689. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95690. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95691. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95692. * The passed axis is also normalized.
  95693. * @param axis the axis to rotate around
  95694. * @param amount the amount to rotate in radians
  95695. * @param space Space to rotate in (Default: local)
  95696. * @returns the TransformNode.
  95697. */
  95698. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95699. /**
  95700. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95701. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95702. * The passed axis is also normalized. .
  95703. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95704. * @param point the point to rotate around
  95705. * @param axis the axis to rotate around
  95706. * @param amount the amount to rotate in radians
  95707. * @returns the TransformNode
  95708. */
  95709. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95710. /**
  95711. * Translates the mesh along the axis vector for the passed distance in the given space.
  95712. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95713. * @param axis the axis to translate in
  95714. * @param distance the distance to translate
  95715. * @param space Space to rotate in (Default: local)
  95716. * @returns the TransformNode.
  95717. */
  95718. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95719. /**
  95720. * Adds a rotation step to the mesh current rotation.
  95721. * x, y, z are Euler angles expressed in radians.
  95722. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95723. * This means this rotation is made in the mesh local space only.
  95724. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95725. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95726. * ```javascript
  95727. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95728. * ```
  95729. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95730. * 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.
  95731. * @param x Rotation to add
  95732. * @param y Rotation to add
  95733. * @param z Rotation to add
  95734. * @returns the TransformNode.
  95735. */
  95736. addRotation(x: number, y: number, z: number): TransformNode;
  95737. /**
  95738. * @hidden
  95739. */
  95740. protected _getEffectiveParent(): Nullable<Node>;
  95741. /**
  95742. * Computes the world matrix of the node
  95743. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95744. * @returns the world matrix
  95745. */
  95746. computeWorldMatrix(force?: boolean): Matrix;
  95747. /**
  95748. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95749. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95750. */
  95751. resetLocalMatrix(independentOfChildren?: boolean): void;
  95752. protected _afterComputeWorldMatrix(): void;
  95753. /**
  95754. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95755. * @param func callback function to add
  95756. *
  95757. * @returns the TransformNode.
  95758. */
  95759. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95760. /**
  95761. * Removes a registered callback function.
  95762. * @param func callback function to remove
  95763. * @returns the TransformNode.
  95764. */
  95765. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95766. /**
  95767. * Gets the position of the current mesh in camera space
  95768. * @param camera defines the camera to use
  95769. * @returns a position
  95770. */
  95771. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95772. /**
  95773. * Returns the distance from the mesh to the active camera
  95774. * @param camera defines the camera to use
  95775. * @returns the distance
  95776. */
  95777. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95778. /**
  95779. * Clone the current transform node
  95780. * @param name Name of the new clone
  95781. * @param newParent New parent for the clone
  95782. * @param doNotCloneChildren Do not clone children hierarchy
  95783. * @returns the new transform node
  95784. */
  95785. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95786. /**
  95787. * Serializes the objects information.
  95788. * @param currentSerializationObject defines the object to serialize in
  95789. * @returns the serialized object
  95790. */
  95791. serialize(currentSerializationObject?: any): any;
  95792. /**
  95793. * Returns a new TransformNode object parsed from the source provided.
  95794. * @param parsedTransformNode is the source.
  95795. * @param scene the scne the object belongs to
  95796. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95797. * @returns a new TransformNode object parsed from the source provided.
  95798. */
  95799. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95800. /**
  95801. * Get all child-transformNodes of this node
  95802. * @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
  95803. * @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
  95804. * @returns an array of TransformNode
  95805. */
  95806. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95807. /**
  95808. * Releases resources associated with this transform node.
  95809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95811. */
  95812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95813. /**
  95814. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95815. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95816. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95817. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95818. * @returns the current mesh
  95819. */
  95820. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95821. private _syncAbsoluteScalingAndRotation;
  95822. }
  95823. }
  95824. declare module BABYLON {
  95825. /**
  95826. * Class used to override all child animations of a given target
  95827. */
  95828. export class AnimationPropertiesOverride {
  95829. /**
  95830. * Gets or sets a value indicating if animation blending must be used
  95831. */
  95832. enableBlending: boolean;
  95833. /**
  95834. * Gets or sets the blending speed to use when enableBlending is true
  95835. */
  95836. blendingSpeed: number;
  95837. /**
  95838. * Gets or sets the default loop mode to use
  95839. */
  95840. loopMode: number;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * Class used to store bone information
  95846. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95847. */
  95848. export class Bone extends Node {
  95849. /**
  95850. * defines the bone name
  95851. */
  95852. name: string;
  95853. private static _tmpVecs;
  95854. private static _tmpQuat;
  95855. private static _tmpMats;
  95856. /**
  95857. * Gets the list of child bones
  95858. */
  95859. children: Bone[];
  95860. /** Gets the animations associated with this bone */
  95861. animations: Animation[];
  95862. /**
  95863. * Gets or sets bone length
  95864. */
  95865. length: number;
  95866. /**
  95867. * @hidden Internal only
  95868. * Set this value to map this bone to a different index in the transform matrices
  95869. * Set this value to -1 to exclude the bone from the transform matrices
  95870. */
  95871. _index: Nullable<number>;
  95872. private _skeleton;
  95873. private _localMatrix;
  95874. private _restPose;
  95875. private _bindPose;
  95876. private _baseMatrix;
  95877. private _absoluteTransform;
  95878. private _invertedAbsoluteTransform;
  95879. private _parent;
  95880. private _scalingDeterminant;
  95881. private _worldTransform;
  95882. private _localScaling;
  95883. private _localRotation;
  95884. private _localPosition;
  95885. private _needToDecompose;
  95886. private _needToCompose;
  95887. /** @hidden */
  95888. _linkedTransformNode: Nullable<TransformNode>;
  95889. /** @hidden */
  95890. _waitingTransformNodeId: Nullable<string>;
  95891. /** @hidden */
  95892. get _matrix(): Matrix;
  95893. /** @hidden */
  95894. set _matrix(value: Matrix);
  95895. /**
  95896. * Create a new bone
  95897. * @param name defines the bone name
  95898. * @param skeleton defines the parent skeleton
  95899. * @param parentBone defines the parent (can be null if the bone is the root)
  95900. * @param localMatrix defines the local matrix
  95901. * @param restPose defines the rest pose matrix
  95902. * @param baseMatrix defines the base matrix
  95903. * @param index defines index of the bone in the hiearchy
  95904. */
  95905. constructor(
  95906. /**
  95907. * defines the bone name
  95908. */
  95909. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95910. /**
  95911. * Gets the current object class name.
  95912. * @return the class name
  95913. */
  95914. getClassName(): string;
  95915. /**
  95916. * Gets the parent skeleton
  95917. * @returns a skeleton
  95918. */
  95919. getSkeleton(): Skeleton;
  95920. /**
  95921. * Gets parent bone
  95922. * @returns a bone or null if the bone is the root of the bone hierarchy
  95923. */
  95924. getParent(): Nullable<Bone>;
  95925. /**
  95926. * Returns an array containing the root bones
  95927. * @returns an array containing the root bones
  95928. */
  95929. getChildren(): Array<Bone>;
  95930. /**
  95931. * Gets the node index in matrix array generated for rendering
  95932. * @returns the node index
  95933. */
  95934. getIndex(): number;
  95935. /**
  95936. * Sets the parent bone
  95937. * @param parent defines the parent (can be null if the bone is the root)
  95938. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95939. */
  95940. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95941. /**
  95942. * Gets the local matrix
  95943. * @returns a matrix
  95944. */
  95945. getLocalMatrix(): Matrix;
  95946. /**
  95947. * Gets the base matrix (initial matrix which remains unchanged)
  95948. * @returns a matrix
  95949. */
  95950. getBaseMatrix(): Matrix;
  95951. /**
  95952. * Gets the rest pose matrix
  95953. * @returns a matrix
  95954. */
  95955. getRestPose(): Matrix;
  95956. /**
  95957. * Sets the rest pose matrix
  95958. * @param matrix the local-space rest pose to set for this bone
  95959. */
  95960. setRestPose(matrix: Matrix): void;
  95961. /**
  95962. * Gets the bind pose matrix
  95963. * @returns the bind pose matrix
  95964. */
  95965. getBindPose(): Matrix;
  95966. /**
  95967. * Sets the bind pose matrix
  95968. * @param matrix the local-space bind pose to set for this bone
  95969. */
  95970. setBindPose(matrix: Matrix): void;
  95971. /**
  95972. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95973. */
  95974. getWorldMatrix(): Matrix;
  95975. /**
  95976. * Sets the local matrix to rest pose matrix
  95977. */
  95978. returnToRest(): void;
  95979. /**
  95980. * Gets the inverse of the absolute transform matrix.
  95981. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95982. * @returns a matrix
  95983. */
  95984. getInvertedAbsoluteTransform(): Matrix;
  95985. /**
  95986. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95987. * @returns a matrix
  95988. */
  95989. getAbsoluteTransform(): Matrix;
  95990. /**
  95991. * Links with the given transform node.
  95992. * The local matrix of this bone is copied from the transform node every frame.
  95993. * @param transformNode defines the transform node to link to
  95994. */
  95995. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95996. /**
  95997. * Gets the node used to drive the bone's transformation
  95998. * @returns a transform node or null
  95999. */
  96000. getTransformNode(): Nullable<TransformNode>;
  96001. /** Gets or sets current position (in local space) */
  96002. get position(): Vector3;
  96003. set position(newPosition: Vector3);
  96004. /** Gets or sets current rotation (in local space) */
  96005. get rotation(): Vector3;
  96006. set rotation(newRotation: Vector3);
  96007. /** Gets or sets current rotation quaternion (in local space) */
  96008. get rotationQuaternion(): Quaternion;
  96009. set rotationQuaternion(newRotation: Quaternion);
  96010. /** Gets or sets current scaling (in local space) */
  96011. get scaling(): Vector3;
  96012. set scaling(newScaling: Vector3);
  96013. /**
  96014. * Gets the animation properties override
  96015. */
  96016. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96017. private _decompose;
  96018. private _compose;
  96019. /**
  96020. * Update the base and local matrices
  96021. * @param matrix defines the new base or local matrix
  96022. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96023. * @param updateLocalMatrix defines if the local matrix should be updated
  96024. */
  96025. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96026. /** @hidden */
  96027. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96028. /**
  96029. * Flag the bone as dirty (Forcing it to update everything)
  96030. */
  96031. markAsDirty(): void;
  96032. /** @hidden */
  96033. _markAsDirtyAndCompose(): void;
  96034. private _markAsDirtyAndDecompose;
  96035. /**
  96036. * Translate the bone in local or world space
  96037. * @param vec The amount to translate the bone
  96038. * @param space The space that the translation is in
  96039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96040. */
  96041. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96042. /**
  96043. * Set the postion of the bone in local or world space
  96044. * @param position The position to set the bone
  96045. * @param space The space that the position is in
  96046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96047. */
  96048. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96049. /**
  96050. * Set the absolute position of the bone (world space)
  96051. * @param position The position to set the bone
  96052. * @param mesh The mesh that this bone is attached to
  96053. */
  96054. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96055. /**
  96056. * Scale the bone on the x, y and z axes (in local space)
  96057. * @param x The amount to scale the bone on the x axis
  96058. * @param y The amount to scale the bone on the y axis
  96059. * @param z The amount to scale the bone on the z axis
  96060. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96061. */
  96062. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96063. /**
  96064. * Set the bone scaling in local space
  96065. * @param scale defines the scaling vector
  96066. */
  96067. setScale(scale: Vector3): void;
  96068. /**
  96069. * Gets the current scaling in local space
  96070. * @returns the current scaling vector
  96071. */
  96072. getScale(): Vector3;
  96073. /**
  96074. * Gets the current scaling in local space and stores it in a target vector
  96075. * @param result defines the target vector
  96076. */
  96077. getScaleToRef(result: Vector3): void;
  96078. /**
  96079. * Set the yaw, pitch, and roll of the bone in local or world space
  96080. * @param yaw The rotation of the bone on the y axis
  96081. * @param pitch The rotation of the bone on the x axis
  96082. * @param roll The rotation of the bone on the z axis
  96083. * @param space The space that the axes of rotation are in
  96084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96085. */
  96086. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96087. /**
  96088. * Add a rotation to the bone on an axis in local or world space
  96089. * @param axis The axis to rotate the bone on
  96090. * @param amount The amount to rotate the bone
  96091. * @param space The space that the axis is in
  96092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96093. */
  96094. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96095. /**
  96096. * Set the rotation of the bone to a particular axis angle in local or world space
  96097. * @param axis The axis to rotate the bone on
  96098. * @param angle The angle that the bone should be rotated to
  96099. * @param space The space that the axis is in
  96100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96101. */
  96102. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96103. /**
  96104. * Set the euler rotation of the bone in local or world space
  96105. * @param rotation The euler rotation that the bone should be set to
  96106. * @param space The space that the rotation is in
  96107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96108. */
  96109. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96110. /**
  96111. * Set the quaternion rotation of the bone in local or world space
  96112. * @param quat The quaternion rotation that the bone should be set to
  96113. * @param space The space that the rotation is in
  96114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96115. */
  96116. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96117. /**
  96118. * Set the rotation matrix of the bone in local or world space
  96119. * @param rotMat The rotation matrix that the bone should be set to
  96120. * @param space The space that the rotation is in
  96121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96122. */
  96123. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96124. private _rotateWithMatrix;
  96125. private _getNegativeRotationToRef;
  96126. /**
  96127. * Get the position of the bone in local or world space
  96128. * @param space The space that the returned position is in
  96129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96130. * @returns The position of the bone
  96131. */
  96132. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96133. /**
  96134. * Copy the position of the bone to a vector3 in local or world space
  96135. * @param space The space that the returned position is in
  96136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96137. * @param result The vector3 to copy the position to
  96138. */
  96139. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96140. /**
  96141. * Get the absolute position of the bone (world space)
  96142. * @param mesh The mesh that this bone is attached to
  96143. * @returns The absolute position of the bone
  96144. */
  96145. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96146. /**
  96147. * Copy the absolute position of the bone (world space) to the result param
  96148. * @param mesh The mesh that this bone is attached to
  96149. * @param result The vector3 to copy the absolute position to
  96150. */
  96151. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96152. /**
  96153. * Compute the absolute transforms of this bone and its children
  96154. */
  96155. computeAbsoluteTransforms(): void;
  96156. /**
  96157. * Get the world direction from an axis that is in the local space of the bone
  96158. * @param localAxis The local direction that is used to compute the world direction
  96159. * @param mesh The mesh that this bone is attached to
  96160. * @returns The world direction
  96161. */
  96162. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96163. /**
  96164. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96165. * @param localAxis The local direction that is used to compute the world direction
  96166. * @param mesh The mesh that this bone is attached to
  96167. * @param result The vector3 that the world direction will be copied to
  96168. */
  96169. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96170. /**
  96171. * Get the euler rotation of the bone in local or world space
  96172. * @param space The space that the rotation should be in
  96173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96174. * @returns The euler rotation
  96175. */
  96176. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96177. /**
  96178. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96179. * @param space The space that the rotation should be in
  96180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96181. * @param result The vector3 that the rotation should be copied to
  96182. */
  96183. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96184. /**
  96185. * Get the quaternion rotation of the bone in either local or world space
  96186. * @param space The space that the rotation should be in
  96187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96188. * @returns The quaternion rotation
  96189. */
  96190. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96191. /**
  96192. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96193. * @param space The space that the rotation should be in
  96194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96195. * @param result The quaternion that the rotation should be copied to
  96196. */
  96197. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96198. /**
  96199. * Get the rotation matrix of the bone in local or world space
  96200. * @param space The space that the rotation should be in
  96201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96202. * @returns The rotation matrix
  96203. */
  96204. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96205. /**
  96206. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96207. * @param space The space that the rotation should be in
  96208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96209. * @param result The quaternion that the rotation should be copied to
  96210. */
  96211. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96212. /**
  96213. * Get the world position of a point that is in the local space of the bone
  96214. * @param position The local position
  96215. * @param mesh The mesh that this bone is attached to
  96216. * @returns The world position
  96217. */
  96218. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96219. /**
  96220. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96221. * @param position The local position
  96222. * @param mesh The mesh that this bone is attached to
  96223. * @param result The vector3 that the world position should be copied to
  96224. */
  96225. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96226. /**
  96227. * Get the local position of a point that is in world space
  96228. * @param position The world position
  96229. * @param mesh The mesh that this bone is attached to
  96230. * @returns The local position
  96231. */
  96232. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96233. /**
  96234. * Get the local position of a point that is in world space and copy it to the result param
  96235. * @param position The world position
  96236. * @param mesh The mesh that this bone is attached to
  96237. * @param result The vector3 that the local position should be copied to
  96238. */
  96239. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96240. /**
  96241. * Set the current local matrix as the restPose for this bone.
  96242. */
  96243. setCurrentPoseAsRest(): void;
  96244. }
  96245. }
  96246. declare module BABYLON {
  96247. /**
  96248. * Defines a runtime animation
  96249. */
  96250. export class RuntimeAnimation {
  96251. private _events;
  96252. /**
  96253. * The current frame of the runtime animation
  96254. */
  96255. private _currentFrame;
  96256. /**
  96257. * The animation used by the runtime animation
  96258. */
  96259. private _animation;
  96260. /**
  96261. * The target of the runtime animation
  96262. */
  96263. private _target;
  96264. /**
  96265. * The initiating animatable
  96266. */
  96267. private _host;
  96268. /**
  96269. * The original value of the runtime animation
  96270. */
  96271. private _originalValue;
  96272. /**
  96273. * The original blend value of the runtime animation
  96274. */
  96275. private _originalBlendValue;
  96276. /**
  96277. * The offsets cache of the runtime animation
  96278. */
  96279. private _offsetsCache;
  96280. /**
  96281. * The high limits cache of the runtime animation
  96282. */
  96283. private _highLimitsCache;
  96284. /**
  96285. * Specifies if the runtime animation has been stopped
  96286. */
  96287. private _stopped;
  96288. /**
  96289. * The blending factor of the runtime animation
  96290. */
  96291. private _blendingFactor;
  96292. /**
  96293. * The BabylonJS scene
  96294. */
  96295. private _scene;
  96296. /**
  96297. * The current value of the runtime animation
  96298. */
  96299. private _currentValue;
  96300. /** @hidden */
  96301. _animationState: _IAnimationState;
  96302. /**
  96303. * The active target of the runtime animation
  96304. */
  96305. private _activeTargets;
  96306. private _currentActiveTarget;
  96307. private _directTarget;
  96308. /**
  96309. * The target path of the runtime animation
  96310. */
  96311. private _targetPath;
  96312. /**
  96313. * The weight of the runtime animation
  96314. */
  96315. private _weight;
  96316. /**
  96317. * The ratio offset of the runtime animation
  96318. */
  96319. private _ratioOffset;
  96320. /**
  96321. * The previous delay of the runtime animation
  96322. */
  96323. private _previousDelay;
  96324. /**
  96325. * The previous ratio of the runtime animation
  96326. */
  96327. private _previousRatio;
  96328. private _enableBlending;
  96329. private _keys;
  96330. private _minFrame;
  96331. private _maxFrame;
  96332. private _minValue;
  96333. private _maxValue;
  96334. private _targetIsArray;
  96335. /**
  96336. * Gets the current frame of the runtime animation
  96337. */
  96338. get currentFrame(): number;
  96339. /**
  96340. * Gets the weight of the runtime animation
  96341. */
  96342. get weight(): number;
  96343. /**
  96344. * Gets the current value of the runtime animation
  96345. */
  96346. get currentValue(): any;
  96347. /**
  96348. * Gets the target path of the runtime animation
  96349. */
  96350. get targetPath(): string;
  96351. /**
  96352. * Gets the actual target of the runtime animation
  96353. */
  96354. get target(): any;
  96355. /**
  96356. * Gets the additive state of the runtime animation
  96357. */
  96358. get isAdditive(): boolean;
  96359. /** @hidden */
  96360. _onLoop: () => void;
  96361. /**
  96362. * Create a new RuntimeAnimation object
  96363. * @param target defines the target of the animation
  96364. * @param animation defines the source animation object
  96365. * @param scene defines the hosting scene
  96366. * @param host defines the initiating Animatable
  96367. */
  96368. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96369. private _preparePath;
  96370. /**
  96371. * Gets the animation from the runtime animation
  96372. */
  96373. get animation(): Animation;
  96374. /**
  96375. * Resets the runtime animation to the beginning
  96376. * @param restoreOriginal defines whether to restore the target property to the original value
  96377. */
  96378. reset(restoreOriginal?: boolean): void;
  96379. /**
  96380. * Specifies if the runtime animation is stopped
  96381. * @returns Boolean specifying if the runtime animation is stopped
  96382. */
  96383. isStopped(): boolean;
  96384. /**
  96385. * Disposes of the runtime animation
  96386. */
  96387. dispose(): void;
  96388. /**
  96389. * Apply the interpolated value to the target
  96390. * @param currentValue defines the value computed by the animation
  96391. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96392. */
  96393. setValue(currentValue: any, weight: number): void;
  96394. private _getOriginalValues;
  96395. private _setValue;
  96396. /**
  96397. * Gets the loop pmode of the runtime animation
  96398. * @returns Loop Mode
  96399. */
  96400. private _getCorrectLoopMode;
  96401. /**
  96402. * Move the current animation to a given frame
  96403. * @param frame defines the frame to move to
  96404. */
  96405. goToFrame(frame: number): void;
  96406. /**
  96407. * @hidden Internal use only
  96408. */
  96409. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96410. /**
  96411. * Execute the current animation
  96412. * @param delay defines the delay to add to the current frame
  96413. * @param from defines the lower bound of the animation range
  96414. * @param to defines the upper bound of the animation range
  96415. * @param loop defines if the current animation must loop
  96416. * @param speedRatio defines the current speed ratio
  96417. * @param weight defines the weight of the animation (default is -1 so no weight)
  96418. * @param onLoop optional callback called when animation loops
  96419. * @returns a boolean indicating if the animation is running
  96420. */
  96421. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96422. }
  96423. }
  96424. declare module BABYLON {
  96425. /**
  96426. * Class used to store an actual running animation
  96427. */
  96428. export class Animatable {
  96429. /** defines the target object */
  96430. target: any;
  96431. /** defines the starting frame number (default is 0) */
  96432. fromFrame: number;
  96433. /** defines the ending frame number (default is 100) */
  96434. toFrame: number;
  96435. /** defines if the animation must loop (default is false) */
  96436. loopAnimation: boolean;
  96437. /** defines a callback to call when animation ends if it is not looping */
  96438. onAnimationEnd?: (() => void) | null | undefined;
  96439. /** defines a callback to call when animation loops */
  96440. onAnimationLoop?: (() => void) | null | undefined;
  96441. /** defines whether the animation should be evaluated additively */
  96442. isAdditive: boolean;
  96443. private _localDelayOffset;
  96444. private _pausedDelay;
  96445. private _runtimeAnimations;
  96446. private _paused;
  96447. private _scene;
  96448. private _speedRatio;
  96449. private _weight;
  96450. private _syncRoot;
  96451. /**
  96452. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96453. * This will only apply for non looping animation (default is true)
  96454. */
  96455. disposeOnEnd: boolean;
  96456. /**
  96457. * Gets a boolean indicating if the animation has started
  96458. */
  96459. animationStarted: boolean;
  96460. /**
  96461. * Observer raised when the animation ends
  96462. */
  96463. onAnimationEndObservable: Observable<Animatable>;
  96464. /**
  96465. * Observer raised when the animation loops
  96466. */
  96467. onAnimationLoopObservable: Observable<Animatable>;
  96468. /**
  96469. * Gets the root Animatable used to synchronize and normalize animations
  96470. */
  96471. get syncRoot(): Nullable<Animatable>;
  96472. /**
  96473. * Gets the current frame of the first RuntimeAnimation
  96474. * Used to synchronize Animatables
  96475. */
  96476. get masterFrame(): number;
  96477. /**
  96478. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96479. */
  96480. get weight(): number;
  96481. set weight(value: number);
  96482. /**
  96483. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96484. */
  96485. get speedRatio(): number;
  96486. set speedRatio(value: number);
  96487. /**
  96488. * Creates a new Animatable
  96489. * @param scene defines the hosting scene
  96490. * @param target defines the target object
  96491. * @param fromFrame defines the starting frame number (default is 0)
  96492. * @param toFrame defines the ending frame number (default is 100)
  96493. * @param loopAnimation defines if the animation must loop (default is false)
  96494. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96495. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96496. * @param animations defines a group of animation to add to the new Animatable
  96497. * @param onAnimationLoop defines a callback to call when animation loops
  96498. * @param isAdditive defines whether the animation should be evaluated additively
  96499. */
  96500. constructor(scene: Scene,
  96501. /** defines the target object */
  96502. target: any,
  96503. /** defines the starting frame number (default is 0) */
  96504. fromFrame?: number,
  96505. /** defines the ending frame number (default is 100) */
  96506. toFrame?: number,
  96507. /** defines if the animation must loop (default is false) */
  96508. loopAnimation?: boolean, speedRatio?: number,
  96509. /** defines a callback to call when animation ends if it is not looping */
  96510. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96511. /** defines a callback to call when animation loops */
  96512. onAnimationLoop?: (() => void) | null | undefined,
  96513. /** defines whether the animation should be evaluated additively */
  96514. isAdditive?: boolean);
  96515. /**
  96516. * Synchronize and normalize current Animatable with a source Animatable
  96517. * This is useful when using animation weights and when animations are not of the same length
  96518. * @param root defines the root Animatable to synchronize with
  96519. * @returns the current Animatable
  96520. */
  96521. syncWith(root: Animatable): Animatable;
  96522. /**
  96523. * Gets the list of runtime animations
  96524. * @returns an array of RuntimeAnimation
  96525. */
  96526. getAnimations(): RuntimeAnimation[];
  96527. /**
  96528. * Adds more animations to the current animatable
  96529. * @param target defines the target of the animations
  96530. * @param animations defines the new animations to add
  96531. */
  96532. appendAnimations(target: any, animations: Animation[]): void;
  96533. /**
  96534. * Gets the source animation for a specific property
  96535. * @param property defines the propertyu to look for
  96536. * @returns null or the source animation for the given property
  96537. */
  96538. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96539. /**
  96540. * Gets the runtime animation for a specific property
  96541. * @param property defines the propertyu to look for
  96542. * @returns null or the runtime animation for the given property
  96543. */
  96544. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96545. /**
  96546. * Resets the animatable to its original state
  96547. */
  96548. reset(): void;
  96549. /**
  96550. * Allows the animatable to blend with current running animations
  96551. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96552. * @param blendingSpeed defines the blending speed to use
  96553. */
  96554. enableBlending(blendingSpeed: number): void;
  96555. /**
  96556. * Disable animation blending
  96557. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96558. */
  96559. disableBlending(): void;
  96560. /**
  96561. * Jump directly to a given frame
  96562. * @param frame defines the frame to jump to
  96563. */
  96564. goToFrame(frame: number): void;
  96565. /**
  96566. * Pause the animation
  96567. */
  96568. pause(): void;
  96569. /**
  96570. * Restart the animation
  96571. */
  96572. restart(): void;
  96573. private _raiseOnAnimationEnd;
  96574. /**
  96575. * Stop and delete the current animation
  96576. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96577. * @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)
  96578. */
  96579. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96580. /**
  96581. * Wait asynchronously for the animation to end
  96582. * @returns a promise which will be fullfilled when the animation ends
  96583. */
  96584. waitAsync(): Promise<Animatable>;
  96585. /** @hidden */
  96586. _animate(delay: number): boolean;
  96587. }
  96588. interface Scene {
  96589. /** @hidden */
  96590. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96591. /** @hidden */
  96592. _processLateAnimationBindingsForMatrices(holder: {
  96593. totalWeight: number;
  96594. totalAdditiveWeight: number;
  96595. animations: RuntimeAnimation[];
  96596. additiveAnimations: RuntimeAnimation[];
  96597. originalValue: Matrix;
  96598. }): any;
  96599. /** @hidden */
  96600. _processLateAnimationBindingsForQuaternions(holder: {
  96601. totalWeight: number;
  96602. totalAdditiveWeight: number;
  96603. animations: RuntimeAnimation[];
  96604. additiveAnimations: RuntimeAnimation[];
  96605. originalValue: Quaternion;
  96606. }, refQuaternion: Quaternion): Quaternion;
  96607. /** @hidden */
  96608. _processLateAnimationBindings(): void;
  96609. /**
  96610. * Will start the animation sequence of a given target
  96611. * @param target defines the target
  96612. * @param from defines from which frame should animation start
  96613. * @param to defines until which frame should animation run.
  96614. * @param weight defines the weight to apply to the animation (1.0 by default)
  96615. * @param loop defines if the animation loops
  96616. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96617. * @param onAnimationEnd defines the function to be executed when the animation ends
  96618. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96619. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96620. * @param onAnimationLoop defines the callback to call when an animation loops
  96621. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96622. * @returns the animatable object created for this animation
  96623. */
  96624. 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;
  96625. /**
  96626. * Will start the animation sequence of a given target
  96627. * @param target defines the target
  96628. * @param from defines from which frame should animation start
  96629. * @param to defines until which frame should animation run.
  96630. * @param loop defines if the animation loops
  96631. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96632. * @param onAnimationEnd defines the function to be executed when the animation ends
  96633. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96634. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96635. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96636. * @param onAnimationLoop defines the callback to call when an animation loops
  96637. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96638. * @returns the animatable object created for this animation
  96639. */
  96640. 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;
  96641. /**
  96642. * Will start the animation sequence of a given target and its hierarchy
  96643. * @param target defines the target
  96644. * @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.
  96645. * @param from defines from which frame should animation start
  96646. * @param to defines until which frame should animation run.
  96647. * @param loop defines if the animation loops
  96648. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96649. * @param onAnimationEnd defines the function to be executed when the animation ends
  96650. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96651. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96652. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96653. * @param onAnimationLoop defines the callback to call when an animation loops
  96654. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96655. * @returns the list of created animatables
  96656. */
  96657. 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[];
  96658. /**
  96659. * Begin a new animation on a given node
  96660. * @param target defines the target where the animation will take place
  96661. * @param animations defines the list of animations to start
  96662. * @param from defines the initial value
  96663. * @param to defines the final value
  96664. * @param loop defines if you want animation to loop (off by default)
  96665. * @param speedRatio defines the speed ratio to apply to all animations
  96666. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96667. * @param onAnimationLoop defines the callback to call when an animation loops
  96668. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96669. * @returns the list of created animatables
  96670. */
  96671. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96672. /**
  96673. * Begin a new animation on a given node and its hierarchy
  96674. * @param target defines the root node where the animation will take place
  96675. * @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.
  96676. * @param animations defines the list of animations to start
  96677. * @param from defines the initial value
  96678. * @param to defines the final value
  96679. * @param loop defines if you want animation to loop (off by default)
  96680. * @param speedRatio defines the speed ratio to apply to all animations
  96681. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96682. * @param onAnimationLoop defines the callback to call when an animation loops
  96683. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96684. * @returns the list of animatables created for all nodes
  96685. */
  96686. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96687. /**
  96688. * Gets the animatable associated with a specific target
  96689. * @param target defines the target of the animatable
  96690. * @returns the required animatable if found
  96691. */
  96692. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96693. /**
  96694. * Gets all animatables associated with a given target
  96695. * @param target defines the target to look animatables for
  96696. * @returns an array of Animatables
  96697. */
  96698. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96699. /**
  96700. * Stops and removes all animations that have been applied to the scene
  96701. */
  96702. stopAllAnimations(): void;
  96703. /**
  96704. * Gets the current delta time used by animation engine
  96705. */
  96706. deltaTime: number;
  96707. }
  96708. interface Bone {
  96709. /**
  96710. * Copy an animation range from another bone
  96711. * @param source defines the source bone
  96712. * @param rangeName defines the range name to copy
  96713. * @param frameOffset defines the frame offset
  96714. * @param rescaleAsRequired defines if rescaling must be applied if required
  96715. * @param skelDimensionsRatio defines the scaling ratio
  96716. * @returns true if operation was successful
  96717. */
  96718. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96719. }
  96720. }
  96721. declare module BABYLON {
  96722. /**
  96723. * Class used to handle skinning animations
  96724. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96725. */
  96726. export class Skeleton implements IAnimatable {
  96727. /** defines the skeleton name */
  96728. name: string;
  96729. /** defines the skeleton Id */
  96730. id: string;
  96731. /**
  96732. * Defines the list of child bones
  96733. */
  96734. bones: Bone[];
  96735. /**
  96736. * Defines an estimate of the dimension of the skeleton at rest
  96737. */
  96738. dimensionsAtRest: Vector3;
  96739. /**
  96740. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96741. */
  96742. needInitialSkinMatrix: boolean;
  96743. /**
  96744. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96745. */
  96746. overrideMesh: Nullable<AbstractMesh>;
  96747. /**
  96748. * Gets the list of animations attached to this skeleton
  96749. */
  96750. animations: Array<Animation>;
  96751. private _scene;
  96752. private _isDirty;
  96753. private _transformMatrices;
  96754. private _transformMatrixTexture;
  96755. private _meshesWithPoseMatrix;
  96756. private _animatables;
  96757. private _identity;
  96758. private _synchronizedWithMesh;
  96759. private _ranges;
  96760. private _lastAbsoluteTransformsUpdateId;
  96761. private _canUseTextureForBones;
  96762. private _uniqueId;
  96763. /** @hidden */
  96764. _numBonesWithLinkedTransformNode: number;
  96765. /** @hidden */
  96766. _hasWaitingData: Nullable<boolean>;
  96767. /** @hidden */
  96768. _waitingOverrideMeshId: Nullable<string>;
  96769. /**
  96770. * Specifies if the skeleton should be serialized
  96771. */
  96772. doNotSerialize: boolean;
  96773. private _useTextureToStoreBoneMatrices;
  96774. /**
  96775. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96776. * Please note that this option is not available if the hardware does not support it
  96777. */
  96778. get useTextureToStoreBoneMatrices(): boolean;
  96779. set useTextureToStoreBoneMatrices(value: boolean);
  96780. private _animationPropertiesOverride;
  96781. /**
  96782. * Gets or sets the animation properties override
  96783. */
  96784. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96785. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96786. /**
  96787. * List of inspectable custom properties (used by the Inspector)
  96788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96789. */
  96790. inspectableCustomProperties: IInspectable[];
  96791. /**
  96792. * An observable triggered before computing the skeleton's matrices
  96793. */
  96794. onBeforeComputeObservable: Observable<Skeleton>;
  96795. /**
  96796. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96797. */
  96798. get isUsingTextureForMatrices(): boolean;
  96799. /**
  96800. * Gets the unique ID of this skeleton
  96801. */
  96802. get uniqueId(): number;
  96803. /**
  96804. * Creates a new skeleton
  96805. * @param name defines the skeleton name
  96806. * @param id defines the skeleton Id
  96807. * @param scene defines the hosting scene
  96808. */
  96809. constructor(
  96810. /** defines the skeleton name */
  96811. name: string,
  96812. /** defines the skeleton Id */
  96813. id: string, scene: Scene);
  96814. /**
  96815. * Gets the current object class name.
  96816. * @return the class name
  96817. */
  96818. getClassName(): string;
  96819. /**
  96820. * Returns an array containing the root bones
  96821. * @returns an array containing the root bones
  96822. */
  96823. getChildren(): Array<Bone>;
  96824. /**
  96825. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96826. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96827. * @returns a Float32Array containing matrices data
  96828. */
  96829. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96830. /**
  96831. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96832. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96833. * @returns a raw texture containing the data
  96834. */
  96835. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96836. /**
  96837. * Gets the current hosting scene
  96838. * @returns a scene object
  96839. */
  96840. getScene(): Scene;
  96841. /**
  96842. * Gets a string representing the current skeleton data
  96843. * @param fullDetails defines a boolean indicating if we want a verbose version
  96844. * @returns a string representing the current skeleton data
  96845. */
  96846. toString(fullDetails?: boolean): string;
  96847. /**
  96848. * Get bone's index searching by name
  96849. * @param name defines bone's name to search for
  96850. * @return the indice of the bone. Returns -1 if not found
  96851. */
  96852. getBoneIndexByName(name: string): number;
  96853. /**
  96854. * Creater a new animation range
  96855. * @param name defines the name of the range
  96856. * @param from defines the start key
  96857. * @param to defines the end key
  96858. */
  96859. createAnimationRange(name: string, from: number, to: number): void;
  96860. /**
  96861. * Delete a specific animation range
  96862. * @param name defines the name of the range
  96863. * @param deleteFrames defines if frames must be removed as well
  96864. */
  96865. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96866. /**
  96867. * Gets a specific animation range
  96868. * @param name defines the name of the range to look for
  96869. * @returns the requested animation range or null if not found
  96870. */
  96871. getAnimationRange(name: string): Nullable<AnimationRange>;
  96872. /**
  96873. * Gets the list of all animation ranges defined on this skeleton
  96874. * @returns an array
  96875. */
  96876. getAnimationRanges(): Nullable<AnimationRange>[];
  96877. /**
  96878. * Copy animation range from a source skeleton.
  96879. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96880. * @param source defines the source skeleton
  96881. * @param name defines the name of the range to copy
  96882. * @param rescaleAsRequired defines if rescaling must be applied if required
  96883. * @returns true if operation was successful
  96884. */
  96885. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96886. /**
  96887. * Forces the skeleton to go to rest pose
  96888. */
  96889. returnToRest(): void;
  96890. private _getHighestAnimationFrame;
  96891. /**
  96892. * Begin a specific animation range
  96893. * @param name defines the name of the range to start
  96894. * @param loop defines if looping must be turned on (false by default)
  96895. * @param speedRatio defines the speed ratio to apply (1 by default)
  96896. * @param onAnimationEnd defines a callback which will be called when animation will end
  96897. * @returns a new animatable
  96898. */
  96899. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96900. /**
  96901. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96902. * @param skeleton defines the Skeleton containing the animation range to convert
  96903. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96904. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96905. * @returns the original skeleton
  96906. */
  96907. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96908. /** @hidden */
  96909. _markAsDirty(): void;
  96910. /** @hidden */
  96911. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96912. /** @hidden */
  96913. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96914. private _computeTransformMatrices;
  96915. /**
  96916. * Build all resources required to render a skeleton
  96917. */
  96918. prepare(): void;
  96919. /**
  96920. * Gets the list of animatables currently running for this skeleton
  96921. * @returns an array of animatables
  96922. */
  96923. getAnimatables(): IAnimatable[];
  96924. /**
  96925. * Clone the current skeleton
  96926. * @param name defines the name of the new skeleton
  96927. * @param id defines the id of the new skeleton
  96928. * @returns the new skeleton
  96929. */
  96930. clone(name: string, id?: string): Skeleton;
  96931. /**
  96932. * Enable animation blending for this skeleton
  96933. * @param blendingSpeed defines the blending speed to apply
  96934. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96935. */
  96936. enableBlending(blendingSpeed?: number): void;
  96937. /**
  96938. * Releases all resources associated with the current skeleton
  96939. */
  96940. dispose(): void;
  96941. /**
  96942. * Serialize the skeleton in a JSON object
  96943. * @returns a JSON object
  96944. */
  96945. serialize(): any;
  96946. /**
  96947. * Creates a new skeleton from serialized data
  96948. * @param parsedSkeleton defines the serialized data
  96949. * @param scene defines the hosting scene
  96950. * @returns a new skeleton
  96951. */
  96952. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96953. /**
  96954. * Compute all node absolute transforms
  96955. * @param forceUpdate defines if computation must be done even if cache is up to date
  96956. */
  96957. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96958. /**
  96959. * Gets the root pose matrix
  96960. * @returns a matrix
  96961. */
  96962. getPoseMatrix(): Nullable<Matrix>;
  96963. /**
  96964. * Sorts bones per internal index
  96965. */
  96966. sortBones(): void;
  96967. private _sortBones;
  96968. /**
  96969. * Set the current local matrix as the restPose for all bones in the skeleton.
  96970. */
  96971. setCurrentPoseAsRest(): void;
  96972. }
  96973. }
  96974. declare module BABYLON {
  96975. /**
  96976. * Creates an instance based on a source mesh.
  96977. */
  96978. export class InstancedMesh extends AbstractMesh {
  96979. private _sourceMesh;
  96980. private _currentLOD;
  96981. /** @hidden */
  96982. _indexInSourceMeshInstanceArray: number;
  96983. constructor(name: string, source: Mesh);
  96984. /**
  96985. * Returns the string "InstancedMesh".
  96986. */
  96987. getClassName(): string;
  96988. /** Gets the list of lights affecting that mesh */
  96989. get lightSources(): Light[];
  96990. _resyncLightSources(): void;
  96991. _resyncLightSource(light: Light): void;
  96992. _removeLightSource(light: Light, dispose: boolean): void;
  96993. /**
  96994. * If the source mesh receives shadows
  96995. */
  96996. get receiveShadows(): boolean;
  96997. /**
  96998. * The material of the source mesh
  96999. */
  97000. get material(): Nullable<Material>;
  97001. /**
  97002. * Visibility of the source mesh
  97003. */
  97004. get visibility(): number;
  97005. /**
  97006. * Skeleton of the source mesh
  97007. */
  97008. get skeleton(): Nullable<Skeleton>;
  97009. /**
  97010. * Rendering ground id of the source mesh
  97011. */
  97012. get renderingGroupId(): number;
  97013. set renderingGroupId(value: number);
  97014. /**
  97015. * Returns the total number of vertices (integer).
  97016. */
  97017. getTotalVertices(): number;
  97018. /**
  97019. * Returns a positive integer : the total number of indices in this mesh geometry.
  97020. * @returns the numner of indices or zero if the mesh has no geometry.
  97021. */
  97022. getTotalIndices(): number;
  97023. /**
  97024. * The source mesh of the instance
  97025. */
  97026. get sourceMesh(): Mesh;
  97027. /**
  97028. * Creates a new InstancedMesh object from the mesh model.
  97029. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97030. * @param name defines the name of the new instance
  97031. * @returns a new InstancedMesh
  97032. */
  97033. createInstance(name: string): InstancedMesh;
  97034. /**
  97035. * Is this node ready to be used/rendered
  97036. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97037. * @return {boolean} is it ready
  97038. */
  97039. isReady(completeCheck?: boolean): boolean;
  97040. /**
  97041. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97042. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97043. * @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.
  97044. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97045. */
  97046. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97047. /**
  97048. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97049. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97050. * The `data` are either a numeric array either a Float32Array.
  97051. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97052. * 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).
  97053. * Note that a new underlying VertexBuffer object is created each call.
  97054. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97055. *
  97056. * Possible `kind` values :
  97057. * - VertexBuffer.PositionKind
  97058. * - VertexBuffer.UVKind
  97059. * - VertexBuffer.UV2Kind
  97060. * - VertexBuffer.UV3Kind
  97061. * - VertexBuffer.UV4Kind
  97062. * - VertexBuffer.UV5Kind
  97063. * - VertexBuffer.UV6Kind
  97064. * - VertexBuffer.ColorKind
  97065. * - VertexBuffer.MatricesIndicesKind
  97066. * - VertexBuffer.MatricesIndicesExtraKind
  97067. * - VertexBuffer.MatricesWeightsKind
  97068. * - VertexBuffer.MatricesWeightsExtraKind
  97069. *
  97070. * Returns the Mesh.
  97071. */
  97072. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97073. /**
  97074. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97075. * If the mesh has no geometry, it is simply returned as it is.
  97076. * The `data` are either a numeric array either a Float32Array.
  97077. * No new underlying VertexBuffer object is created.
  97078. * 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.
  97079. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97080. *
  97081. * Possible `kind` values :
  97082. * - VertexBuffer.PositionKind
  97083. * - VertexBuffer.UVKind
  97084. * - VertexBuffer.UV2Kind
  97085. * - VertexBuffer.UV3Kind
  97086. * - VertexBuffer.UV4Kind
  97087. * - VertexBuffer.UV5Kind
  97088. * - VertexBuffer.UV6Kind
  97089. * - VertexBuffer.ColorKind
  97090. * - VertexBuffer.MatricesIndicesKind
  97091. * - VertexBuffer.MatricesIndicesExtraKind
  97092. * - VertexBuffer.MatricesWeightsKind
  97093. * - VertexBuffer.MatricesWeightsExtraKind
  97094. *
  97095. * Returns the Mesh.
  97096. */
  97097. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97098. /**
  97099. * Sets the mesh indices.
  97100. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97101. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97102. * This method creates a new index buffer each call.
  97103. * Returns the Mesh.
  97104. */
  97105. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97106. /**
  97107. * Boolean : True if the mesh owns the requested kind of data.
  97108. */
  97109. isVerticesDataPresent(kind: string): boolean;
  97110. /**
  97111. * Returns an array of indices (IndicesArray).
  97112. */
  97113. getIndices(): Nullable<IndicesArray>;
  97114. get _positions(): Nullable<Vector3[]>;
  97115. /**
  97116. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97117. * This means the mesh underlying bounding box and sphere are recomputed.
  97118. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97119. * @returns the current mesh
  97120. */
  97121. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97122. /** @hidden */
  97123. _preActivate(): InstancedMesh;
  97124. /** @hidden */
  97125. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97126. /** @hidden */
  97127. _postActivate(): void;
  97128. getWorldMatrix(): Matrix;
  97129. get isAnInstance(): boolean;
  97130. /**
  97131. * Returns the current associated LOD AbstractMesh.
  97132. */
  97133. getLOD(camera: Camera): AbstractMesh;
  97134. /** @hidden */
  97135. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97136. /** @hidden */
  97137. _syncSubMeshes(): InstancedMesh;
  97138. /** @hidden */
  97139. _generatePointsArray(): boolean;
  97140. /** @hidden */
  97141. _updateBoundingInfo(): AbstractMesh;
  97142. /**
  97143. * Creates a new InstancedMesh from the current mesh.
  97144. * - name (string) : the cloned mesh name
  97145. * - newParent (optional Node) : the optional Node to parent the clone to.
  97146. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97147. *
  97148. * Returns the clone.
  97149. */
  97150. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97151. /**
  97152. * Disposes the InstancedMesh.
  97153. * Returns nothing.
  97154. */
  97155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97156. }
  97157. interface Mesh {
  97158. /**
  97159. * Register a custom buffer that will be instanced
  97160. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97161. * @param kind defines the buffer kind
  97162. * @param stride defines the stride in floats
  97163. */
  97164. registerInstancedBuffer(kind: string, stride: number): void;
  97165. /**
  97166. * true to use the edge renderer for all instances of this mesh
  97167. */
  97168. edgesShareWithInstances: boolean;
  97169. /** @hidden */
  97170. _userInstancedBuffersStorage: {
  97171. data: {
  97172. [key: string]: Float32Array;
  97173. };
  97174. sizes: {
  97175. [key: string]: number;
  97176. };
  97177. vertexBuffers: {
  97178. [key: string]: Nullable<VertexBuffer>;
  97179. };
  97180. strides: {
  97181. [key: string]: number;
  97182. };
  97183. };
  97184. }
  97185. interface AbstractMesh {
  97186. /**
  97187. * Object used to store instanced buffers defined by user
  97188. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97189. */
  97190. instancedBuffers: {
  97191. [key: string]: any;
  97192. };
  97193. }
  97194. }
  97195. declare module BABYLON {
  97196. /**
  97197. * Defines the options associated with the creation of a shader material.
  97198. */
  97199. export interface IShaderMaterialOptions {
  97200. /**
  97201. * Does the material work in alpha blend mode
  97202. */
  97203. needAlphaBlending: boolean;
  97204. /**
  97205. * Does the material work in alpha test mode
  97206. */
  97207. needAlphaTesting: boolean;
  97208. /**
  97209. * The list of attribute names used in the shader
  97210. */
  97211. attributes: string[];
  97212. /**
  97213. * The list of unifrom names used in the shader
  97214. */
  97215. uniforms: string[];
  97216. /**
  97217. * The list of UBO names used in the shader
  97218. */
  97219. uniformBuffers: string[];
  97220. /**
  97221. * The list of sampler names used in the shader
  97222. */
  97223. samplers: string[];
  97224. /**
  97225. * The list of defines used in the shader
  97226. */
  97227. defines: string[];
  97228. }
  97229. /**
  97230. * 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.
  97231. *
  97232. * This returned material effects how the mesh will look based on the code in the shaders.
  97233. *
  97234. * @see https://doc.babylonjs.com/how_to/shader_material
  97235. */
  97236. export class ShaderMaterial extends Material {
  97237. private _shaderPath;
  97238. private _options;
  97239. private _textures;
  97240. private _textureArrays;
  97241. private _floats;
  97242. private _ints;
  97243. private _floatsArrays;
  97244. private _colors3;
  97245. private _colors3Arrays;
  97246. private _colors4;
  97247. private _colors4Arrays;
  97248. private _vectors2;
  97249. private _vectors3;
  97250. private _vectors4;
  97251. private _matrices;
  97252. private _matrixArrays;
  97253. private _matrices3x3;
  97254. private _matrices2x2;
  97255. private _vectors2Arrays;
  97256. private _vectors3Arrays;
  97257. private _vectors4Arrays;
  97258. private _cachedWorldViewMatrix;
  97259. private _cachedWorldViewProjectionMatrix;
  97260. private _renderId;
  97261. private _multiview;
  97262. private _cachedDefines;
  97263. /** Define the Url to load snippets */
  97264. static SnippetUrl: string;
  97265. /** Snippet ID if the material was created from the snippet server */
  97266. snippetId: string;
  97267. /**
  97268. * Instantiate a new shader material.
  97269. * 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.
  97270. * This returned material effects how the mesh will look based on the code in the shaders.
  97271. * @see https://doc.babylonjs.com/how_to/shader_material
  97272. * @param name Define the name of the material in the scene
  97273. * @param scene Define the scene the material belongs to
  97274. * @param shaderPath Defines the route to the shader code in one of three ways:
  97275. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97276. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97277. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97278. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97279. * @param options Define the options used to create the shader
  97280. */
  97281. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97282. /**
  97283. * Gets the shader path used to define the shader code
  97284. * It can be modified to trigger a new compilation
  97285. */
  97286. get shaderPath(): any;
  97287. /**
  97288. * Sets the shader path used to define the shader code
  97289. * It can be modified to trigger a new compilation
  97290. */
  97291. set shaderPath(shaderPath: any);
  97292. /**
  97293. * Gets the options used to compile the shader.
  97294. * They can be modified to trigger a new compilation
  97295. */
  97296. get options(): IShaderMaterialOptions;
  97297. /**
  97298. * Gets the current class name of the material e.g. "ShaderMaterial"
  97299. * Mainly use in serialization.
  97300. * @returns the class name
  97301. */
  97302. getClassName(): string;
  97303. /**
  97304. * Specifies if the material will require alpha blending
  97305. * @returns a boolean specifying if alpha blending is needed
  97306. */
  97307. needAlphaBlending(): boolean;
  97308. /**
  97309. * Specifies if this material should be rendered in alpha test mode
  97310. * @returns a boolean specifying if an alpha test is needed.
  97311. */
  97312. needAlphaTesting(): boolean;
  97313. private _checkUniform;
  97314. /**
  97315. * Set a texture in the shader.
  97316. * @param name Define the name of the uniform samplers as defined in the shader
  97317. * @param texture Define the texture to bind to this sampler
  97318. * @return the material itself allowing "fluent" like uniform updates
  97319. */
  97320. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97321. /**
  97322. * Set a texture array in the shader.
  97323. * @param name Define the name of the uniform sampler array as defined in the shader
  97324. * @param textures Define the list of textures to bind to this sampler
  97325. * @return the material itself allowing "fluent" like uniform updates
  97326. */
  97327. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97328. /**
  97329. * Set a float in the shader.
  97330. * @param name Define the name of the uniform as defined in the shader
  97331. * @param value Define the value to give to the uniform
  97332. * @return the material itself allowing "fluent" like uniform updates
  97333. */
  97334. setFloat(name: string, value: number): ShaderMaterial;
  97335. /**
  97336. * Set a int in the shader.
  97337. * @param name Define the name of the uniform as defined in the shader
  97338. * @param value Define the value to give to the uniform
  97339. * @return the material itself allowing "fluent" like uniform updates
  97340. */
  97341. setInt(name: string, value: number): ShaderMaterial;
  97342. /**
  97343. * Set an array of floats in the shader.
  97344. * @param name Define the name of the uniform as defined in the shader
  97345. * @param value Define the value to give to the uniform
  97346. * @return the material itself allowing "fluent" like uniform updates
  97347. */
  97348. setFloats(name: string, value: number[]): ShaderMaterial;
  97349. /**
  97350. * Set a vec3 in the shader from a Color3.
  97351. * @param name Define the name of the uniform as defined in the shader
  97352. * @param value Define the value to give to the uniform
  97353. * @return the material itself allowing "fluent" like uniform updates
  97354. */
  97355. setColor3(name: string, value: Color3): ShaderMaterial;
  97356. /**
  97357. * Set a vec3 array in the shader from a Color3 array.
  97358. * @param name Define the name of the uniform as defined in the shader
  97359. * @param value Define the value to give to the uniform
  97360. * @return the material itself allowing "fluent" like uniform updates
  97361. */
  97362. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97363. /**
  97364. * Set a vec4 in the shader from a Color4.
  97365. * @param name Define the name of the uniform as defined in the shader
  97366. * @param value Define the value to give to the uniform
  97367. * @return the material itself allowing "fluent" like uniform updates
  97368. */
  97369. setColor4(name: string, value: Color4): ShaderMaterial;
  97370. /**
  97371. * Set a vec4 array in the shader from a Color4 array.
  97372. * @param name Define the name of the uniform as defined in the shader
  97373. * @param value Define the value to give to the uniform
  97374. * @return the material itself allowing "fluent" like uniform updates
  97375. */
  97376. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97377. /**
  97378. * Set a vec2 in the shader from a Vector2.
  97379. * @param name Define the name of the uniform as defined in the shader
  97380. * @param value Define the value to give to the uniform
  97381. * @return the material itself allowing "fluent" like uniform updates
  97382. */
  97383. setVector2(name: string, value: Vector2): ShaderMaterial;
  97384. /**
  97385. * Set a vec3 in the shader from a Vector3.
  97386. * @param name Define the name of the uniform as defined in the shader
  97387. * @param value Define the value to give to the uniform
  97388. * @return the material itself allowing "fluent" like uniform updates
  97389. */
  97390. setVector3(name: string, value: Vector3): ShaderMaterial;
  97391. /**
  97392. * Set a vec4 in the shader from a Vector4.
  97393. * @param name Define the name of the uniform as defined in the shader
  97394. * @param value Define the value to give to the uniform
  97395. * @return the material itself allowing "fluent" like uniform updates
  97396. */
  97397. setVector4(name: string, value: Vector4): ShaderMaterial;
  97398. /**
  97399. * Set a mat4 in the shader from a Matrix.
  97400. * @param name Define the name of the uniform as defined in the shader
  97401. * @param value Define the value to give to the uniform
  97402. * @return the material itself allowing "fluent" like uniform updates
  97403. */
  97404. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97405. /**
  97406. * Set a float32Array in the shader from a matrix array.
  97407. * @param name Define the name of the uniform as defined in the shader
  97408. * @param value Define the value to give to the uniform
  97409. * @return the material itself allowing "fluent" like uniform updates
  97410. */
  97411. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97412. /**
  97413. * Set a mat3 in the shader from a Float32Array.
  97414. * @param name Define the name of the uniform as defined in the shader
  97415. * @param value Define the value to give to the uniform
  97416. * @return the material itself allowing "fluent" like uniform updates
  97417. */
  97418. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97419. /**
  97420. * Set a mat2 in the shader from a Float32Array.
  97421. * @param name Define the name of the uniform as defined in the shader
  97422. * @param value Define the value to give to the uniform
  97423. * @return the material itself allowing "fluent" like uniform updates
  97424. */
  97425. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97426. /**
  97427. * Set a vec2 array in the shader from a number array.
  97428. * @param name Define the name of the uniform as defined in the shader
  97429. * @param value Define the value to give to the uniform
  97430. * @return the material itself allowing "fluent" like uniform updates
  97431. */
  97432. setArray2(name: string, value: number[]): ShaderMaterial;
  97433. /**
  97434. * Set a vec3 array in the shader from a number array.
  97435. * @param name Define the name of the uniform as defined in the shader
  97436. * @param value Define the value to give to the uniform
  97437. * @return the material itself allowing "fluent" like uniform updates
  97438. */
  97439. setArray3(name: string, value: number[]): ShaderMaterial;
  97440. /**
  97441. * Set a vec4 array in the shader from a number array.
  97442. * @param name Define the name of the uniform as defined in the shader
  97443. * @param value Define the value to give to the uniform
  97444. * @return the material itself allowing "fluent" like uniform updates
  97445. */
  97446. setArray4(name: string, value: number[]): ShaderMaterial;
  97447. private _checkCache;
  97448. /**
  97449. * Specifies that the submesh is ready to be used
  97450. * @param mesh defines the mesh to check
  97451. * @param subMesh defines which submesh to check
  97452. * @param useInstances specifies that instances should be used
  97453. * @returns a boolean indicating that the submesh is ready or not
  97454. */
  97455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97456. /**
  97457. * Checks if the material is ready to render the requested mesh
  97458. * @param mesh Define the mesh to render
  97459. * @param useInstances Define whether or not the material is used with instances
  97460. * @returns true if ready, otherwise false
  97461. */
  97462. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97463. /**
  97464. * Binds the world matrix to the material
  97465. * @param world defines the world transformation matrix
  97466. * @param effectOverride - If provided, use this effect instead of internal effect
  97467. */
  97468. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97469. /**
  97470. * Binds the submesh to this material by preparing the effect and shader to draw
  97471. * @param world defines the world transformation matrix
  97472. * @param mesh defines the mesh containing the submesh
  97473. * @param subMesh defines the submesh to bind the material to
  97474. */
  97475. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97476. /**
  97477. * Binds the material to the mesh
  97478. * @param world defines the world transformation matrix
  97479. * @param mesh defines the mesh to bind the material to
  97480. * @param effectOverride - If provided, use this effect instead of internal effect
  97481. */
  97482. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97483. protected _afterBind(mesh?: Mesh): void;
  97484. /**
  97485. * Gets the active textures from the material
  97486. * @returns an array of textures
  97487. */
  97488. getActiveTextures(): BaseTexture[];
  97489. /**
  97490. * Specifies if the material uses a texture
  97491. * @param texture defines the texture to check against the material
  97492. * @returns a boolean specifying if the material uses the texture
  97493. */
  97494. hasTexture(texture: BaseTexture): boolean;
  97495. /**
  97496. * Makes a duplicate of the material, and gives it a new name
  97497. * @param name defines the new name for the duplicated material
  97498. * @returns the cloned material
  97499. */
  97500. clone(name: string): ShaderMaterial;
  97501. /**
  97502. * Disposes the material
  97503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97506. */
  97507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97508. /**
  97509. * Serializes this material in a JSON representation
  97510. * @returns the serialized material object
  97511. */
  97512. serialize(): any;
  97513. /**
  97514. * Creates a shader material from parsed shader material data
  97515. * @param source defines the JSON represnetation of the material
  97516. * @param scene defines the hosting scene
  97517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97518. * @returns a new material
  97519. */
  97520. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97521. /**
  97522. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97523. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97524. * @param url defines the url to load from
  97525. * @param scene defines the hosting scene
  97526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97527. * @returns a promise that will resolve to the new ShaderMaterial
  97528. */
  97529. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97530. /**
  97531. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97532. * @param snippetId defines the snippet to load
  97533. * @param scene defines the hosting scene
  97534. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97535. * @returns a promise that will resolve to the new ShaderMaterial
  97536. */
  97537. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97538. }
  97539. }
  97540. declare module BABYLON {
  97541. /** @hidden */
  97542. export var colorPixelShader: {
  97543. name: string;
  97544. shader: string;
  97545. };
  97546. }
  97547. declare module BABYLON {
  97548. /** @hidden */
  97549. export var colorVertexShader: {
  97550. name: string;
  97551. shader: string;
  97552. };
  97553. }
  97554. declare module BABYLON {
  97555. /**
  97556. * Line mesh
  97557. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97558. */
  97559. export class LinesMesh extends Mesh {
  97560. /**
  97561. * If vertex color should be applied to the mesh
  97562. */
  97563. readonly useVertexColor?: boolean | undefined;
  97564. /**
  97565. * If vertex alpha should be applied to the mesh
  97566. */
  97567. readonly useVertexAlpha?: boolean | undefined;
  97568. /**
  97569. * Color of the line (Default: White)
  97570. */
  97571. color: Color3;
  97572. /**
  97573. * Alpha of the line (Default: 1)
  97574. */
  97575. alpha: number;
  97576. /**
  97577. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97578. * This margin is expressed in world space coordinates, so its value may vary.
  97579. * Default value is 0.1
  97580. */
  97581. intersectionThreshold: number;
  97582. private _colorShader;
  97583. private color4;
  97584. /**
  97585. * Creates a new LinesMesh
  97586. * @param name defines the name
  97587. * @param scene defines the hosting scene
  97588. * @param parent defines the parent mesh if any
  97589. * @param source defines the optional source LinesMesh used to clone data from
  97590. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97591. * When false, achieved by calling a clone(), also passing False.
  97592. * This will make creation of children, recursive.
  97593. * @param useVertexColor defines if this LinesMesh supports vertex color
  97594. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97595. */
  97596. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97597. /**
  97598. * If vertex color should be applied to the mesh
  97599. */
  97600. useVertexColor?: boolean | undefined,
  97601. /**
  97602. * If vertex alpha should be applied to the mesh
  97603. */
  97604. useVertexAlpha?: boolean | undefined);
  97605. private _addClipPlaneDefine;
  97606. private _removeClipPlaneDefine;
  97607. isReady(): boolean;
  97608. /**
  97609. * Returns the string "LineMesh"
  97610. */
  97611. getClassName(): string;
  97612. /**
  97613. * @hidden
  97614. */
  97615. get material(): Material;
  97616. /**
  97617. * @hidden
  97618. */
  97619. set material(value: Material);
  97620. /**
  97621. * @hidden
  97622. */
  97623. get checkCollisions(): boolean;
  97624. /** @hidden */
  97625. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97626. /** @hidden */
  97627. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97628. /**
  97629. * Disposes of the line mesh
  97630. * @param doNotRecurse If children should be disposed
  97631. */
  97632. dispose(doNotRecurse?: boolean): void;
  97633. /**
  97634. * Returns a new LineMesh object cloned from the current one.
  97635. */
  97636. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97637. /**
  97638. * Creates a new InstancedLinesMesh object from the mesh model.
  97639. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97640. * @param name defines the name of the new instance
  97641. * @returns a new InstancedLinesMesh
  97642. */
  97643. createInstance(name: string): InstancedLinesMesh;
  97644. }
  97645. /**
  97646. * Creates an instance based on a source LinesMesh
  97647. */
  97648. export class InstancedLinesMesh extends InstancedMesh {
  97649. /**
  97650. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97651. * This margin is expressed in world space coordinates, so its value may vary.
  97652. * Initilized with the intersectionThreshold value of the source LinesMesh
  97653. */
  97654. intersectionThreshold: number;
  97655. constructor(name: string, source: LinesMesh);
  97656. /**
  97657. * Returns the string "InstancedLinesMesh".
  97658. */
  97659. getClassName(): string;
  97660. }
  97661. }
  97662. declare module BABYLON {
  97663. /** @hidden */
  97664. export var linePixelShader: {
  97665. name: string;
  97666. shader: string;
  97667. };
  97668. }
  97669. declare module BABYLON {
  97670. /** @hidden */
  97671. export var lineVertexShader: {
  97672. name: string;
  97673. shader: string;
  97674. };
  97675. }
  97676. declare module BABYLON {
  97677. interface Scene {
  97678. /** @hidden */
  97679. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97680. }
  97681. interface AbstractMesh {
  97682. /**
  97683. * Gets the edgesRenderer associated with the mesh
  97684. */
  97685. edgesRenderer: Nullable<EdgesRenderer>;
  97686. }
  97687. interface LinesMesh {
  97688. /**
  97689. * Enables the edge rendering mode on the mesh.
  97690. * This mode makes the mesh edges visible
  97691. * @param epsilon defines the maximal distance between two angles to detect a face
  97692. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97693. * @returns the currentAbstractMesh
  97694. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97695. */
  97696. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97697. }
  97698. interface InstancedLinesMesh {
  97699. /**
  97700. * Enables the edge rendering mode on the mesh.
  97701. * This mode makes the mesh edges visible
  97702. * @param epsilon defines the maximal distance between two angles to detect a face
  97703. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97704. * @returns the current InstancedLinesMesh
  97705. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97706. */
  97707. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97708. }
  97709. /**
  97710. * Defines the minimum contract an Edges renderer should follow.
  97711. */
  97712. export interface IEdgesRenderer extends IDisposable {
  97713. /**
  97714. * Gets or sets a boolean indicating if the edgesRenderer is active
  97715. */
  97716. isEnabled: boolean;
  97717. /**
  97718. * Renders the edges of the attached mesh,
  97719. */
  97720. render(): void;
  97721. /**
  97722. * Checks wether or not the edges renderer is ready to render.
  97723. * @return true if ready, otherwise false.
  97724. */
  97725. isReady(): boolean;
  97726. /**
  97727. * List of instances to render in case the source mesh has instances
  97728. */
  97729. customInstances: SmartArray<Matrix>;
  97730. }
  97731. /**
  97732. * Defines the additional options of the edges renderer
  97733. */
  97734. export interface IEdgesRendererOptions {
  97735. /**
  97736. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97737. * If not defined, the default value is true
  97738. */
  97739. useAlternateEdgeFinder?: boolean;
  97740. /**
  97741. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97742. * If not defined, the default value is true.
  97743. * 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)
  97744. * This option is used only if useAlternateEdgeFinder = true
  97745. */
  97746. useFastVertexMerger?: boolean;
  97747. /**
  97748. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97749. * The default value is 1e-6
  97750. * This option is used only if useAlternateEdgeFinder = true
  97751. */
  97752. epsilonVertexMerge?: number;
  97753. /**
  97754. * 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
  97755. * 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.
  97756. * This option is used only if useAlternateEdgeFinder = true
  97757. */
  97758. applyTessellation?: boolean;
  97759. /**
  97760. * 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
  97761. * The default value is 1e-6
  97762. * This option is used only if useAlternateEdgeFinder = true
  97763. */
  97764. epsilonVertexAligned?: number;
  97765. }
  97766. /**
  97767. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97768. */
  97769. export class EdgesRenderer implements IEdgesRenderer {
  97770. /**
  97771. * Define the size of the edges with an orthographic camera
  97772. */
  97773. edgesWidthScalerForOrthographic: number;
  97774. /**
  97775. * Define the size of the edges with a perspective camera
  97776. */
  97777. edgesWidthScalerForPerspective: number;
  97778. protected _source: AbstractMesh;
  97779. protected _linesPositions: number[];
  97780. protected _linesNormals: number[];
  97781. protected _linesIndices: number[];
  97782. protected _epsilon: number;
  97783. protected _indicesCount: number;
  97784. protected _lineShader: ShaderMaterial;
  97785. protected _ib: DataBuffer;
  97786. protected _buffers: {
  97787. [key: string]: Nullable<VertexBuffer>;
  97788. };
  97789. protected _buffersForInstances: {
  97790. [key: string]: Nullable<VertexBuffer>;
  97791. };
  97792. protected _checkVerticesInsteadOfIndices: boolean;
  97793. protected _options: Nullable<IEdgesRendererOptions>;
  97794. private _meshRebuildObserver;
  97795. private _meshDisposeObserver;
  97796. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97797. isEnabled: boolean;
  97798. /**
  97799. * List of instances to render in case the source mesh has instances
  97800. */
  97801. customInstances: SmartArray<Matrix>;
  97802. private static GetShader;
  97803. /**
  97804. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97805. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97806. * @param source Mesh used to create edges
  97807. * @param epsilon sum of angles in adjacency to check for edge
  97808. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97809. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97810. * @param options The options to apply when generating the edges
  97811. */
  97812. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97813. protected _prepareRessources(): void;
  97814. /** @hidden */
  97815. _rebuild(): void;
  97816. /**
  97817. * Releases the required resources for the edges renderer
  97818. */
  97819. dispose(): void;
  97820. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97821. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97822. /**
  97823. * Checks if the pair of p0 and p1 is en edge
  97824. * @param faceIndex
  97825. * @param edge
  97826. * @param faceNormals
  97827. * @param p0
  97828. * @param p1
  97829. * @private
  97830. */
  97831. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97832. /**
  97833. * push line into the position, normal and index buffer
  97834. * @protected
  97835. */
  97836. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97837. /**
  97838. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97839. */
  97840. private _tessellateTriangle;
  97841. private _generateEdgesLinesAlternate;
  97842. /**
  97843. * Generates lines edges from adjacencjes
  97844. * @private
  97845. */
  97846. _generateEdgesLines(): void;
  97847. /**
  97848. * Checks wether or not the edges renderer is ready to render.
  97849. * @return true if ready, otherwise false.
  97850. */
  97851. isReady(): boolean;
  97852. /**
  97853. * Renders the edges of the attached mesh,
  97854. */
  97855. render(): void;
  97856. }
  97857. /**
  97858. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97859. */
  97860. export class LineEdgesRenderer extends EdgesRenderer {
  97861. /**
  97862. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97863. * @param source LineMesh used to generate edges
  97864. * @param epsilon not important (specified angle for edge detection)
  97865. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97866. */
  97867. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97868. /**
  97869. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97870. */
  97871. _generateEdgesLines(): void;
  97872. }
  97873. }
  97874. declare module BABYLON {
  97875. /**
  97876. * This represents the object necessary to create a rendering group.
  97877. * This is exclusively used and created by the rendering manager.
  97878. * To modify the behavior, you use the available helpers in your scene or meshes.
  97879. * @hidden
  97880. */
  97881. export class RenderingGroup {
  97882. index: number;
  97883. private static _zeroVector;
  97884. private _scene;
  97885. private _opaqueSubMeshes;
  97886. private _transparentSubMeshes;
  97887. private _alphaTestSubMeshes;
  97888. private _depthOnlySubMeshes;
  97889. private _particleSystems;
  97890. private _spriteManagers;
  97891. private _opaqueSortCompareFn;
  97892. private _alphaTestSortCompareFn;
  97893. private _transparentSortCompareFn;
  97894. private _renderOpaque;
  97895. private _renderAlphaTest;
  97896. private _renderTransparent;
  97897. /** @hidden */
  97898. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97899. onBeforeTransparentRendering: () => void;
  97900. /**
  97901. * Set the opaque sort comparison function.
  97902. * If null the sub meshes will be render in the order they were created
  97903. */
  97904. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97905. /**
  97906. * Set the alpha test sort comparison function.
  97907. * If null the sub meshes will be render in the order they were created
  97908. */
  97909. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97910. /**
  97911. * Set the transparent sort comparison function.
  97912. * If null the sub meshes will be render in the order they were created
  97913. */
  97914. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97915. /**
  97916. * Creates a new rendering group.
  97917. * @param index The rendering group index
  97918. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97919. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97920. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97921. */
  97922. 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>);
  97923. /**
  97924. * Render all the sub meshes contained in the group.
  97925. * @param customRenderFunction Used to override the default render behaviour of the group.
  97926. * @returns true if rendered some submeshes.
  97927. */
  97928. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97929. /**
  97930. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97931. * @param subMeshes The submeshes to render
  97932. */
  97933. private renderOpaqueSorted;
  97934. /**
  97935. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97936. * @param subMeshes The submeshes to render
  97937. */
  97938. private renderAlphaTestSorted;
  97939. /**
  97940. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97941. * @param subMeshes The submeshes to render
  97942. */
  97943. private renderTransparentSorted;
  97944. /**
  97945. * Renders the submeshes in a specified order.
  97946. * @param subMeshes The submeshes to sort before render
  97947. * @param sortCompareFn The comparison function use to sort
  97948. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97949. * @param transparent Specifies to activate blending if true
  97950. */
  97951. private static renderSorted;
  97952. /**
  97953. * Renders the submeshes in the order they were dispatched (no sort applied).
  97954. * @param subMeshes The submeshes to render
  97955. */
  97956. private static renderUnsorted;
  97957. /**
  97958. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97959. * are rendered back to front if in the same alpha index.
  97960. *
  97961. * @param a The first submesh
  97962. * @param b The second submesh
  97963. * @returns The result of the comparison
  97964. */
  97965. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97966. /**
  97967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97968. * are rendered back to front.
  97969. *
  97970. * @param a The first submesh
  97971. * @param b The second submesh
  97972. * @returns The result of the comparison
  97973. */
  97974. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97975. /**
  97976. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97977. * are rendered front to back (prevent overdraw).
  97978. *
  97979. * @param a The first submesh
  97980. * @param b The second submesh
  97981. * @returns The result of the comparison
  97982. */
  97983. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97984. /**
  97985. * Resets the different lists of submeshes to prepare a new frame.
  97986. */
  97987. prepare(): void;
  97988. dispose(): void;
  97989. /**
  97990. * Inserts the submesh in its correct queue depending on its material.
  97991. * @param subMesh The submesh to dispatch
  97992. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97993. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97994. */
  97995. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97996. dispatchSprites(spriteManager: ISpriteManager): void;
  97997. dispatchParticles(particleSystem: IParticleSystem): void;
  97998. private _renderParticles;
  97999. private _renderSprites;
  98000. }
  98001. }
  98002. declare module BABYLON {
  98003. /**
  98004. * Interface describing the different options available in the rendering manager
  98005. * regarding Auto Clear between groups.
  98006. */
  98007. export interface IRenderingManagerAutoClearSetup {
  98008. /**
  98009. * Defines whether or not autoclear is enable.
  98010. */
  98011. autoClear: boolean;
  98012. /**
  98013. * Defines whether or not to autoclear the depth buffer.
  98014. */
  98015. depth: boolean;
  98016. /**
  98017. * Defines whether or not to autoclear the stencil buffer.
  98018. */
  98019. stencil: boolean;
  98020. }
  98021. /**
  98022. * This class is used by the onRenderingGroupObservable
  98023. */
  98024. export class RenderingGroupInfo {
  98025. /**
  98026. * The Scene that being rendered
  98027. */
  98028. scene: Scene;
  98029. /**
  98030. * The camera currently used for the rendering pass
  98031. */
  98032. camera: Nullable<Camera>;
  98033. /**
  98034. * The ID of the renderingGroup being processed
  98035. */
  98036. renderingGroupId: number;
  98037. }
  98038. /**
  98039. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98040. * It is enable to manage the different groups as well as the different necessary sort functions.
  98041. * This should not be used directly aside of the few static configurations
  98042. */
  98043. export class RenderingManager {
  98044. /**
  98045. * The max id used for rendering groups (not included)
  98046. */
  98047. static MAX_RENDERINGGROUPS: number;
  98048. /**
  98049. * The min id used for rendering groups (included)
  98050. */
  98051. static MIN_RENDERINGGROUPS: number;
  98052. /**
  98053. * Used to globally prevent autoclearing scenes.
  98054. */
  98055. static AUTOCLEAR: boolean;
  98056. /**
  98057. * @hidden
  98058. */
  98059. _useSceneAutoClearSetup: boolean;
  98060. private _scene;
  98061. private _renderingGroups;
  98062. private _depthStencilBufferAlreadyCleaned;
  98063. private _autoClearDepthStencil;
  98064. private _customOpaqueSortCompareFn;
  98065. private _customAlphaTestSortCompareFn;
  98066. private _customTransparentSortCompareFn;
  98067. private _renderingGroupInfo;
  98068. /**
  98069. * Instantiates a new rendering group for a particular scene
  98070. * @param scene Defines the scene the groups belongs to
  98071. */
  98072. constructor(scene: Scene);
  98073. private _clearDepthStencilBuffer;
  98074. /**
  98075. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98076. * @hidden
  98077. */
  98078. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98079. /**
  98080. * Resets the different information of the group to prepare a new frame
  98081. * @hidden
  98082. */
  98083. reset(): void;
  98084. /**
  98085. * Dispose and release the group and its associated resources.
  98086. * @hidden
  98087. */
  98088. dispose(): void;
  98089. /**
  98090. * Clear the info related to rendering groups preventing retention points during dispose.
  98091. */
  98092. freeRenderingGroups(): void;
  98093. private _prepareRenderingGroup;
  98094. /**
  98095. * Add a sprite manager to the rendering manager in order to render it this frame.
  98096. * @param spriteManager Define the sprite manager to render
  98097. */
  98098. dispatchSprites(spriteManager: ISpriteManager): void;
  98099. /**
  98100. * Add a particle system to the rendering manager in order to render it this frame.
  98101. * @param particleSystem Define the particle system to render
  98102. */
  98103. dispatchParticles(particleSystem: IParticleSystem): void;
  98104. /**
  98105. * Add a submesh to the manager in order to render it this frame
  98106. * @param subMesh The submesh to dispatch
  98107. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98108. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98109. */
  98110. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98111. /**
  98112. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98113. * This allowed control for front to back rendering or reversly depending of the special needs.
  98114. *
  98115. * @param renderingGroupId The rendering group id corresponding to its index
  98116. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98117. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98118. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98119. */
  98120. 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;
  98121. /**
  98122. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98123. *
  98124. * @param renderingGroupId The rendering group id corresponding to its index
  98125. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98126. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98127. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98128. */
  98129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98130. /**
  98131. * Gets the current auto clear configuration for one rendering group of the rendering
  98132. * manager.
  98133. * @param index the rendering group index to get the information for
  98134. * @returns The auto clear setup for the requested rendering group
  98135. */
  98136. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98137. }
  98138. }
  98139. declare module BABYLON {
  98140. /**
  98141. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98142. */
  98143. export interface ICustomShaderOptions {
  98144. /**
  98145. * Gets or sets the custom shader name to use
  98146. */
  98147. shaderName: string;
  98148. /**
  98149. * The list of attribute names used in the shader
  98150. */
  98151. attributes?: string[];
  98152. /**
  98153. * The list of unifrom names used in the shader
  98154. */
  98155. uniforms?: string[];
  98156. /**
  98157. * The list of sampler names used in the shader
  98158. */
  98159. samplers?: string[];
  98160. /**
  98161. * The list of defines used in the shader
  98162. */
  98163. defines?: string[];
  98164. }
  98165. /**
  98166. * Interface to implement to create a shadow generator compatible with BJS.
  98167. */
  98168. export interface IShadowGenerator {
  98169. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98170. id: string;
  98171. /**
  98172. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98173. * @returns The render target texture if present otherwise, null
  98174. */
  98175. getShadowMap(): Nullable<RenderTargetTexture>;
  98176. /**
  98177. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98178. * @param subMesh The submesh we want to render in the shadow map
  98179. * @param useInstances Defines wether will draw in the map using instances
  98180. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98181. * @returns true if ready otherwise, false
  98182. */
  98183. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98184. /**
  98185. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98186. * @param defines Defines of the material we want to update
  98187. * @param lightIndex Index of the light in the enabled light list of the material
  98188. */
  98189. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98190. /**
  98191. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98192. * defined in the generator but impacting the effect).
  98193. * It implies the unifroms available on the materials are the standard BJS ones.
  98194. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98195. * @param effect The effect we are binfing the information for
  98196. */
  98197. bindShadowLight(lightIndex: string, effect: Effect): void;
  98198. /**
  98199. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98200. * (eq to shadow prjection matrix * light transform matrix)
  98201. * @returns The transform matrix used to create the shadow map
  98202. */
  98203. getTransformMatrix(): Matrix;
  98204. /**
  98205. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98206. * Cube and 2D textures for instance.
  98207. */
  98208. recreateShadowMap(): void;
  98209. /**
  98210. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98211. * @param onCompiled Callback triggered at the and of the effects compilation
  98212. * @param options Sets of optional options forcing the compilation with different modes
  98213. */
  98214. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98215. useInstances: boolean;
  98216. }>): void;
  98217. /**
  98218. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98219. * @param options Sets of optional options forcing the compilation with different modes
  98220. * @returns A promise that resolves when the compilation completes
  98221. */
  98222. forceCompilationAsync(options?: Partial<{
  98223. useInstances: boolean;
  98224. }>): Promise<void>;
  98225. /**
  98226. * Serializes the shadow generator setup to a json object.
  98227. * @returns The serialized JSON object
  98228. */
  98229. serialize(): any;
  98230. /**
  98231. * Disposes the Shadow map and related Textures and effects.
  98232. */
  98233. dispose(): void;
  98234. }
  98235. /**
  98236. * Default implementation IShadowGenerator.
  98237. * This is the main object responsible of generating shadows in the framework.
  98238. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98239. */
  98240. export class ShadowGenerator implements IShadowGenerator {
  98241. /**
  98242. * Name of the shadow generator class
  98243. */
  98244. static CLASSNAME: string;
  98245. /**
  98246. * Shadow generator mode None: no filtering applied.
  98247. */
  98248. static readonly FILTER_NONE: number;
  98249. /**
  98250. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98251. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98252. */
  98253. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98254. /**
  98255. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98256. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98257. */
  98258. static readonly FILTER_POISSONSAMPLING: number;
  98259. /**
  98260. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98261. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98262. */
  98263. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98264. /**
  98265. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98266. * edge artifacts on steep falloff.
  98267. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98268. */
  98269. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98270. /**
  98271. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98272. * edge artifacts on steep falloff.
  98273. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98274. */
  98275. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98276. /**
  98277. * Shadow generator mode PCF: Percentage Closer Filtering
  98278. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98279. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98280. */
  98281. static readonly FILTER_PCF: number;
  98282. /**
  98283. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98284. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98285. * Contact Hardening
  98286. */
  98287. static readonly FILTER_PCSS: number;
  98288. /**
  98289. * Reserved for PCF and PCSS
  98290. * Highest Quality.
  98291. *
  98292. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98293. *
  98294. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98295. */
  98296. static readonly QUALITY_HIGH: number;
  98297. /**
  98298. * Reserved for PCF and PCSS
  98299. * Good tradeoff for quality/perf cross devices
  98300. *
  98301. * Execute PCF on a 3*3 kernel.
  98302. *
  98303. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98304. */
  98305. static readonly QUALITY_MEDIUM: number;
  98306. /**
  98307. * Reserved for PCF and PCSS
  98308. * The lowest quality but the fastest.
  98309. *
  98310. * Execute PCF on a 1*1 kernel.
  98311. *
  98312. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98313. */
  98314. static readonly QUALITY_LOW: number;
  98315. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98316. id: string;
  98317. /** Gets or sets the custom shader name to use */
  98318. customShaderOptions: ICustomShaderOptions;
  98319. /**
  98320. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98321. */
  98322. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98323. /**
  98324. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98325. */
  98326. onAfterShadowMapRenderObservable: Observable<Effect>;
  98327. /**
  98328. * Observable triggered before a mesh is rendered in the shadow map.
  98329. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98330. */
  98331. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98332. /**
  98333. * Observable triggered after a mesh is rendered in the shadow map.
  98334. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98335. */
  98336. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98337. protected _bias: number;
  98338. /**
  98339. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98340. */
  98341. get bias(): number;
  98342. /**
  98343. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98344. */
  98345. set bias(bias: number);
  98346. protected _normalBias: number;
  98347. /**
  98348. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98349. */
  98350. get normalBias(): number;
  98351. /**
  98352. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98353. */
  98354. set normalBias(normalBias: number);
  98355. protected _blurBoxOffset: number;
  98356. /**
  98357. * Gets the blur box offset: offset applied during the blur pass.
  98358. * Only useful if useKernelBlur = false
  98359. */
  98360. get blurBoxOffset(): number;
  98361. /**
  98362. * Sets the blur box offset: offset applied during the blur pass.
  98363. * Only useful if useKernelBlur = false
  98364. */
  98365. set blurBoxOffset(value: number);
  98366. protected _blurScale: number;
  98367. /**
  98368. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98369. * 2 means half of the size.
  98370. */
  98371. get blurScale(): number;
  98372. /**
  98373. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98374. * 2 means half of the size.
  98375. */
  98376. set blurScale(value: number);
  98377. protected _blurKernel: number;
  98378. /**
  98379. * Gets the blur kernel: kernel size of the blur pass.
  98380. * Only useful if useKernelBlur = true
  98381. */
  98382. get blurKernel(): number;
  98383. /**
  98384. * Sets the blur kernel: kernel size of the blur pass.
  98385. * Only useful if useKernelBlur = true
  98386. */
  98387. set blurKernel(value: number);
  98388. protected _useKernelBlur: boolean;
  98389. /**
  98390. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98391. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98392. */
  98393. get useKernelBlur(): boolean;
  98394. /**
  98395. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98396. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98397. */
  98398. set useKernelBlur(value: boolean);
  98399. protected _depthScale: number;
  98400. /**
  98401. * Gets the depth scale used in ESM mode.
  98402. */
  98403. get depthScale(): number;
  98404. /**
  98405. * Sets the depth scale used in ESM mode.
  98406. * This can override the scale stored on the light.
  98407. */
  98408. set depthScale(value: number);
  98409. protected _validateFilter(filter: number): number;
  98410. protected _filter: number;
  98411. /**
  98412. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98413. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98414. */
  98415. get filter(): number;
  98416. /**
  98417. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98418. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98419. */
  98420. set filter(value: number);
  98421. /**
  98422. * Gets if the current filter is set to Poisson Sampling.
  98423. */
  98424. get usePoissonSampling(): boolean;
  98425. /**
  98426. * Sets the current filter to Poisson Sampling.
  98427. */
  98428. set usePoissonSampling(value: boolean);
  98429. /**
  98430. * Gets if the current filter is set to ESM.
  98431. */
  98432. get useExponentialShadowMap(): boolean;
  98433. /**
  98434. * Sets the current filter is to ESM.
  98435. */
  98436. set useExponentialShadowMap(value: boolean);
  98437. /**
  98438. * Gets if the current filter is set to filtered ESM.
  98439. */
  98440. get useBlurExponentialShadowMap(): boolean;
  98441. /**
  98442. * Gets if the current filter is set to filtered ESM.
  98443. */
  98444. set useBlurExponentialShadowMap(value: boolean);
  98445. /**
  98446. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98447. * exponential to prevent steep falloff artifacts).
  98448. */
  98449. get useCloseExponentialShadowMap(): boolean;
  98450. /**
  98451. * Sets the current filter to "close ESM" (using the inverse of the
  98452. * exponential to prevent steep falloff artifacts).
  98453. */
  98454. set useCloseExponentialShadowMap(value: boolean);
  98455. /**
  98456. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98457. * exponential to prevent steep falloff artifacts).
  98458. */
  98459. get useBlurCloseExponentialShadowMap(): boolean;
  98460. /**
  98461. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98462. * exponential to prevent steep falloff artifacts).
  98463. */
  98464. set useBlurCloseExponentialShadowMap(value: boolean);
  98465. /**
  98466. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98467. */
  98468. get usePercentageCloserFiltering(): boolean;
  98469. /**
  98470. * Sets the current filter to "PCF" (percentage closer filtering).
  98471. */
  98472. set usePercentageCloserFiltering(value: boolean);
  98473. protected _filteringQuality: number;
  98474. /**
  98475. * Gets the PCF or PCSS Quality.
  98476. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98477. */
  98478. get filteringQuality(): number;
  98479. /**
  98480. * Sets the PCF or PCSS Quality.
  98481. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98482. */
  98483. set filteringQuality(filteringQuality: number);
  98484. /**
  98485. * Gets if the current filter is set to "PCSS" (contact hardening).
  98486. */
  98487. get useContactHardeningShadow(): boolean;
  98488. /**
  98489. * Sets the current filter to "PCSS" (contact hardening).
  98490. */
  98491. set useContactHardeningShadow(value: boolean);
  98492. protected _contactHardeningLightSizeUVRatio: number;
  98493. /**
  98494. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98495. * Using a ratio helps keeping shape stability independently of the map size.
  98496. *
  98497. * It does not account for the light projection as it was having too much
  98498. * instability during the light setup or during light position changes.
  98499. *
  98500. * Only valid if useContactHardeningShadow is true.
  98501. */
  98502. get contactHardeningLightSizeUVRatio(): number;
  98503. /**
  98504. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98505. * Using a ratio helps keeping shape stability independently of the map size.
  98506. *
  98507. * It does not account for the light projection as it was having too much
  98508. * instability during the light setup or during light position changes.
  98509. *
  98510. * Only valid if useContactHardeningShadow is true.
  98511. */
  98512. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98513. protected _darkness: number;
  98514. /** Gets or sets the actual darkness of a shadow */
  98515. get darkness(): number;
  98516. set darkness(value: number);
  98517. /**
  98518. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98519. * 0 means strongest and 1 would means no shadow.
  98520. * @returns the darkness.
  98521. */
  98522. getDarkness(): number;
  98523. /**
  98524. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98525. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98526. * @returns the shadow generator allowing fluent coding.
  98527. */
  98528. setDarkness(darkness: number): ShadowGenerator;
  98529. protected _transparencyShadow: boolean;
  98530. /** Gets or sets the ability to have transparent shadow */
  98531. get transparencyShadow(): boolean;
  98532. set transparencyShadow(value: boolean);
  98533. /**
  98534. * Sets the ability to have transparent shadow (boolean).
  98535. * @param transparent True if transparent else False
  98536. * @returns the shadow generator allowing fluent coding
  98537. */
  98538. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98539. /**
  98540. * Enables or disables shadows with varying strength based on the transparency
  98541. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98542. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98543. * mesh.visibility * alphaTexture.a
  98544. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98545. */
  98546. enableSoftTransparentShadow: boolean;
  98547. protected _shadowMap: Nullable<RenderTargetTexture>;
  98548. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98549. /**
  98550. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98551. * @returns The render target texture if present otherwise, null
  98552. */
  98553. getShadowMap(): Nullable<RenderTargetTexture>;
  98554. /**
  98555. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98556. * @returns The render target texture if the shadow map is present otherwise, null
  98557. */
  98558. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98559. /**
  98560. * Gets the class name of that object
  98561. * @returns "ShadowGenerator"
  98562. */
  98563. getClassName(): string;
  98564. /**
  98565. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98566. * @param mesh Mesh to add
  98567. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98568. * @returns the Shadow Generator itself
  98569. */
  98570. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98571. /**
  98572. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98573. * @param mesh Mesh to remove
  98574. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98575. * @returns the Shadow Generator itself
  98576. */
  98577. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98578. /**
  98579. * Controls the extent to which the shadows fade out at the edge of the frustum
  98580. */
  98581. frustumEdgeFalloff: number;
  98582. protected _light: IShadowLight;
  98583. /**
  98584. * Returns the associated light object.
  98585. * @returns the light generating the shadow
  98586. */
  98587. getLight(): IShadowLight;
  98588. /**
  98589. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98590. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98591. * It might on the other hand introduce peter panning.
  98592. */
  98593. forceBackFacesOnly: boolean;
  98594. protected _scene: Scene;
  98595. protected _lightDirection: Vector3;
  98596. protected _effect: Effect;
  98597. protected _viewMatrix: Matrix;
  98598. protected _projectionMatrix: Matrix;
  98599. protected _transformMatrix: Matrix;
  98600. protected _cachedPosition: Vector3;
  98601. protected _cachedDirection: Vector3;
  98602. protected _cachedDefines: string;
  98603. protected _currentRenderID: number;
  98604. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98605. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98606. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98607. protected _blurPostProcesses: PostProcess[];
  98608. protected _mapSize: number;
  98609. protected _currentFaceIndex: number;
  98610. protected _currentFaceIndexCache: number;
  98611. protected _textureType: number;
  98612. protected _defaultTextureMatrix: Matrix;
  98613. protected _storedUniqueId: Nullable<number>;
  98614. /** @hidden */
  98615. static _SceneComponentInitialization: (scene: Scene) => void;
  98616. /**
  98617. * Gets or sets the size of the texture what stores the shadows
  98618. */
  98619. get mapSize(): number;
  98620. set mapSize(size: number);
  98621. /**
  98622. * Creates a ShadowGenerator object.
  98623. * A ShadowGenerator is the required tool to use the shadows.
  98624. * Each light casting shadows needs to use its own ShadowGenerator.
  98625. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98626. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98627. * @param light The light object generating the shadows.
  98628. * @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.
  98629. */
  98630. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98631. protected _initializeGenerator(): void;
  98632. protected _createTargetRenderTexture(): void;
  98633. protected _initializeShadowMap(): void;
  98634. protected _initializeBlurRTTAndPostProcesses(): void;
  98635. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98636. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98637. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98638. protected _applyFilterValues(): void;
  98639. /**
  98640. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98641. * @param onCompiled Callback triggered at the and of the effects compilation
  98642. * @param options Sets of optional options forcing the compilation with different modes
  98643. */
  98644. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98645. useInstances: boolean;
  98646. }>): void;
  98647. /**
  98648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98649. * @param options Sets of optional options forcing the compilation with different modes
  98650. * @returns A promise that resolves when the compilation completes
  98651. */
  98652. forceCompilationAsync(options?: Partial<{
  98653. useInstances: boolean;
  98654. }>): Promise<void>;
  98655. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98656. private _prepareShadowDefines;
  98657. /**
  98658. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98659. * @param subMesh The submesh we want to render in the shadow map
  98660. * @param useInstances Defines wether will draw in the map using instances
  98661. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98662. * @returns true if ready otherwise, false
  98663. */
  98664. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98665. /**
  98666. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98667. * @param defines Defines of the material we want to update
  98668. * @param lightIndex Index of the light in the enabled light list of the material
  98669. */
  98670. prepareDefines(defines: any, lightIndex: number): void;
  98671. /**
  98672. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98673. * defined in the generator but impacting the effect).
  98674. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98675. * @param effect The effect we are binfing the information for
  98676. */
  98677. bindShadowLight(lightIndex: string, effect: Effect): void;
  98678. /**
  98679. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98680. * (eq to shadow prjection matrix * light transform matrix)
  98681. * @returns The transform matrix used to create the shadow map
  98682. */
  98683. getTransformMatrix(): Matrix;
  98684. /**
  98685. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98686. * Cube and 2D textures for instance.
  98687. */
  98688. recreateShadowMap(): void;
  98689. protected _disposeBlurPostProcesses(): void;
  98690. protected _disposeRTTandPostProcesses(): void;
  98691. /**
  98692. * Disposes the ShadowGenerator.
  98693. * Returns nothing.
  98694. */
  98695. dispose(): void;
  98696. /**
  98697. * Serializes the shadow generator setup to a json object.
  98698. * @returns The serialized JSON object
  98699. */
  98700. serialize(): any;
  98701. /**
  98702. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98703. * @param parsedShadowGenerator The JSON object to parse
  98704. * @param scene The scene to create the shadow map for
  98705. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98706. * @returns The parsed shadow generator
  98707. */
  98708. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98709. }
  98710. }
  98711. declare module BABYLON {
  98712. /**
  98713. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98714. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98715. * 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.
  98716. */
  98717. export abstract class Light extends Node {
  98718. /**
  98719. * Falloff Default: light is falling off following the material specification:
  98720. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98721. */
  98722. static readonly FALLOFF_DEFAULT: number;
  98723. /**
  98724. * Falloff Physical: light is falling off following the inverse squared distance law.
  98725. */
  98726. static readonly FALLOFF_PHYSICAL: number;
  98727. /**
  98728. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98729. * to enhance interoperability with other engines.
  98730. */
  98731. static readonly FALLOFF_GLTF: number;
  98732. /**
  98733. * Falloff Standard: light is falling off like in the standard material
  98734. * to enhance interoperability with other materials.
  98735. */
  98736. static readonly FALLOFF_STANDARD: number;
  98737. /**
  98738. * If every light affecting the material is in this lightmapMode,
  98739. * material.lightmapTexture adds or multiplies
  98740. * (depends on material.useLightmapAsShadowmap)
  98741. * after every other light calculations.
  98742. */
  98743. static readonly LIGHTMAP_DEFAULT: number;
  98744. /**
  98745. * material.lightmapTexture as only diffuse lighting from this light
  98746. * adds only specular lighting from this light
  98747. * adds dynamic shadows
  98748. */
  98749. static readonly LIGHTMAP_SPECULAR: number;
  98750. /**
  98751. * material.lightmapTexture as only lighting
  98752. * no light calculation from this light
  98753. * only adds dynamic shadows from this light
  98754. */
  98755. static readonly LIGHTMAP_SHADOWSONLY: number;
  98756. /**
  98757. * Each light type uses the default quantity according to its type:
  98758. * point/spot lights use luminous intensity
  98759. * directional lights use illuminance
  98760. */
  98761. static readonly INTENSITYMODE_AUTOMATIC: number;
  98762. /**
  98763. * lumen (lm)
  98764. */
  98765. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98766. /**
  98767. * candela (lm/sr)
  98768. */
  98769. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98770. /**
  98771. * lux (lm/m^2)
  98772. */
  98773. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98774. /**
  98775. * nit (cd/m^2)
  98776. */
  98777. static readonly INTENSITYMODE_LUMINANCE: number;
  98778. /**
  98779. * Light type const id of the point light.
  98780. */
  98781. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98782. /**
  98783. * Light type const id of the directional light.
  98784. */
  98785. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98786. /**
  98787. * Light type const id of the spot light.
  98788. */
  98789. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98790. /**
  98791. * Light type const id of the hemispheric light.
  98792. */
  98793. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98794. /**
  98795. * Diffuse gives the basic color to an object.
  98796. */
  98797. diffuse: Color3;
  98798. /**
  98799. * Specular produces a highlight color on an object.
  98800. * Note: This is note affecting PBR materials.
  98801. */
  98802. specular: Color3;
  98803. /**
  98804. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98805. * falling off base on range or angle.
  98806. * This can be set to any values in Light.FALLOFF_x.
  98807. *
  98808. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98809. * other types of materials.
  98810. */
  98811. falloffType: number;
  98812. /**
  98813. * Strength of the light.
  98814. * Note: By default it is define in the framework own unit.
  98815. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98816. */
  98817. intensity: number;
  98818. private _range;
  98819. protected _inverseSquaredRange: number;
  98820. /**
  98821. * Defines how far from the source the light is impacting in scene units.
  98822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98823. */
  98824. get range(): number;
  98825. /**
  98826. * Defines how far from the source the light is impacting in scene units.
  98827. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98828. */
  98829. set range(value: number);
  98830. /**
  98831. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98832. * of light.
  98833. */
  98834. private _photometricScale;
  98835. private _intensityMode;
  98836. /**
  98837. * Gets the photometric scale used to interpret the intensity.
  98838. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98839. */
  98840. get intensityMode(): number;
  98841. /**
  98842. * Sets the photometric scale used to interpret the intensity.
  98843. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98844. */
  98845. set intensityMode(value: number);
  98846. private _radius;
  98847. /**
  98848. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98849. */
  98850. get radius(): number;
  98851. /**
  98852. * sets the light radius used by PBR Materials to simulate soft area lights.
  98853. */
  98854. set radius(value: number);
  98855. private _renderPriority;
  98856. /**
  98857. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98858. * exceeding the number allowed of the materials.
  98859. */
  98860. renderPriority: number;
  98861. private _shadowEnabled;
  98862. /**
  98863. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98864. * the current shadow generator.
  98865. */
  98866. get shadowEnabled(): boolean;
  98867. /**
  98868. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98869. * the current shadow generator.
  98870. */
  98871. set shadowEnabled(value: boolean);
  98872. private _includedOnlyMeshes;
  98873. /**
  98874. * Gets the only meshes impacted by this light.
  98875. */
  98876. get includedOnlyMeshes(): AbstractMesh[];
  98877. /**
  98878. * Sets the only meshes impacted by this light.
  98879. */
  98880. set includedOnlyMeshes(value: AbstractMesh[]);
  98881. private _excludedMeshes;
  98882. /**
  98883. * Gets the meshes not impacted by this light.
  98884. */
  98885. get excludedMeshes(): AbstractMesh[];
  98886. /**
  98887. * Sets the meshes not impacted by this light.
  98888. */
  98889. set excludedMeshes(value: AbstractMesh[]);
  98890. private _excludeWithLayerMask;
  98891. /**
  98892. * Gets the layer id use to find what meshes are not impacted by the light.
  98893. * Inactive if 0
  98894. */
  98895. get excludeWithLayerMask(): number;
  98896. /**
  98897. * Sets the layer id use to find what meshes are not impacted by the light.
  98898. * Inactive if 0
  98899. */
  98900. set excludeWithLayerMask(value: number);
  98901. private _includeOnlyWithLayerMask;
  98902. /**
  98903. * Gets the layer id use to find what meshes are impacted by the light.
  98904. * Inactive if 0
  98905. */
  98906. get includeOnlyWithLayerMask(): number;
  98907. /**
  98908. * Sets the layer id use to find what meshes are impacted by the light.
  98909. * Inactive if 0
  98910. */
  98911. set includeOnlyWithLayerMask(value: number);
  98912. private _lightmapMode;
  98913. /**
  98914. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98915. */
  98916. get lightmapMode(): number;
  98917. /**
  98918. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98919. */
  98920. set lightmapMode(value: number);
  98921. /**
  98922. * Shadow generator associted to the light.
  98923. * @hidden Internal use only.
  98924. */
  98925. _shadowGenerator: Nullable<IShadowGenerator>;
  98926. /**
  98927. * @hidden Internal use only.
  98928. */
  98929. _excludedMeshesIds: string[];
  98930. /**
  98931. * @hidden Internal use only.
  98932. */
  98933. _includedOnlyMeshesIds: string[];
  98934. /**
  98935. * The current light unifom buffer.
  98936. * @hidden Internal use only.
  98937. */
  98938. _uniformBuffer: UniformBuffer;
  98939. /** @hidden */
  98940. _renderId: number;
  98941. /**
  98942. * Creates a Light object in the scene.
  98943. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98944. * @param name The firendly name of the light
  98945. * @param scene The scene the light belongs too
  98946. */
  98947. constructor(name: string, scene: Scene);
  98948. protected abstract _buildUniformLayout(): void;
  98949. /**
  98950. * Sets the passed Effect "effect" with the Light information.
  98951. * @param effect The effect to update
  98952. * @param lightIndex The index of the light in the effect to update
  98953. * @returns The light
  98954. */
  98955. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98956. /**
  98957. * Sets the passed Effect "effect" with the Light textures.
  98958. * @param effect The effect to update
  98959. * @param lightIndex The index of the light in the effect to update
  98960. * @returns The light
  98961. */
  98962. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98963. /**
  98964. * Binds the lights information from the scene to the effect for the given mesh.
  98965. * @param lightIndex Light index
  98966. * @param scene The scene where the light belongs to
  98967. * @param effect The effect we are binding the data to
  98968. * @param useSpecular Defines if specular is supported
  98969. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98970. */
  98971. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98972. /**
  98973. * Sets the passed Effect "effect" with the Light information.
  98974. * @param effect The effect to update
  98975. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98976. * @returns The light
  98977. */
  98978. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98979. /**
  98980. * Returns the string "Light".
  98981. * @returns the class name
  98982. */
  98983. getClassName(): string;
  98984. /** @hidden */
  98985. readonly _isLight: boolean;
  98986. /**
  98987. * Converts the light information to a readable string for debug purpose.
  98988. * @param fullDetails Supports for multiple levels of logging within scene loading
  98989. * @returns the human readable light info
  98990. */
  98991. toString(fullDetails?: boolean): string;
  98992. /** @hidden */
  98993. protected _syncParentEnabledState(): void;
  98994. /**
  98995. * Set the enabled state of this node.
  98996. * @param value - the new enabled state
  98997. */
  98998. setEnabled(value: boolean): void;
  98999. /**
  99000. * Returns the Light associated shadow generator if any.
  99001. * @return the associated shadow generator.
  99002. */
  99003. getShadowGenerator(): Nullable<IShadowGenerator>;
  99004. /**
  99005. * Returns a Vector3, the absolute light position in the World.
  99006. * @returns the world space position of the light
  99007. */
  99008. getAbsolutePosition(): Vector3;
  99009. /**
  99010. * Specifies if the light will affect the passed mesh.
  99011. * @param mesh The mesh to test against the light
  99012. * @return true the mesh is affected otherwise, false.
  99013. */
  99014. canAffectMesh(mesh: AbstractMesh): boolean;
  99015. /**
  99016. * Sort function to order lights for rendering.
  99017. * @param a First Light object to compare to second.
  99018. * @param b Second Light object to compare first.
  99019. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99020. */
  99021. static CompareLightsPriority(a: Light, b: Light): number;
  99022. /**
  99023. * Releases resources associated with this node.
  99024. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99025. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99026. */
  99027. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99028. /**
  99029. * Returns the light type ID (integer).
  99030. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99031. */
  99032. getTypeID(): number;
  99033. /**
  99034. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99035. * @returns the scaled intensity in intensity mode unit
  99036. */
  99037. getScaledIntensity(): number;
  99038. /**
  99039. * Returns a new Light object, named "name", from the current one.
  99040. * @param name The name of the cloned light
  99041. * @param newParent The parent of this light, if it has one
  99042. * @returns the new created light
  99043. */
  99044. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99045. /**
  99046. * Serializes the current light into a Serialization object.
  99047. * @returns the serialized object.
  99048. */
  99049. serialize(): any;
  99050. /**
  99051. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99052. * This new light is named "name" and added to the passed scene.
  99053. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99054. * @param name The friendly name of the light
  99055. * @param scene The scene the new light will belong to
  99056. * @returns the constructor function
  99057. */
  99058. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99059. /**
  99060. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99061. * @param parsedLight The JSON representation of the light
  99062. * @param scene The scene to create the parsed light in
  99063. * @returns the created light after parsing
  99064. */
  99065. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99066. private _hookArrayForExcluded;
  99067. private _hookArrayForIncludedOnly;
  99068. private _resyncMeshes;
  99069. /**
  99070. * Forces the meshes to update their light related information in their rendering used effects
  99071. * @hidden Internal Use Only
  99072. */
  99073. _markMeshesAsLightDirty(): void;
  99074. /**
  99075. * Recomputes the cached photometric scale if needed.
  99076. */
  99077. private _computePhotometricScale;
  99078. /**
  99079. * Returns the Photometric Scale according to the light type and intensity mode.
  99080. */
  99081. private _getPhotometricScale;
  99082. /**
  99083. * Reorder the light in the scene according to their defined priority.
  99084. * @hidden Internal Use Only
  99085. */
  99086. _reorderLightsInScene(): void;
  99087. /**
  99088. * Prepares the list of defines specific to the light type.
  99089. * @param defines the list of defines
  99090. * @param lightIndex defines the index of the light for the effect
  99091. */
  99092. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99093. }
  99094. }
  99095. declare module BABYLON {
  99096. /**
  99097. * Configuration needed for prepass-capable materials
  99098. */
  99099. export class PrePassConfiguration {
  99100. /**
  99101. * Previous world matrices of meshes carrying this material
  99102. * Used for computing velocity
  99103. */
  99104. previousWorldMatrices: {
  99105. [index: number]: Matrix;
  99106. };
  99107. /**
  99108. * Previous view project matrix
  99109. * Used for computing velocity
  99110. */
  99111. previousViewProjection: Matrix;
  99112. /**
  99113. * Previous bones of meshes carrying this material
  99114. * Used for computing velocity
  99115. */
  99116. previousBones: {
  99117. [index: number]: Float32Array;
  99118. };
  99119. /**
  99120. * Add the required uniforms to the current list.
  99121. * @param uniforms defines the current uniform list.
  99122. */
  99123. static AddUniforms(uniforms: string[]): void;
  99124. /**
  99125. * Add the required samplers to the current list.
  99126. * @param samplers defines the current sampler list.
  99127. */
  99128. static AddSamplers(samplers: string[]): void;
  99129. /**
  99130. * Binds the material data.
  99131. * @param effect defines the effect to update
  99132. * @param scene defines the scene the material belongs to.
  99133. * @param mesh The mesh
  99134. * @param world World matrix of this mesh
  99135. * @param isFrozen Is the material frozen
  99136. */
  99137. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99138. }
  99139. }
  99140. declare module BABYLON {
  99141. /**
  99142. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99143. * This is the base of the follow, arc rotate cameras and Free camera
  99144. * @see https://doc.babylonjs.com/features/cameras
  99145. */
  99146. export class TargetCamera extends Camera {
  99147. private static _RigCamTransformMatrix;
  99148. private static _TargetTransformMatrix;
  99149. private static _TargetFocalPoint;
  99150. private _tmpUpVector;
  99151. private _tmpTargetVector;
  99152. /**
  99153. * Define the current direction the camera is moving to
  99154. */
  99155. cameraDirection: Vector3;
  99156. /**
  99157. * Define the current rotation the camera is rotating to
  99158. */
  99159. cameraRotation: Vector2;
  99160. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99161. ignoreParentScaling: boolean;
  99162. /**
  99163. * When set, the up vector of the camera will be updated by the rotation of the camera
  99164. */
  99165. updateUpVectorFromRotation: boolean;
  99166. private _tmpQuaternion;
  99167. /**
  99168. * Define the current rotation of the camera
  99169. */
  99170. rotation: Vector3;
  99171. /**
  99172. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99173. */
  99174. rotationQuaternion: Quaternion;
  99175. /**
  99176. * Define the current speed of the camera
  99177. */
  99178. speed: number;
  99179. /**
  99180. * Add constraint to the camera to prevent it to move freely in all directions and
  99181. * around all axis.
  99182. */
  99183. noRotationConstraint: boolean;
  99184. /**
  99185. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99186. * panning
  99187. */
  99188. invertRotation: boolean;
  99189. /**
  99190. * Speed multiplier for inverse camera panning
  99191. */
  99192. inverseRotationSpeed: number;
  99193. /**
  99194. * Define the current target of the camera as an object or a position.
  99195. */
  99196. lockedTarget: any;
  99197. /** @hidden */
  99198. _currentTarget: Vector3;
  99199. /** @hidden */
  99200. _initialFocalDistance: number;
  99201. /** @hidden */
  99202. _viewMatrix: Matrix;
  99203. /** @hidden */
  99204. _camMatrix: Matrix;
  99205. /** @hidden */
  99206. _cameraTransformMatrix: Matrix;
  99207. /** @hidden */
  99208. _cameraRotationMatrix: Matrix;
  99209. /** @hidden */
  99210. _referencePoint: Vector3;
  99211. /** @hidden */
  99212. _transformedReferencePoint: Vector3;
  99213. /** @hidden */
  99214. _reset: () => void;
  99215. private _defaultUp;
  99216. /**
  99217. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99218. * This is the base of the follow, arc rotate cameras and Free camera
  99219. * @see https://doc.babylonjs.com/features/cameras
  99220. * @param name Defines the name of the camera in the scene
  99221. * @param position Defines the start position of the camera in the scene
  99222. * @param scene Defines the scene the camera belongs to
  99223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99224. */
  99225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99226. /**
  99227. * Gets the position in front of the camera at a given distance.
  99228. * @param distance The distance from the camera we want the position to be
  99229. * @returns the position
  99230. */
  99231. getFrontPosition(distance: number): Vector3;
  99232. /** @hidden */
  99233. _getLockedTargetPosition(): Nullable<Vector3>;
  99234. private _storedPosition;
  99235. private _storedRotation;
  99236. private _storedRotationQuaternion;
  99237. /**
  99238. * Store current camera state of the camera (fov, position, rotation, etc..)
  99239. * @returns the camera
  99240. */
  99241. storeState(): Camera;
  99242. /**
  99243. * Restored camera state. You must call storeState() first
  99244. * @returns whether it was successful or not
  99245. * @hidden
  99246. */
  99247. _restoreStateValues(): boolean;
  99248. /** @hidden */
  99249. _initCache(): void;
  99250. /** @hidden */
  99251. _updateCache(ignoreParentClass?: boolean): void;
  99252. /** @hidden */
  99253. _isSynchronizedViewMatrix(): boolean;
  99254. /** @hidden */
  99255. _computeLocalCameraSpeed(): number;
  99256. /**
  99257. * Defines the target the camera should look at.
  99258. * @param target Defines the new target as a Vector or a mesh
  99259. */
  99260. setTarget(target: Vector3): void;
  99261. /**
  99262. * Defines the target point of the camera.
  99263. * The camera looks towards it form the radius distance.
  99264. */
  99265. get target(): Vector3;
  99266. set target(value: Vector3);
  99267. /**
  99268. * Return the current target position of the camera. This value is expressed in local space.
  99269. * @returns the target position
  99270. */
  99271. getTarget(): Vector3;
  99272. /** @hidden */
  99273. _decideIfNeedsToMove(): boolean;
  99274. /** @hidden */
  99275. _updatePosition(): void;
  99276. /** @hidden */
  99277. _checkInputs(): void;
  99278. protected _updateCameraRotationMatrix(): void;
  99279. /**
  99280. * 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)
  99281. * @returns the current camera
  99282. */
  99283. private _rotateUpVectorWithCameraRotationMatrix;
  99284. private _cachedRotationZ;
  99285. private _cachedQuaternionRotationZ;
  99286. /** @hidden */
  99287. _getViewMatrix(): Matrix;
  99288. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99289. /**
  99290. * @hidden
  99291. */
  99292. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99293. /**
  99294. * @hidden
  99295. */
  99296. _updateRigCameras(): void;
  99297. private _getRigCamPositionAndTarget;
  99298. /**
  99299. * Gets the current object class name.
  99300. * @return the class name
  99301. */
  99302. getClassName(): string;
  99303. }
  99304. }
  99305. declare module BABYLON {
  99306. /**
  99307. * Gather the list of keyboard event types as constants.
  99308. */
  99309. export class KeyboardEventTypes {
  99310. /**
  99311. * The keydown event is fired when a key becomes active (pressed).
  99312. */
  99313. static readonly KEYDOWN: number;
  99314. /**
  99315. * The keyup event is fired when a key has been released.
  99316. */
  99317. static readonly KEYUP: number;
  99318. }
  99319. /**
  99320. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99321. */
  99322. export class KeyboardInfo {
  99323. /**
  99324. * Defines the type of event (KeyboardEventTypes)
  99325. */
  99326. type: number;
  99327. /**
  99328. * Defines the related dom event
  99329. */
  99330. event: KeyboardEvent;
  99331. /**
  99332. * Instantiates a new keyboard info.
  99333. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99334. * @param type Defines the type of event (KeyboardEventTypes)
  99335. * @param event Defines the related dom event
  99336. */
  99337. constructor(
  99338. /**
  99339. * Defines the type of event (KeyboardEventTypes)
  99340. */
  99341. type: number,
  99342. /**
  99343. * Defines the related dom event
  99344. */
  99345. event: KeyboardEvent);
  99346. }
  99347. /**
  99348. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99349. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99350. */
  99351. export class KeyboardInfoPre extends KeyboardInfo {
  99352. /**
  99353. * Defines the type of event (KeyboardEventTypes)
  99354. */
  99355. type: number;
  99356. /**
  99357. * Defines the related dom event
  99358. */
  99359. event: KeyboardEvent;
  99360. /**
  99361. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99362. */
  99363. skipOnPointerObservable: boolean;
  99364. /**
  99365. * Instantiates a new keyboard pre info.
  99366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99367. * @param type Defines the type of event (KeyboardEventTypes)
  99368. * @param event Defines the related dom event
  99369. */
  99370. constructor(
  99371. /**
  99372. * Defines the type of event (KeyboardEventTypes)
  99373. */
  99374. type: number,
  99375. /**
  99376. * Defines the related dom event
  99377. */
  99378. event: KeyboardEvent);
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Manage the keyboard inputs to control the movement of a free camera.
  99384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99385. */
  99386. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99387. /**
  99388. * Defines the camera the input is attached to.
  99389. */
  99390. camera: FreeCamera;
  99391. /**
  99392. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99393. */
  99394. keysUp: number[];
  99395. /**
  99396. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99397. */
  99398. keysUpward: number[];
  99399. /**
  99400. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99401. */
  99402. keysDown: number[];
  99403. /**
  99404. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99405. */
  99406. keysDownward: number[];
  99407. /**
  99408. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99409. */
  99410. keysLeft: number[];
  99411. /**
  99412. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99413. */
  99414. keysRight: number[];
  99415. private _keys;
  99416. private _onCanvasBlurObserver;
  99417. private _onKeyboardObserver;
  99418. private _engine;
  99419. private _scene;
  99420. /**
  99421. * Attach the input controls to a specific dom element to get the input from.
  99422. * @param element Defines the element the controls should be listened from
  99423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99424. */
  99425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99426. /**
  99427. * Detach the current controls from the specified dom element.
  99428. * @param element Defines the element to stop listening the inputs from
  99429. */
  99430. detachControl(element: Nullable<HTMLElement>): void;
  99431. /**
  99432. * Update the current camera state depending on the inputs that have been used this frame.
  99433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99434. */
  99435. checkInputs(): void;
  99436. /**
  99437. * Gets the class name of the current intput.
  99438. * @returns the class name
  99439. */
  99440. getClassName(): string;
  99441. /** @hidden */
  99442. _onLostFocus(): void;
  99443. /**
  99444. * Get the friendly name associated with the input class.
  99445. * @returns the input friendly name
  99446. */
  99447. getSimpleName(): string;
  99448. }
  99449. }
  99450. declare module BABYLON {
  99451. /**
  99452. * Gather the list of pointer event types as constants.
  99453. */
  99454. export class PointerEventTypes {
  99455. /**
  99456. * 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.
  99457. */
  99458. static readonly POINTERDOWN: number;
  99459. /**
  99460. * The pointerup event is fired when a pointer is no longer active.
  99461. */
  99462. static readonly POINTERUP: number;
  99463. /**
  99464. * The pointermove event is fired when a pointer changes coordinates.
  99465. */
  99466. static readonly POINTERMOVE: number;
  99467. /**
  99468. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99469. */
  99470. static readonly POINTERWHEEL: number;
  99471. /**
  99472. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99473. */
  99474. static readonly POINTERPICK: number;
  99475. /**
  99476. * The pointertap event is fired when a the object has been touched and released without drag.
  99477. */
  99478. static readonly POINTERTAP: number;
  99479. /**
  99480. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99481. */
  99482. static readonly POINTERDOUBLETAP: number;
  99483. }
  99484. /**
  99485. * Base class of pointer info types.
  99486. */
  99487. export class PointerInfoBase {
  99488. /**
  99489. * Defines the type of event (PointerEventTypes)
  99490. */
  99491. type: number;
  99492. /**
  99493. * Defines the related dom event
  99494. */
  99495. event: PointerEvent | MouseWheelEvent;
  99496. /**
  99497. * Instantiates the base class of pointers info.
  99498. * @param type Defines the type of event (PointerEventTypes)
  99499. * @param event Defines the related dom event
  99500. */
  99501. constructor(
  99502. /**
  99503. * Defines the type of event (PointerEventTypes)
  99504. */
  99505. type: number,
  99506. /**
  99507. * Defines the related dom event
  99508. */
  99509. event: PointerEvent | MouseWheelEvent);
  99510. }
  99511. /**
  99512. * This class is used to store pointer related info for the onPrePointerObservable event.
  99513. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99514. */
  99515. export class PointerInfoPre extends PointerInfoBase {
  99516. /**
  99517. * Ray from a pointer if availible (eg. 6dof controller)
  99518. */
  99519. ray: Nullable<Ray>;
  99520. /**
  99521. * Defines the local position of the pointer on the canvas.
  99522. */
  99523. localPosition: Vector2;
  99524. /**
  99525. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99526. */
  99527. skipOnPointerObservable: boolean;
  99528. /**
  99529. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99530. * @param type Defines the type of event (PointerEventTypes)
  99531. * @param event Defines the related dom event
  99532. * @param localX Defines the local x coordinates of the pointer when the event occured
  99533. * @param localY Defines the local y coordinates of the pointer when the event occured
  99534. */
  99535. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99536. }
  99537. /**
  99538. * This type contains all the data related to a pointer event in Babylon.js.
  99539. * 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.
  99540. */
  99541. export class PointerInfo extends PointerInfoBase {
  99542. /**
  99543. * Defines the picking info associated to the info (if any)\
  99544. */
  99545. pickInfo: Nullable<PickingInfo>;
  99546. /**
  99547. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99548. * @param type Defines the type of event (PointerEventTypes)
  99549. * @param event Defines the related dom event
  99550. * @param pickInfo Defines the picking info associated to the info (if any)\
  99551. */
  99552. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99553. /**
  99554. * Defines the picking info associated to the info (if any)\
  99555. */
  99556. pickInfo: Nullable<PickingInfo>);
  99557. }
  99558. /**
  99559. * Data relating to a touch event on the screen.
  99560. */
  99561. export interface PointerTouch {
  99562. /**
  99563. * X coordinate of touch.
  99564. */
  99565. x: number;
  99566. /**
  99567. * Y coordinate of touch.
  99568. */
  99569. y: number;
  99570. /**
  99571. * Id of touch. Unique for each finger.
  99572. */
  99573. pointerId: number;
  99574. /**
  99575. * Event type passed from DOM.
  99576. */
  99577. type: any;
  99578. }
  99579. }
  99580. declare module BABYLON {
  99581. /**
  99582. * Manage the mouse inputs to control the movement of a free camera.
  99583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99584. */
  99585. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99586. /**
  99587. * Define if touch is enabled in the mouse input
  99588. */
  99589. touchEnabled: boolean;
  99590. /**
  99591. * Defines the camera the input is attached to.
  99592. */
  99593. camera: FreeCamera;
  99594. /**
  99595. * Defines the buttons associated with the input to handle camera move.
  99596. */
  99597. buttons: number[];
  99598. /**
  99599. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99600. */
  99601. angularSensibility: number;
  99602. private _pointerInput;
  99603. private _onMouseMove;
  99604. private _observer;
  99605. private previousPosition;
  99606. /**
  99607. * Observable for when a pointer move event occurs containing the move offset
  99608. */
  99609. onPointerMovedObservable: Observable<{
  99610. offsetX: number;
  99611. offsetY: number;
  99612. }>;
  99613. /**
  99614. * @hidden
  99615. * If the camera should be rotated automatically based on pointer movement
  99616. */
  99617. _allowCameraRotation: boolean;
  99618. /**
  99619. * Manage the mouse inputs to control the movement of a free camera.
  99620. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99621. * @param touchEnabled Defines if touch is enabled or not
  99622. */
  99623. constructor(
  99624. /**
  99625. * Define if touch is enabled in the mouse input
  99626. */
  99627. touchEnabled?: boolean);
  99628. /**
  99629. * Attach the input controls to a specific dom element to get the input from.
  99630. * @param element Defines the element the controls should be listened from
  99631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99632. */
  99633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99634. /**
  99635. * Called on JS contextmenu event.
  99636. * Override this method to provide functionality.
  99637. */
  99638. protected onContextMenu(evt: PointerEvent): void;
  99639. /**
  99640. * Detach the current controls from the specified dom element.
  99641. * @param element Defines the element to stop listening the inputs from
  99642. */
  99643. detachControl(element: Nullable<HTMLElement>): void;
  99644. /**
  99645. * Gets the class name of the current intput.
  99646. * @returns the class name
  99647. */
  99648. getClassName(): string;
  99649. /**
  99650. * Get the friendly name associated with the input class.
  99651. * @returns the input friendly name
  99652. */
  99653. getSimpleName(): string;
  99654. }
  99655. }
  99656. declare module BABYLON {
  99657. /**
  99658. * Manage the touch inputs to control the movement of a free camera.
  99659. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99660. */
  99661. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99662. /**
  99663. * Define if mouse events can be treated as touch events
  99664. */
  99665. allowMouse: boolean;
  99666. /**
  99667. * Defines the camera the input is attached to.
  99668. */
  99669. camera: FreeCamera;
  99670. /**
  99671. * Defines the touch sensibility for rotation.
  99672. * The higher the faster.
  99673. */
  99674. touchAngularSensibility: number;
  99675. /**
  99676. * Defines the touch sensibility for move.
  99677. * The higher the faster.
  99678. */
  99679. touchMoveSensibility: number;
  99680. private _offsetX;
  99681. private _offsetY;
  99682. private _pointerPressed;
  99683. private _pointerInput;
  99684. private _observer;
  99685. private _onLostFocus;
  99686. /**
  99687. * Manage the touch inputs to control the movement of a free camera.
  99688. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99689. * @param allowMouse Defines if mouse events can be treated as touch events
  99690. */
  99691. constructor(
  99692. /**
  99693. * Define if mouse events can be treated as touch events
  99694. */
  99695. allowMouse?: boolean);
  99696. /**
  99697. * Attach the input controls to a specific dom element to get the input from.
  99698. * @param element Defines the element the controls should be listened from
  99699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99700. */
  99701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99702. /**
  99703. * Detach the current controls from the specified dom element.
  99704. * @param element Defines the element to stop listening the inputs from
  99705. */
  99706. detachControl(element: Nullable<HTMLElement>): void;
  99707. /**
  99708. * Update the current camera state depending on the inputs that have been used this frame.
  99709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99710. */
  99711. checkInputs(): void;
  99712. /**
  99713. * Gets the class name of the current intput.
  99714. * @returns the class name
  99715. */
  99716. getClassName(): string;
  99717. /**
  99718. * Get the friendly name associated with the input class.
  99719. * @returns the input friendly name
  99720. */
  99721. getSimpleName(): string;
  99722. }
  99723. }
  99724. declare module BABYLON {
  99725. /**
  99726. * Default Inputs manager for the FreeCamera.
  99727. * It groups all the default supported inputs for ease of use.
  99728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99729. */
  99730. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99731. /**
  99732. * @hidden
  99733. */
  99734. _mouseInput: Nullable<FreeCameraMouseInput>;
  99735. /**
  99736. * Instantiates a new FreeCameraInputsManager.
  99737. * @param camera Defines the camera the inputs belong to
  99738. */
  99739. constructor(camera: FreeCamera);
  99740. /**
  99741. * Add keyboard input support to the input manager.
  99742. * @returns the current input manager
  99743. */
  99744. addKeyboard(): FreeCameraInputsManager;
  99745. /**
  99746. * Add mouse input support to the input manager.
  99747. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99748. * @returns the current input manager
  99749. */
  99750. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99751. /**
  99752. * Removes the mouse input support from the manager
  99753. * @returns the current input manager
  99754. */
  99755. removeMouse(): FreeCameraInputsManager;
  99756. /**
  99757. * Add touch input support to the input manager.
  99758. * @returns the current input manager
  99759. */
  99760. addTouch(): FreeCameraInputsManager;
  99761. /**
  99762. * Remove all attached input methods from a camera
  99763. */
  99764. clear(): void;
  99765. }
  99766. }
  99767. declare module BABYLON {
  99768. /**
  99769. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99770. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99771. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99772. */
  99773. export class FreeCamera extends TargetCamera {
  99774. /**
  99775. * Define the collision ellipsoid of the camera.
  99776. * This is helpful to simulate a camera body like the player body around the camera
  99777. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99778. */
  99779. ellipsoid: Vector3;
  99780. /**
  99781. * Define an offset for the position of the ellipsoid around the camera.
  99782. * This can be helpful to determine the center of the body near the gravity center of the body
  99783. * instead of its head.
  99784. */
  99785. ellipsoidOffset: Vector3;
  99786. /**
  99787. * Enable or disable collisions of the camera with the rest of the scene objects.
  99788. */
  99789. checkCollisions: boolean;
  99790. /**
  99791. * Enable or disable gravity on the camera.
  99792. */
  99793. applyGravity: boolean;
  99794. /**
  99795. * Define the input manager associated to the camera.
  99796. */
  99797. inputs: FreeCameraInputsManager;
  99798. /**
  99799. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99800. * Higher values reduce sensitivity.
  99801. */
  99802. get angularSensibility(): number;
  99803. /**
  99804. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99805. * Higher values reduce sensitivity.
  99806. */
  99807. set angularSensibility(value: number);
  99808. /**
  99809. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99810. */
  99811. get keysUp(): number[];
  99812. set keysUp(value: number[]);
  99813. /**
  99814. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99815. */
  99816. get keysUpward(): number[];
  99817. set keysUpward(value: number[]);
  99818. /**
  99819. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99820. */
  99821. get keysDown(): number[];
  99822. set keysDown(value: number[]);
  99823. /**
  99824. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99825. */
  99826. get keysDownward(): number[];
  99827. set keysDownward(value: number[]);
  99828. /**
  99829. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99830. */
  99831. get keysLeft(): number[];
  99832. set keysLeft(value: number[]);
  99833. /**
  99834. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99835. */
  99836. get keysRight(): number[];
  99837. set keysRight(value: number[]);
  99838. /**
  99839. * Event raised when the camera collide with a mesh in the scene.
  99840. */
  99841. onCollide: (collidedMesh: AbstractMesh) => void;
  99842. private _collider;
  99843. private _needMoveForGravity;
  99844. private _oldPosition;
  99845. private _diffPosition;
  99846. private _newPosition;
  99847. /** @hidden */
  99848. _localDirection: Vector3;
  99849. /** @hidden */
  99850. _transformedDirection: Vector3;
  99851. /**
  99852. * Instantiates a Free Camera.
  99853. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99854. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99855. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99856. * @param name Define the name of the camera in the scene
  99857. * @param position Define the start position of the camera in the scene
  99858. * @param scene Define the scene the camera belongs to
  99859. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99860. */
  99861. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99862. /**
  99863. * Attached controls to the current camera.
  99864. * @param element Defines the element the controls should be listened from
  99865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99866. */
  99867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99868. /**
  99869. * Detach the current controls from the camera.
  99870. * The camera will stop reacting to inputs.
  99871. * @param element Defines the element to stop listening the inputs from
  99872. */
  99873. detachControl(element: HTMLElement): void;
  99874. private _collisionMask;
  99875. /**
  99876. * Define a collision mask to limit the list of object the camera can collide with
  99877. */
  99878. get collisionMask(): number;
  99879. set collisionMask(mask: number);
  99880. /** @hidden */
  99881. _collideWithWorld(displacement: Vector3): void;
  99882. private _onCollisionPositionChange;
  99883. /** @hidden */
  99884. _checkInputs(): void;
  99885. /** @hidden */
  99886. _decideIfNeedsToMove(): boolean;
  99887. /** @hidden */
  99888. _updatePosition(): void;
  99889. /**
  99890. * Destroy the camera and release the current resources hold by it.
  99891. */
  99892. dispose(): void;
  99893. /**
  99894. * Gets the current object class name.
  99895. * @return the class name
  99896. */
  99897. getClassName(): string;
  99898. }
  99899. }
  99900. declare module BABYLON {
  99901. /**
  99902. * Represents a gamepad control stick position
  99903. */
  99904. export class StickValues {
  99905. /**
  99906. * The x component of the control stick
  99907. */
  99908. x: number;
  99909. /**
  99910. * The y component of the control stick
  99911. */
  99912. y: number;
  99913. /**
  99914. * Initializes the gamepad x and y control stick values
  99915. * @param x The x component of the gamepad control stick value
  99916. * @param y The y component of the gamepad control stick value
  99917. */
  99918. constructor(
  99919. /**
  99920. * The x component of the control stick
  99921. */
  99922. x: number,
  99923. /**
  99924. * The y component of the control stick
  99925. */
  99926. y: number);
  99927. }
  99928. /**
  99929. * An interface which manages callbacks for gamepad button changes
  99930. */
  99931. export interface GamepadButtonChanges {
  99932. /**
  99933. * Called when a gamepad has been changed
  99934. */
  99935. changed: boolean;
  99936. /**
  99937. * Called when a gamepad press event has been triggered
  99938. */
  99939. pressChanged: boolean;
  99940. /**
  99941. * Called when a touch event has been triggered
  99942. */
  99943. touchChanged: boolean;
  99944. /**
  99945. * Called when a value has changed
  99946. */
  99947. valueChanged: boolean;
  99948. }
  99949. /**
  99950. * Represents a gamepad
  99951. */
  99952. export class Gamepad {
  99953. /**
  99954. * The id of the gamepad
  99955. */
  99956. id: string;
  99957. /**
  99958. * The index of the gamepad
  99959. */
  99960. index: number;
  99961. /**
  99962. * The browser gamepad
  99963. */
  99964. browserGamepad: any;
  99965. /**
  99966. * Specifies what type of gamepad this represents
  99967. */
  99968. type: number;
  99969. private _leftStick;
  99970. private _rightStick;
  99971. /** @hidden */
  99972. _isConnected: boolean;
  99973. private _leftStickAxisX;
  99974. private _leftStickAxisY;
  99975. private _rightStickAxisX;
  99976. private _rightStickAxisY;
  99977. /**
  99978. * Triggered when the left control stick has been changed
  99979. */
  99980. private _onleftstickchanged;
  99981. /**
  99982. * Triggered when the right control stick has been changed
  99983. */
  99984. private _onrightstickchanged;
  99985. /**
  99986. * Represents a gamepad controller
  99987. */
  99988. static GAMEPAD: number;
  99989. /**
  99990. * Represents a generic controller
  99991. */
  99992. static GENERIC: number;
  99993. /**
  99994. * Represents an XBox controller
  99995. */
  99996. static XBOX: number;
  99997. /**
  99998. * Represents a pose-enabled controller
  99999. */
  100000. static POSE_ENABLED: number;
  100001. /**
  100002. * Represents an Dual Shock controller
  100003. */
  100004. static DUALSHOCK: number;
  100005. /**
  100006. * Specifies whether the left control stick should be Y-inverted
  100007. */
  100008. protected _invertLeftStickY: boolean;
  100009. /**
  100010. * Specifies if the gamepad has been connected
  100011. */
  100012. get isConnected(): boolean;
  100013. /**
  100014. * Initializes the gamepad
  100015. * @param id The id of the gamepad
  100016. * @param index The index of the gamepad
  100017. * @param browserGamepad The browser gamepad
  100018. * @param leftStickX The x component of the left joystick
  100019. * @param leftStickY The y component of the left joystick
  100020. * @param rightStickX The x component of the right joystick
  100021. * @param rightStickY The y component of the right joystick
  100022. */
  100023. constructor(
  100024. /**
  100025. * The id of the gamepad
  100026. */
  100027. id: string,
  100028. /**
  100029. * The index of the gamepad
  100030. */
  100031. index: number,
  100032. /**
  100033. * The browser gamepad
  100034. */
  100035. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100036. /**
  100037. * Callback triggered when the left joystick has changed
  100038. * @param callback
  100039. */
  100040. onleftstickchanged(callback: (values: StickValues) => void): void;
  100041. /**
  100042. * Callback triggered when the right joystick has changed
  100043. * @param callback
  100044. */
  100045. onrightstickchanged(callback: (values: StickValues) => void): void;
  100046. /**
  100047. * Gets the left joystick
  100048. */
  100049. get leftStick(): StickValues;
  100050. /**
  100051. * Sets the left joystick values
  100052. */
  100053. set leftStick(newValues: StickValues);
  100054. /**
  100055. * Gets the right joystick
  100056. */
  100057. get rightStick(): StickValues;
  100058. /**
  100059. * Sets the right joystick value
  100060. */
  100061. set rightStick(newValues: StickValues);
  100062. /**
  100063. * Updates the gamepad joystick positions
  100064. */
  100065. update(): void;
  100066. /**
  100067. * Disposes the gamepad
  100068. */
  100069. dispose(): void;
  100070. }
  100071. /**
  100072. * Represents a generic gamepad
  100073. */
  100074. export class GenericPad extends Gamepad {
  100075. private _buttons;
  100076. private _onbuttondown;
  100077. private _onbuttonup;
  100078. /**
  100079. * Observable triggered when a button has been pressed
  100080. */
  100081. onButtonDownObservable: Observable<number>;
  100082. /**
  100083. * Observable triggered when a button has been released
  100084. */
  100085. onButtonUpObservable: Observable<number>;
  100086. /**
  100087. * Callback triggered when a button has been pressed
  100088. * @param callback Called when a button has been pressed
  100089. */
  100090. onbuttondown(callback: (buttonPressed: number) => void): void;
  100091. /**
  100092. * Callback triggered when a button has been released
  100093. * @param callback Called when a button has been released
  100094. */
  100095. onbuttonup(callback: (buttonReleased: number) => void): void;
  100096. /**
  100097. * Initializes the generic gamepad
  100098. * @param id The id of the generic gamepad
  100099. * @param index The index of the generic gamepad
  100100. * @param browserGamepad The browser gamepad
  100101. */
  100102. constructor(id: string, index: number, browserGamepad: any);
  100103. private _setButtonValue;
  100104. /**
  100105. * Updates the generic gamepad
  100106. */
  100107. update(): void;
  100108. /**
  100109. * Disposes the generic gamepad
  100110. */
  100111. dispose(): void;
  100112. }
  100113. }
  100114. declare module BABYLON {
  100115. /**
  100116. * Defines the types of pose enabled controllers that are supported
  100117. */
  100118. export enum PoseEnabledControllerType {
  100119. /**
  100120. * HTC Vive
  100121. */
  100122. VIVE = 0,
  100123. /**
  100124. * Oculus Rift
  100125. */
  100126. OCULUS = 1,
  100127. /**
  100128. * Windows mixed reality
  100129. */
  100130. WINDOWS = 2,
  100131. /**
  100132. * Samsung gear VR
  100133. */
  100134. GEAR_VR = 3,
  100135. /**
  100136. * Google Daydream
  100137. */
  100138. DAYDREAM = 4,
  100139. /**
  100140. * Generic
  100141. */
  100142. GENERIC = 5
  100143. }
  100144. /**
  100145. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100146. */
  100147. export interface MutableGamepadButton {
  100148. /**
  100149. * Value of the button/trigger
  100150. */
  100151. value: number;
  100152. /**
  100153. * If the button/trigger is currently touched
  100154. */
  100155. touched: boolean;
  100156. /**
  100157. * If the button/trigger is currently pressed
  100158. */
  100159. pressed: boolean;
  100160. }
  100161. /**
  100162. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100163. * @hidden
  100164. */
  100165. export interface ExtendedGamepadButton extends GamepadButton {
  100166. /**
  100167. * If the button/trigger is currently pressed
  100168. */
  100169. readonly pressed: boolean;
  100170. /**
  100171. * If the button/trigger is currently touched
  100172. */
  100173. readonly touched: boolean;
  100174. /**
  100175. * Value of the button/trigger
  100176. */
  100177. readonly value: number;
  100178. }
  100179. /** @hidden */
  100180. export interface _GamePadFactory {
  100181. /**
  100182. * Returns whether or not the current gamepad can be created for this type of controller.
  100183. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100184. * @returns true if it can be created, otherwise false
  100185. */
  100186. canCreate(gamepadInfo: any): boolean;
  100187. /**
  100188. * Creates a new instance of the Gamepad.
  100189. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100190. * @returns the new gamepad instance
  100191. */
  100192. create(gamepadInfo: any): Gamepad;
  100193. }
  100194. /**
  100195. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100196. */
  100197. export class PoseEnabledControllerHelper {
  100198. /** @hidden */
  100199. static _ControllerFactories: _GamePadFactory[];
  100200. /** @hidden */
  100201. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100202. /**
  100203. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100204. * @param vrGamepad the gamepad to initialized
  100205. * @returns a vr controller of the type the gamepad identified as
  100206. */
  100207. static InitiateController(vrGamepad: any): Gamepad;
  100208. }
  100209. /**
  100210. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100211. */
  100212. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100213. /**
  100214. * If the controller is used in a webXR session
  100215. */
  100216. isXR: boolean;
  100217. private _deviceRoomPosition;
  100218. private _deviceRoomRotationQuaternion;
  100219. /**
  100220. * The device position in babylon space
  100221. */
  100222. devicePosition: Vector3;
  100223. /**
  100224. * The device rotation in babylon space
  100225. */
  100226. deviceRotationQuaternion: Quaternion;
  100227. /**
  100228. * The scale factor of the device in babylon space
  100229. */
  100230. deviceScaleFactor: number;
  100231. /**
  100232. * (Likely devicePosition should be used instead) The device position in its room space
  100233. */
  100234. position: Vector3;
  100235. /**
  100236. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100237. */
  100238. rotationQuaternion: Quaternion;
  100239. /**
  100240. * The type of controller (Eg. Windows mixed reality)
  100241. */
  100242. controllerType: PoseEnabledControllerType;
  100243. protected _calculatedPosition: Vector3;
  100244. private _calculatedRotation;
  100245. /**
  100246. * The raw pose from the device
  100247. */
  100248. rawPose: DevicePose;
  100249. private _trackPosition;
  100250. private _maxRotationDistFromHeadset;
  100251. private _draggedRoomRotation;
  100252. /**
  100253. * @hidden
  100254. */
  100255. _disableTrackPosition(fixedPosition: Vector3): void;
  100256. /**
  100257. * Internal, the mesh attached to the controller
  100258. * @hidden
  100259. */
  100260. _mesh: Nullable<AbstractMesh>;
  100261. private _poseControlledCamera;
  100262. private _leftHandSystemQuaternion;
  100263. /**
  100264. * Internal, matrix used to convert room space to babylon space
  100265. * @hidden
  100266. */
  100267. _deviceToWorld: Matrix;
  100268. /**
  100269. * Node to be used when casting a ray from the controller
  100270. * @hidden
  100271. */
  100272. _pointingPoseNode: Nullable<TransformNode>;
  100273. /**
  100274. * Name of the child mesh that can be used to cast a ray from the controller
  100275. */
  100276. static readonly POINTING_POSE: string;
  100277. /**
  100278. * Creates a new PoseEnabledController from a gamepad
  100279. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100280. */
  100281. constructor(browserGamepad: any);
  100282. private _workingMatrix;
  100283. /**
  100284. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100285. */
  100286. update(): void;
  100287. /**
  100288. * Updates only the pose device and mesh without doing any button event checking
  100289. */
  100290. protected _updatePoseAndMesh(): void;
  100291. /**
  100292. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100293. * @param poseData raw pose fromthe device
  100294. */
  100295. updateFromDevice(poseData: DevicePose): void;
  100296. /**
  100297. * @hidden
  100298. */
  100299. _meshAttachedObservable: Observable<AbstractMesh>;
  100300. /**
  100301. * Attaches a mesh to the controller
  100302. * @param mesh the mesh to be attached
  100303. */
  100304. attachToMesh(mesh: AbstractMesh): void;
  100305. /**
  100306. * Attaches the controllers mesh to a camera
  100307. * @param camera the camera the mesh should be attached to
  100308. */
  100309. attachToPoseControlledCamera(camera: TargetCamera): void;
  100310. /**
  100311. * Disposes of the controller
  100312. */
  100313. dispose(): void;
  100314. /**
  100315. * The mesh that is attached to the controller
  100316. */
  100317. get mesh(): Nullable<AbstractMesh>;
  100318. /**
  100319. * Gets the ray of the controller in the direction the controller is pointing
  100320. * @param length the length the resulting ray should be
  100321. * @returns a ray in the direction the controller is pointing
  100322. */
  100323. getForwardRay(length?: number): Ray;
  100324. }
  100325. }
  100326. declare module BABYLON {
  100327. /**
  100328. * Defines the WebVRController object that represents controllers tracked in 3D space
  100329. */
  100330. export abstract class WebVRController extends PoseEnabledController {
  100331. /**
  100332. * Internal, the default controller model for the controller
  100333. */
  100334. protected _defaultModel: Nullable<AbstractMesh>;
  100335. /**
  100336. * Fired when the trigger state has changed
  100337. */
  100338. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100339. /**
  100340. * Fired when the main button state has changed
  100341. */
  100342. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100343. /**
  100344. * Fired when the secondary button state has changed
  100345. */
  100346. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100347. /**
  100348. * Fired when the pad state has changed
  100349. */
  100350. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100351. /**
  100352. * Fired when controllers stick values have changed
  100353. */
  100354. onPadValuesChangedObservable: Observable<StickValues>;
  100355. /**
  100356. * Array of button availible on the controller
  100357. */
  100358. protected _buttons: Array<MutableGamepadButton>;
  100359. private _onButtonStateChange;
  100360. /**
  100361. * Fired when a controller button's state has changed
  100362. * @param callback the callback containing the button that was modified
  100363. */
  100364. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100365. /**
  100366. * X and Y axis corresponding to the controllers joystick
  100367. */
  100368. pad: StickValues;
  100369. /**
  100370. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100371. */
  100372. hand: string;
  100373. /**
  100374. * The default controller model for the controller
  100375. */
  100376. get defaultModel(): Nullable<AbstractMesh>;
  100377. /**
  100378. * Creates a new WebVRController from a gamepad
  100379. * @param vrGamepad the gamepad that the WebVRController should be created from
  100380. */
  100381. constructor(vrGamepad: any);
  100382. /**
  100383. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100384. */
  100385. update(): void;
  100386. /**
  100387. * Function to be called when a button is modified
  100388. */
  100389. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100390. /**
  100391. * Loads a mesh and attaches it to the controller
  100392. * @param scene the scene the mesh should be added to
  100393. * @param meshLoaded callback for when the mesh has been loaded
  100394. */
  100395. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100396. private _setButtonValue;
  100397. private _changes;
  100398. private _checkChanges;
  100399. /**
  100400. * Disposes of th webVRCOntroller
  100401. */
  100402. dispose(): void;
  100403. }
  100404. }
  100405. declare module BABYLON {
  100406. /**
  100407. * The HemisphericLight simulates the ambient environment light,
  100408. * so the passed direction is the light reflection direction, not the incoming direction.
  100409. */
  100410. export class HemisphericLight extends Light {
  100411. /**
  100412. * The groundColor is the light in the opposite direction to the one specified during creation.
  100413. * 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.
  100414. */
  100415. groundColor: Color3;
  100416. /**
  100417. * The light reflection direction, not the incoming direction.
  100418. */
  100419. direction: Vector3;
  100420. /**
  100421. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100422. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100423. * The HemisphericLight can't cast shadows.
  100424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100425. * @param name The friendly name of the light
  100426. * @param direction The direction of the light reflection
  100427. * @param scene The scene the light belongs to
  100428. */
  100429. constructor(name: string, direction: Vector3, scene: Scene);
  100430. protected _buildUniformLayout(): void;
  100431. /**
  100432. * Returns the string "HemisphericLight".
  100433. * @return The class name
  100434. */
  100435. getClassName(): string;
  100436. /**
  100437. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100438. * Returns the updated direction.
  100439. * @param target The target the direction should point to
  100440. * @return The computed direction
  100441. */
  100442. setDirectionToTarget(target: Vector3): Vector3;
  100443. /**
  100444. * Returns the shadow generator associated to the light.
  100445. * @returns Always null for hemispheric lights because it does not support shadows.
  100446. */
  100447. getShadowGenerator(): Nullable<IShadowGenerator>;
  100448. /**
  100449. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100450. * @param effect The effect to update
  100451. * @param lightIndex The index of the light in the effect to update
  100452. * @returns The hemispheric light
  100453. */
  100454. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100455. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100456. /**
  100457. * Computes the world matrix of the node
  100458. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100459. * @param useWasUpdatedFlag defines a reserved property
  100460. * @returns the world matrix
  100461. */
  100462. computeWorldMatrix(): Matrix;
  100463. /**
  100464. * Returns the integer 3.
  100465. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100466. */
  100467. getTypeID(): number;
  100468. /**
  100469. * Prepares the list of defines specific to the light type.
  100470. * @param defines the list of defines
  100471. * @param lightIndex defines the index of the light for the effect
  100472. */
  100473. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100474. }
  100475. }
  100476. declare module BABYLON {
  100477. /** @hidden */
  100478. export var vrMultiviewToSingleviewPixelShader: {
  100479. name: string;
  100480. shader: string;
  100481. };
  100482. }
  100483. declare module BABYLON {
  100484. /**
  100485. * Renders to multiple views with a single draw call
  100486. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100487. */
  100488. export class MultiviewRenderTarget extends RenderTargetTexture {
  100489. /**
  100490. * Creates a multiview render target
  100491. * @param scene scene used with the render target
  100492. * @param size the size of the render target (used for each view)
  100493. */
  100494. constructor(scene: Scene, size?: number | {
  100495. width: number;
  100496. height: number;
  100497. } | {
  100498. ratio: number;
  100499. });
  100500. /**
  100501. * @hidden
  100502. * @param faceIndex the face index, if its a cube texture
  100503. */
  100504. _bindFrameBuffer(faceIndex?: number): void;
  100505. /**
  100506. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100507. * @returns the view count
  100508. */
  100509. getViewCount(): number;
  100510. }
  100511. }
  100512. declare module BABYLON {
  100513. interface Engine {
  100514. /**
  100515. * Creates a new multiview render target
  100516. * @param width defines the width of the texture
  100517. * @param height defines the height of the texture
  100518. * @returns the created multiview texture
  100519. */
  100520. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100521. /**
  100522. * Binds a multiview framebuffer to be drawn to
  100523. * @param multiviewTexture texture to bind
  100524. */
  100525. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100526. }
  100527. interface Camera {
  100528. /**
  100529. * @hidden
  100530. * 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)
  100531. */
  100532. _useMultiviewToSingleView: boolean;
  100533. /**
  100534. * @hidden
  100535. * 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)
  100536. */
  100537. _multiviewTexture: Nullable<RenderTargetTexture>;
  100538. /**
  100539. * @hidden
  100540. * ensures the multiview texture of the camera exists and has the specified width/height
  100541. * @param width height to set on the multiview texture
  100542. * @param height width to set on the multiview texture
  100543. */
  100544. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100545. }
  100546. interface Scene {
  100547. /** @hidden */
  100548. _transformMatrixR: Matrix;
  100549. /** @hidden */
  100550. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100551. /** @hidden */
  100552. _createMultiviewUbo(): void;
  100553. /** @hidden */
  100554. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100555. /** @hidden */
  100556. _renderMultiviewToSingleView(camera: Camera): void;
  100557. }
  100558. }
  100559. declare module BABYLON {
  100560. /**
  100561. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100562. * This will not be used for webXR as it supports displaying texture arrays directly
  100563. */
  100564. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100565. /**
  100566. * Gets a string identifying the name of the class
  100567. * @returns "VRMultiviewToSingleviewPostProcess" string
  100568. */
  100569. getClassName(): string;
  100570. /**
  100571. * Initializes a VRMultiviewToSingleview
  100572. * @param name name of the post process
  100573. * @param camera camera to be applied to
  100574. * @param scaleFactor scaling factor to the size of the output texture
  100575. */
  100576. constructor(name: string, camera: Camera, scaleFactor: number);
  100577. }
  100578. }
  100579. declare module BABYLON {
  100580. /**
  100581. * Interface used to define additional presentation attributes
  100582. */
  100583. export interface IVRPresentationAttributes {
  100584. /**
  100585. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100586. */
  100587. highRefreshRate: boolean;
  100588. /**
  100589. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100590. */
  100591. foveationLevel: number;
  100592. }
  100593. interface Engine {
  100594. /** @hidden */
  100595. _vrDisplay: any;
  100596. /** @hidden */
  100597. _vrSupported: boolean;
  100598. /** @hidden */
  100599. _oldSize: Size;
  100600. /** @hidden */
  100601. _oldHardwareScaleFactor: number;
  100602. /** @hidden */
  100603. _vrExclusivePointerMode: boolean;
  100604. /** @hidden */
  100605. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100606. /** @hidden */
  100607. _onVRDisplayPointerRestricted: () => void;
  100608. /** @hidden */
  100609. _onVRDisplayPointerUnrestricted: () => void;
  100610. /** @hidden */
  100611. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100612. /** @hidden */
  100613. _onVrDisplayDisconnect: Nullable<() => void>;
  100614. /** @hidden */
  100615. _onVrDisplayPresentChange: Nullable<() => void>;
  100616. /**
  100617. * Observable signaled when VR display mode changes
  100618. */
  100619. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100620. /**
  100621. * Observable signaled when VR request present is complete
  100622. */
  100623. onVRRequestPresentComplete: Observable<boolean>;
  100624. /**
  100625. * Observable signaled when VR request present starts
  100626. */
  100627. onVRRequestPresentStart: Observable<Engine>;
  100628. /**
  100629. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100630. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100631. */
  100632. isInVRExclusivePointerMode: boolean;
  100633. /**
  100634. * Gets a boolean indicating if a webVR device was detected
  100635. * @returns true if a webVR device was detected
  100636. */
  100637. isVRDevicePresent(): boolean;
  100638. /**
  100639. * Gets the current webVR device
  100640. * @returns the current webVR device (or null)
  100641. */
  100642. getVRDevice(): any;
  100643. /**
  100644. * Initializes a webVR display and starts listening to display change events
  100645. * The onVRDisplayChangedObservable will be notified upon these changes
  100646. * @returns A promise containing a VRDisplay and if vr is supported
  100647. */
  100648. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100649. /** @hidden */
  100650. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100651. /**
  100652. * Gets or sets the presentation attributes used to configure VR rendering
  100653. */
  100654. vrPresentationAttributes?: IVRPresentationAttributes;
  100655. /**
  100656. * Call this function to switch to webVR mode
  100657. * Will do nothing if webVR is not supported or if there is no webVR device
  100658. * @param options the webvr options provided to the camera. mainly used for multiview
  100659. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100660. */
  100661. enableVR(options: WebVROptions): void;
  100662. /** @hidden */
  100663. _onVRFullScreenTriggered(): void;
  100664. }
  100665. }
  100666. declare module BABYLON {
  100667. /**
  100668. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100669. * IMPORTANT!! The data is right-hand data.
  100670. * @export
  100671. * @interface DevicePose
  100672. */
  100673. export interface DevicePose {
  100674. /**
  100675. * The position of the device, values in array are [x,y,z].
  100676. */
  100677. readonly position: Nullable<Float32Array>;
  100678. /**
  100679. * The linearVelocity of the device, values in array are [x,y,z].
  100680. */
  100681. readonly linearVelocity: Nullable<Float32Array>;
  100682. /**
  100683. * The linearAcceleration of the device, values in array are [x,y,z].
  100684. */
  100685. readonly linearAcceleration: Nullable<Float32Array>;
  100686. /**
  100687. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100688. */
  100689. readonly orientation: Nullable<Float32Array>;
  100690. /**
  100691. * The angularVelocity of the device, values in array are [x,y,z].
  100692. */
  100693. readonly angularVelocity: Nullable<Float32Array>;
  100694. /**
  100695. * The angularAcceleration of the device, values in array are [x,y,z].
  100696. */
  100697. readonly angularAcceleration: Nullable<Float32Array>;
  100698. }
  100699. /**
  100700. * Interface representing a pose controlled object in Babylon.
  100701. * A pose controlled object has both regular pose values as well as pose values
  100702. * from an external device such as a VR head mounted display
  100703. */
  100704. export interface PoseControlled {
  100705. /**
  100706. * The position of the object in babylon space.
  100707. */
  100708. position: Vector3;
  100709. /**
  100710. * The rotation quaternion of the object in babylon space.
  100711. */
  100712. rotationQuaternion: Quaternion;
  100713. /**
  100714. * The position of the device in babylon space.
  100715. */
  100716. devicePosition?: Vector3;
  100717. /**
  100718. * The rotation quaternion of the device in babylon space.
  100719. */
  100720. deviceRotationQuaternion: Quaternion;
  100721. /**
  100722. * The raw pose coming from the device.
  100723. */
  100724. rawPose: Nullable<DevicePose>;
  100725. /**
  100726. * The scale of the device to be used when translating from device space to babylon space.
  100727. */
  100728. deviceScaleFactor: number;
  100729. /**
  100730. * Updates the poseControlled values based on the input device pose.
  100731. * @param poseData the pose data to update the object with
  100732. */
  100733. updateFromDevice(poseData: DevicePose): void;
  100734. }
  100735. /**
  100736. * Set of options to customize the webVRCamera
  100737. */
  100738. export interface WebVROptions {
  100739. /**
  100740. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100741. */
  100742. trackPosition?: boolean;
  100743. /**
  100744. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100745. */
  100746. positionScale?: number;
  100747. /**
  100748. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100749. */
  100750. displayName?: string;
  100751. /**
  100752. * Should the native controller meshes be initialized. (default: true)
  100753. */
  100754. controllerMeshes?: boolean;
  100755. /**
  100756. * Creating a default HemiLight only on controllers. (default: true)
  100757. */
  100758. defaultLightingOnControllers?: boolean;
  100759. /**
  100760. * If you don't want to use the default VR button of the helper. (default: false)
  100761. */
  100762. useCustomVRButton?: boolean;
  100763. /**
  100764. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100765. */
  100766. customVRButton?: HTMLButtonElement;
  100767. /**
  100768. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100769. */
  100770. rayLength?: number;
  100771. /**
  100772. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100773. */
  100774. defaultHeight?: number;
  100775. /**
  100776. * If multiview should be used if availible (default: false)
  100777. */
  100778. useMultiview?: boolean;
  100779. }
  100780. /**
  100781. * This represents a WebVR camera.
  100782. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100783. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100784. */
  100785. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100786. private webVROptions;
  100787. /**
  100788. * @hidden
  100789. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100790. */
  100791. _vrDevice: any;
  100792. /**
  100793. * The rawPose of the vrDevice.
  100794. */
  100795. rawPose: Nullable<DevicePose>;
  100796. private _onVREnabled;
  100797. private _specsVersion;
  100798. private _attached;
  100799. private _frameData;
  100800. protected _descendants: Array<Node>;
  100801. private _deviceRoomPosition;
  100802. /** @hidden */
  100803. _deviceRoomRotationQuaternion: Quaternion;
  100804. private _standingMatrix;
  100805. /**
  100806. * Represents device position in babylon space.
  100807. */
  100808. devicePosition: Vector3;
  100809. /**
  100810. * Represents device rotation in babylon space.
  100811. */
  100812. deviceRotationQuaternion: Quaternion;
  100813. /**
  100814. * The scale of the device to be used when translating from device space to babylon space.
  100815. */
  100816. deviceScaleFactor: number;
  100817. private _deviceToWorld;
  100818. private _worldToDevice;
  100819. /**
  100820. * References to the webVR controllers for the vrDevice.
  100821. */
  100822. controllers: Array<WebVRController>;
  100823. /**
  100824. * Emits an event when a controller is attached.
  100825. */
  100826. onControllersAttachedObservable: Observable<WebVRController[]>;
  100827. /**
  100828. * Emits an event when a controller's mesh has been loaded;
  100829. */
  100830. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100831. /**
  100832. * Emits an event when the HMD's pose has been updated.
  100833. */
  100834. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100835. private _poseSet;
  100836. /**
  100837. * If the rig cameras be used as parent instead of this camera.
  100838. */
  100839. rigParenting: boolean;
  100840. private _lightOnControllers;
  100841. private _defaultHeight?;
  100842. /**
  100843. * Instantiates a WebVRFreeCamera.
  100844. * @param name The name of the WebVRFreeCamera
  100845. * @param position The starting anchor position for the camera
  100846. * @param scene The scene the camera belongs to
  100847. * @param webVROptions a set of customizable options for the webVRCamera
  100848. */
  100849. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100850. /**
  100851. * Gets the device distance from the ground in meters.
  100852. * @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.
  100853. */
  100854. deviceDistanceToRoomGround(): number;
  100855. /**
  100856. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100857. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100858. */
  100859. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100860. /**
  100861. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100862. * @returns A promise with a boolean set to if the standing matrix is supported.
  100863. */
  100864. useStandingMatrixAsync(): Promise<boolean>;
  100865. /**
  100866. * Disposes the camera
  100867. */
  100868. dispose(): void;
  100869. /**
  100870. * Gets a vrController by name.
  100871. * @param name The name of the controller to retreive
  100872. * @returns the controller matching the name specified or null if not found
  100873. */
  100874. getControllerByName(name: string): Nullable<WebVRController>;
  100875. private _leftController;
  100876. /**
  100877. * The controller corresponding to the users left hand.
  100878. */
  100879. get leftController(): Nullable<WebVRController>;
  100880. private _rightController;
  100881. /**
  100882. * The controller corresponding to the users right hand.
  100883. */
  100884. get rightController(): Nullable<WebVRController>;
  100885. /**
  100886. * Casts a ray forward from the vrCamera's gaze.
  100887. * @param length Length of the ray (default: 100)
  100888. * @returns the ray corresponding to the gaze
  100889. */
  100890. getForwardRay(length?: number): Ray;
  100891. /**
  100892. * @hidden
  100893. * Updates the camera based on device's frame data
  100894. */
  100895. _checkInputs(): void;
  100896. /**
  100897. * Updates the poseControlled values based on the input device pose.
  100898. * @param poseData Pose coming from the device
  100899. */
  100900. updateFromDevice(poseData: DevicePose): void;
  100901. private _htmlElementAttached;
  100902. private _detachIfAttached;
  100903. /**
  100904. * WebVR's attach control will start broadcasting frames to the device.
  100905. * Note that in certain browsers (chrome for example) this function must be called
  100906. * within a user-interaction callback. Example:
  100907. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100908. *
  100909. * @param element html element to attach the vrDevice to
  100910. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100911. */
  100912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100913. /**
  100914. * Detaches the camera from the html element and disables VR
  100915. *
  100916. * @param element html element to detach from
  100917. */
  100918. detachControl(element: HTMLElement): void;
  100919. /**
  100920. * @returns the name of this class
  100921. */
  100922. getClassName(): string;
  100923. /**
  100924. * Calls resetPose on the vrDisplay
  100925. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100926. */
  100927. resetToCurrentRotation(): void;
  100928. /**
  100929. * @hidden
  100930. * Updates the rig cameras (left and right eye)
  100931. */
  100932. _updateRigCameras(): void;
  100933. private _workingVector;
  100934. private _oneVector;
  100935. private _workingMatrix;
  100936. private updateCacheCalled;
  100937. private _correctPositionIfNotTrackPosition;
  100938. /**
  100939. * @hidden
  100940. * Updates the cached values of the camera
  100941. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100942. */
  100943. _updateCache(ignoreParentClass?: boolean): void;
  100944. /**
  100945. * @hidden
  100946. * Get current device position in babylon world
  100947. */
  100948. _computeDevicePosition(): void;
  100949. /**
  100950. * Updates the current device position and rotation in the babylon world
  100951. */
  100952. update(): void;
  100953. /**
  100954. * @hidden
  100955. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100956. * @returns an identity matrix
  100957. */
  100958. _getViewMatrix(): Matrix;
  100959. private _tmpMatrix;
  100960. /**
  100961. * This function is called by the two RIG cameras.
  100962. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100963. * @hidden
  100964. */
  100965. _getWebVRViewMatrix(): Matrix;
  100966. /** @hidden */
  100967. _getWebVRProjectionMatrix(): Matrix;
  100968. private _onGamepadConnectedObserver;
  100969. private _onGamepadDisconnectedObserver;
  100970. private _updateCacheWhenTrackingDisabledObserver;
  100971. /**
  100972. * Initializes the controllers and their meshes
  100973. */
  100974. initControllers(): void;
  100975. }
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100980. *
  100981. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100982. *
  100983. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100984. */
  100985. export class MaterialHelper {
  100986. /**
  100987. * Bind the current view position to an effect.
  100988. * @param effect The effect to be bound
  100989. * @param scene The scene the eyes position is used from
  100990. * @param variableName name of the shader variable that will hold the eye position
  100991. */
  100992. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100993. /**
  100994. * Helps preparing the defines values about the UVs in used in the effect.
  100995. * UVs are shared as much as we can accross channels in the shaders.
  100996. * @param texture The texture we are preparing the UVs for
  100997. * @param defines The defines to update
  100998. * @param key The channel key "diffuse", "specular"... used in the shader
  100999. */
  101000. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101001. /**
  101002. * Binds a texture matrix value to its corrsponding uniform
  101003. * @param texture The texture to bind the matrix for
  101004. * @param uniformBuffer The uniform buffer receivin the data
  101005. * @param key The channel key "diffuse", "specular"... used in the shader
  101006. */
  101007. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101008. /**
  101009. * Gets the current status of the fog (should it be enabled?)
  101010. * @param mesh defines the mesh to evaluate for fog support
  101011. * @param scene defines the hosting scene
  101012. * @returns true if fog must be enabled
  101013. */
  101014. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101015. /**
  101016. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101017. * @param mesh defines the current mesh
  101018. * @param scene defines the current scene
  101019. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101020. * @param pointsCloud defines if point cloud rendering has to be turned on
  101021. * @param fogEnabled defines if fog has to be turned on
  101022. * @param alphaTest defines if alpha testing has to be turned on
  101023. * @param defines defines the current list of defines
  101024. */
  101025. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101026. /**
  101027. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101028. * @param scene defines the current scene
  101029. * @param engine defines the current engine
  101030. * @param defines specifies the list of active defines
  101031. * @param useInstances defines if instances have to be turned on
  101032. * @param useClipPlane defines if clip plane have to be turned on
  101033. * @param useInstances defines if instances have to be turned on
  101034. * @param useThinInstances defines if thin instances have to be turned on
  101035. */
  101036. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101037. /**
  101038. * Prepares the defines for bones
  101039. * @param mesh The mesh containing the geometry data we will draw
  101040. * @param defines The defines to update
  101041. */
  101042. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101043. /**
  101044. * Prepares the defines for morph targets
  101045. * @param mesh The mesh containing the geometry data we will draw
  101046. * @param defines The defines to update
  101047. */
  101048. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101049. /**
  101050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101051. * @param mesh The mesh containing the geometry data we will draw
  101052. * @param defines The defines to update
  101053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101054. * @param useBones Precise whether bones should be used or not (override mesh info)
  101055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101057. * @returns false if defines are considered not dirty and have not been checked
  101058. */
  101059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101060. /**
  101061. * Prepares the defines related to multiview
  101062. * @param scene The scene we are intending to draw
  101063. * @param defines The defines to update
  101064. */
  101065. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101066. /**
  101067. * Prepares the defines related to the prepass
  101068. * @param scene The scene we are intending to draw
  101069. * @param defines The defines to update
  101070. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101071. */
  101072. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101073. /**
  101074. * Prepares the defines related to the light information passed in parameter
  101075. * @param scene The scene we are intending to draw
  101076. * @param mesh The mesh the effect is compiling for
  101077. * @param light The light the effect is compiling for
  101078. * @param lightIndex The index of the light
  101079. * @param defines The defines to update
  101080. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101081. * @param state Defines the current state regarding what is needed (normals, etc...)
  101082. */
  101083. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101084. needNormals: boolean;
  101085. needRebuild: boolean;
  101086. shadowEnabled: boolean;
  101087. specularEnabled: boolean;
  101088. lightmapMode: boolean;
  101089. }): void;
  101090. /**
  101091. * Prepares the defines related to the light information passed in parameter
  101092. * @param scene The scene we are intending to draw
  101093. * @param mesh The mesh the effect is compiling for
  101094. * @param defines The defines to update
  101095. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101096. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101097. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101098. * @returns true if normals will be required for the rest of the effect
  101099. */
  101100. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101101. /**
  101102. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101103. * @param lightIndex defines the light index
  101104. * @param uniformsList The uniform list
  101105. * @param samplersList The sampler list
  101106. * @param projectedLightTexture defines if projected texture must be used
  101107. * @param uniformBuffersList defines an optional list of uniform buffers
  101108. */
  101109. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101110. /**
  101111. * Prepares the uniforms and samplers list to be used in the effect
  101112. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101113. * @param samplersList The sampler list
  101114. * @param defines The defines helping in the list generation
  101115. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101116. */
  101117. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101118. /**
  101119. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101120. * @param defines The defines to update while falling back
  101121. * @param fallbacks The authorized effect fallbacks
  101122. * @param maxSimultaneousLights The maximum number of lights allowed
  101123. * @param rank the current rank of the Effect
  101124. * @returns The newly affected rank
  101125. */
  101126. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101127. private static _TmpMorphInfluencers;
  101128. /**
  101129. * Prepares the list of attributes required for morph targets according to the effect defines.
  101130. * @param attribs The current list of supported attribs
  101131. * @param mesh The mesh to prepare the morph targets attributes for
  101132. * @param influencers The number of influencers
  101133. */
  101134. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101135. /**
  101136. * Prepares the list of attributes required for morph targets according to the effect defines.
  101137. * @param attribs The current list of supported attribs
  101138. * @param mesh The mesh to prepare the morph targets attributes for
  101139. * @param defines The current Defines of the effect
  101140. */
  101141. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101142. /**
  101143. * Prepares the list of attributes required for bones according to the effect defines.
  101144. * @param attribs The current list of supported attribs
  101145. * @param mesh The mesh to prepare the bones attributes for
  101146. * @param defines The current Defines of the effect
  101147. * @param fallbacks The current efffect fallback strategy
  101148. */
  101149. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101150. /**
  101151. * Check and prepare the list of attributes required for instances according to the effect defines.
  101152. * @param attribs The current list of supported attribs
  101153. * @param defines The current MaterialDefines of the effect
  101154. */
  101155. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101156. /**
  101157. * Add the list of attributes required for instances to the attribs array.
  101158. * @param attribs The current list of supported attribs
  101159. */
  101160. static PushAttributesForInstances(attribs: string[]): void;
  101161. /**
  101162. * Binds the light information to the effect.
  101163. * @param light The light containing the generator
  101164. * @param effect The effect we are binding the data to
  101165. * @param lightIndex The light index in the effect used to render
  101166. */
  101167. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101168. /**
  101169. * Binds the lights information from the scene to the effect for the given mesh.
  101170. * @param light Light to bind
  101171. * @param lightIndex Light index
  101172. * @param scene The scene where the light belongs to
  101173. * @param effect The effect we are binding the data to
  101174. * @param useSpecular Defines if specular is supported
  101175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101176. */
  101177. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101178. /**
  101179. * Binds the lights information from the scene to the effect for the given mesh.
  101180. * @param scene The scene the lights belongs to
  101181. * @param mesh The mesh we are binding the information to render
  101182. * @param effect The effect we are binding the data to
  101183. * @param defines The generated defines for the effect
  101184. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101186. */
  101187. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101188. private static _tempFogColor;
  101189. /**
  101190. * Binds the fog information from the scene to the effect for the given mesh.
  101191. * @param scene The scene the lights belongs to
  101192. * @param mesh The mesh we are binding the information to render
  101193. * @param effect The effect we are binding the data to
  101194. * @param linearSpace Defines if the fog effect is applied in linear space
  101195. */
  101196. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101197. /**
  101198. * Binds the bones information from the mesh to the effect.
  101199. * @param mesh The mesh we are binding the information to render
  101200. * @param effect The effect we are binding the data to
  101201. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101202. */
  101203. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101204. private static _CopyBonesTransformationMatrices;
  101205. /**
  101206. * Binds the morph targets information from the mesh to the effect.
  101207. * @param abstractMesh The mesh we are binding the information to render
  101208. * @param effect The effect we are binding the data to
  101209. */
  101210. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101211. /**
  101212. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101213. * @param defines The generated defines used in the effect
  101214. * @param effect The effect we are binding the data to
  101215. * @param scene The scene we are willing to render with logarithmic scale for
  101216. */
  101217. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101218. /**
  101219. * Binds the clip plane information from the scene to the effect.
  101220. * @param scene The scene the clip plane information are extracted from
  101221. * @param effect The effect we are binding the data to
  101222. */
  101223. static BindClipPlane(effect: Effect, scene: Scene): void;
  101224. }
  101225. }
  101226. declare module BABYLON {
  101227. /**
  101228. * Block used to expose an input value
  101229. */
  101230. export class InputBlock extends NodeMaterialBlock {
  101231. private _mode;
  101232. private _associatedVariableName;
  101233. private _storedValue;
  101234. private _valueCallback;
  101235. private _type;
  101236. private _animationType;
  101237. /** Gets or set a value used to limit the range of float values */
  101238. min: number;
  101239. /** Gets or set a value used to limit the range of float values */
  101240. max: number;
  101241. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101242. isBoolean: boolean;
  101243. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101244. matrixMode: number;
  101245. /** @hidden */
  101246. _systemValue: Nullable<NodeMaterialSystemValues>;
  101247. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101248. isConstant: boolean;
  101249. /** Gets or sets the group to use to display this block in the Inspector */
  101250. groupInInspector: string;
  101251. /** Gets an observable raised when the value is changed */
  101252. onValueChangedObservable: Observable<InputBlock>;
  101253. /**
  101254. * Gets or sets the connection point type (default is float)
  101255. */
  101256. get type(): NodeMaterialBlockConnectionPointTypes;
  101257. /**
  101258. * Creates a new InputBlock
  101259. * @param name defines the block name
  101260. * @param target defines the target of that block (Vertex by default)
  101261. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101262. */
  101263. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101264. /**
  101265. * Validates if a name is a reserve word.
  101266. * @param newName the new name to be given to the node.
  101267. * @returns false if the name is a reserve word, else true.
  101268. */
  101269. validateBlockName(newName: string): boolean;
  101270. /**
  101271. * Gets the output component
  101272. */
  101273. get output(): NodeMaterialConnectionPoint;
  101274. /**
  101275. * Set the source of this connection point to a vertex attribute
  101276. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101277. * @returns the current connection point
  101278. */
  101279. setAsAttribute(attributeName?: string): InputBlock;
  101280. /**
  101281. * Set the source of this connection point to a system value
  101282. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101283. * @returns the current connection point
  101284. */
  101285. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101286. /**
  101287. * Gets or sets the value of that point.
  101288. * Please note that this value will be ignored if valueCallback is defined
  101289. */
  101290. get value(): any;
  101291. set value(value: any);
  101292. /**
  101293. * Gets or sets a callback used to get the value of that point.
  101294. * Please note that setting this value will force the connection point to ignore the value property
  101295. */
  101296. get valueCallback(): () => any;
  101297. set valueCallback(value: () => any);
  101298. /**
  101299. * Gets or sets the associated variable name in the shader
  101300. */
  101301. get associatedVariableName(): string;
  101302. set associatedVariableName(value: string);
  101303. /** Gets or sets the type of animation applied to the input */
  101304. get animationType(): AnimatedInputBlockTypes;
  101305. set animationType(value: AnimatedInputBlockTypes);
  101306. /**
  101307. * Gets a boolean indicating that this connection point not defined yet
  101308. */
  101309. get isUndefined(): boolean;
  101310. /**
  101311. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101312. * In this case the connection point name must be the name of the uniform to use.
  101313. * Can only be set on inputs
  101314. */
  101315. get isUniform(): boolean;
  101316. set isUniform(value: boolean);
  101317. /**
  101318. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101319. * In this case the connection point name must be the name of the attribute to use
  101320. * Can only be set on inputs
  101321. */
  101322. get isAttribute(): boolean;
  101323. set isAttribute(value: boolean);
  101324. /**
  101325. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101326. * Can only be set on exit points
  101327. */
  101328. get isVarying(): boolean;
  101329. set isVarying(value: boolean);
  101330. /**
  101331. * Gets a boolean indicating that the current connection point is a system value
  101332. */
  101333. get isSystemValue(): boolean;
  101334. /**
  101335. * Gets or sets the current well known value or null if not defined as a system value
  101336. */
  101337. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101338. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101339. /**
  101340. * Gets the current class name
  101341. * @returns the class name
  101342. */
  101343. getClassName(): string;
  101344. /**
  101345. * Animate the input if animationType !== None
  101346. * @param scene defines the rendering scene
  101347. */
  101348. animate(scene: Scene): void;
  101349. private _emitDefine;
  101350. initialize(state: NodeMaterialBuildState): void;
  101351. /**
  101352. * Set the input block to its default value (based on its type)
  101353. */
  101354. setDefaultValue(): void;
  101355. private _emitConstant;
  101356. /** @hidden */
  101357. get _noContextSwitch(): boolean;
  101358. private _emit;
  101359. /** @hidden */
  101360. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101361. /** @hidden */
  101362. _transmit(effect: Effect, scene: Scene): void;
  101363. protected _buildBlock(state: NodeMaterialBuildState): void;
  101364. protected _dumpPropertiesCode(): string;
  101365. dispose(): void;
  101366. serialize(): any;
  101367. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101368. }
  101369. }
  101370. declare module BABYLON {
  101371. /**
  101372. * Enum used to define the compatibility state between two connection points
  101373. */
  101374. export enum NodeMaterialConnectionPointCompatibilityStates {
  101375. /** Points are compatibles */
  101376. Compatible = 0,
  101377. /** Points are incompatible because of their types */
  101378. TypeIncompatible = 1,
  101379. /** Points are incompatible because of their targets (vertex vs fragment) */
  101380. TargetIncompatible = 2
  101381. }
  101382. /**
  101383. * Defines the direction of a connection point
  101384. */
  101385. export enum NodeMaterialConnectionPointDirection {
  101386. /** Input */
  101387. Input = 0,
  101388. /** Output */
  101389. Output = 1
  101390. }
  101391. /**
  101392. * Defines a connection point for a block
  101393. */
  101394. export class NodeMaterialConnectionPoint {
  101395. /** @hidden */
  101396. _ownerBlock: NodeMaterialBlock;
  101397. /** @hidden */
  101398. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101399. private _endpoints;
  101400. private _associatedVariableName;
  101401. private _direction;
  101402. /** @hidden */
  101403. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101404. /** @hidden */
  101405. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101406. private _type;
  101407. /** @hidden */
  101408. _enforceAssociatedVariableName: boolean;
  101409. /** Gets the direction of the point */
  101410. get direction(): NodeMaterialConnectionPointDirection;
  101411. /** Indicates that this connection point needs dual validation before being connected to another point */
  101412. needDualDirectionValidation: boolean;
  101413. /**
  101414. * Gets or sets the additional types supported by this connection point
  101415. */
  101416. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101417. /**
  101418. * Gets or sets the additional types excluded by this connection point
  101419. */
  101420. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101421. /**
  101422. * Observable triggered when this point is connected
  101423. */
  101424. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101425. /**
  101426. * Gets or sets the associated variable name in the shader
  101427. */
  101428. get associatedVariableName(): string;
  101429. set associatedVariableName(value: string);
  101430. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101431. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101432. /**
  101433. * Gets or sets the connection point type (default is float)
  101434. */
  101435. get type(): NodeMaterialBlockConnectionPointTypes;
  101436. set type(value: NodeMaterialBlockConnectionPointTypes);
  101437. /**
  101438. * Gets or sets the connection point name
  101439. */
  101440. name: string;
  101441. /**
  101442. * Gets or sets the connection point name
  101443. */
  101444. displayName: string;
  101445. /**
  101446. * Gets or sets a boolean indicating that this connection point can be omitted
  101447. */
  101448. isOptional: boolean;
  101449. /**
  101450. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101451. */
  101452. isExposedOnFrame: boolean;
  101453. /**
  101454. * Gets or sets number indicating the position that the port is exposed to on a frame
  101455. */
  101456. exposedPortPosition: number;
  101457. /**
  101458. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101459. */
  101460. define: string;
  101461. /** @hidden */
  101462. _prioritizeVertex: boolean;
  101463. private _target;
  101464. /** Gets or sets the target of that connection point */
  101465. get target(): NodeMaterialBlockTargets;
  101466. set target(value: NodeMaterialBlockTargets);
  101467. /**
  101468. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101469. */
  101470. get isConnected(): boolean;
  101471. /**
  101472. * Gets a boolean indicating that the current point is connected to an input block
  101473. */
  101474. get isConnectedToInputBlock(): boolean;
  101475. /**
  101476. * Gets a the connected input block (if any)
  101477. */
  101478. get connectInputBlock(): Nullable<InputBlock>;
  101479. /** Get the other side of the connection (if any) */
  101480. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101481. /** Get the block that owns this connection point */
  101482. get ownerBlock(): NodeMaterialBlock;
  101483. /** Get the block connected on the other side of this connection (if any) */
  101484. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101485. /** Get the block connected on the endpoints of this connection (if any) */
  101486. get connectedBlocks(): Array<NodeMaterialBlock>;
  101487. /** Gets the list of connected endpoints */
  101488. get endpoints(): NodeMaterialConnectionPoint[];
  101489. /** Gets a boolean indicating if that output point is connected to at least one input */
  101490. get hasEndpoints(): boolean;
  101491. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101492. get isConnectedInVertexShader(): boolean;
  101493. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101494. get isConnectedInFragmentShader(): boolean;
  101495. /**
  101496. * Creates a block suitable to be used as an input for this input point.
  101497. * If null is returned, a block based on the point type will be created.
  101498. * @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
  101499. */
  101500. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101501. /**
  101502. * Creates a new connection point
  101503. * @param name defines the connection point name
  101504. * @param ownerBlock defines the block hosting this connection point
  101505. * @param direction defines the direction of the connection point
  101506. */
  101507. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101508. /**
  101509. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101510. * @returns the class name
  101511. */
  101512. getClassName(): string;
  101513. /**
  101514. * Gets a boolean indicating if the current point can be connected to another point
  101515. * @param connectionPoint defines the other connection point
  101516. * @returns a boolean
  101517. */
  101518. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101519. /**
  101520. * Gets a number indicating if the current point can be connected to another point
  101521. * @param connectionPoint defines the other connection point
  101522. * @returns a number defining the compatibility state
  101523. */
  101524. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101525. /**
  101526. * Connect this point to another connection point
  101527. * @param connectionPoint defines the other connection point
  101528. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101529. * @returns the current connection point
  101530. */
  101531. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101532. /**
  101533. * Disconnect this point from one of his endpoint
  101534. * @param endpoint defines the other connection point
  101535. * @returns the current connection point
  101536. */
  101537. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101538. /**
  101539. * Serializes this point in a JSON representation
  101540. * @param isInput defines if the connection point is an input (default is true)
  101541. * @returns the serialized point object
  101542. */
  101543. serialize(isInput?: boolean): any;
  101544. /**
  101545. * Release resources
  101546. */
  101547. dispose(): void;
  101548. }
  101549. }
  101550. declare module BABYLON {
  101551. /**
  101552. * Enum used to define the material modes
  101553. */
  101554. export enum NodeMaterialModes {
  101555. /** Regular material */
  101556. Material = 0,
  101557. /** For post process */
  101558. PostProcess = 1,
  101559. /** For particle system */
  101560. Particle = 2,
  101561. /** For procedural texture */
  101562. ProceduralTexture = 3
  101563. }
  101564. }
  101565. declare module BABYLON {
  101566. /**
  101567. * Block used to read a texture from a sampler
  101568. */
  101569. export class TextureBlock extends NodeMaterialBlock {
  101570. private _defineName;
  101571. private _linearDefineName;
  101572. private _gammaDefineName;
  101573. private _tempTextureRead;
  101574. private _samplerName;
  101575. private _transformedUVName;
  101576. private _textureTransformName;
  101577. private _textureInfoName;
  101578. private _mainUVName;
  101579. private _mainUVDefineName;
  101580. private _fragmentOnly;
  101581. /**
  101582. * Gets or sets the texture associated with the node
  101583. */
  101584. texture: Nullable<Texture>;
  101585. /**
  101586. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101587. */
  101588. convertToGammaSpace: boolean;
  101589. /**
  101590. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101591. */
  101592. convertToLinearSpace: boolean;
  101593. /**
  101594. * Create a new TextureBlock
  101595. * @param name defines the block name
  101596. */
  101597. constructor(name: string, fragmentOnly?: boolean);
  101598. /**
  101599. * Gets the current class name
  101600. * @returns the class name
  101601. */
  101602. getClassName(): string;
  101603. /**
  101604. * Gets the uv input component
  101605. */
  101606. get uv(): NodeMaterialConnectionPoint;
  101607. /**
  101608. * Gets the rgba output component
  101609. */
  101610. get rgba(): NodeMaterialConnectionPoint;
  101611. /**
  101612. * Gets the rgb output component
  101613. */
  101614. get rgb(): NodeMaterialConnectionPoint;
  101615. /**
  101616. * Gets the r output component
  101617. */
  101618. get r(): NodeMaterialConnectionPoint;
  101619. /**
  101620. * Gets the g output component
  101621. */
  101622. get g(): NodeMaterialConnectionPoint;
  101623. /**
  101624. * Gets the b output component
  101625. */
  101626. get b(): NodeMaterialConnectionPoint;
  101627. /**
  101628. * Gets the a output component
  101629. */
  101630. get a(): NodeMaterialConnectionPoint;
  101631. get target(): NodeMaterialBlockTargets;
  101632. autoConfigure(material: NodeMaterial): void;
  101633. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101635. isReady(): boolean;
  101636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101637. private get _isMixed();
  101638. private _injectVertexCode;
  101639. private _writeTextureRead;
  101640. private _writeOutput;
  101641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101642. protected _dumpPropertiesCode(): string;
  101643. serialize(): any;
  101644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101645. }
  101646. }
  101647. declare module BABYLON {
  101648. /** @hidden */
  101649. export var reflectionFunction: {
  101650. name: string;
  101651. shader: string;
  101652. };
  101653. }
  101654. declare module BABYLON {
  101655. /**
  101656. * Base block used to read a reflection texture from a sampler
  101657. */
  101658. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101659. /** @hidden */
  101660. _define3DName: string;
  101661. /** @hidden */
  101662. _defineCubicName: string;
  101663. /** @hidden */
  101664. _defineExplicitName: string;
  101665. /** @hidden */
  101666. _defineProjectionName: string;
  101667. /** @hidden */
  101668. _defineLocalCubicName: string;
  101669. /** @hidden */
  101670. _defineSphericalName: string;
  101671. /** @hidden */
  101672. _definePlanarName: string;
  101673. /** @hidden */
  101674. _defineEquirectangularName: string;
  101675. /** @hidden */
  101676. _defineMirroredEquirectangularFixedName: string;
  101677. /** @hidden */
  101678. _defineEquirectangularFixedName: string;
  101679. /** @hidden */
  101680. _defineSkyboxName: string;
  101681. /** @hidden */
  101682. _defineOppositeZ: string;
  101683. /** @hidden */
  101684. _cubeSamplerName: string;
  101685. /** @hidden */
  101686. _2DSamplerName: string;
  101687. protected _positionUVWName: string;
  101688. protected _directionWName: string;
  101689. protected _reflectionVectorName: string;
  101690. /** @hidden */
  101691. _reflectionCoordsName: string;
  101692. /** @hidden */
  101693. _reflectionMatrixName: string;
  101694. protected _reflectionColorName: string;
  101695. /**
  101696. * Gets or sets the texture associated with the node
  101697. */
  101698. texture: Nullable<BaseTexture>;
  101699. /**
  101700. * Create a new ReflectionTextureBaseBlock
  101701. * @param name defines the block name
  101702. */
  101703. constructor(name: string);
  101704. /**
  101705. * Gets the current class name
  101706. * @returns the class name
  101707. */
  101708. getClassName(): string;
  101709. /**
  101710. * Gets the world position input component
  101711. */
  101712. abstract get position(): NodeMaterialConnectionPoint;
  101713. /**
  101714. * Gets the world position input component
  101715. */
  101716. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101717. /**
  101718. * Gets the world normal input component
  101719. */
  101720. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101721. /**
  101722. * Gets the world input component
  101723. */
  101724. abstract get world(): NodeMaterialConnectionPoint;
  101725. /**
  101726. * Gets the camera (or eye) position component
  101727. */
  101728. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101729. /**
  101730. * Gets the view input component
  101731. */
  101732. abstract get view(): NodeMaterialConnectionPoint;
  101733. protected _getTexture(): Nullable<BaseTexture>;
  101734. autoConfigure(material: NodeMaterial): void;
  101735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101736. isReady(): boolean;
  101737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101738. /**
  101739. * Gets the code to inject in the vertex shader
  101740. * @param state current state of the node material building
  101741. * @returns the shader code
  101742. */
  101743. handleVertexSide(state: NodeMaterialBuildState): string;
  101744. /**
  101745. * Handles the inits for the fragment code path
  101746. * @param state node material build state
  101747. */
  101748. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101749. /**
  101750. * Generates the reflection coords code for the fragment code path
  101751. * @param worldNormalVarName name of the world normal variable
  101752. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101753. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101754. * @returns the shader code
  101755. */
  101756. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101757. /**
  101758. * Generates the reflection color code for the fragment code path
  101759. * @param lodVarName name of the lod variable
  101760. * @param swizzleLookupTexture swizzle to use for the final color variable
  101761. * @returns the shader code
  101762. */
  101763. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101764. /**
  101765. * Generates the code corresponding to the connected output points
  101766. * @param state node material build state
  101767. * @param varName name of the variable to output
  101768. * @returns the shader code
  101769. */
  101770. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101771. protected _buildBlock(state: NodeMaterialBuildState): this;
  101772. protected _dumpPropertiesCode(): string;
  101773. serialize(): any;
  101774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101775. }
  101776. }
  101777. declare module BABYLON {
  101778. /**
  101779. * Defines a connection point to be used for points with a custom object type
  101780. */
  101781. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101782. private _blockType;
  101783. private _blockName;
  101784. private _nameForCheking?;
  101785. /**
  101786. * Creates a new connection point
  101787. * @param name defines the connection point name
  101788. * @param ownerBlock defines the block hosting this connection point
  101789. * @param direction defines the direction of the connection point
  101790. */
  101791. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101792. /**
  101793. * Gets a number indicating if the current point can be connected to another point
  101794. * @param connectionPoint defines the other connection point
  101795. * @returns a number defining the compatibility state
  101796. */
  101797. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101798. /**
  101799. * Creates a block suitable to be used as an input for this input point.
  101800. * If null is returned, a block based on the point type will be created.
  101801. * @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
  101802. */
  101803. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101804. }
  101805. }
  101806. declare module BABYLON {
  101807. /**
  101808. * Enum defining the type of properties that can be edited in the property pages in the NME
  101809. */
  101810. export enum PropertyTypeForEdition {
  101811. /** property is a boolean */
  101812. Boolean = 0,
  101813. /** property is a float */
  101814. Float = 1,
  101815. /** property is a Vector2 */
  101816. Vector2 = 2,
  101817. /** property is a list of values */
  101818. List = 3
  101819. }
  101820. /**
  101821. * Interface that defines an option in a variable of type list
  101822. */
  101823. export interface IEditablePropertyListOption {
  101824. /** label of the option */
  101825. "label": string;
  101826. /** value of the option */
  101827. "value": number;
  101828. }
  101829. /**
  101830. * Interface that defines the options available for an editable property
  101831. */
  101832. export interface IEditablePropertyOption {
  101833. /** min value */
  101834. "min"?: number;
  101835. /** max value */
  101836. "max"?: number;
  101837. /** notifiers: indicates which actions to take when the property is changed */
  101838. "notifiers"?: {
  101839. /** the material should be rebuilt */
  101840. "rebuild"?: boolean;
  101841. /** the preview should be updated */
  101842. "update"?: boolean;
  101843. };
  101844. /** list of the options for a variable of type list */
  101845. "options"?: IEditablePropertyListOption[];
  101846. }
  101847. /**
  101848. * Interface that describes an editable property
  101849. */
  101850. export interface IPropertyDescriptionForEdition {
  101851. /** name of the property */
  101852. "propertyName": string;
  101853. /** display name of the property */
  101854. "displayName": string;
  101855. /** type of the property */
  101856. "type": PropertyTypeForEdition;
  101857. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101858. "groupName": string;
  101859. /** options for the property */
  101860. "options": IEditablePropertyOption;
  101861. }
  101862. /**
  101863. * Decorator that flags a property in a node material block as being editable
  101864. */
  101865. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101866. }
  101867. declare module BABYLON {
  101868. /**
  101869. * Block used to implement the refraction part of the sub surface module of the PBR material
  101870. */
  101871. export class RefractionBlock extends NodeMaterialBlock {
  101872. /** @hidden */
  101873. _define3DName: string;
  101874. /** @hidden */
  101875. _refractionMatrixName: string;
  101876. /** @hidden */
  101877. _defineLODRefractionAlpha: string;
  101878. /** @hidden */
  101879. _defineLinearSpecularRefraction: string;
  101880. /** @hidden */
  101881. _defineOppositeZ: string;
  101882. /** @hidden */
  101883. _cubeSamplerName: string;
  101884. /** @hidden */
  101885. _2DSamplerName: string;
  101886. /** @hidden */
  101887. _vRefractionMicrosurfaceInfosName: string;
  101888. /** @hidden */
  101889. _vRefractionInfosName: string;
  101890. private _scene;
  101891. /**
  101892. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101893. * Materials half opaque for instance using refraction could benefit from this control.
  101894. */
  101895. linkRefractionWithTransparency: boolean;
  101896. /**
  101897. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101898. */
  101899. invertRefractionY: boolean;
  101900. /**
  101901. * Gets or sets the texture associated with the node
  101902. */
  101903. texture: Nullable<BaseTexture>;
  101904. /**
  101905. * Create a new RefractionBlock
  101906. * @param name defines the block name
  101907. */
  101908. constructor(name: string);
  101909. /**
  101910. * Gets the current class name
  101911. * @returns the class name
  101912. */
  101913. getClassName(): string;
  101914. /**
  101915. * Gets the intensity input component
  101916. */
  101917. get intensity(): NodeMaterialConnectionPoint;
  101918. /**
  101919. * Gets the index of refraction input component
  101920. */
  101921. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101922. /**
  101923. * Gets the tint at distance input component
  101924. */
  101925. get tintAtDistance(): NodeMaterialConnectionPoint;
  101926. /**
  101927. * Gets the view input component
  101928. */
  101929. get view(): NodeMaterialConnectionPoint;
  101930. /**
  101931. * Gets the refraction object output component
  101932. */
  101933. get refraction(): NodeMaterialConnectionPoint;
  101934. /**
  101935. * Returns true if the block has a texture
  101936. */
  101937. get hasTexture(): boolean;
  101938. protected _getTexture(): Nullable<BaseTexture>;
  101939. autoConfigure(material: NodeMaterial): void;
  101940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101941. isReady(): boolean;
  101942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101943. /**
  101944. * Gets the main code of the block (fragment side)
  101945. * @param state current state of the node material building
  101946. * @returns the shader code
  101947. */
  101948. getCode(state: NodeMaterialBuildState): string;
  101949. protected _buildBlock(state: NodeMaterialBuildState): this;
  101950. protected _dumpPropertiesCode(): string;
  101951. serialize(): any;
  101952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101953. }
  101954. }
  101955. declare module BABYLON {
  101956. /**
  101957. * Base block used as input for post process
  101958. */
  101959. export class CurrentScreenBlock extends NodeMaterialBlock {
  101960. private _samplerName;
  101961. private _linearDefineName;
  101962. private _gammaDefineName;
  101963. private _mainUVName;
  101964. private _tempTextureRead;
  101965. /**
  101966. * Gets or sets the texture associated with the node
  101967. */
  101968. texture: Nullable<BaseTexture>;
  101969. /**
  101970. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101971. */
  101972. convertToGammaSpace: boolean;
  101973. /**
  101974. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101975. */
  101976. convertToLinearSpace: boolean;
  101977. /**
  101978. * Create a new CurrentScreenBlock
  101979. * @param name defines the block name
  101980. */
  101981. constructor(name: string);
  101982. /**
  101983. * Gets the current class name
  101984. * @returns the class name
  101985. */
  101986. getClassName(): string;
  101987. /**
  101988. * Gets the uv input component
  101989. */
  101990. get uv(): NodeMaterialConnectionPoint;
  101991. /**
  101992. * Gets the rgba output component
  101993. */
  101994. get rgba(): NodeMaterialConnectionPoint;
  101995. /**
  101996. * Gets the rgb output component
  101997. */
  101998. get rgb(): NodeMaterialConnectionPoint;
  101999. /**
  102000. * Gets the r output component
  102001. */
  102002. get r(): NodeMaterialConnectionPoint;
  102003. /**
  102004. * Gets the g output component
  102005. */
  102006. get g(): NodeMaterialConnectionPoint;
  102007. /**
  102008. * Gets the b output component
  102009. */
  102010. get b(): NodeMaterialConnectionPoint;
  102011. /**
  102012. * Gets the a output component
  102013. */
  102014. get a(): NodeMaterialConnectionPoint;
  102015. /**
  102016. * Initialize the block and prepare the context for build
  102017. * @param state defines the state that will be used for the build
  102018. */
  102019. initialize(state: NodeMaterialBuildState): void;
  102020. get target(): NodeMaterialBlockTargets;
  102021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102022. isReady(): boolean;
  102023. private _injectVertexCode;
  102024. private _writeTextureRead;
  102025. private _writeOutput;
  102026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102027. serialize(): any;
  102028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102029. }
  102030. }
  102031. declare module BABYLON {
  102032. /**
  102033. * Base block used for the particle texture
  102034. */
  102035. export class ParticleTextureBlock extends NodeMaterialBlock {
  102036. private _samplerName;
  102037. private _linearDefineName;
  102038. private _gammaDefineName;
  102039. private _tempTextureRead;
  102040. /**
  102041. * Gets or sets the texture associated with the node
  102042. */
  102043. texture: Nullable<BaseTexture>;
  102044. /**
  102045. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102046. */
  102047. convertToGammaSpace: boolean;
  102048. /**
  102049. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102050. */
  102051. convertToLinearSpace: boolean;
  102052. /**
  102053. * Create a new ParticleTextureBlock
  102054. * @param name defines the block name
  102055. */
  102056. constructor(name: string);
  102057. /**
  102058. * Gets the current class name
  102059. * @returns the class name
  102060. */
  102061. getClassName(): string;
  102062. /**
  102063. * Gets the uv input component
  102064. */
  102065. get uv(): NodeMaterialConnectionPoint;
  102066. /**
  102067. * Gets the rgba output component
  102068. */
  102069. get rgba(): NodeMaterialConnectionPoint;
  102070. /**
  102071. * Gets the rgb output component
  102072. */
  102073. get rgb(): NodeMaterialConnectionPoint;
  102074. /**
  102075. * Gets the r output component
  102076. */
  102077. get r(): NodeMaterialConnectionPoint;
  102078. /**
  102079. * Gets the g output component
  102080. */
  102081. get g(): NodeMaterialConnectionPoint;
  102082. /**
  102083. * Gets the b output component
  102084. */
  102085. get b(): NodeMaterialConnectionPoint;
  102086. /**
  102087. * Gets the a output component
  102088. */
  102089. get a(): NodeMaterialConnectionPoint;
  102090. /**
  102091. * Initialize the block and prepare the context for build
  102092. * @param state defines the state that will be used for the build
  102093. */
  102094. initialize(state: NodeMaterialBuildState): void;
  102095. autoConfigure(material: NodeMaterial): void;
  102096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102097. isReady(): boolean;
  102098. private _writeOutput;
  102099. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102100. serialize(): any;
  102101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /**
  102106. * Class used to store shared data between 2 NodeMaterialBuildState
  102107. */
  102108. export class NodeMaterialBuildStateSharedData {
  102109. /**
  102110. * Gets the list of emitted varyings
  102111. */
  102112. temps: string[];
  102113. /**
  102114. * Gets the list of emitted varyings
  102115. */
  102116. varyings: string[];
  102117. /**
  102118. * Gets the varying declaration string
  102119. */
  102120. varyingDeclaration: string;
  102121. /**
  102122. * Input blocks
  102123. */
  102124. inputBlocks: InputBlock[];
  102125. /**
  102126. * Input blocks
  102127. */
  102128. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102129. /**
  102130. * Bindable blocks (Blocks that need to set data to the effect)
  102131. */
  102132. bindableBlocks: NodeMaterialBlock[];
  102133. /**
  102134. * List of blocks that can provide a compilation fallback
  102135. */
  102136. blocksWithFallbacks: NodeMaterialBlock[];
  102137. /**
  102138. * List of blocks that can provide a define update
  102139. */
  102140. blocksWithDefines: NodeMaterialBlock[];
  102141. /**
  102142. * List of blocks that can provide a repeatable content
  102143. */
  102144. repeatableContentBlocks: NodeMaterialBlock[];
  102145. /**
  102146. * List of blocks that can provide a dynamic list of uniforms
  102147. */
  102148. dynamicUniformBlocks: NodeMaterialBlock[];
  102149. /**
  102150. * List of blocks that can block the isReady function for the material
  102151. */
  102152. blockingBlocks: NodeMaterialBlock[];
  102153. /**
  102154. * Gets the list of animated inputs
  102155. */
  102156. animatedInputs: InputBlock[];
  102157. /**
  102158. * Build Id used to avoid multiple recompilations
  102159. */
  102160. buildId: number;
  102161. /** List of emitted variables */
  102162. variableNames: {
  102163. [key: string]: number;
  102164. };
  102165. /** List of emitted defines */
  102166. defineNames: {
  102167. [key: string]: number;
  102168. };
  102169. /** Should emit comments? */
  102170. emitComments: boolean;
  102171. /** Emit build activity */
  102172. verbose: boolean;
  102173. /** Gets or sets the hosting scene */
  102174. scene: Scene;
  102175. /**
  102176. * Gets the compilation hints emitted at compilation time
  102177. */
  102178. hints: {
  102179. needWorldViewMatrix: boolean;
  102180. needWorldViewProjectionMatrix: boolean;
  102181. needAlphaBlending: boolean;
  102182. needAlphaTesting: boolean;
  102183. };
  102184. /**
  102185. * List of compilation checks
  102186. */
  102187. checks: {
  102188. emitVertex: boolean;
  102189. emitFragment: boolean;
  102190. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102191. };
  102192. /**
  102193. * Is vertex program allowed to be empty?
  102194. */
  102195. allowEmptyVertexProgram: boolean;
  102196. /** Creates a new shared data */
  102197. constructor();
  102198. /**
  102199. * Emits console errors and exceptions if there is a failing check
  102200. */
  102201. emitErrors(): void;
  102202. }
  102203. }
  102204. declare module BABYLON {
  102205. /**
  102206. * Class used to store node based material build state
  102207. */
  102208. export class NodeMaterialBuildState {
  102209. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102210. supportUniformBuffers: boolean;
  102211. /**
  102212. * Gets the list of emitted attributes
  102213. */
  102214. attributes: string[];
  102215. /**
  102216. * Gets the list of emitted uniforms
  102217. */
  102218. uniforms: string[];
  102219. /**
  102220. * Gets the list of emitted constants
  102221. */
  102222. constants: string[];
  102223. /**
  102224. * Gets the list of emitted samplers
  102225. */
  102226. samplers: string[];
  102227. /**
  102228. * Gets the list of emitted functions
  102229. */
  102230. functions: {
  102231. [key: string]: string;
  102232. };
  102233. /**
  102234. * Gets the list of emitted extensions
  102235. */
  102236. extensions: {
  102237. [key: string]: string;
  102238. };
  102239. /**
  102240. * Gets the target of the compilation state
  102241. */
  102242. target: NodeMaterialBlockTargets;
  102243. /**
  102244. * Gets the list of emitted counters
  102245. */
  102246. counters: {
  102247. [key: string]: number;
  102248. };
  102249. /**
  102250. * Shared data between multiple NodeMaterialBuildState instances
  102251. */
  102252. sharedData: NodeMaterialBuildStateSharedData;
  102253. /** @hidden */
  102254. _vertexState: NodeMaterialBuildState;
  102255. /** @hidden */
  102256. _attributeDeclaration: string;
  102257. /** @hidden */
  102258. _uniformDeclaration: string;
  102259. /** @hidden */
  102260. _constantDeclaration: string;
  102261. /** @hidden */
  102262. _samplerDeclaration: string;
  102263. /** @hidden */
  102264. _varyingTransfer: string;
  102265. /** @hidden */
  102266. _injectAtEnd: string;
  102267. private _repeatableContentAnchorIndex;
  102268. /** @hidden */
  102269. _builtCompilationString: string;
  102270. /**
  102271. * Gets the emitted compilation strings
  102272. */
  102273. compilationString: string;
  102274. /**
  102275. * Finalize the compilation strings
  102276. * @param state defines the current compilation state
  102277. */
  102278. finalize(state: NodeMaterialBuildState): void;
  102279. /** @hidden */
  102280. get _repeatableContentAnchor(): string;
  102281. /** @hidden */
  102282. _getFreeVariableName(prefix: string): string;
  102283. /** @hidden */
  102284. _getFreeDefineName(prefix: string): string;
  102285. /** @hidden */
  102286. _excludeVariableName(name: string): void;
  102287. /** @hidden */
  102288. _emit2DSampler(name: string): void;
  102289. /** @hidden */
  102290. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102291. /** @hidden */
  102292. _emitExtension(name: string, extension: string, define?: string): void;
  102293. /** @hidden */
  102294. _emitFunction(name: string, code: string, comments: string): void;
  102295. /** @hidden */
  102296. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102297. replaceStrings?: {
  102298. search: RegExp;
  102299. replace: string;
  102300. }[];
  102301. repeatKey?: string;
  102302. }): string;
  102303. /** @hidden */
  102304. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102305. repeatKey?: string;
  102306. removeAttributes?: boolean;
  102307. removeUniforms?: boolean;
  102308. removeVaryings?: boolean;
  102309. removeIfDef?: boolean;
  102310. replaceStrings?: {
  102311. search: RegExp;
  102312. replace: string;
  102313. }[];
  102314. }, storeKey?: string): void;
  102315. /** @hidden */
  102316. _registerTempVariable(name: string): boolean;
  102317. /** @hidden */
  102318. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102319. /** @hidden */
  102320. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102321. /** @hidden */
  102322. _emitFloat(value: number): string;
  102323. }
  102324. }
  102325. declare module BABYLON {
  102326. /**
  102327. * Helper class used to generate session unique ID
  102328. */
  102329. export class UniqueIdGenerator {
  102330. private static _UniqueIdCounter;
  102331. /**
  102332. * Gets an unique (relatively to the current scene) Id
  102333. */
  102334. static get UniqueId(): number;
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /**
  102339. * Defines a block that can be used inside a node based material
  102340. */
  102341. export class NodeMaterialBlock {
  102342. private _buildId;
  102343. private _buildTarget;
  102344. private _target;
  102345. private _isFinalMerger;
  102346. private _isInput;
  102347. private _name;
  102348. protected _isUnique: boolean;
  102349. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102350. inputsAreExclusive: boolean;
  102351. /** @hidden */
  102352. _codeVariableName: string;
  102353. /** @hidden */
  102354. _inputs: NodeMaterialConnectionPoint[];
  102355. /** @hidden */
  102356. _outputs: NodeMaterialConnectionPoint[];
  102357. /** @hidden */
  102358. _preparationId: number;
  102359. /**
  102360. * Gets the name of the block
  102361. */
  102362. get name(): string;
  102363. /**
  102364. * Sets the name of the block. Will check if the name is valid.
  102365. */
  102366. set name(newName: string);
  102367. /**
  102368. * Gets or sets the unique id of the node
  102369. */
  102370. uniqueId: number;
  102371. /**
  102372. * Gets or sets the comments associated with this block
  102373. */
  102374. comments: string;
  102375. /**
  102376. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102377. */
  102378. get isUnique(): boolean;
  102379. /**
  102380. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102381. */
  102382. get isFinalMerger(): boolean;
  102383. /**
  102384. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102385. */
  102386. get isInput(): boolean;
  102387. /**
  102388. * Gets or sets the build Id
  102389. */
  102390. get buildId(): number;
  102391. set buildId(value: number);
  102392. /**
  102393. * Gets or sets the target of the block
  102394. */
  102395. get target(): NodeMaterialBlockTargets;
  102396. set target(value: NodeMaterialBlockTargets);
  102397. /**
  102398. * Gets the list of input points
  102399. */
  102400. get inputs(): NodeMaterialConnectionPoint[];
  102401. /** Gets the list of output points */
  102402. get outputs(): NodeMaterialConnectionPoint[];
  102403. /**
  102404. * Find an input by its name
  102405. * @param name defines the name of the input to look for
  102406. * @returns the input or null if not found
  102407. */
  102408. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102409. /**
  102410. * Find an output by its name
  102411. * @param name defines the name of the outputto look for
  102412. * @returns the output or null if not found
  102413. */
  102414. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102415. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102416. visibleInInspector: boolean;
  102417. /**
  102418. * Creates a new NodeMaterialBlock
  102419. * @param name defines the block name
  102420. * @param target defines the target of that block (Vertex by default)
  102421. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102422. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102423. */
  102424. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102425. /**
  102426. * Initialize the block and prepare the context for build
  102427. * @param state defines the state that will be used for the build
  102428. */
  102429. initialize(state: NodeMaterialBuildState): void;
  102430. /**
  102431. * Bind data to effect. Will only be called for blocks with isBindable === true
  102432. * @param effect defines the effect to bind data to
  102433. * @param nodeMaterial defines the hosting NodeMaterial
  102434. * @param mesh defines the mesh that will be rendered
  102435. * @param subMesh defines the submesh that will be rendered
  102436. */
  102437. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102438. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102439. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102440. protected _writeFloat(value: number): string;
  102441. /**
  102442. * Gets the current class name e.g. "NodeMaterialBlock"
  102443. * @returns the class name
  102444. */
  102445. getClassName(): string;
  102446. /**
  102447. * Register a new input. Must be called inside a block constructor
  102448. * @param name defines the connection point name
  102449. * @param type defines the connection point type
  102450. * @param isOptional defines a boolean indicating that this input can be omitted
  102451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102452. * @param point an already created connection point. If not provided, create a new one
  102453. * @returns the current block
  102454. */
  102455. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102456. /**
  102457. * Register a new output. Must be called inside a block constructor
  102458. * @param name defines the connection point name
  102459. * @param type defines the connection point type
  102460. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102461. * @param point an already created connection point. If not provided, create a new one
  102462. * @returns the current block
  102463. */
  102464. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102465. /**
  102466. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102467. * @param forOutput defines an optional connection point to check compatibility with
  102468. * @returns the first available input or null
  102469. */
  102470. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102471. /**
  102472. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102473. * @param forBlock defines an optional block to check compatibility with
  102474. * @returns the first available input or null
  102475. */
  102476. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102477. /**
  102478. * Gets the sibling of the given output
  102479. * @param current defines the current output
  102480. * @returns the next output in the list or null
  102481. */
  102482. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102483. /**
  102484. * Connect current block with another block
  102485. * @param other defines the block to connect with
  102486. * @param options define the various options to help pick the right connections
  102487. * @returns the current block
  102488. */
  102489. connectTo(other: NodeMaterialBlock, options?: {
  102490. input?: string;
  102491. output?: string;
  102492. outputSwizzle?: string;
  102493. }): this | undefined;
  102494. protected _buildBlock(state: NodeMaterialBuildState): void;
  102495. /**
  102496. * Add uniforms, samplers and uniform buffers at compilation time
  102497. * @param state defines the state to update
  102498. * @param nodeMaterial defines the node material requesting the update
  102499. * @param defines defines the material defines to update
  102500. * @param uniformBuffers defines the list of uniform buffer names
  102501. */
  102502. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102503. /**
  102504. * Add potential fallbacks if shader compilation fails
  102505. * @param mesh defines the mesh to be rendered
  102506. * @param fallbacks defines the current prioritized list of fallbacks
  102507. */
  102508. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102509. /**
  102510. * Initialize defines for shader compilation
  102511. * @param mesh defines the mesh to be rendered
  102512. * @param nodeMaterial defines the node material requesting the update
  102513. * @param defines defines the material defines to update
  102514. * @param useInstances specifies that instances should be used
  102515. */
  102516. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102517. /**
  102518. * Update defines for shader compilation
  102519. * @param mesh defines the mesh to be rendered
  102520. * @param nodeMaterial defines the node material requesting the update
  102521. * @param defines defines the material defines to update
  102522. * @param useInstances specifies that instances should be used
  102523. * @param subMesh defines which submesh to render
  102524. */
  102525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102526. /**
  102527. * Lets the block try to connect some inputs automatically
  102528. * @param material defines the hosting NodeMaterial
  102529. */
  102530. autoConfigure(material: NodeMaterial): void;
  102531. /**
  102532. * Function called when a block is declared as repeatable content generator
  102533. * @param vertexShaderState defines the current compilation state for the vertex shader
  102534. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102535. * @param mesh defines the mesh to be rendered
  102536. * @param defines defines the material defines to update
  102537. */
  102538. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102539. /**
  102540. * Checks if the block is ready
  102541. * @param mesh defines the mesh to be rendered
  102542. * @param nodeMaterial defines the node material requesting the update
  102543. * @param defines defines the material defines to update
  102544. * @param useInstances specifies that instances should be used
  102545. * @returns true if the block is ready
  102546. */
  102547. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102548. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102549. private _processBuild;
  102550. /**
  102551. * Validates the new name for the block node.
  102552. * @param newName the new name to be given to the node.
  102553. * @returns false if the name is a reserve word, else true.
  102554. */
  102555. validateBlockName(newName: string): boolean;
  102556. /**
  102557. * Compile the current node and generate the shader code
  102558. * @param state defines the current compilation state (uniforms, samplers, current string)
  102559. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102560. * @returns true if already built
  102561. */
  102562. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102563. protected _inputRename(name: string): string;
  102564. protected _outputRename(name: string): string;
  102565. protected _dumpPropertiesCode(): string;
  102566. /** @hidden */
  102567. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102568. /** @hidden */
  102569. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102570. /**
  102571. * Clone the current block to a new identical block
  102572. * @param scene defines the hosting scene
  102573. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102574. * @returns a copy of the current block
  102575. */
  102576. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102577. /**
  102578. * Serializes this block in a JSON representation
  102579. * @returns the serialized block object
  102580. */
  102581. serialize(): any;
  102582. /** @hidden */
  102583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102584. private _deserializePortDisplayNamesAndExposedOnFrame;
  102585. /**
  102586. * Release resources
  102587. */
  102588. dispose(): void;
  102589. }
  102590. }
  102591. declare module BABYLON {
  102592. /**
  102593. * Base class of materials working in push mode in babylon JS
  102594. * @hidden
  102595. */
  102596. export class PushMaterial extends Material {
  102597. protected _activeEffect: Effect;
  102598. protected _normalMatrix: Matrix;
  102599. constructor(name: string, scene: Scene);
  102600. getEffect(): Effect;
  102601. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102602. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102603. /**
  102604. * Binds the given world matrix to the active effect
  102605. *
  102606. * @param world the matrix to bind
  102607. */
  102608. bindOnlyWorldMatrix(world: Matrix): void;
  102609. /**
  102610. * Binds the given normal matrix to the active effect
  102611. *
  102612. * @param normalMatrix the matrix to bind
  102613. */
  102614. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102615. bind(world: Matrix, mesh?: Mesh): void;
  102616. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102617. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102618. }
  102619. }
  102620. declare module BABYLON {
  102621. /**
  102622. * Root class for all node material optimizers
  102623. */
  102624. export class NodeMaterialOptimizer {
  102625. /**
  102626. * Function used to optimize a NodeMaterial graph
  102627. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102628. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102629. */
  102630. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102631. }
  102632. }
  102633. declare module BABYLON {
  102634. /**
  102635. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102636. */
  102637. export class TransformBlock extends NodeMaterialBlock {
  102638. /**
  102639. * Defines the value to use to complement W value to transform it to a Vector4
  102640. */
  102641. complementW: number;
  102642. /**
  102643. * Defines the value to use to complement z value to transform it to a Vector4
  102644. */
  102645. complementZ: number;
  102646. /**
  102647. * Creates a new TransformBlock
  102648. * @param name defines the block name
  102649. */
  102650. constructor(name: string);
  102651. /**
  102652. * Gets the current class name
  102653. * @returns the class name
  102654. */
  102655. getClassName(): string;
  102656. /**
  102657. * Gets the vector input
  102658. */
  102659. get vector(): NodeMaterialConnectionPoint;
  102660. /**
  102661. * Gets the output component
  102662. */
  102663. get output(): NodeMaterialConnectionPoint;
  102664. /**
  102665. * Gets the xyz output component
  102666. */
  102667. get xyz(): NodeMaterialConnectionPoint;
  102668. /**
  102669. * Gets the matrix transform input
  102670. */
  102671. get transform(): NodeMaterialConnectionPoint;
  102672. protected _buildBlock(state: NodeMaterialBuildState): this;
  102673. /**
  102674. * Update defines for shader compilation
  102675. * @param mesh defines the mesh to be rendered
  102676. * @param nodeMaterial defines the node material requesting the update
  102677. * @param defines defines the material defines to update
  102678. * @param useInstances specifies that instances should be used
  102679. * @param subMesh defines which submesh to render
  102680. */
  102681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102682. serialize(): any;
  102683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102684. protected _dumpPropertiesCode(): string;
  102685. }
  102686. }
  102687. declare module BABYLON {
  102688. /**
  102689. * Block used to output the vertex position
  102690. */
  102691. export class VertexOutputBlock extends NodeMaterialBlock {
  102692. /**
  102693. * Creates a new VertexOutputBlock
  102694. * @param name defines the block name
  102695. */
  102696. constructor(name: string);
  102697. /**
  102698. * Gets the current class name
  102699. * @returns the class name
  102700. */
  102701. getClassName(): string;
  102702. /**
  102703. * Gets the vector input component
  102704. */
  102705. get vector(): NodeMaterialConnectionPoint;
  102706. protected _buildBlock(state: NodeMaterialBuildState): this;
  102707. }
  102708. }
  102709. declare module BABYLON {
  102710. /**
  102711. * Block used to output the final color
  102712. */
  102713. export class FragmentOutputBlock extends NodeMaterialBlock {
  102714. /**
  102715. * Create a new FragmentOutputBlock
  102716. * @param name defines the block name
  102717. */
  102718. constructor(name: string);
  102719. /**
  102720. * Gets the current class name
  102721. * @returns the class name
  102722. */
  102723. getClassName(): string;
  102724. /**
  102725. * Gets the rgba input component
  102726. */
  102727. get rgba(): NodeMaterialConnectionPoint;
  102728. /**
  102729. * Gets the rgb input component
  102730. */
  102731. get rgb(): NodeMaterialConnectionPoint;
  102732. /**
  102733. * Gets the a input component
  102734. */
  102735. get a(): NodeMaterialConnectionPoint;
  102736. protected _buildBlock(state: NodeMaterialBuildState): this;
  102737. }
  102738. }
  102739. declare module BABYLON {
  102740. /**
  102741. * Block used for the particle ramp gradient section
  102742. */
  102743. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102744. /**
  102745. * Create a new ParticleRampGradientBlock
  102746. * @param name defines the block name
  102747. */
  102748. constructor(name: string);
  102749. /**
  102750. * Gets the current class name
  102751. * @returns the class name
  102752. */
  102753. getClassName(): string;
  102754. /**
  102755. * Gets the color input component
  102756. */
  102757. get color(): NodeMaterialConnectionPoint;
  102758. /**
  102759. * Gets the rampColor output component
  102760. */
  102761. get rampColor(): NodeMaterialConnectionPoint;
  102762. /**
  102763. * Initialize the block and prepare the context for build
  102764. * @param state defines the state that will be used for the build
  102765. */
  102766. initialize(state: NodeMaterialBuildState): void;
  102767. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102768. }
  102769. }
  102770. declare module BABYLON {
  102771. /**
  102772. * Block used for the particle blend multiply section
  102773. */
  102774. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102775. /**
  102776. * Create a new ParticleBlendMultiplyBlock
  102777. * @param name defines the block name
  102778. */
  102779. constructor(name: string);
  102780. /**
  102781. * Gets the current class name
  102782. * @returns the class name
  102783. */
  102784. getClassName(): string;
  102785. /**
  102786. * Gets the color input component
  102787. */
  102788. get color(): NodeMaterialConnectionPoint;
  102789. /**
  102790. * Gets the alphaTexture input component
  102791. */
  102792. get alphaTexture(): NodeMaterialConnectionPoint;
  102793. /**
  102794. * Gets the alphaColor input component
  102795. */
  102796. get alphaColor(): NodeMaterialConnectionPoint;
  102797. /**
  102798. * Gets the blendColor output component
  102799. */
  102800. get blendColor(): NodeMaterialConnectionPoint;
  102801. /**
  102802. * Initialize the block and prepare the context for build
  102803. * @param state defines the state that will be used for the build
  102804. */
  102805. initialize(state: NodeMaterialBuildState): void;
  102806. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102807. }
  102808. }
  102809. declare module BABYLON {
  102810. /**
  102811. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102812. */
  102813. export class VectorMergerBlock extends NodeMaterialBlock {
  102814. /**
  102815. * Create a new VectorMergerBlock
  102816. * @param name defines the block name
  102817. */
  102818. constructor(name: string);
  102819. /**
  102820. * Gets the current class name
  102821. * @returns the class name
  102822. */
  102823. getClassName(): string;
  102824. /**
  102825. * Gets the xyz component (input)
  102826. */
  102827. get xyzIn(): NodeMaterialConnectionPoint;
  102828. /**
  102829. * Gets the xy component (input)
  102830. */
  102831. get xyIn(): NodeMaterialConnectionPoint;
  102832. /**
  102833. * Gets the x component (input)
  102834. */
  102835. get x(): NodeMaterialConnectionPoint;
  102836. /**
  102837. * Gets the y component (input)
  102838. */
  102839. get y(): NodeMaterialConnectionPoint;
  102840. /**
  102841. * Gets the z component (input)
  102842. */
  102843. get z(): NodeMaterialConnectionPoint;
  102844. /**
  102845. * Gets the w component (input)
  102846. */
  102847. get w(): NodeMaterialConnectionPoint;
  102848. /**
  102849. * Gets the xyzw component (output)
  102850. */
  102851. get xyzw(): NodeMaterialConnectionPoint;
  102852. /**
  102853. * Gets the xyz component (output)
  102854. */
  102855. get xyzOut(): NodeMaterialConnectionPoint;
  102856. /**
  102857. * Gets the xy component (output)
  102858. */
  102859. get xyOut(): NodeMaterialConnectionPoint;
  102860. /**
  102861. * Gets the xy component (output)
  102862. * @deprecated Please use xyOut instead.
  102863. */
  102864. get xy(): NodeMaterialConnectionPoint;
  102865. /**
  102866. * Gets the xyz component (output)
  102867. * @deprecated Please use xyzOut instead.
  102868. */
  102869. get xyz(): NodeMaterialConnectionPoint;
  102870. protected _buildBlock(state: NodeMaterialBuildState): this;
  102871. }
  102872. }
  102873. declare module BABYLON {
  102874. /**
  102875. * Block used to remap a float from a range to a new one
  102876. */
  102877. export class RemapBlock extends NodeMaterialBlock {
  102878. /**
  102879. * Gets or sets the source range
  102880. */
  102881. sourceRange: Vector2;
  102882. /**
  102883. * Gets or sets the target range
  102884. */
  102885. targetRange: Vector2;
  102886. /**
  102887. * Creates a new RemapBlock
  102888. * @param name defines the block name
  102889. */
  102890. constructor(name: string);
  102891. /**
  102892. * Gets the current class name
  102893. * @returns the class name
  102894. */
  102895. getClassName(): string;
  102896. /**
  102897. * Gets the input component
  102898. */
  102899. get input(): NodeMaterialConnectionPoint;
  102900. /**
  102901. * Gets the source min input component
  102902. */
  102903. get sourceMin(): NodeMaterialConnectionPoint;
  102904. /**
  102905. * Gets the source max input component
  102906. */
  102907. get sourceMax(): NodeMaterialConnectionPoint;
  102908. /**
  102909. * Gets the target min input component
  102910. */
  102911. get targetMin(): NodeMaterialConnectionPoint;
  102912. /**
  102913. * Gets the target max input component
  102914. */
  102915. get targetMax(): NodeMaterialConnectionPoint;
  102916. /**
  102917. * Gets the output component
  102918. */
  102919. get output(): NodeMaterialConnectionPoint;
  102920. protected _buildBlock(state: NodeMaterialBuildState): this;
  102921. protected _dumpPropertiesCode(): string;
  102922. serialize(): any;
  102923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102924. }
  102925. }
  102926. declare module BABYLON {
  102927. /**
  102928. * Block used to multiply 2 values
  102929. */
  102930. export class MultiplyBlock extends NodeMaterialBlock {
  102931. /**
  102932. * Creates a new MultiplyBlock
  102933. * @param name defines the block name
  102934. */
  102935. constructor(name: string);
  102936. /**
  102937. * Gets the current class name
  102938. * @returns the class name
  102939. */
  102940. getClassName(): string;
  102941. /**
  102942. * Gets the left operand input component
  102943. */
  102944. get left(): NodeMaterialConnectionPoint;
  102945. /**
  102946. * Gets the right operand input component
  102947. */
  102948. get right(): NodeMaterialConnectionPoint;
  102949. /**
  102950. * Gets the output component
  102951. */
  102952. get output(): NodeMaterialConnectionPoint;
  102953. protected _buildBlock(state: NodeMaterialBuildState): this;
  102954. }
  102955. }
  102956. declare module BABYLON {
  102957. /**
  102958. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102959. */
  102960. export class ColorSplitterBlock extends NodeMaterialBlock {
  102961. /**
  102962. * Create a new ColorSplitterBlock
  102963. * @param name defines the block name
  102964. */
  102965. constructor(name: string);
  102966. /**
  102967. * Gets the current class name
  102968. * @returns the class name
  102969. */
  102970. getClassName(): string;
  102971. /**
  102972. * Gets the rgba component (input)
  102973. */
  102974. get rgba(): NodeMaterialConnectionPoint;
  102975. /**
  102976. * Gets the rgb component (input)
  102977. */
  102978. get rgbIn(): NodeMaterialConnectionPoint;
  102979. /**
  102980. * Gets the rgb component (output)
  102981. */
  102982. get rgbOut(): NodeMaterialConnectionPoint;
  102983. /**
  102984. * Gets the r component (output)
  102985. */
  102986. get r(): NodeMaterialConnectionPoint;
  102987. /**
  102988. * Gets the g component (output)
  102989. */
  102990. get g(): NodeMaterialConnectionPoint;
  102991. /**
  102992. * Gets the b component (output)
  102993. */
  102994. get b(): NodeMaterialConnectionPoint;
  102995. /**
  102996. * Gets the a component (output)
  102997. */
  102998. get a(): NodeMaterialConnectionPoint;
  102999. protected _inputRename(name: string): string;
  103000. protected _outputRename(name: string): string;
  103001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103002. }
  103003. }
  103004. declare module BABYLON {
  103005. /**
  103006. * Operations supported by the Trigonometry block
  103007. */
  103008. export enum TrigonometryBlockOperations {
  103009. /** Cos */
  103010. Cos = 0,
  103011. /** Sin */
  103012. Sin = 1,
  103013. /** Abs */
  103014. Abs = 2,
  103015. /** Exp */
  103016. Exp = 3,
  103017. /** Exp2 */
  103018. Exp2 = 4,
  103019. /** Round */
  103020. Round = 5,
  103021. /** Floor */
  103022. Floor = 6,
  103023. /** Ceiling */
  103024. Ceiling = 7,
  103025. /** Square root */
  103026. Sqrt = 8,
  103027. /** Log */
  103028. Log = 9,
  103029. /** Tangent */
  103030. Tan = 10,
  103031. /** Arc tangent */
  103032. ArcTan = 11,
  103033. /** Arc cosinus */
  103034. ArcCos = 12,
  103035. /** Arc sinus */
  103036. ArcSin = 13,
  103037. /** Fraction */
  103038. Fract = 14,
  103039. /** Sign */
  103040. Sign = 15,
  103041. /** To radians (from degrees) */
  103042. Radians = 16,
  103043. /** To degrees (from radians) */
  103044. Degrees = 17
  103045. }
  103046. /**
  103047. * Block used to apply trigonometry operation to floats
  103048. */
  103049. export class TrigonometryBlock extends NodeMaterialBlock {
  103050. /**
  103051. * Gets or sets the operation applied by the block
  103052. */
  103053. operation: TrigonometryBlockOperations;
  103054. /**
  103055. * Creates a new TrigonometryBlock
  103056. * @param name defines the block name
  103057. */
  103058. constructor(name: string);
  103059. /**
  103060. * Gets the current class name
  103061. * @returns the class name
  103062. */
  103063. getClassName(): string;
  103064. /**
  103065. * Gets the input component
  103066. */
  103067. get input(): NodeMaterialConnectionPoint;
  103068. /**
  103069. * Gets the output component
  103070. */
  103071. get output(): NodeMaterialConnectionPoint;
  103072. protected _buildBlock(state: NodeMaterialBuildState): this;
  103073. serialize(): any;
  103074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103075. protected _dumpPropertiesCode(): string;
  103076. }
  103077. }
  103078. declare module BABYLON {
  103079. /**
  103080. * Interface used to configure the node material editor
  103081. */
  103082. export interface INodeMaterialEditorOptions {
  103083. /** Define the URl to load node editor script */
  103084. editorURL?: string;
  103085. }
  103086. /** @hidden */
  103087. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103088. NORMAL: boolean;
  103089. TANGENT: boolean;
  103090. UV1: boolean;
  103091. /** BONES */
  103092. NUM_BONE_INFLUENCERS: number;
  103093. BonesPerMesh: number;
  103094. BONETEXTURE: boolean;
  103095. /** MORPH TARGETS */
  103096. MORPHTARGETS: boolean;
  103097. MORPHTARGETS_NORMAL: boolean;
  103098. MORPHTARGETS_TANGENT: boolean;
  103099. MORPHTARGETS_UV: boolean;
  103100. NUM_MORPH_INFLUENCERS: number;
  103101. /** IMAGE PROCESSING */
  103102. IMAGEPROCESSING: boolean;
  103103. VIGNETTE: boolean;
  103104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103105. VIGNETTEBLENDMODEOPAQUE: boolean;
  103106. TONEMAPPING: boolean;
  103107. TONEMAPPING_ACES: boolean;
  103108. CONTRAST: boolean;
  103109. EXPOSURE: boolean;
  103110. COLORCURVES: boolean;
  103111. COLORGRADING: boolean;
  103112. COLORGRADING3D: boolean;
  103113. SAMPLER3DGREENDEPTH: boolean;
  103114. SAMPLER3DBGRMAP: boolean;
  103115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103116. /** MISC. */
  103117. BUMPDIRECTUV: number;
  103118. constructor();
  103119. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103120. }
  103121. /**
  103122. * Class used to configure NodeMaterial
  103123. */
  103124. export interface INodeMaterialOptions {
  103125. /**
  103126. * Defines if blocks should emit comments
  103127. */
  103128. emitComments: boolean;
  103129. }
  103130. /**
  103131. * Class used to create a node based material built by assembling shader blocks
  103132. */
  103133. export class NodeMaterial extends PushMaterial {
  103134. private static _BuildIdGenerator;
  103135. private _options;
  103136. private _vertexCompilationState;
  103137. private _fragmentCompilationState;
  103138. private _sharedData;
  103139. private _buildId;
  103140. private _buildWasSuccessful;
  103141. private _cachedWorldViewMatrix;
  103142. private _cachedWorldViewProjectionMatrix;
  103143. private _optimizers;
  103144. private _animationFrame;
  103145. /** Define the Url to load node editor script */
  103146. static EditorURL: string;
  103147. /** Define the Url to load snippets */
  103148. static SnippetUrl: string;
  103149. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103150. static IgnoreTexturesAtLoadTime: boolean;
  103151. private BJSNODEMATERIALEDITOR;
  103152. /** Get the inspector from bundle or global */
  103153. private _getGlobalNodeMaterialEditor;
  103154. /**
  103155. * Snippet ID if the material was created from the snippet server
  103156. */
  103157. snippetId: string;
  103158. /**
  103159. * Gets or sets data used by visual editor
  103160. * @see https://nme.babylonjs.com
  103161. */
  103162. editorData: any;
  103163. /**
  103164. * 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)
  103165. */
  103166. ignoreAlpha: boolean;
  103167. /**
  103168. * Defines the maximum number of lights that can be used in the material
  103169. */
  103170. maxSimultaneousLights: number;
  103171. /**
  103172. * Observable raised when the material is built
  103173. */
  103174. onBuildObservable: Observable<NodeMaterial>;
  103175. /**
  103176. * Gets or sets the root nodes of the material vertex shader
  103177. */
  103178. _vertexOutputNodes: NodeMaterialBlock[];
  103179. /**
  103180. * Gets or sets the root nodes of the material fragment (pixel) shader
  103181. */
  103182. _fragmentOutputNodes: NodeMaterialBlock[];
  103183. /** Gets or sets options to control the node material overall behavior */
  103184. get options(): INodeMaterialOptions;
  103185. set options(options: INodeMaterialOptions);
  103186. /**
  103187. * Default configuration related to image processing available in the standard Material.
  103188. */
  103189. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103190. /**
  103191. * Gets the image processing configuration used either in this material.
  103192. */
  103193. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103194. /**
  103195. * Sets the Default image processing configuration used either in the this material.
  103196. *
  103197. * If sets to null, the scene one is in use.
  103198. */
  103199. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103200. /**
  103201. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103202. */
  103203. attachedBlocks: NodeMaterialBlock[];
  103204. /**
  103205. * Specifies the mode of the node material
  103206. * @hidden
  103207. */
  103208. _mode: NodeMaterialModes;
  103209. /**
  103210. * Gets the mode property
  103211. */
  103212. get mode(): NodeMaterialModes;
  103213. /**
  103214. * Create a new node based material
  103215. * @param name defines the material name
  103216. * @param scene defines the hosting scene
  103217. * @param options defines creation option
  103218. */
  103219. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103220. /**
  103221. * Gets the current class name of the material e.g. "NodeMaterial"
  103222. * @returns the class name
  103223. */
  103224. getClassName(): string;
  103225. /**
  103226. * Keep track of the image processing observer to allow dispose and replace.
  103227. */
  103228. private _imageProcessingObserver;
  103229. /**
  103230. * Attaches a new image processing configuration to the Standard Material.
  103231. * @param configuration
  103232. */
  103233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103234. /**
  103235. * Get a block by its name
  103236. * @param name defines the name of the block to retrieve
  103237. * @returns the required block or null if not found
  103238. */
  103239. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103240. /**
  103241. * Get a block by its name
  103242. * @param predicate defines the predicate used to find the good candidate
  103243. * @returns the required block or null if not found
  103244. */
  103245. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103246. /**
  103247. * Get an input block by its name
  103248. * @param predicate defines the predicate used to find the good candidate
  103249. * @returns the required input block or null if not found
  103250. */
  103251. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103252. /**
  103253. * Gets the list of input blocks attached to this material
  103254. * @returns an array of InputBlocks
  103255. */
  103256. getInputBlocks(): InputBlock[];
  103257. /**
  103258. * Adds a new optimizer to the list of optimizers
  103259. * @param optimizer defines the optimizers to add
  103260. * @returns the current material
  103261. */
  103262. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103263. /**
  103264. * Remove an optimizer from the list of optimizers
  103265. * @param optimizer defines the optimizers to remove
  103266. * @returns the current material
  103267. */
  103268. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103269. /**
  103270. * Add a new block to the list of output nodes
  103271. * @param node defines the node to add
  103272. * @returns the current material
  103273. */
  103274. addOutputNode(node: NodeMaterialBlock): this;
  103275. /**
  103276. * Remove a block from the list of root nodes
  103277. * @param node defines the node to remove
  103278. * @returns the current material
  103279. */
  103280. removeOutputNode(node: NodeMaterialBlock): this;
  103281. private _addVertexOutputNode;
  103282. private _removeVertexOutputNode;
  103283. private _addFragmentOutputNode;
  103284. private _removeFragmentOutputNode;
  103285. /**
  103286. * Specifies if the material will require alpha blending
  103287. * @returns a boolean specifying if alpha blending is needed
  103288. */
  103289. needAlphaBlending(): boolean;
  103290. /**
  103291. * Specifies if this material should be rendered in alpha test mode
  103292. * @returns a boolean specifying if an alpha test is needed.
  103293. */
  103294. needAlphaTesting(): boolean;
  103295. private _initializeBlock;
  103296. private _resetDualBlocks;
  103297. /**
  103298. * Remove a block from the current node material
  103299. * @param block defines the block to remove
  103300. */
  103301. removeBlock(block: NodeMaterialBlock): void;
  103302. /**
  103303. * Build the material and generates the inner effect
  103304. * @param verbose defines if the build should log activity
  103305. */
  103306. build(verbose?: boolean): void;
  103307. /**
  103308. * Runs an otpimization phase to try to improve the shader code
  103309. */
  103310. optimize(): void;
  103311. private _prepareDefinesForAttributes;
  103312. /**
  103313. * Create a post process from the material
  103314. * @param camera The camera to apply the render pass to.
  103315. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103317. * @param engine The engine which the post process will be applied. (default: current engine)
  103318. * @param reusable If the post process can be reused on the same frame. (default: false)
  103319. * @param textureType Type of textures used when performing the post process. (default: 0)
  103320. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103321. * @returns the post process created
  103322. */
  103323. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103324. /**
  103325. * Create the post process effect from the material
  103326. * @param postProcess The post process to create the effect for
  103327. */
  103328. createEffectForPostProcess(postProcess: PostProcess): void;
  103329. private _createEffectForPostProcess;
  103330. /**
  103331. * Create a new procedural texture based on this node material
  103332. * @param size defines the size of the texture
  103333. * @param scene defines the hosting scene
  103334. * @returns the new procedural texture attached to this node material
  103335. */
  103336. createProceduralTexture(size: number | {
  103337. width: number;
  103338. height: number;
  103339. layers?: number;
  103340. }, scene: Scene): Nullable<ProceduralTexture>;
  103341. private _createEffectForParticles;
  103342. private _checkInternals;
  103343. /**
  103344. * Create the effect to be used as the custom effect for a particle system
  103345. * @param particleSystem Particle system to create the effect for
  103346. * @param onCompiled defines a function to call when the effect creation is successful
  103347. * @param onError defines a function to call when the effect creation has failed
  103348. */
  103349. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103350. private _processDefines;
  103351. /**
  103352. * Get if the submesh is ready to be used and all its information available.
  103353. * Child classes can use it to update shaders
  103354. * @param mesh defines the mesh to check
  103355. * @param subMesh defines which submesh to check
  103356. * @param useInstances specifies that instances should be used
  103357. * @returns a boolean indicating that the submesh is ready or not
  103358. */
  103359. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103360. /**
  103361. * Get a string representing the shaders built by the current node graph
  103362. */
  103363. get compiledShaders(): string;
  103364. /**
  103365. * Binds the world matrix to the material
  103366. * @param world defines the world transformation matrix
  103367. */
  103368. bindOnlyWorldMatrix(world: Matrix): void;
  103369. /**
  103370. * Binds the submesh to this material by preparing the effect and shader to draw
  103371. * @param world defines the world transformation matrix
  103372. * @param mesh defines the mesh containing the submesh
  103373. * @param subMesh defines the submesh to bind the material to
  103374. */
  103375. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103376. /**
  103377. * Gets the active textures from the material
  103378. * @returns an array of textures
  103379. */
  103380. getActiveTextures(): BaseTexture[];
  103381. /**
  103382. * Gets the list of texture blocks
  103383. * @returns an array of texture blocks
  103384. */
  103385. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103386. /**
  103387. * Specifies if the material uses a texture
  103388. * @param texture defines the texture to check against the material
  103389. * @returns a boolean specifying if the material uses the texture
  103390. */
  103391. hasTexture(texture: BaseTexture): boolean;
  103392. /**
  103393. * Disposes the material
  103394. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103395. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103396. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103397. */
  103398. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103399. /** Creates the node editor window. */
  103400. private _createNodeEditor;
  103401. /**
  103402. * Launch the node material editor
  103403. * @param config Define the configuration of the editor
  103404. * @return a promise fulfilled when the node editor is visible
  103405. */
  103406. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103407. /**
  103408. * Clear the current material
  103409. */
  103410. clear(): void;
  103411. /**
  103412. * Clear the current material and set it to a default state
  103413. */
  103414. setToDefault(): void;
  103415. /**
  103416. * Clear the current material and set it to a default state for post process
  103417. */
  103418. setToDefaultPostProcess(): void;
  103419. /**
  103420. * Clear the current material and set it to a default state for procedural texture
  103421. */
  103422. setToDefaultProceduralTexture(): void;
  103423. /**
  103424. * Clear the current material and set it to a default state for particle
  103425. */
  103426. setToDefaultParticle(): void;
  103427. /**
  103428. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103429. * @param url defines the url to load from
  103430. * @returns a promise that will fullfil when the material is fully loaded
  103431. */
  103432. loadAsync(url: string): Promise<void>;
  103433. private _gatherBlocks;
  103434. /**
  103435. * Generate a string containing the code declaration required to create an equivalent of this material
  103436. * @returns a string
  103437. */
  103438. generateCode(): string;
  103439. /**
  103440. * Serializes this material in a JSON representation
  103441. * @returns the serialized material object
  103442. */
  103443. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103444. private _restoreConnections;
  103445. /**
  103446. * Clear the current graph and load a new one from a serialization object
  103447. * @param source defines the JSON representation of the material
  103448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103449. * @param merge defines whether or not the source must be merged or replace the current content
  103450. */
  103451. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103452. /**
  103453. * Makes a duplicate of the current material.
  103454. * @param name - name to use for the new material.
  103455. */
  103456. clone(name: string): NodeMaterial;
  103457. /**
  103458. * Creates a node material from parsed material data
  103459. * @param source defines the JSON representation of the material
  103460. * @param scene defines the hosting scene
  103461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103462. * @returns a new node material
  103463. */
  103464. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103465. /**
  103466. * Creates a node material from a snippet saved in a remote file
  103467. * @param name defines the name of the material to create
  103468. * @param url defines the url to load from
  103469. * @param scene defines the hosting scene
  103470. * @returns a promise that will resolve to the new node material
  103471. */
  103472. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103473. /**
  103474. * Creates a node material from a snippet saved by the node material editor
  103475. * @param snippetId defines the snippet to load
  103476. * @param scene defines the hosting scene
  103477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103478. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103479. * @returns a promise that will resolve to the new node material
  103480. */
  103481. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103482. /**
  103483. * Creates a new node material set to default basic configuration
  103484. * @param name defines the name of the material
  103485. * @param scene defines the hosting scene
  103486. * @returns a new NodeMaterial
  103487. */
  103488. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103489. }
  103490. }
  103491. declare module BABYLON {
  103492. interface ThinEngine {
  103493. /**
  103494. * Unbind a list of render target textures from the webGL context
  103495. * This is used only when drawBuffer extension or webGL2 are active
  103496. * @param textures defines the render target textures to unbind
  103497. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103498. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103499. */
  103500. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103501. /**
  103502. * Create a multi render target texture
  103503. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103504. * @param size defines the size of the texture
  103505. * @param options defines the creation options
  103506. * @returns the cube texture as an InternalTexture
  103507. */
  103508. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103509. /**
  103510. * Update the sample count for a given multiple render target texture
  103511. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103512. * @param textures defines the textures to update
  103513. * @param samples defines the sample count to set
  103514. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103515. */
  103516. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103517. /**
  103518. * Select a subsets of attachments to draw to.
  103519. * @param attachments gl attachments
  103520. */
  103521. bindAttachments(attachments: number[]): void;
  103522. /**
  103523. * Creates a layout object to draw/clear on specific textures in a MRT
  103524. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103525. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103526. */
  103527. buildTextureLayout(textureStatus: boolean[]): number[];
  103528. /**
  103529. * Restores the webgl state to only draw on the main color attachment
  103530. */
  103531. restoreSingleAttachment(): void;
  103532. }
  103533. }
  103534. declare module BABYLON {
  103535. /**
  103536. * Creation options of the multi render target texture.
  103537. */
  103538. export interface IMultiRenderTargetOptions {
  103539. /**
  103540. * Define if the texture needs to create mip maps after render.
  103541. */
  103542. generateMipMaps?: boolean;
  103543. /**
  103544. * Define the types of all the draw buffers we want to create
  103545. */
  103546. types?: number[];
  103547. /**
  103548. * Define the sampling modes of all the draw buffers we want to create
  103549. */
  103550. samplingModes?: number[];
  103551. /**
  103552. * Define if a depth buffer is required
  103553. */
  103554. generateDepthBuffer?: boolean;
  103555. /**
  103556. * Define if a stencil buffer is required
  103557. */
  103558. generateStencilBuffer?: boolean;
  103559. /**
  103560. * Define if a depth texture is required instead of a depth buffer
  103561. */
  103562. generateDepthTexture?: boolean;
  103563. /**
  103564. * Define the number of desired draw buffers
  103565. */
  103566. textureCount?: number;
  103567. /**
  103568. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103569. */
  103570. doNotChangeAspectRatio?: boolean;
  103571. /**
  103572. * Define the default type of the buffers we are creating
  103573. */
  103574. defaultType?: number;
  103575. }
  103576. /**
  103577. * A multi render target, like a render target provides the ability to render to a texture.
  103578. * Unlike the render target, it can render to several draw buffers in one draw.
  103579. * This is specially interesting in deferred rendering or for any effects requiring more than
  103580. * just one color from a single pass.
  103581. */
  103582. export class MultiRenderTarget extends RenderTargetTexture {
  103583. private _internalTextures;
  103584. private _textures;
  103585. private _multiRenderTargetOptions;
  103586. private _count;
  103587. /**
  103588. * Get if draw buffers are currently supported by the used hardware and browser.
  103589. */
  103590. get isSupported(): boolean;
  103591. /**
  103592. * Get the list of textures generated by the multi render target.
  103593. */
  103594. get textures(): Texture[];
  103595. /**
  103596. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103597. */
  103598. get count(): number;
  103599. /**
  103600. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103601. */
  103602. get depthTexture(): Texture;
  103603. /**
  103604. * Set the wrapping mode on U of all the textures we are rendering to.
  103605. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103606. */
  103607. set wrapU(wrap: number);
  103608. /**
  103609. * Set the wrapping mode on V of all the textures we are rendering to.
  103610. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103611. */
  103612. set wrapV(wrap: number);
  103613. /**
  103614. * Instantiate a new multi render target texture.
  103615. * A multi render target, like a render target provides the ability to render to a texture.
  103616. * Unlike the render target, it can render to several draw buffers in one draw.
  103617. * This is specially interesting in deferred rendering or for any effects requiring more than
  103618. * just one color from a single pass.
  103619. * @param name Define the name of the texture
  103620. * @param size Define the size of the buffers to render to
  103621. * @param count Define the number of target we are rendering into
  103622. * @param scene Define the scene the texture belongs to
  103623. * @param options Define the options used to create the multi render target
  103624. */
  103625. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103626. private _initTypes;
  103627. /** @hidden */
  103628. _rebuild(forceFullRebuild?: boolean): void;
  103629. private _createInternalTextures;
  103630. private _createTextures;
  103631. /**
  103632. * Replaces a texture within the MRT.
  103633. * @param texture The new texture to insert in the MRT
  103634. * @param index The index of the texture to replace
  103635. */
  103636. replaceTexture(texture: Texture, index: number): void;
  103637. /**
  103638. * Define the number of samples used if MSAA is enabled.
  103639. */
  103640. get samples(): number;
  103641. set samples(value: number);
  103642. /**
  103643. * Resize all the textures in the multi render target.
  103644. * Be careful as it will recreate all the data in the new texture.
  103645. * @param size Define the new size
  103646. */
  103647. resize(size: any): void;
  103648. /**
  103649. * Changes the number of render targets in this MRT
  103650. * Be careful as it will recreate all the data in the new texture.
  103651. * @param count new texture count
  103652. * @param options Specifies texture types and sampling modes for new textures
  103653. */
  103654. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103655. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103656. /**
  103657. * Dispose the render targets and their associated resources
  103658. */
  103659. dispose(): void;
  103660. /**
  103661. * Release all the underlying texture used as draw buffers.
  103662. */
  103663. releaseInternalTextures(): void;
  103664. }
  103665. }
  103666. declare module BABYLON {
  103667. /** @hidden */
  103668. export var imageProcessingPixelShader: {
  103669. name: string;
  103670. shader: string;
  103671. };
  103672. }
  103673. declare module BABYLON {
  103674. /**
  103675. * ImageProcessingPostProcess
  103676. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103677. */
  103678. export class ImageProcessingPostProcess extends PostProcess {
  103679. /**
  103680. * Default configuration related to image processing available in the PBR Material.
  103681. */
  103682. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103683. /**
  103684. * Gets the image processing configuration used either in this material.
  103685. */
  103686. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103687. /**
  103688. * Sets the Default image processing configuration used either in the this material.
  103689. *
  103690. * If sets to null, the scene one is in use.
  103691. */
  103692. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103693. /**
  103694. * Keep track of the image processing observer to allow dispose and replace.
  103695. */
  103696. private _imageProcessingObserver;
  103697. /**
  103698. * Attaches a new image processing configuration to the PBR Material.
  103699. * @param configuration
  103700. */
  103701. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103702. /**
  103703. * If the post process is supported.
  103704. */
  103705. get isSupported(): boolean;
  103706. /**
  103707. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103708. */
  103709. get colorCurves(): Nullable<ColorCurves>;
  103710. /**
  103711. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103712. */
  103713. set colorCurves(value: Nullable<ColorCurves>);
  103714. /**
  103715. * Gets wether the color curves effect is enabled.
  103716. */
  103717. get colorCurvesEnabled(): boolean;
  103718. /**
  103719. * Sets wether the color curves effect is enabled.
  103720. */
  103721. set colorCurvesEnabled(value: boolean);
  103722. /**
  103723. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103724. */
  103725. get colorGradingTexture(): Nullable<BaseTexture>;
  103726. /**
  103727. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103728. */
  103729. set colorGradingTexture(value: Nullable<BaseTexture>);
  103730. /**
  103731. * Gets wether the color grading effect is enabled.
  103732. */
  103733. get colorGradingEnabled(): boolean;
  103734. /**
  103735. * Gets wether the color grading effect is enabled.
  103736. */
  103737. set colorGradingEnabled(value: boolean);
  103738. /**
  103739. * Gets exposure used in the effect.
  103740. */
  103741. get exposure(): number;
  103742. /**
  103743. * Sets exposure used in the effect.
  103744. */
  103745. set exposure(value: number);
  103746. /**
  103747. * Gets wether tonemapping is enabled or not.
  103748. */
  103749. get toneMappingEnabled(): boolean;
  103750. /**
  103751. * Sets wether tonemapping is enabled or not
  103752. */
  103753. set toneMappingEnabled(value: boolean);
  103754. /**
  103755. * Gets the type of tone mapping effect.
  103756. */
  103757. get toneMappingType(): number;
  103758. /**
  103759. * Sets the type of tone mapping effect.
  103760. */
  103761. set toneMappingType(value: number);
  103762. /**
  103763. * Gets contrast used in the effect.
  103764. */
  103765. get contrast(): number;
  103766. /**
  103767. * Sets contrast used in the effect.
  103768. */
  103769. set contrast(value: number);
  103770. /**
  103771. * Gets Vignette stretch size.
  103772. */
  103773. get vignetteStretch(): number;
  103774. /**
  103775. * Sets Vignette stretch size.
  103776. */
  103777. set vignetteStretch(value: number);
  103778. /**
  103779. * Gets Vignette centre X Offset.
  103780. */
  103781. get vignetteCentreX(): number;
  103782. /**
  103783. * Sets Vignette centre X Offset.
  103784. */
  103785. set vignetteCentreX(value: number);
  103786. /**
  103787. * Gets Vignette centre Y Offset.
  103788. */
  103789. get vignetteCentreY(): number;
  103790. /**
  103791. * Sets Vignette centre Y Offset.
  103792. */
  103793. set vignetteCentreY(value: number);
  103794. /**
  103795. * Gets Vignette weight or intensity of the vignette effect.
  103796. */
  103797. get vignetteWeight(): number;
  103798. /**
  103799. * Sets Vignette weight or intensity of the vignette effect.
  103800. */
  103801. set vignetteWeight(value: number);
  103802. /**
  103803. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103804. * if vignetteEnabled is set to true.
  103805. */
  103806. get vignetteColor(): Color4;
  103807. /**
  103808. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103809. * if vignetteEnabled is set to true.
  103810. */
  103811. set vignetteColor(value: Color4);
  103812. /**
  103813. * Gets Camera field of view used by the Vignette effect.
  103814. */
  103815. get vignetteCameraFov(): number;
  103816. /**
  103817. * Sets Camera field of view used by the Vignette effect.
  103818. */
  103819. set vignetteCameraFov(value: number);
  103820. /**
  103821. * Gets the vignette blend mode allowing different kind of effect.
  103822. */
  103823. get vignetteBlendMode(): number;
  103824. /**
  103825. * Sets the vignette blend mode allowing different kind of effect.
  103826. */
  103827. set vignetteBlendMode(value: number);
  103828. /**
  103829. * Gets wether the vignette effect is enabled.
  103830. */
  103831. get vignetteEnabled(): boolean;
  103832. /**
  103833. * Sets wether the vignette effect is enabled.
  103834. */
  103835. set vignetteEnabled(value: boolean);
  103836. private _fromLinearSpace;
  103837. /**
  103838. * Gets wether the input of the processing is in Gamma or Linear Space.
  103839. */
  103840. get fromLinearSpace(): boolean;
  103841. /**
  103842. * Sets wether the input of the processing is in Gamma or Linear Space.
  103843. */
  103844. set fromLinearSpace(value: boolean);
  103845. /**
  103846. * Defines cache preventing GC.
  103847. */
  103848. private _defines;
  103849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103850. /**
  103851. * "ImageProcessingPostProcess"
  103852. * @returns "ImageProcessingPostProcess"
  103853. */
  103854. getClassName(): string;
  103855. /**
  103856. * @hidden
  103857. */
  103858. _updateParameters(): void;
  103859. dispose(camera?: Camera): void;
  103860. }
  103861. }
  103862. declare module BABYLON {
  103863. /**
  103864. * Interface for defining prepass effects in the prepass post-process pipeline
  103865. */
  103866. export interface PrePassEffectConfiguration {
  103867. /**
  103868. * Name of the effect
  103869. */
  103870. name: string;
  103871. /**
  103872. * Post process to attach for this effect
  103873. */
  103874. postProcess?: PostProcess;
  103875. /**
  103876. * Textures required in the MRT
  103877. */
  103878. texturesRequired: number[];
  103879. /**
  103880. * Is the effect enabled
  103881. */
  103882. enabled: boolean;
  103883. /**
  103884. * Disposes the effect configuration
  103885. */
  103886. dispose?: () => void;
  103887. /**
  103888. * Creates the associated post process
  103889. */
  103890. createPostProcess?: () => PostProcess;
  103891. }
  103892. }
  103893. declare module BABYLON {
  103894. /**
  103895. * Options to be used when creating a FresnelParameters.
  103896. */
  103897. export type IFresnelParametersCreationOptions = {
  103898. /**
  103899. * Define the color used on edges (grazing angle)
  103900. */
  103901. leftColor?: Color3;
  103902. /**
  103903. * Define the color used on center
  103904. */
  103905. rightColor?: Color3;
  103906. /**
  103907. * Define bias applied to computed fresnel term
  103908. */
  103909. bias?: number;
  103910. /**
  103911. * Defined the power exponent applied to fresnel term
  103912. */
  103913. power?: number;
  103914. /**
  103915. * Define if the fresnel effect is enable or not.
  103916. */
  103917. isEnabled?: boolean;
  103918. };
  103919. /**
  103920. * Serialized format for FresnelParameters.
  103921. */
  103922. export type IFresnelParametersSerialized = {
  103923. /**
  103924. * Define the color used on edges (grazing angle) [as an array]
  103925. */
  103926. leftColor: number[];
  103927. /**
  103928. * Define the color used on center [as an array]
  103929. */
  103930. rightColor: number[];
  103931. /**
  103932. * Define bias applied to computed fresnel term
  103933. */
  103934. bias: number;
  103935. /**
  103936. * Defined the power exponent applied to fresnel term
  103937. */
  103938. power?: number;
  103939. /**
  103940. * Define if the fresnel effect is enable or not.
  103941. */
  103942. isEnabled: boolean;
  103943. };
  103944. /**
  103945. * This represents all the required information to add a fresnel effect on a material:
  103946. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103947. */
  103948. export class FresnelParameters {
  103949. private _isEnabled;
  103950. /**
  103951. * Define if the fresnel effect is enable or not.
  103952. */
  103953. get isEnabled(): boolean;
  103954. set isEnabled(value: boolean);
  103955. /**
  103956. * Define the color used on edges (grazing angle)
  103957. */
  103958. leftColor: Color3;
  103959. /**
  103960. * Define the color used on center
  103961. */
  103962. rightColor: Color3;
  103963. /**
  103964. * Define bias applied to computed fresnel term
  103965. */
  103966. bias: number;
  103967. /**
  103968. * Defined the power exponent applied to fresnel term
  103969. */
  103970. power: number;
  103971. /**
  103972. * Creates a new FresnelParameters object.
  103973. *
  103974. * @param options provide your own settings to optionally to override defaults
  103975. */
  103976. constructor(options?: IFresnelParametersCreationOptions);
  103977. /**
  103978. * Clones the current fresnel and its valuues
  103979. * @returns a clone fresnel configuration
  103980. */
  103981. clone(): FresnelParameters;
  103982. /**
  103983. * Determines equality between FresnelParameters objects
  103984. * @param otherFresnelParameters defines the second operand
  103985. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103986. */
  103987. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103988. /**
  103989. * Serializes the current fresnel parameters to a JSON representation.
  103990. * @return the JSON serialization
  103991. */
  103992. serialize(): IFresnelParametersSerialized;
  103993. /**
  103994. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103995. * @param parsedFresnelParameters Define the JSON representation
  103996. * @returns the parsed parameters
  103997. */
  103998. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103999. }
  104000. }
  104001. declare module BABYLON {
  104002. /**
  104003. * This groups all the flags used to control the materials channel.
  104004. */
  104005. export class MaterialFlags {
  104006. private static _DiffuseTextureEnabled;
  104007. /**
  104008. * Are diffuse textures enabled in the application.
  104009. */
  104010. static get DiffuseTextureEnabled(): boolean;
  104011. static set DiffuseTextureEnabled(value: boolean);
  104012. private static _DetailTextureEnabled;
  104013. /**
  104014. * Are detail textures enabled in the application.
  104015. */
  104016. static get DetailTextureEnabled(): boolean;
  104017. static set DetailTextureEnabled(value: boolean);
  104018. private static _AmbientTextureEnabled;
  104019. /**
  104020. * Are ambient textures enabled in the application.
  104021. */
  104022. static get AmbientTextureEnabled(): boolean;
  104023. static set AmbientTextureEnabled(value: boolean);
  104024. private static _OpacityTextureEnabled;
  104025. /**
  104026. * Are opacity textures enabled in the application.
  104027. */
  104028. static get OpacityTextureEnabled(): boolean;
  104029. static set OpacityTextureEnabled(value: boolean);
  104030. private static _ReflectionTextureEnabled;
  104031. /**
  104032. * Are reflection textures enabled in the application.
  104033. */
  104034. static get ReflectionTextureEnabled(): boolean;
  104035. static set ReflectionTextureEnabled(value: boolean);
  104036. private static _EmissiveTextureEnabled;
  104037. /**
  104038. * Are emissive textures enabled in the application.
  104039. */
  104040. static get EmissiveTextureEnabled(): boolean;
  104041. static set EmissiveTextureEnabled(value: boolean);
  104042. private static _SpecularTextureEnabled;
  104043. /**
  104044. * Are specular textures enabled in the application.
  104045. */
  104046. static get SpecularTextureEnabled(): boolean;
  104047. static set SpecularTextureEnabled(value: boolean);
  104048. private static _BumpTextureEnabled;
  104049. /**
  104050. * Are bump textures enabled in the application.
  104051. */
  104052. static get BumpTextureEnabled(): boolean;
  104053. static set BumpTextureEnabled(value: boolean);
  104054. private static _LightmapTextureEnabled;
  104055. /**
  104056. * Are lightmap textures enabled in the application.
  104057. */
  104058. static get LightmapTextureEnabled(): boolean;
  104059. static set LightmapTextureEnabled(value: boolean);
  104060. private static _RefractionTextureEnabled;
  104061. /**
  104062. * Are refraction textures enabled in the application.
  104063. */
  104064. static get RefractionTextureEnabled(): boolean;
  104065. static set RefractionTextureEnabled(value: boolean);
  104066. private static _ColorGradingTextureEnabled;
  104067. /**
  104068. * Are color grading textures enabled in the application.
  104069. */
  104070. static get ColorGradingTextureEnabled(): boolean;
  104071. static set ColorGradingTextureEnabled(value: boolean);
  104072. private static _FresnelEnabled;
  104073. /**
  104074. * Are fresnels enabled in the application.
  104075. */
  104076. static get FresnelEnabled(): boolean;
  104077. static set FresnelEnabled(value: boolean);
  104078. private static _ClearCoatTextureEnabled;
  104079. /**
  104080. * Are clear coat textures enabled in the application.
  104081. */
  104082. static get ClearCoatTextureEnabled(): boolean;
  104083. static set ClearCoatTextureEnabled(value: boolean);
  104084. private static _ClearCoatBumpTextureEnabled;
  104085. /**
  104086. * Are clear coat bump textures enabled in the application.
  104087. */
  104088. static get ClearCoatBumpTextureEnabled(): boolean;
  104089. static set ClearCoatBumpTextureEnabled(value: boolean);
  104090. private static _ClearCoatTintTextureEnabled;
  104091. /**
  104092. * Are clear coat tint textures enabled in the application.
  104093. */
  104094. static get ClearCoatTintTextureEnabled(): boolean;
  104095. static set ClearCoatTintTextureEnabled(value: boolean);
  104096. private static _SheenTextureEnabled;
  104097. /**
  104098. * Are sheen textures enabled in the application.
  104099. */
  104100. static get SheenTextureEnabled(): boolean;
  104101. static set SheenTextureEnabled(value: boolean);
  104102. private static _AnisotropicTextureEnabled;
  104103. /**
  104104. * Are anisotropic textures enabled in the application.
  104105. */
  104106. static get AnisotropicTextureEnabled(): boolean;
  104107. static set AnisotropicTextureEnabled(value: boolean);
  104108. private static _ThicknessTextureEnabled;
  104109. /**
  104110. * Are thickness textures enabled in the application.
  104111. */
  104112. static get ThicknessTextureEnabled(): boolean;
  104113. static set ThicknessTextureEnabled(value: boolean);
  104114. }
  104115. }
  104116. declare module BABYLON {
  104117. /** @hidden */
  104118. export var defaultFragmentDeclaration: {
  104119. name: string;
  104120. shader: string;
  104121. };
  104122. }
  104123. declare module BABYLON {
  104124. /** @hidden */
  104125. export var defaultUboDeclaration: {
  104126. name: string;
  104127. shader: string;
  104128. };
  104129. }
  104130. declare module BABYLON {
  104131. /** @hidden */
  104132. export var prePassDeclaration: {
  104133. name: string;
  104134. shader: string;
  104135. };
  104136. }
  104137. declare module BABYLON {
  104138. /** @hidden */
  104139. export var lightFragmentDeclaration: {
  104140. name: string;
  104141. shader: string;
  104142. };
  104143. }
  104144. declare module BABYLON {
  104145. /** @hidden */
  104146. export var lightUboDeclaration: {
  104147. name: string;
  104148. shader: string;
  104149. };
  104150. }
  104151. declare module BABYLON {
  104152. /** @hidden */
  104153. export var lightsFragmentFunctions: {
  104154. name: string;
  104155. shader: string;
  104156. };
  104157. }
  104158. declare module BABYLON {
  104159. /** @hidden */
  104160. export var shadowsFragmentFunctions: {
  104161. name: string;
  104162. shader: string;
  104163. };
  104164. }
  104165. declare module BABYLON {
  104166. /** @hidden */
  104167. export var fresnelFunction: {
  104168. name: string;
  104169. shader: string;
  104170. };
  104171. }
  104172. declare module BABYLON {
  104173. /** @hidden */
  104174. export var bumpFragmentMainFunctions: {
  104175. name: string;
  104176. shader: string;
  104177. };
  104178. }
  104179. declare module BABYLON {
  104180. /** @hidden */
  104181. export var bumpFragmentFunctions: {
  104182. name: string;
  104183. shader: string;
  104184. };
  104185. }
  104186. declare module BABYLON {
  104187. /** @hidden */
  104188. export var logDepthDeclaration: {
  104189. name: string;
  104190. shader: string;
  104191. };
  104192. }
  104193. declare module BABYLON {
  104194. /** @hidden */
  104195. export var bumpFragment: {
  104196. name: string;
  104197. shader: string;
  104198. };
  104199. }
  104200. declare module BABYLON {
  104201. /** @hidden */
  104202. export var depthPrePass: {
  104203. name: string;
  104204. shader: string;
  104205. };
  104206. }
  104207. declare module BABYLON {
  104208. /** @hidden */
  104209. export var lightFragment: {
  104210. name: string;
  104211. shader: string;
  104212. };
  104213. }
  104214. declare module BABYLON {
  104215. /** @hidden */
  104216. export var logDepthFragment: {
  104217. name: string;
  104218. shader: string;
  104219. };
  104220. }
  104221. declare module BABYLON {
  104222. /** @hidden */
  104223. export var defaultPixelShader: {
  104224. name: string;
  104225. shader: string;
  104226. };
  104227. }
  104228. declare module BABYLON {
  104229. /** @hidden */
  104230. export var defaultVertexDeclaration: {
  104231. name: string;
  104232. shader: string;
  104233. };
  104234. }
  104235. declare module BABYLON {
  104236. /** @hidden */
  104237. export var prePassVertexDeclaration: {
  104238. name: string;
  104239. shader: string;
  104240. };
  104241. }
  104242. declare module BABYLON {
  104243. /** @hidden */
  104244. export var bumpVertexDeclaration: {
  104245. name: string;
  104246. shader: string;
  104247. };
  104248. }
  104249. declare module BABYLON {
  104250. /** @hidden */
  104251. export var prePassVertex: {
  104252. name: string;
  104253. shader: string;
  104254. };
  104255. }
  104256. declare module BABYLON {
  104257. /** @hidden */
  104258. export var bumpVertex: {
  104259. name: string;
  104260. shader: string;
  104261. };
  104262. }
  104263. declare module BABYLON {
  104264. /** @hidden */
  104265. export var fogVertex: {
  104266. name: string;
  104267. shader: string;
  104268. };
  104269. }
  104270. declare module BABYLON {
  104271. /** @hidden */
  104272. export var shadowsVertex: {
  104273. name: string;
  104274. shader: string;
  104275. };
  104276. }
  104277. declare module BABYLON {
  104278. /** @hidden */
  104279. export var pointCloudVertex: {
  104280. name: string;
  104281. shader: string;
  104282. };
  104283. }
  104284. declare module BABYLON {
  104285. /** @hidden */
  104286. export var logDepthVertex: {
  104287. name: string;
  104288. shader: string;
  104289. };
  104290. }
  104291. declare module BABYLON {
  104292. /** @hidden */
  104293. export var defaultVertexShader: {
  104294. name: string;
  104295. shader: string;
  104296. };
  104297. }
  104298. declare module BABYLON {
  104299. /**
  104300. * @hidden
  104301. */
  104302. export interface IMaterialDetailMapDefines {
  104303. DETAIL: boolean;
  104304. DETAILDIRECTUV: number;
  104305. DETAIL_NORMALBLENDMETHOD: number;
  104306. /** @hidden */
  104307. _areTexturesDirty: boolean;
  104308. }
  104309. /**
  104310. * Define the code related to the detail map parameters of a material
  104311. *
  104312. * Inspired from:
  104313. * 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
  104314. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104315. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104316. */
  104317. export class DetailMapConfiguration {
  104318. private _texture;
  104319. /**
  104320. * The detail texture of the material.
  104321. */
  104322. texture: Nullable<BaseTexture>;
  104323. /**
  104324. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104325. * Bigger values mean stronger blending
  104326. */
  104327. diffuseBlendLevel: number;
  104328. /**
  104329. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104330. * Bigger values mean stronger blending. Only used with PBR materials
  104331. */
  104332. roughnessBlendLevel: number;
  104333. /**
  104334. * Defines how strong the bump effect from the detail map is
  104335. * Bigger values mean stronger effect
  104336. */
  104337. bumpLevel: number;
  104338. private _normalBlendMethod;
  104339. /**
  104340. * The method used to blend the bump and detail normals together
  104341. */
  104342. normalBlendMethod: number;
  104343. private _isEnabled;
  104344. /**
  104345. * Enable or disable the detail map on this material
  104346. */
  104347. isEnabled: boolean;
  104348. /** @hidden */
  104349. private _internalMarkAllSubMeshesAsTexturesDirty;
  104350. /** @hidden */
  104351. _markAllSubMeshesAsTexturesDirty(): void;
  104352. /**
  104353. * Instantiate a new detail map
  104354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104355. */
  104356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104357. /**
  104358. * Gets whether the submesh is ready to be used or not.
  104359. * @param defines the list of "defines" to update.
  104360. * @param scene defines the scene the material belongs to.
  104361. * @returns - boolean indicating that the submesh is ready or not.
  104362. */
  104363. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104364. /**
  104365. * Update the defines for detail map usage
  104366. * @param defines the list of "defines" to update.
  104367. * @param scene defines the scene the material belongs to.
  104368. */
  104369. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104370. /**
  104371. * Binds the material data.
  104372. * @param uniformBuffer defines the Uniform buffer to fill in.
  104373. * @param scene defines the scene the material belongs to.
  104374. * @param isFrozen defines whether the material is frozen or not.
  104375. */
  104376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104377. /**
  104378. * Checks to see if a texture is used in the material.
  104379. * @param texture - Base texture to use.
  104380. * @returns - Boolean specifying if a texture is used in the material.
  104381. */
  104382. hasTexture(texture: BaseTexture): boolean;
  104383. /**
  104384. * Returns an array of the actively used textures.
  104385. * @param activeTextures Array of BaseTextures
  104386. */
  104387. getActiveTextures(activeTextures: BaseTexture[]): void;
  104388. /**
  104389. * Returns the animatable textures.
  104390. * @param animatables Array of animatable textures.
  104391. */
  104392. getAnimatables(animatables: IAnimatable[]): void;
  104393. /**
  104394. * Disposes the resources of the material.
  104395. * @param forceDisposeTextures - Forces the disposal of all textures.
  104396. */
  104397. dispose(forceDisposeTextures?: boolean): void;
  104398. /**
  104399. * Get the current class name useful for serialization or dynamic coding.
  104400. * @returns "DetailMap"
  104401. */
  104402. getClassName(): string;
  104403. /**
  104404. * Add the required uniforms to the current list.
  104405. * @param uniforms defines the current uniform list.
  104406. */
  104407. static AddUniforms(uniforms: string[]): void;
  104408. /**
  104409. * Add the required samplers to the current list.
  104410. * @param samplers defines the current sampler list.
  104411. */
  104412. static AddSamplers(samplers: string[]): void;
  104413. /**
  104414. * Add the required uniforms to the current buffer.
  104415. * @param uniformBuffer defines the current uniform buffer.
  104416. */
  104417. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104418. /**
  104419. * Makes a duplicate of the current instance into another one.
  104420. * @param detailMap define the instance where to copy the info
  104421. */
  104422. copyTo(detailMap: DetailMapConfiguration): void;
  104423. /**
  104424. * Serializes this detail map instance
  104425. * @returns - An object with the serialized instance.
  104426. */
  104427. serialize(): any;
  104428. /**
  104429. * Parses a detail map setting from a serialized object.
  104430. * @param source - Serialized object.
  104431. * @param scene Defines the scene we are parsing for
  104432. * @param rootUrl Defines the rootUrl to load from
  104433. */
  104434. parse(source: any, scene: Scene, rootUrl: string): void;
  104435. }
  104436. }
  104437. declare module BABYLON {
  104438. /** @hidden */
  104439. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104440. MAINUV1: boolean;
  104441. MAINUV2: boolean;
  104442. DIFFUSE: boolean;
  104443. DIFFUSEDIRECTUV: number;
  104444. DETAIL: boolean;
  104445. DETAILDIRECTUV: number;
  104446. DETAIL_NORMALBLENDMETHOD: number;
  104447. AMBIENT: boolean;
  104448. AMBIENTDIRECTUV: number;
  104449. OPACITY: boolean;
  104450. OPACITYDIRECTUV: number;
  104451. OPACITYRGB: boolean;
  104452. REFLECTION: boolean;
  104453. EMISSIVE: boolean;
  104454. EMISSIVEDIRECTUV: number;
  104455. SPECULAR: boolean;
  104456. SPECULARDIRECTUV: number;
  104457. BUMP: boolean;
  104458. BUMPDIRECTUV: number;
  104459. PARALLAX: boolean;
  104460. PARALLAXOCCLUSION: boolean;
  104461. SPECULAROVERALPHA: boolean;
  104462. CLIPPLANE: boolean;
  104463. CLIPPLANE2: boolean;
  104464. CLIPPLANE3: boolean;
  104465. CLIPPLANE4: boolean;
  104466. CLIPPLANE5: boolean;
  104467. CLIPPLANE6: boolean;
  104468. ALPHATEST: boolean;
  104469. DEPTHPREPASS: boolean;
  104470. ALPHAFROMDIFFUSE: boolean;
  104471. POINTSIZE: boolean;
  104472. FOG: boolean;
  104473. SPECULARTERM: boolean;
  104474. DIFFUSEFRESNEL: boolean;
  104475. OPACITYFRESNEL: boolean;
  104476. REFLECTIONFRESNEL: boolean;
  104477. REFRACTIONFRESNEL: boolean;
  104478. EMISSIVEFRESNEL: boolean;
  104479. FRESNEL: boolean;
  104480. NORMAL: boolean;
  104481. UV1: boolean;
  104482. UV2: boolean;
  104483. VERTEXCOLOR: boolean;
  104484. VERTEXALPHA: boolean;
  104485. NUM_BONE_INFLUENCERS: number;
  104486. BonesPerMesh: number;
  104487. BONETEXTURE: boolean;
  104488. BONES_VELOCITY_ENABLED: boolean;
  104489. INSTANCES: boolean;
  104490. THIN_INSTANCES: boolean;
  104491. GLOSSINESS: boolean;
  104492. ROUGHNESS: boolean;
  104493. EMISSIVEASILLUMINATION: boolean;
  104494. LINKEMISSIVEWITHDIFFUSE: boolean;
  104495. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104496. LIGHTMAP: boolean;
  104497. LIGHTMAPDIRECTUV: number;
  104498. OBJECTSPACE_NORMALMAP: boolean;
  104499. USELIGHTMAPASSHADOWMAP: boolean;
  104500. REFLECTIONMAP_3D: boolean;
  104501. REFLECTIONMAP_SPHERICAL: boolean;
  104502. REFLECTIONMAP_PLANAR: boolean;
  104503. REFLECTIONMAP_CUBIC: boolean;
  104504. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104505. REFLECTIONMAP_PROJECTION: boolean;
  104506. REFLECTIONMAP_SKYBOX: boolean;
  104507. REFLECTIONMAP_EXPLICIT: boolean;
  104508. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104509. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104510. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104511. INVERTCUBICMAP: boolean;
  104512. LOGARITHMICDEPTH: boolean;
  104513. REFRACTION: boolean;
  104514. REFRACTIONMAP_3D: boolean;
  104515. REFLECTIONOVERALPHA: boolean;
  104516. TWOSIDEDLIGHTING: boolean;
  104517. SHADOWFLOAT: boolean;
  104518. MORPHTARGETS: boolean;
  104519. MORPHTARGETS_NORMAL: boolean;
  104520. MORPHTARGETS_TANGENT: boolean;
  104521. MORPHTARGETS_UV: boolean;
  104522. NUM_MORPH_INFLUENCERS: number;
  104523. NONUNIFORMSCALING: boolean;
  104524. PREMULTIPLYALPHA: boolean;
  104525. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104526. ALPHABLEND: boolean;
  104527. PREPASS: boolean;
  104528. PREPASS_IRRADIANCE: boolean;
  104529. PREPASS_IRRADIANCE_INDEX: number;
  104530. PREPASS_ALBEDO: boolean;
  104531. PREPASS_ALBEDO_INDEX: number;
  104532. PREPASS_DEPTHNORMAL: boolean;
  104533. PREPASS_DEPTHNORMAL_INDEX: number;
  104534. PREPASS_POSITION: boolean;
  104535. PREPASS_POSITION_INDEX: number;
  104536. PREPASS_VELOCITY: boolean;
  104537. PREPASS_VELOCITY_INDEX: number;
  104538. PREPASS_REFLECTIVITY: boolean;
  104539. PREPASS_REFLECTIVITY_INDEX: number;
  104540. SCENE_MRT_COUNT: number;
  104541. RGBDLIGHTMAP: boolean;
  104542. RGBDREFLECTION: boolean;
  104543. RGBDREFRACTION: boolean;
  104544. IMAGEPROCESSING: boolean;
  104545. VIGNETTE: boolean;
  104546. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104547. VIGNETTEBLENDMODEOPAQUE: boolean;
  104548. TONEMAPPING: boolean;
  104549. TONEMAPPING_ACES: boolean;
  104550. CONTRAST: boolean;
  104551. COLORCURVES: boolean;
  104552. COLORGRADING: boolean;
  104553. COLORGRADING3D: boolean;
  104554. SAMPLER3DGREENDEPTH: boolean;
  104555. SAMPLER3DBGRMAP: boolean;
  104556. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104557. MULTIVIEW: boolean;
  104558. /**
  104559. * If the reflection texture on this material is in linear color space
  104560. * @hidden
  104561. */
  104562. IS_REFLECTION_LINEAR: boolean;
  104563. /**
  104564. * If the refraction texture on this material is in linear color space
  104565. * @hidden
  104566. */
  104567. IS_REFRACTION_LINEAR: boolean;
  104568. EXPOSURE: boolean;
  104569. constructor();
  104570. setReflectionMode(modeToEnable: string): void;
  104571. }
  104572. /**
  104573. * This is the default material used in Babylon. It is the best trade off between quality
  104574. * and performances.
  104575. * @see https://doc.babylonjs.com/babylon101/materials
  104576. */
  104577. export class StandardMaterial extends PushMaterial {
  104578. private _diffuseTexture;
  104579. /**
  104580. * The basic texture of the material as viewed under a light.
  104581. */
  104582. diffuseTexture: Nullable<BaseTexture>;
  104583. private _ambientTexture;
  104584. /**
  104585. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104586. */
  104587. ambientTexture: Nullable<BaseTexture>;
  104588. private _opacityTexture;
  104589. /**
  104590. * Define the transparency of the material from a texture.
  104591. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104592. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104593. */
  104594. opacityTexture: Nullable<BaseTexture>;
  104595. private _reflectionTexture;
  104596. /**
  104597. * Define the texture used to display the reflection.
  104598. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104599. */
  104600. reflectionTexture: Nullable<BaseTexture>;
  104601. private _emissiveTexture;
  104602. /**
  104603. * Define texture of the material as if self lit.
  104604. * This will be mixed in the final result even in the absence of light.
  104605. */
  104606. emissiveTexture: Nullable<BaseTexture>;
  104607. private _specularTexture;
  104608. /**
  104609. * Define how the color and intensity of the highlight given by the light in the material.
  104610. */
  104611. specularTexture: Nullable<BaseTexture>;
  104612. private _bumpTexture;
  104613. /**
  104614. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104615. * 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.
  104616. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104617. */
  104618. bumpTexture: Nullable<BaseTexture>;
  104619. private _lightmapTexture;
  104620. /**
  104621. * Complex lighting can be computationally expensive to compute at runtime.
  104622. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104623. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104624. */
  104625. lightmapTexture: Nullable<BaseTexture>;
  104626. private _refractionTexture;
  104627. /**
  104628. * Define the texture used to display the refraction.
  104629. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104630. */
  104631. refractionTexture: Nullable<BaseTexture>;
  104632. /**
  104633. * The color of the material lit by the environmental background lighting.
  104634. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104635. */
  104636. ambientColor: Color3;
  104637. /**
  104638. * The basic color of the material as viewed under a light.
  104639. */
  104640. diffuseColor: Color3;
  104641. /**
  104642. * Define how the color and intensity of the highlight given by the light in the material.
  104643. */
  104644. specularColor: Color3;
  104645. /**
  104646. * Define the color of the material as if self lit.
  104647. * This will be mixed in the final result even in the absence of light.
  104648. */
  104649. emissiveColor: Color3;
  104650. /**
  104651. * Defines how sharp are the highlights in the material.
  104652. * The bigger the value the sharper giving a more glossy feeling to the result.
  104653. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104654. */
  104655. specularPower: number;
  104656. private _useAlphaFromDiffuseTexture;
  104657. /**
  104658. * Does the transparency come from the diffuse texture alpha channel.
  104659. */
  104660. useAlphaFromDiffuseTexture: boolean;
  104661. private _useEmissiveAsIllumination;
  104662. /**
  104663. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104664. */
  104665. useEmissiveAsIllumination: boolean;
  104666. private _linkEmissiveWithDiffuse;
  104667. /**
  104668. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104669. * the emissive level when the final color is close to one.
  104670. */
  104671. linkEmissiveWithDiffuse: boolean;
  104672. private _useSpecularOverAlpha;
  104673. /**
  104674. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104676. */
  104677. useSpecularOverAlpha: boolean;
  104678. private _useReflectionOverAlpha;
  104679. /**
  104680. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104681. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104682. */
  104683. useReflectionOverAlpha: boolean;
  104684. private _disableLighting;
  104685. /**
  104686. * Does lights from the scene impacts this material.
  104687. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104688. */
  104689. disableLighting: boolean;
  104690. private _useObjectSpaceNormalMap;
  104691. /**
  104692. * Allows using an object space normal map (instead of tangent space).
  104693. */
  104694. useObjectSpaceNormalMap: boolean;
  104695. private _useParallax;
  104696. /**
  104697. * Is parallax enabled or not.
  104698. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104699. */
  104700. useParallax: boolean;
  104701. private _useParallaxOcclusion;
  104702. /**
  104703. * Is parallax occlusion enabled or not.
  104704. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104705. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104706. */
  104707. useParallaxOcclusion: boolean;
  104708. /**
  104709. * 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.
  104710. */
  104711. parallaxScaleBias: number;
  104712. private _roughness;
  104713. /**
  104714. * Helps to define how blurry the reflections should appears in the material.
  104715. */
  104716. roughness: number;
  104717. /**
  104718. * In case of refraction, define the value of the index of refraction.
  104719. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104720. */
  104721. indexOfRefraction: number;
  104722. /**
  104723. * Invert the refraction texture alongside the y axis.
  104724. * It can be useful with procedural textures or probe for instance.
  104725. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104726. */
  104727. invertRefractionY: boolean;
  104728. /**
  104729. * Defines the alpha limits in alpha test mode.
  104730. */
  104731. alphaCutOff: number;
  104732. private _useLightmapAsShadowmap;
  104733. /**
  104734. * In case of light mapping, define whether the map contains light or shadow informations.
  104735. */
  104736. useLightmapAsShadowmap: boolean;
  104737. private _diffuseFresnelParameters;
  104738. /**
  104739. * Define the diffuse fresnel parameters of the material.
  104740. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104741. */
  104742. diffuseFresnelParameters: FresnelParameters;
  104743. private _opacityFresnelParameters;
  104744. /**
  104745. * Define the opacity fresnel parameters of the material.
  104746. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104747. */
  104748. opacityFresnelParameters: FresnelParameters;
  104749. private _reflectionFresnelParameters;
  104750. /**
  104751. * Define the reflection fresnel parameters of the material.
  104752. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104753. */
  104754. reflectionFresnelParameters: FresnelParameters;
  104755. private _refractionFresnelParameters;
  104756. /**
  104757. * Define the refraction fresnel parameters of the material.
  104758. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104759. */
  104760. refractionFresnelParameters: FresnelParameters;
  104761. private _emissiveFresnelParameters;
  104762. /**
  104763. * Define the emissive fresnel parameters of the material.
  104764. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104765. */
  104766. emissiveFresnelParameters: FresnelParameters;
  104767. private _useReflectionFresnelFromSpecular;
  104768. /**
  104769. * If true automatically deducts the fresnels values from the material specularity.
  104770. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104771. */
  104772. useReflectionFresnelFromSpecular: boolean;
  104773. private _useGlossinessFromSpecularMapAlpha;
  104774. /**
  104775. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104776. */
  104777. useGlossinessFromSpecularMapAlpha: boolean;
  104778. private _maxSimultaneousLights;
  104779. /**
  104780. * Defines the maximum number of lights that can be used in the material
  104781. */
  104782. maxSimultaneousLights: number;
  104783. private _invertNormalMapX;
  104784. /**
  104785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104786. */
  104787. invertNormalMapX: boolean;
  104788. private _invertNormalMapY;
  104789. /**
  104790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104791. */
  104792. invertNormalMapY: boolean;
  104793. private _twoSidedLighting;
  104794. /**
  104795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104796. */
  104797. twoSidedLighting: boolean;
  104798. /**
  104799. * Default configuration related to image processing available in the standard Material.
  104800. */
  104801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104802. /**
  104803. * Gets the image processing configuration used either in this material.
  104804. */
  104805. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104806. /**
  104807. * Sets the Default image processing configuration used either in the this material.
  104808. *
  104809. * If sets to null, the scene one is in use.
  104810. */
  104811. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104812. /**
  104813. * Keep track of the image processing observer to allow dispose and replace.
  104814. */
  104815. private _imageProcessingObserver;
  104816. /**
  104817. * Attaches a new image processing configuration to the Standard Material.
  104818. * @param configuration
  104819. */
  104820. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104821. /**
  104822. * Defines additionnal PrePass parameters for the material.
  104823. */
  104824. readonly prePassConfiguration: PrePassConfiguration;
  104825. /**
  104826. * Gets wether the color curves effect is enabled.
  104827. */
  104828. get cameraColorCurvesEnabled(): boolean;
  104829. /**
  104830. * Sets wether the color curves effect is enabled.
  104831. */
  104832. set cameraColorCurvesEnabled(value: boolean);
  104833. /**
  104834. * Gets wether the color grading effect is enabled.
  104835. */
  104836. get cameraColorGradingEnabled(): boolean;
  104837. /**
  104838. * Gets wether the color grading effect is enabled.
  104839. */
  104840. set cameraColorGradingEnabled(value: boolean);
  104841. /**
  104842. * Gets wether tonemapping is enabled or not.
  104843. */
  104844. get cameraToneMappingEnabled(): boolean;
  104845. /**
  104846. * Sets wether tonemapping is enabled or not
  104847. */
  104848. set cameraToneMappingEnabled(value: boolean);
  104849. /**
  104850. * The camera exposure used on this material.
  104851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104852. * This corresponds to a photographic exposure.
  104853. */
  104854. get cameraExposure(): number;
  104855. /**
  104856. * The camera exposure used on this material.
  104857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104858. * This corresponds to a photographic exposure.
  104859. */
  104860. set cameraExposure(value: number);
  104861. /**
  104862. * Gets The camera contrast used on this material.
  104863. */
  104864. get cameraContrast(): number;
  104865. /**
  104866. * Sets The camera contrast used on this material.
  104867. */
  104868. set cameraContrast(value: number);
  104869. /**
  104870. * Gets the Color Grading 2D Lookup Texture.
  104871. */
  104872. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104873. /**
  104874. * Sets the Color Grading 2D Lookup Texture.
  104875. */
  104876. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104877. /**
  104878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104880. * 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;
  104881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104882. */
  104883. get cameraColorCurves(): Nullable<ColorCurves>;
  104884. /**
  104885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104887. * 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;
  104888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104889. */
  104890. set cameraColorCurves(value: Nullable<ColorCurves>);
  104891. /**
  104892. * Can this material render to several textures at once
  104893. */
  104894. get canRenderToMRT(): boolean;
  104895. /**
  104896. * Defines the detail map parameters for the material.
  104897. */
  104898. readonly detailMap: DetailMapConfiguration;
  104899. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104900. protected _worldViewProjectionMatrix: Matrix;
  104901. protected _globalAmbientColor: Color3;
  104902. protected _useLogarithmicDepth: boolean;
  104903. protected _rebuildInParallel: boolean;
  104904. /**
  104905. * Instantiates a new standard material.
  104906. * This is the default material used in Babylon. It is the best trade off between quality
  104907. * and performances.
  104908. * @see https://doc.babylonjs.com/babylon101/materials
  104909. * @param name Define the name of the material in the scene
  104910. * @param scene Define the scene the material belong to
  104911. */
  104912. constructor(name: string, scene: Scene);
  104913. /**
  104914. * Gets a boolean indicating that current material needs to register RTT
  104915. */
  104916. get hasRenderTargetTextures(): boolean;
  104917. /**
  104918. * Gets the current class name of the material e.g. "StandardMaterial"
  104919. * Mainly use in serialization.
  104920. * @returns the class name
  104921. */
  104922. getClassName(): string;
  104923. /**
  104924. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104925. * You can try switching to logarithmic depth.
  104926. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104927. */
  104928. get useLogarithmicDepth(): boolean;
  104929. set useLogarithmicDepth(value: boolean);
  104930. /**
  104931. * Specifies if the material will require alpha blending
  104932. * @returns a boolean specifying if alpha blending is needed
  104933. */
  104934. needAlphaBlending(): boolean;
  104935. /**
  104936. * Specifies if this material should be rendered in alpha test mode
  104937. * @returns a boolean specifying if an alpha test is needed.
  104938. */
  104939. needAlphaTesting(): boolean;
  104940. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104941. /**
  104942. * Get the texture used for alpha test purpose.
  104943. * @returns the diffuse texture in case of the standard material.
  104944. */
  104945. getAlphaTestTexture(): Nullable<BaseTexture>;
  104946. /**
  104947. * Get if the submesh is ready to be used and all its information available.
  104948. * Child classes can use it to update shaders
  104949. * @param mesh defines the mesh to check
  104950. * @param subMesh defines which submesh to check
  104951. * @param useInstances specifies that instances should be used
  104952. * @returns a boolean indicating that the submesh is ready or not
  104953. */
  104954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104955. /**
  104956. * Builds the material UBO layouts.
  104957. * Used internally during the effect preparation.
  104958. */
  104959. buildUniformLayout(): void;
  104960. /**
  104961. * Unbinds the material from the mesh
  104962. */
  104963. unbind(): void;
  104964. /**
  104965. * Binds the submesh to this material by preparing the effect and shader to draw
  104966. * @param world defines the world transformation matrix
  104967. * @param mesh defines the mesh containing the submesh
  104968. * @param subMesh defines the submesh to bind the material to
  104969. */
  104970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104971. /**
  104972. * Get the list of animatables in the material.
  104973. * @returns the list of animatables object used in the material
  104974. */
  104975. getAnimatables(): IAnimatable[];
  104976. /**
  104977. * Gets the active textures from the material
  104978. * @returns an array of textures
  104979. */
  104980. getActiveTextures(): BaseTexture[];
  104981. /**
  104982. * Specifies if the material uses a texture
  104983. * @param texture defines the texture to check against the material
  104984. * @returns a boolean specifying if the material uses the texture
  104985. */
  104986. hasTexture(texture: BaseTexture): boolean;
  104987. /**
  104988. * Disposes the material
  104989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104991. */
  104992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104993. /**
  104994. * Makes a duplicate of the material, and gives it a new name
  104995. * @param name defines the new name for the duplicated material
  104996. * @returns the cloned material
  104997. */
  104998. clone(name: string): StandardMaterial;
  104999. /**
  105000. * Serializes this material in a JSON representation
  105001. * @returns the serialized material object
  105002. */
  105003. serialize(): any;
  105004. /**
  105005. * Creates a standard material from parsed material data
  105006. * @param source defines the JSON representation of the material
  105007. * @param scene defines the hosting scene
  105008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105009. * @returns a new standard material
  105010. */
  105011. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105012. /**
  105013. * Are diffuse textures enabled in the application.
  105014. */
  105015. static get DiffuseTextureEnabled(): boolean;
  105016. static set DiffuseTextureEnabled(value: boolean);
  105017. /**
  105018. * Are detail textures enabled in the application.
  105019. */
  105020. static get DetailTextureEnabled(): boolean;
  105021. static set DetailTextureEnabled(value: boolean);
  105022. /**
  105023. * Are ambient textures enabled in the application.
  105024. */
  105025. static get AmbientTextureEnabled(): boolean;
  105026. static set AmbientTextureEnabled(value: boolean);
  105027. /**
  105028. * Are opacity textures enabled in the application.
  105029. */
  105030. static get OpacityTextureEnabled(): boolean;
  105031. static set OpacityTextureEnabled(value: boolean);
  105032. /**
  105033. * Are reflection textures enabled in the application.
  105034. */
  105035. static get ReflectionTextureEnabled(): boolean;
  105036. static set ReflectionTextureEnabled(value: boolean);
  105037. /**
  105038. * Are emissive textures enabled in the application.
  105039. */
  105040. static get EmissiveTextureEnabled(): boolean;
  105041. static set EmissiveTextureEnabled(value: boolean);
  105042. /**
  105043. * Are specular textures enabled in the application.
  105044. */
  105045. static get SpecularTextureEnabled(): boolean;
  105046. static set SpecularTextureEnabled(value: boolean);
  105047. /**
  105048. * Are bump textures enabled in the application.
  105049. */
  105050. static get BumpTextureEnabled(): boolean;
  105051. static set BumpTextureEnabled(value: boolean);
  105052. /**
  105053. * Are lightmap textures enabled in the application.
  105054. */
  105055. static get LightmapTextureEnabled(): boolean;
  105056. static set LightmapTextureEnabled(value: boolean);
  105057. /**
  105058. * Are refraction textures enabled in the application.
  105059. */
  105060. static get RefractionTextureEnabled(): boolean;
  105061. static set RefractionTextureEnabled(value: boolean);
  105062. /**
  105063. * Are color grading textures enabled in the application.
  105064. */
  105065. static get ColorGradingTextureEnabled(): boolean;
  105066. static set ColorGradingTextureEnabled(value: boolean);
  105067. /**
  105068. * Are fresnels enabled in the application.
  105069. */
  105070. static get FresnelEnabled(): boolean;
  105071. static set FresnelEnabled(value: boolean);
  105072. }
  105073. }
  105074. declare module BABYLON {
  105075. /** @hidden */
  105076. export var rgbdDecodePixelShader: {
  105077. name: string;
  105078. shader: string;
  105079. };
  105080. }
  105081. declare module BABYLON {
  105082. /**
  105083. * Class used to host RGBD texture specific utilities
  105084. */
  105085. export class RGBDTextureTools {
  105086. /**
  105087. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105088. * @param texture the texture to expand.
  105089. */
  105090. static ExpandRGBDTexture(texture: Texture): void;
  105091. }
  105092. }
  105093. declare module BABYLON {
  105094. /**
  105095. * Class used to host texture specific utilities
  105096. */
  105097. export class BRDFTextureTools {
  105098. /**
  105099. * Prevents texture cache collision
  105100. */
  105101. private static _instanceNumber;
  105102. /**
  105103. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105104. * @param scene defines the hosting scene
  105105. * @returns the environment BRDF texture
  105106. */
  105107. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105108. private static _environmentBRDFBase64Texture;
  105109. }
  105110. }
  105111. declare module BABYLON {
  105112. /**
  105113. * @hidden
  105114. */
  105115. export interface IMaterialClearCoatDefines {
  105116. CLEARCOAT: boolean;
  105117. CLEARCOAT_DEFAULTIOR: boolean;
  105118. CLEARCOAT_TEXTURE: boolean;
  105119. CLEARCOAT_TEXTUREDIRECTUV: number;
  105120. CLEARCOAT_BUMP: boolean;
  105121. CLEARCOAT_BUMPDIRECTUV: number;
  105122. CLEARCOAT_REMAP_F0: boolean;
  105123. CLEARCOAT_TINT: boolean;
  105124. CLEARCOAT_TINT_TEXTURE: boolean;
  105125. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105126. /** @hidden */
  105127. _areTexturesDirty: boolean;
  105128. }
  105129. /**
  105130. * Define the code related to the clear coat parameters of the pbr material.
  105131. */
  105132. export class PBRClearCoatConfiguration {
  105133. /**
  105134. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105135. * The default fits with a polyurethane material.
  105136. */
  105137. private static readonly _DefaultIndexOfRefraction;
  105138. private _isEnabled;
  105139. /**
  105140. * Defines if the clear coat is enabled in the material.
  105141. */
  105142. isEnabled: boolean;
  105143. /**
  105144. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105145. */
  105146. intensity: number;
  105147. /**
  105148. * Defines the clear coat layer roughness.
  105149. */
  105150. roughness: number;
  105151. private _indexOfRefraction;
  105152. /**
  105153. * Defines the index of refraction of the clear coat.
  105154. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105155. * The default fits with a polyurethane material.
  105156. * Changing the default value is more performance intensive.
  105157. */
  105158. indexOfRefraction: number;
  105159. private _texture;
  105160. /**
  105161. * Stores the clear coat values in a texture.
  105162. */
  105163. texture: Nullable<BaseTexture>;
  105164. private _remapF0OnInterfaceChange;
  105165. /**
  105166. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105167. */
  105168. remapF0OnInterfaceChange: boolean;
  105169. private _bumpTexture;
  105170. /**
  105171. * Define the clear coat specific bump texture.
  105172. */
  105173. bumpTexture: Nullable<BaseTexture>;
  105174. private _isTintEnabled;
  105175. /**
  105176. * Defines if the clear coat tint is enabled in the material.
  105177. */
  105178. isTintEnabled: boolean;
  105179. /**
  105180. * Defines the clear coat tint of the material.
  105181. * This is only use if tint is enabled
  105182. */
  105183. tintColor: Color3;
  105184. /**
  105185. * Defines the distance at which the tint color should be found in the
  105186. * clear coat media.
  105187. * This is only use if tint is enabled
  105188. */
  105189. tintColorAtDistance: number;
  105190. /**
  105191. * Defines the clear coat layer thickness.
  105192. * This is only use if tint is enabled
  105193. */
  105194. tintThickness: number;
  105195. private _tintTexture;
  105196. /**
  105197. * Stores the clear tint values in a texture.
  105198. * rgb is tint
  105199. * a is a thickness factor
  105200. */
  105201. tintTexture: Nullable<BaseTexture>;
  105202. /** @hidden */
  105203. private _internalMarkAllSubMeshesAsTexturesDirty;
  105204. /** @hidden */
  105205. _markAllSubMeshesAsTexturesDirty(): void;
  105206. /**
  105207. * Instantiate a new istance of clear coat configuration.
  105208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105209. */
  105210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105211. /**
  105212. * Gets wehter the submesh is ready to be used or not.
  105213. * @param defines the list of "defines" to update.
  105214. * @param scene defines the scene the material belongs to.
  105215. * @param engine defines the engine the material belongs to.
  105216. * @param disableBumpMap defines wether the material disables bump or not.
  105217. * @returns - boolean indicating that the submesh is ready or not.
  105218. */
  105219. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105220. /**
  105221. * Checks to see if a texture is used in the material.
  105222. * @param defines the list of "defines" to update.
  105223. * @param scene defines the scene to the material belongs to.
  105224. */
  105225. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105226. /**
  105227. * Binds the material data.
  105228. * @param uniformBuffer defines the Uniform buffer to fill in.
  105229. * @param scene defines the scene the material belongs to.
  105230. * @param engine defines the engine the material belongs to.
  105231. * @param disableBumpMap defines wether the material disables bump or not.
  105232. * @param isFrozen defines wether the material is frozen or not.
  105233. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105234. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105235. */
  105236. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  105237. /**
  105238. * Checks to see if a texture is used in the material.
  105239. * @param texture - Base texture to use.
  105240. * @returns - Boolean specifying if a texture is used in the material.
  105241. */
  105242. hasTexture(texture: BaseTexture): boolean;
  105243. /**
  105244. * Returns an array of the actively used textures.
  105245. * @param activeTextures Array of BaseTextures
  105246. */
  105247. getActiveTextures(activeTextures: BaseTexture[]): void;
  105248. /**
  105249. * Returns the animatable textures.
  105250. * @param animatables Array of animatable textures.
  105251. */
  105252. getAnimatables(animatables: IAnimatable[]): void;
  105253. /**
  105254. * Disposes the resources of the material.
  105255. * @param forceDisposeTextures - Forces the disposal of all textures.
  105256. */
  105257. dispose(forceDisposeTextures?: boolean): void;
  105258. /**
  105259. * Get the current class name of the texture useful for serialization or dynamic coding.
  105260. * @returns "PBRClearCoatConfiguration"
  105261. */
  105262. getClassName(): string;
  105263. /**
  105264. * Add fallbacks to the effect fallbacks list.
  105265. * @param defines defines the Base texture to use.
  105266. * @param fallbacks defines the current fallback list.
  105267. * @param currentRank defines the current fallback rank.
  105268. * @returns the new fallback rank.
  105269. */
  105270. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105271. /**
  105272. * Add the required uniforms to the current list.
  105273. * @param uniforms defines the current uniform list.
  105274. */
  105275. static AddUniforms(uniforms: string[]): void;
  105276. /**
  105277. * Add the required samplers to the current list.
  105278. * @param samplers defines the current sampler list.
  105279. */
  105280. static AddSamplers(samplers: string[]): void;
  105281. /**
  105282. * Add the required uniforms to the current buffer.
  105283. * @param uniformBuffer defines the current uniform buffer.
  105284. */
  105285. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105286. /**
  105287. * Makes a duplicate of the current configuration into another one.
  105288. * @param clearCoatConfiguration define the config where to copy the info
  105289. */
  105290. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105291. /**
  105292. * Serializes this clear coat configuration.
  105293. * @returns - An object with the serialized config.
  105294. */
  105295. serialize(): any;
  105296. /**
  105297. * Parses a anisotropy Configuration from a serialized object.
  105298. * @param source - Serialized object.
  105299. * @param scene Defines the scene we are parsing for
  105300. * @param rootUrl Defines the rootUrl to load from
  105301. */
  105302. parse(source: any, scene: Scene, rootUrl: string): void;
  105303. }
  105304. }
  105305. declare module BABYLON {
  105306. /**
  105307. * @hidden
  105308. */
  105309. export interface IMaterialAnisotropicDefines {
  105310. ANISOTROPIC: boolean;
  105311. ANISOTROPIC_TEXTURE: boolean;
  105312. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105313. MAINUV1: boolean;
  105314. _areTexturesDirty: boolean;
  105315. _needUVs: boolean;
  105316. }
  105317. /**
  105318. * Define the code related to the anisotropic parameters of the pbr material.
  105319. */
  105320. export class PBRAnisotropicConfiguration {
  105321. private _isEnabled;
  105322. /**
  105323. * Defines if the anisotropy is enabled in the material.
  105324. */
  105325. isEnabled: boolean;
  105326. /**
  105327. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105328. */
  105329. intensity: number;
  105330. /**
  105331. * Defines if the effect is along the tangents, bitangents or in between.
  105332. * By default, the effect is "strectching" the highlights along the tangents.
  105333. */
  105334. direction: Vector2;
  105335. private _texture;
  105336. /**
  105337. * Stores the anisotropy values in a texture.
  105338. * rg is direction (like normal from -1 to 1)
  105339. * b is a intensity
  105340. */
  105341. texture: Nullable<BaseTexture>;
  105342. /** @hidden */
  105343. private _internalMarkAllSubMeshesAsTexturesDirty;
  105344. /** @hidden */
  105345. _markAllSubMeshesAsTexturesDirty(): void;
  105346. /**
  105347. * Instantiate a new istance of anisotropy configuration.
  105348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105349. */
  105350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105351. /**
  105352. * Specifies that the submesh is ready to be used.
  105353. * @param defines the list of "defines" to update.
  105354. * @param scene defines the scene the material belongs to.
  105355. * @returns - boolean indicating that the submesh is ready or not.
  105356. */
  105357. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105358. /**
  105359. * Checks to see if a texture is used in the material.
  105360. * @param defines the list of "defines" to update.
  105361. * @param mesh the mesh we are preparing the defines for.
  105362. * @param scene defines the scene the material belongs to.
  105363. */
  105364. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105365. /**
  105366. * Binds the material data.
  105367. * @param uniformBuffer defines the Uniform buffer to fill in.
  105368. * @param scene defines the scene the material belongs to.
  105369. * @param isFrozen defines wether the material is frozen or not.
  105370. */
  105371. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105372. /**
  105373. * Checks to see if a texture is used in the material.
  105374. * @param texture - Base texture to use.
  105375. * @returns - Boolean specifying if a texture is used in the material.
  105376. */
  105377. hasTexture(texture: BaseTexture): boolean;
  105378. /**
  105379. * Returns an array of the actively used textures.
  105380. * @param activeTextures Array of BaseTextures
  105381. */
  105382. getActiveTextures(activeTextures: BaseTexture[]): void;
  105383. /**
  105384. * Returns the animatable textures.
  105385. * @param animatables Array of animatable textures.
  105386. */
  105387. getAnimatables(animatables: IAnimatable[]): void;
  105388. /**
  105389. * Disposes the resources of the material.
  105390. * @param forceDisposeTextures - Forces the disposal of all textures.
  105391. */
  105392. dispose(forceDisposeTextures?: boolean): void;
  105393. /**
  105394. * Get the current class name of the texture useful for serialization or dynamic coding.
  105395. * @returns "PBRAnisotropicConfiguration"
  105396. */
  105397. getClassName(): string;
  105398. /**
  105399. * Add fallbacks to the effect fallbacks list.
  105400. * @param defines defines the Base texture to use.
  105401. * @param fallbacks defines the current fallback list.
  105402. * @param currentRank defines the current fallback rank.
  105403. * @returns the new fallback rank.
  105404. */
  105405. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105406. /**
  105407. * Add the required uniforms to the current list.
  105408. * @param uniforms defines the current uniform list.
  105409. */
  105410. static AddUniforms(uniforms: string[]): void;
  105411. /**
  105412. * Add the required uniforms to the current buffer.
  105413. * @param uniformBuffer defines the current uniform buffer.
  105414. */
  105415. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105416. /**
  105417. * Add the required samplers to the current list.
  105418. * @param samplers defines the current sampler list.
  105419. */
  105420. static AddSamplers(samplers: string[]): void;
  105421. /**
  105422. * Makes a duplicate of the current configuration into another one.
  105423. * @param anisotropicConfiguration define the config where to copy the info
  105424. */
  105425. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105426. /**
  105427. * Serializes this anisotropy configuration.
  105428. * @returns - An object with the serialized config.
  105429. */
  105430. serialize(): any;
  105431. /**
  105432. * Parses a anisotropy Configuration from a serialized object.
  105433. * @param source - Serialized object.
  105434. * @param scene Defines the scene we are parsing for
  105435. * @param rootUrl Defines the rootUrl to load from
  105436. */
  105437. parse(source: any, scene: Scene, rootUrl: string): void;
  105438. }
  105439. }
  105440. declare module BABYLON {
  105441. /**
  105442. * @hidden
  105443. */
  105444. export interface IMaterialBRDFDefines {
  105445. BRDF_V_HEIGHT_CORRELATED: boolean;
  105446. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105447. SPHERICAL_HARMONICS: boolean;
  105448. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105449. /** @hidden */
  105450. _areMiscDirty: boolean;
  105451. }
  105452. /**
  105453. * Define the code related to the BRDF parameters of the pbr material.
  105454. */
  105455. export class PBRBRDFConfiguration {
  105456. /**
  105457. * Default value used for the energy conservation.
  105458. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105459. */
  105460. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105461. /**
  105462. * Default value used for the Smith Visibility Height Correlated mode.
  105463. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105464. */
  105465. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105466. /**
  105467. * Default value used for the IBL diffuse part.
  105468. * This can help switching back to the polynomials mode globally which is a tiny bit
  105469. * less GPU intensive at the drawback of a lower quality.
  105470. */
  105471. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105472. /**
  105473. * Default value used for activating energy conservation for the specular workflow.
  105474. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105475. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105476. */
  105477. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105478. private _useEnergyConservation;
  105479. /**
  105480. * Defines if the material uses energy conservation.
  105481. */
  105482. useEnergyConservation: boolean;
  105483. private _useSmithVisibilityHeightCorrelated;
  105484. /**
  105485. * LEGACY Mode set to false
  105486. * Defines if the material uses height smith correlated visibility term.
  105487. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105488. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105489. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105490. * Not relying on height correlated will also disable energy conservation.
  105491. */
  105492. useSmithVisibilityHeightCorrelated: boolean;
  105493. private _useSphericalHarmonics;
  105494. /**
  105495. * LEGACY Mode set to false
  105496. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105497. * diffuse part of the IBL.
  105498. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105499. * to the ground truth.
  105500. */
  105501. useSphericalHarmonics: boolean;
  105502. private _useSpecularGlossinessInputEnergyConservation;
  105503. /**
  105504. * Defines if the material uses energy conservation, when the specular workflow is active.
  105505. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105506. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105507. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105508. */
  105509. useSpecularGlossinessInputEnergyConservation: boolean;
  105510. /** @hidden */
  105511. private _internalMarkAllSubMeshesAsMiscDirty;
  105512. /** @hidden */
  105513. _markAllSubMeshesAsMiscDirty(): void;
  105514. /**
  105515. * Instantiate a new istance of clear coat configuration.
  105516. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105517. */
  105518. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105519. /**
  105520. * Checks to see if a texture is used in the material.
  105521. * @param defines the list of "defines" to update.
  105522. */
  105523. prepareDefines(defines: IMaterialBRDFDefines): void;
  105524. /**
  105525. * Get the current class name of the texture useful for serialization or dynamic coding.
  105526. * @returns "PBRClearCoatConfiguration"
  105527. */
  105528. getClassName(): string;
  105529. /**
  105530. * Makes a duplicate of the current configuration into another one.
  105531. * @param brdfConfiguration define the config where to copy the info
  105532. */
  105533. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105534. /**
  105535. * Serializes this BRDF configuration.
  105536. * @returns - An object with the serialized config.
  105537. */
  105538. serialize(): any;
  105539. /**
  105540. * Parses a anisotropy Configuration from a serialized object.
  105541. * @param source - Serialized object.
  105542. * @param scene Defines the scene we are parsing for
  105543. * @param rootUrl Defines the rootUrl to load from
  105544. */
  105545. parse(source: any, scene: Scene, rootUrl: string): void;
  105546. }
  105547. }
  105548. declare module BABYLON {
  105549. /**
  105550. * @hidden
  105551. */
  105552. export interface IMaterialSheenDefines {
  105553. SHEEN: boolean;
  105554. SHEEN_TEXTURE: boolean;
  105555. SHEEN_TEXTUREDIRECTUV: number;
  105556. SHEEN_LINKWITHALBEDO: boolean;
  105557. SHEEN_ROUGHNESS: boolean;
  105558. SHEEN_ALBEDOSCALING: boolean;
  105559. /** @hidden */
  105560. _areTexturesDirty: boolean;
  105561. }
  105562. /**
  105563. * Define the code related to the Sheen parameters of the pbr material.
  105564. */
  105565. export class PBRSheenConfiguration {
  105566. private _isEnabled;
  105567. /**
  105568. * Defines if the material uses sheen.
  105569. */
  105570. isEnabled: boolean;
  105571. private _linkSheenWithAlbedo;
  105572. /**
  105573. * Defines if the sheen is linked to the sheen color.
  105574. */
  105575. linkSheenWithAlbedo: boolean;
  105576. /**
  105577. * Defines the sheen intensity.
  105578. */
  105579. intensity: number;
  105580. /**
  105581. * Defines the sheen color.
  105582. */
  105583. color: Color3;
  105584. private _texture;
  105585. /**
  105586. * Stores the sheen tint values in a texture.
  105587. * rgb is tint
  105588. * a is a intensity or roughness if roughness has been defined
  105589. */
  105590. texture: Nullable<BaseTexture>;
  105591. private _roughness;
  105592. /**
  105593. * Defines the sheen roughness.
  105594. * It is not taken into account if linkSheenWithAlbedo is true.
  105595. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105596. */
  105597. roughness: Nullable<number>;
  105598. private _albedoScaling;
  105599. /**
  105600. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105601. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105602. * making it easier to setup and tweak the effect
  105603. */
  105604. albedoScaling: boolean;
  105605. /** @hidden */
  105606. private _internalMarkAllSubMeshesAsTexturesDirty;
  105607. /** @hidden */
  105608. _markAllSubMeshesAsTexturesDirty(): void;
  105609. /**
  105610. * Instantiate a new istance of clear coat configuration.
  105611. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105612. */
  105613. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105614. /**
  105615. * Specifies that the submesh is ready to be used.
  105616. * @param defines the list of "defines" to update.
  105617. * @param scene defines the scene the material belongs to.
  105618. * @returns - boolean indicating that the submesh is ready or not.
  105619. */
  105620. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105621. /**
  105622. * Checks to see if a texture is used in the material.
  105623. * @param defines the list of "defines" to update.
  105624. * @param scene defines the scene the material belongs to.
  105625. */
  105626. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105627. /**
  105628. * Binds the material data.
  105629. * @param uniformBuffer defines the Uniform buffer to fill in.
  105630. * @param scene defines the scene the material belongs to.
  105631. * @param isFrozen defines wether the material is frozen or not.
  105632. */
  105633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105634. /**
  105635. * Checks to see if a texture is used in the material.
  105636. * @param texture - Base texture to use.
  105637. * @returns - Boolean specifying if a texture is used in the material.
  105638. */
  105639. hasTexture(texture: BaseTexture): boolean;
  105640. /**
  105641. * Returns an array of the actively used textures.
  105642. * @param activeTextures Array of BaseTextures
  105643. */
  105644. getActiveTextures(activeTextures: BaseTexture[]): void;
  105645. /**
  105646. * Returns the animatable textures.
  105647. * @param animatables Array of animatable textures.
  105648. */
  105649. getAnimatables(animatables: IAnimatable[]): void;
  105650. /**
  105651. * Disposes the resources of the material.
  105652. * @param forceDisposeTextures - Forces the disposal of all textures.
  105653. */
  105654. dispose(forceDisposeTextures?: boolean): void;
  105655. /**
  105656. * Get the current class name of the texture useful for serialization or dynamic coding.
  105657. * @returns "PBRSheenConfiguration"
  105658. */
  105659. getClassName(): string;
  105660. /**
  105661. * Add fallbacks to the effect fallbacks list.
  105662. * @param defines defines the Base texture to use.
  105663. * @param fallbacks defines the current fallback list.
  105664. * @param currentRank defines the current fallback rank.
  105665. * @returns the new fallback rank.
  105666. */
  105667. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105668. /**
  105669. * Add the required uniforms to the current list.
  105670. * @param uniforms defines the current uniform list.
  105671. */
  105672. static AddUniforms(uniforms: string[]): void;
  105673. /**
  105674. * Add the required uniforms to the current buffer.
  105675. * @param uniformBuffer defines the current uniform buffer.
  105676. */
  105677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105678. /**
  105679. * Add the required samplers to the current list.
  105680. * @param samplers defines the current sampler list.
  105681. */
  105682. static AddSamplers(samplers: string[]): void;
  105683. /**
  105684. * Makes a duplicate of the current configuration into another one.
  105685. * @param sheenConfiguration define the config where to copy the info
  105686. */
  105687. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105688. /**
  105689. * Serializes this BRDF configuration.
  105690. * @returns - An object with the serialized config.
  105691. */
  105692. serialize(): any;
  105693. /**
  105694. * Parses a anisotropy Configuration from a serialized object.
  105695. * @param source - Serialized object.
  105696. * @param scene Defines the scene we are parsing for
  105697. * @param rootUrl Defines the rootUrl to load from
  105698. */
  105699. parse(source: any, scene: Scene, rootUrl: string): void;
  105700. }
  105701. }
  105702. declare module BABYLON {
  105703. /**
  105704. * @hidden
  105705. */
  105706. export interface IMaterialSubSurfaceDefines {
  105707. SUBSURFACE: boolean;
  105708. SS_REFRACTION: boolean;
  105709. SS_TRANSLUCENCY: boolean;
  105710. SS_SCATTERING: boolean;
  105711. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105712. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105713. SS_REFRACTIONMAP_3D: boolean;
  105714. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105715. SS_LODINREFRACTIONALPHA: boolean;
  105716. SS_GAMMAREFRACTION: boolean;
  105717. SS_RGBDREFRACTION: boolean;
  105718. SS_LINEARSPECULARREFRACTION: boolean;
  105719. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105720. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105721. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105722. /** @hidden */
  105723. _areTexturesDirty: boolean;
  105724. }
  105725. /**
  105726. * Define the code related to the sub surface parameters of the pbr material.
  105727. */
  105728. export class PBRSubSurfaceConfiguration {
  105729. private _isRefractionEnabled;
  105730. /**
  105731. * Defines if the refraction is enabled in the material.
  105732. */
  105733. isRefractionEnabled: boolean;
  105734. private _isTranslucencyEnabled;
  105735. /**
  105736. * Defines if the translucency is enabled in the material.
  105737. */
  105738. isTranslucencyEnabled: boolean;
  105739. private _isScatteringEnabled;
  105740. /**
  105741. * Defines if the sub surface scattering is enabled in the material.
  105742. */
  105743. isScatteringEnabled: boolean;
  105744. private _scatteringDiffusionProfileIndex;
  105745. /**
  105746. * Diffusion profile for subsurface scattering.
  105747. * Useful for better scattering in the skins or foliages.
  105748. */
  105749. get scatteringDiffusionProfile(): Nullable<Color3>;
  105750. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105751. /**
  105752. * Defines the refraction intensity of the material.
  105753. * The refraction when enabled replaces the Diffuse part of the material.
  105754. * The intensity helps transitionning between diffuse and refraction.
  105755. */
  105756. refractionIntensity: number;
  105757. /**
  105758. * Defines the translucency intensity of the material.
  105759. * When translucency has been enabled, this defines how much of the "translucency"
  105760. * is addded to the diffuse part of the material.
  105761. */
  105762. translucencyIntensity: number;
  105763. /**
  105764. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105765. */
  105766. useAlbedoToTintRefraction: boolean;
  105767. private _thicknessTexture;
  105768. /**
  105769. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105770. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105771. * 0 would mean minimumThickness
  105772. * 1 would mean maximumThickness
  105773. * The other channels might be use as a mask to vary the different effects intensity.
  105774. */
  105775. thicknessTexture: Nullable<BaseTexture>;
  105776. private _refractionTexture;
  105777. /**
  105778. * Defines the texture to use for refraction.
  105779. */
  105780. refractionTexture: Nullable<BaseTexture>;
  105781. private _indexOfRefraction;
  105782. /**
  105783. * Index of refraction of the material base layer.
  105784. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105785. *
  105786. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105787. *
  105788. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105789. */
  105790. indexOfRefraction: number;
  105791. private _volumeIndexOfRefraction;
  105792. /**
  105793. * Index of refraction of the material's volume.
  105794. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105795. *
  105796. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105797. * the volume will use the same IOR as the surface.
  105798. */
  105799. get volumeIndexOfRefraction(): number;
  105800. set volumeIndexOfRefraction(value: number);
  105801. private _invertRefractionY;
  105802. /**
  105803. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105804. */
  105805. invertRefractionY: boolean;
  105806. private _linkRefractionWithTransparency;
  105807. /**
  105808. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105809. * Materials half opaque for instance using refraction could benefit from this control.
  105810. */
  105811. linkRefractionWithTransparency: boolean;
  105812. /**
  105813. * Defines the minimum thickness stored in the thickness map.
  105814. * If no thickness map is defined, this value will be used to simulate thickness.
  105815. */
  105816. minimumThickness: number;
  105817. /**
  105818. * Defines the maximum thickness stored in the thickness map.
  105819. */
  105820. maximumThickness: number;
  105821. /**
  105822. * Defines the volume tint of the material.
  105823. * This is used for both translucency and scattering.
  105824. */
  105825. tintColor: Color3;
  105826. /**
  105827. * Defines the distance at which the tint color should be found in the media.
  105828. * This is used for refraction only.
  105829. */
  105830. tintColorAtDistance: number;
  105831. /**
  105832. * Defines how far each channel transmit through the media.
  105833. * It is defined as a color to simplify it selection.
  105834. */
  105835. diffusionDistance: Color3;
  105836. private _useMaskFromThicknessTexture;
  105837. /**
  105838. * Stores the intensity of the different subsurface effects in the thickness texture.
  105839. * * the green channel is the translucency intensity.
  105840. * * the blue channel is the scattering intensity.
  105841. * * the alpha channel is the refraction intensity.
  105842. */
  105843. useMaskFromThicknessTexture: boolean;
  105844. private _scene;
  105845. /** @hidden */
  105846. private _internalMarkAllSubMeshesAsTexturesDirty;
  105847. private _internalMarkScenePrePassDirty;
  105848. /** @hidden */
  105849. _markAllSubMeshesAsTexturesDirty(): void;
  105850. /** @hidden */
  105851. _markScenePrePassDirty(): void;
  105852. /**
  105853. * Instantiate a new istance of sub surface configuration.
  105854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105855. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105856. * @param scene The scene
  105857. */
  105858. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105859. /**
  105860. * Gets wehter the submesh is ready to be used or not.
  105861. * @param defines the list of "defines" to update.
  105862. * @param scene defines the scene the material belongs to.
  105863. * @returns - boolean indicating that the submesh is ready or not.
  105864. */
  105865. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105866. /**
  105867. * Checks to see if a texture is used in the material.
  105868. * @param defines the list of "defines" to update.
  105869. * @param scene defines the scene to the material belongs to.
  105870. */
  105871. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105872. /**
  105873. * Binds the material data.
  105874. * @param uniformBuffer defines the Uniform buffer to fill in.
  105875. * @param scene defines the scene the material belongs to.
  105876. * @param engine defines the engine the material belongs to.
  105877. * @param isFrozen defines whether the material is frozen or not.
  105878. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105879. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105880. */
  105881. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105882. /**
  105883. * Unbinds the material from the mesh.
  105884. * @param activeEffect defines the effect that should be unbound from.
  105885. * @returns true if unbound, otherwise false
  105886. */
  105887. unbind(activeEffect: Effect): boolean;
  105888. /**
  105889. * Returns the texture used for refraction or null if none is used.
  105890. * @param scene defines the scene the material belongs to.
  105891. * @returns - Refraction texture if present. If no refraction texture and refraction
  105892. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105893. */
  105894. private _getRefractionTexture;
  105895. /**
  105896. * Returns true if alpha blending should be disabled.
  105897. */
  105898. get disableAlphaBlending(): boolean;
  105899. /**
  105900. * Fills the list of render target textures.
  105901. * @param renderTargets the list of render targets to update
  105902. */
  105903. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105904. /**
  105905. * Checks to see if a texture is used in the material.
  105906. * @param texture - Base texture to use.
  105907. * @returns - Boolean specifying if a texture is used in the material.
  105908. */
  105909. hasTexture(texture: BaseTexture): boolean;
  105910. /**
  105911. * Gets a boolean indicating that current material needs to register RTT
  105912. * @returns true if this uses a render target otherwise false.
  105913. */
  105914. hasRenderTargetTextures(): boolean;
  105915. /**
  105916. * Returns an array of the actively used textures.
  105917. * @param activeTextures Array of BaseTextures
  105918. */
  105919. getActiveTextures(activeTextures: BaseTexture[]): void;
  105920. /**
  105921. * Returns the animatable textures.
  105922. * @param animatables Array of animatable textures.
  105923. */
  105924. getAnimatables(animatables: IAnimatable[]): void;
  105925. /**
  105926. * Disposes the resources of the material.
  105927. * @param forceDisposeTextures - Forces the disposal of all textures.
  105928. */
  105929. dispose(forceDisposeTextures?: boolean): void;
  105930. /**
  105931. * Get the current class name of the texture useful for serialization or dynamic coding.
  105932. * @returns "PBRSubSurfaceConfiguration"
  105933. */
  105934. getClassName(): string;
  105935. /**
  105936. * Add fallbacks to the effect fallbacks list.
  105937. * @param defines defines the Base texture to use.
  105938. * @param fallbacks defines the current fallback list.
  105939. * @param currentRank defines the current fallback rank.
  105940. * @returns the new fallback rank.
  105941. */
  105942. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105943. /**
  105944. * Add the required uniforms to the current list.
  105945. * @param uniforms defines the current uniform list.
  105946. */
  105947. static AddUniforms(uniforms: string[]): void;
  105948. /**
  105949. * Add the required samplers to the current list.
  105950. * @param samplers defines the current sampler list.
  105951. */
  105952. static AddSamplers(samplers: string[]): void;
  105953. /**
  105954. * Add the required uniforms to the current buffer.
  105955. * @param uniformBuffer defines the current uniform buffer.
  105956. */
  105957. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105958. /**
  105959. * Makes a duplicate of the current configuration into another one.
  105960. * @param configuration define the config where to copy the info
  105961. */
  105962. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105963. /**
  105964. * Serializes this Sub Surface configuration.
  105965. * @returns - An object with the serialized config.
  105966. */
  105967. serialize(): any;
  105968. /**
  105969. * Parses a anisotropy Configuration from a serialized object.
  105970. * @param source - Serialized object.
  105971. * @param scene Defines the scene we are parsing for
  105972. * @param rootUrl Defines the rootUrl to load from
  105973. */
  105974. parse(source: any, scene: Scene, rootUrl: string): void;
  105975. }
  105976. }
  105977. declare module BABYLON {
  105978. /**
  105979. * Class representing spherical harmonics coefficients to the 3rd degree
  105980. */
  105981. export class SphericalHarmonics {
  105982. /**
  105983. * Defines whether or not the harmonics have been prescaled for rendering.
  105984. */
  105985. preScaled: boolean;
  105986. /**
  105987. * The l0,0 coefficients of the spherical harmonics
  105988. */
  105989. l00: Vector3;
  105990. /**
  105991. * The l1,-1 coefficients of the spherical harmonics
  105992. */
  105993. l1_1: Vector3;
  105994. /**
  105995. * The l1,0 coefficients of the spherical harmonics
  105996. */
  105997. l10: Vector3;
  105998. /**
  105999. * The l1,1 coefficients of the spherical harmonics
  106000. */
  106001. l11: Vector3;
  106002. /**
  106003. * The l2,-2 coefficients of the spherical harmonics
  106004. */
  106005. l2_2: Vector3;
  106006. /**
  106007. * The l2,-1 coefficients of the spherical harmonics
  106008. */
  106009. l2_1: Vector3;
  106010. /**
  106011. * The l2,0 coefficients of the spherical harmonics
  106012. */
  106013. l20: Vector3;
  106014. /**
  106015. * The l2,1 coefficients of the spherical harmonics
  106016. */
  106017. l21: Vector3;
  106018. /**
  106019. * The l2,2 coefficients of the spherical harmonics
  106020. */
  106021. l22: Vector3;
  106022. /**
  106023. * Adds a light to the spherical harmonics
  106024. * @param direction the direction of the light
  106025. * @param color the color of the light
  106026. * @param deltaSolidAngle the delta solid angle of the light
  106027. */
  106028. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106029. /**
  106030. * Scales the spherical harmonics by the given amount
  106031. * @param scale the amount to scale
  106032. */
  106033. scaleInPlace(scale: number): void;
  106034. /**
  106035. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106036. *
  106037. * ```
  106038. * E_lm = A_l * L_lm
  106039. * ```
  106040. *
  106041. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106042. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106043. * the scaling factors are given in equation 9.
  106044. */
  106045. convertIncidentRadianceToIrradiance(): void;
  106046. /**
  106047. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106048. *
  106049. * ```
  106050. * L = (1/pi) * E * rho
  106051. * ```
  106052. *
  106053. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106054. */
  106055. convertIrradianceToLambertianRadiance(): void;
  106056. /**
  106057. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106058. * required operations at run time.
  106059. *
  106060. * This is simply done by scaling back the SH with Ylm constants parameter.
  106061. * The trigonometric part being applied by the shader at run time.
  106062. */
  106063. preScaleForRendering(): void;
  106064. /**
  106065. * Constructs a spherical harmonics from an array.
  106066. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106067. * @returns the spherical harmonics
  106068. */
  106069. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106070. /**
  106071. * Gets the spherical harmonics from polynomial
  106072. * @param polynomial the spherical polynomial
  106073. * @returns the spherical harmonics
  106074. */
  106075. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106076. }
  106077. /**
  106078. * Class representing spherical polynomial coefficients to the 3rd degree
  106079. */
  106080. export class SphericalPolynomial {
  106081. private _harmonics;
  106082. /**
  106083. * The spherical harmonics used to create the polynomials.
  106084. */
  106085. get preScaledHarmonics(): SphericalHarmonics;
  106086. /**
  106087. * The x coefficients of the spherical polynomial
  106088. */
  106089. x: Vector3;
  106090. /**
  106091. * The y coefficients of the spherical polynomial
  106092. */
  106093. y: Vector3;
  106094. /**
  106095. * The z coefficients of the spherical polynomial
  106096. */
  106097. z: Vector3;
  106098. /**
  106099. * The xx coefficients of the spherical polynomial
  106100. */
  106101. xx: Vector3;
  106102. /**
  106103. * The yy coefficients of the spherical polynomial
  106104. */
  106105. yy: Vector3;
  106106. /**
  106107. * The zz coefficients of the spherical polynomial
  106108. */
  106109. zz: Vector3;
  106110. /**
  106111. * The xy coefficients of the spherical polynomial
  106112. */
  106113. xy: Vector3;
  106114. /**
  106115. * The yz coefficients of the spherical polynomial
  106116. */
  106117. yz: Vector3;
  106118. /**
  106119. * The zx coefficients of the spherical polynomial
  106120. */
  106121. zx: Vector3;
  106122. /**
  106123. * Adds an ambient color to the spherical polynomial
  106124. * @param color the color to add
  106125. */
  106126. addAmbient(color: Color3): void;
  106127. /**
  106128. * Scales the spherical polynomial by the given amount
  106129. * @param scale the amount to scale
  106130. */
  106131. scaleInPlace(scale: number): void;
  106132. /**
  106133. * Gets the spherical polynomial from harmonics
  106134. * @param harmonics the spherical harmonics
  106135. * @returns the spherical polynomial
  106136. */
  106137. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106138. /**
  106139. * Constructs a spherical polynomial from an array.
  106140. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106141. * @returns the spherical polynomial
  106142. */
  106143. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106144. }
  106145. }
  106146. declare module BABYLON {
  106147. /**
  106148. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106149. */
  106150. export interface CubeMapInfo {
  106151. /**
  106152. * The pixel array for the front face.
  106153. * This is stored in format, left to right, up to down format.
  106154. */
  106155. front: Nullable<ArrayBufferView>;
  106156. /**
  106157. * The pixel array for the back face.
  106158. * This is stored in format, left to right, up to down format.
  106159. */
  106160. back: Nullable<ArrayBufferView>;
  106161. /**
  106162. * The pixel array for the left face.
  106163. * This is stored in format, left to right, up to down format.
  106164. */
  106165. left: Nullable<ArrayBufferView>;
  106166. /**
  106167. * The pixel array for the right face.
  106168. * This is stored in format, left to right, up to down format.
  106169. */
  106170. right: Nullable<ArrayBufferView>;
  106171. /**
  106172. * The pixel array for the up face.
  106173. * This is stored in format, left to right, up to down format.
  106174. */
  106175. up: Nullable<ArrayBufferView>;
  106176. /**
  106177. * The pixel array for the down face.
  106178. * This is stored in format, left to right, up to down format.
  106179. */
  106180. down: Nullable<ArrayBufferView>;
  106181. /**
  106182. * The size of the cubemap stored.
  106183. *
  106184. * Each faces will be size * size pixels.
  106185. */
  106186. size: number;
  106187. /**
  106188. * The format of the texture.
  106189. *
  106190. * RGBA, RGB.
  106191. */
  106192. format: number;
  106193. /**
  106194. * The type of the texture data.
  106195. *
  106196. * UNSIGNED_INT, FLOAT.
  106197. */
  106198. type: number;
  106199. /**
  106200. * Specifies whether the texture is in gamma space.
  106201. */
  106202. gammaSpace: boolean;
  106203. }
  106204. /**
  106205. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106206. */
  106207. export class PanoramaToCubeMapTools {
  106208. private static FACE_LEFT;
  106209. private static FACE_RIGHT;
  106210. private static FACE_FRONT;
  106211. private static FACE_BACK;
  106212. private static FACE_DOWN;
  106213. private static FACE_UP;
  106214. /**
  106215. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106216. *
  106217. * @param float32Array The source data.
  106218. * @param inputWidth The width of the input panorama.
  106219. * @param inputHeight The height of the input panorama.
  106220. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106221. * @return The cubemap data
  106222. */
  106223. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106224. private static CreateCubemapTexture;
  106225. private static CalcProjectionSpherical;
  106226. }
  106227. }
  106228. declare module BABYLON {
  106229. /**
  106230. * Helper class dealing with the extraction of spherical polynomial dataArray
  106231. * from a cube map.
  106232. */
  106233. export class CubeMapToSphericalPolynomialTools {
  106234. private static FileFaces;
  106235. /**
  106236. * Converts a texture to the according Spherical Polynomial data.
  106237. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106238. *
  106239. * @param texture The texture to extract the information from.
  106240. * @return The Spherical Polynomial data.
  106241. */
  106242. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106243. /**
  106244. * Converts a cubemap to the according Spherical Polynomial data.
  106245. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106246. *
  106247. * @param cubeInfo The Cube map to extract the information from.
  106248. * @return The Spherical Polynomial data.
  106249. */
  106250. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106251. }
  106252. }
  106253. declare module BABYLON {
  106254. interface BaseTexture {
  106255. /**
  106256. * Get the polynomial representation of the texture data.
  106257. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106258. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106259. */
  106260. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106261. }
  106262. }
  106263. declare module BABYLON {
  106264. /** @hidden */
  106265. export var pbrFragmentDeclaration: {
  106266. name: string;
  106267. shader: string;
  106268. };
  106269. }
  106270. declare module BABYLON {
  106271. /** @hidden */
  106272. export var pbrUboDeclaration: {
  106273. name: string;
  106274. shader: string;
  106275. };
  106276. }
  106277. declare module BABYLON {
  106278. /** @hidden */
  106279. export var pbrFragmentExtraDeclaration: {
  106280. name: string;
  106281. shader: string;
  106282. };
  106283. }
  106284. declare module BABYLON {
  106285. /** @hidden */
  106286. export var pbrFragmentSamplersDeclaration: {
  106287. name: string;
  106288. shader: string;
  106289. };
  106290. }
  106291. declare module BABYLON {
  106292. /** @hidden */
  106293. export var subSurfaceScatteringFunctions: {
  106294. name: string;
  106295. shader: string;
  106296. };
  106297. }
  106298. declare module BABYLON {
  106299. /** @hidden */
  106300. export var importanceSampling: {
  106301. name: string;
  106302. shader: string;
  106303. };
  106304. }
  106305. declare module BABYLON {
  106306. /** @hidden */
  106307. export var pbrHelperFunctions: {
  106308. name: string;
  106309. shader: string;
  106310. };
  106311. }
  106312. declare module BABYLON {
  106313. /** @hidden */
  106314. export var harmonicsFunctions: {
  106315. name: string;
  106316. shader: string;
  106317. };
  106318. }
  106319. declare module BABYLON {
  106320. /** @hidden */
  106321. export var pbrDirectLightingSetupFunctions: {
  106322. name: string;
  106323. shader: string;
  106324. };
  106325. }
  106326. declare module BABYLON {
  106327. /** @hidden */
  106328. export var pbrDirectLightingFalloffFunctions: {
  106329. name: string;
  106330. shader: string;
  106331. };
  106332. }
  106333. declare module BABYLON {
  106334. /** @hidden */
  106335. export var pbrBRDFFunctions: {
  106336. name: string;
  106337. shader: string;
  106338. };
  106339. }
  106340. declare module BABYLON {
  106341. /** @hidden */
  106342. export var hdrFilteringFunctions: {
  106343. name: string;
  106344. shader: string;
  106345. };
  106346. }
  106347. declare module BABYLON {
  106348. /** @hidden */
  106349. export var pbrDirectLightingFunctions: {
  106350. name: string;
  106351. shader: string;
  106352. };
  106353. }
  106354. declare module BABYLON {
  106355. /** @hidden */
  106356. export var pbrIBLFunctions: {
  106357. name: string;
  106358. shader: string;
  106359. };
  106360. }
  106361. declare module BABYLON {
  106362. /** @hidden */
  106363. export var pbrBlockAlbedoOpacity: {
  106364. name: string;
  106365. shader: string;
  106366. };
  106367. }
  106368. declare module BABYLON {
  106369. /** @hidden */
  106370. export var pbrBlockReflectivity: {
  106371. name: string;
  106372. shader: string;
  106373. };
  106374. }
  106375. declare module BABYLON {
  106376. /** @hidden */
  106377. export var pbrBlockAmbientOcclusion: {
  106378. name: string;
  106379. shader: string;
  106380. };
  106381. }
  106382. declare module BABYLON {
  106383. /** @hidden */
  106384. export var pbrBlockAlphaFresnel: {
  106385. name: string;
  106386. shader: string;
  106387. };
  106388. }
  106389. declare module BABYLON {
  106390. /** @hidden */
  106391. export var pbrBlockAnisotropic: {
  106392. name: string;
  106393. shader: string;
  106394. };
  106395. }
  106396. declare module BABYLON {
  106397. /** @hidden */
  106398. export var pbrBlockReflection: {
  106399. name: string;
  106400. shader: string;
  106401. };
  106402. }
  106403. declare module BABYLON {
  106404. /** @hidden */
  106405. export var pbrBlockSheen: {
  106406. name: string;
  106407. shader: string;
  106408. };
  106409. }
  106410. declare module BABYLON {
  106411. /** @hidden */
  106412. export var pbrBlockClearcoat: {
  106413. name: string;
  106414. shader: string;
  106415. };
  106416. }
  106417. declare module BABYLON {
  106418. /** @hidden */
  106419. export var pbrBlockSubSurface: {
  106420. name: string;
  106421. shader: string;
  106422. };
  106423. }
  106424. declare module BABYLON {
  106425. /** @hidden */
  106426. export var pbrBlockNormalGeometric: {
  106427. name: string;
  106428. shader: string;
  106429. };
  106430. }
  106431. declare module BABYLON {
  106432. /** @hidden */
  106433. export var pbrBlockNormalFinal: {
  106434. name: string;
  106435. shader: string;
  106436. };
  106437. }
  106438. declare module BABYLON {
  106439. /** @hidden */
  106440. export var pbrBlockLightmapInit: {
  106441. name: string;
  106442. shader: string;
  106443. };
  106444. }
  106445. declare module BABYLON {
  106446. /** @hidden */
  106447. export var pbrBlockGeometryInfo: {
  106448. name: string;
  106449. shader: string;
  106450. };
  106451. }
  106452. declare module BABYLON {
  106453. /** @hidden */
  106454. export var pbrBlockReflectance0: {
  106455. name: string;
  106456. shader: string;
  106457. };
  106458. }
  106459. declare module BABYLON {
  106460. /** @hidden */
  106461. export var pbrBlockReflectance: {
  106462. name: string;
  106463. shader: string;
  106464. };
  106465. }
  106466. declare module BABYLON {
  106467. /** @hidden */
  106468. export var pbrBlockDirectLighting: {
  106469. name: string;
  106470. shader: string;
  106471. };
  106472. }
  106473. declare module BABYLON {
  106474. /** @hidden */
  106475. export var pbrBlockFinalLitComponents: {
  106476. name: string;
  106477. shader: string;
  106478. };
  106479. }
  106480. declare module BABYLON {
  106481. /** @hidden */
  106482. export var pbrBlockFinalUnlitComponents: {
  106483. name: string;
  106484. shader: string;
  106485. };
  106486. }
  106487. declare module BABYLON {
  106488. /** @hidden */
  106489. export var pbrBlockFinalColorComposition: {
  106490. name: string;
  106491. shader: string;
  106492. };
  106493. }
  106494. declare module BABYLON {
  106495. /** @hidden */
  106496. export var pbrBlockImageProcessing: {
  106497. name: string;
  106498. shader: string;
  106499. };
  106500. }
  106501. declare module BABYLON {
  106502. /** @hidden */
  106503. export var pbrDebug: {
  106504. name: string;
  106505. shader: string;
  106506. };
  106507. }
  106508. declare module BABYLON {
  106509. /** @hidden */
  106510. export var pbrPixelShader: {
  106511. name: string;
  106512. shader: string;
  106513. };
  106514. }
  106515. declare module BABYLON {
  106516. /** @hidden */
  106517. export var pbrVertexDeclaration: {
  106518. name: string;
  106519. shader: string;
  106520. };
  106521. }
  106522. declare module BABYLON {
  106523. /** @hidden */
  106524. export var pbrVertexShader: {
  106525. name: string;
  106526. shader: string;
  106527. };
  106528. }
  106529. declare module BABYLON {
  106530. /**
  106531. * Manages the defines for the PBR Material.
  106532. * @hidden
  106533. */
  106534. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106535. PBR: boolean;
  106536. NUM_SAMPLES: string;
  106537. REALTIME_FILTERING: boolean;
  106538. MAINUV1: boolean;
  106539. MAINUV2: boolean;
  106540. UV1: boolean;
  106541. UV2: boolean;
  106542. ALBEDO: boolean;
  106543. GAMMAALBEDO: boolean;
  106544. ALBEDODIRECTUV: number;
  106545. VERTEXCOLOR: boolean;
  106546. DETAIL: boolean;
  106547. DETAILDIRECTUV: number;
  106548. DETAIL_NORMALBLENDMETHOD: number;
  106549. AMBIENT: boolean;
  106550. AMBIENTDIRECTUV: number;
  106551. AMBIENTINGRAYSCALE: boolean;
  106552. OPACITY: boolean;
  106553. VERTEXALPHA: boolean;
  106554. OPACITYDIRECTUV: number;
  106555. OPACITYRGB: boolean;
  106556. ALPHATEST: boolean;
  106557. DEPTHPREPASS: boolean;
  106558. ALPHABLEND: boolean;
  106559. ALPHAFROMALBEDO: boolean;
  106560. ALPHATESTVALUE: string;
  106561. SPECULAROVERALPHA: boolean;
  106562. RADIANCEOVERALPHA: boolean;
  106563. ALPHAFRESNEL: boolean;
  106564. LINEARALPHAFRESNEL: boolean;
  106565. PREMULTIPLYALPHA: boolean;
  106566. EMISSIVE: boolean;
  106567. EMISSIVEDIRECTUV: number;
  106568. REFLECTIVITY: boolean;
  106569. REFLECTIVITYDIRECTUV: number;
  106570. SPECULARTERM: boolean;
  106571. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106572. MICROSURFACEAUTOMATIC: boolean;
  106573. LODBASEDMICROSFURACE: boolean;
  106574. MICROSURFACEMAP: boolean;
  106575. MICROSURFACEMAPDIRECTUV: number;
  106576. METALLICWORKFLOW: boolean;
  106577. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106578. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106579. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106580. AOSTOREINMETALMAPRED: boolean;
  106581. METALLIC_REFLECTANCE: boolean;
  106582. METALLIC_REFLECTANCEDIRECTUV: number;
  106583. ENVIRONMENTBRDF: boolean;
  106584. ENVIRONMENTBRDF_RGBD: boolean;
  106585. NORMAL: boolean;
  106586. TANGENT: boolean;
  106587. BUMP: boolean;
  106588. BUMPDIRECTUV: number;
  106589. OBJECTSPACE_NORMALMAP: boolean;
  106590. PARALLAX: boolean;
  106591. PARALLAXOCCLUSION: boolean;
  106592. NORMALXYSCALE: boolean;
  106593. LIGHTMAP: boolean;
  106594. LIGHTMAPDIRECTUV: number;
  106595. USELIGHTMAPASSHADOWMAP: boolean;
  106596. GAMMALIGHTMAP: boolean;
  106597. RGBDLIGHTMAP: boolean;
  106598. REFLECTION: boolean;
  106599. REFLECTIONMAP_3D: boolean;
  106600. REFLECTIONMAP_SPHERICAL: boolean;
  106601. REFLECTIONMAP_PLANAR: boolean;
  106602. REFLECTIONMAP_CUBIC: boolean;
  106603. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106604. REFLECTIONMAP_PROJECTION: boolean;
  106605. REFLECTIONMAP_SKYBOX: boolean;
  106606. REFLECTIONMAP_EXPLICIT: boolean;
  106607. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106608. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106609. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106610. INVERTCUBICMAP: boolean;
  106611. USESPHERICALFROMREFLECTIONMAP: boolean;
  106612. USEIRRADIANCEMAP: boolean;
  106613. SPHERICAL_HARMONICS: boolean;
  106614. USESPHERICALINVERTEX: boolean;
  106615. REFLECTIONMAP_OPPOSITEZ: boolean;
  106616. LODINREFLECTIONALPHA: boolean;
  106617. GAMMAREFLECTION: boolean;
  106618. RGBDREFLECTION: boolean;
  106619. LINEARSPECULARREFLECTION: boolean;
  106620. RADIANCEOCCLUSION: boolean;
  106621. HORIZONOCCLUSION: boolean;
  106622. INSTANCES: boolean;
  106623. THIN_INSTANCES: boolean;
  106624. PREPASS: boolean;
  106625. PREPASS_IRRADIANCE: boolean;
  106626. PREPASS_IRRADIANCE_INDEX: number;
  106627. PREPASS_ALBEDO: boolean;
  106628. PREPASS_ALBEDO_INDEX: number;
  106629. PREPASS_DEPTHNORMAL: boolean;
  106630. PREPASS_DEPTHNORMAL_INDEX: number;
  106631. PREPASS_POSITION: boolean;
  106632. PREPASS_POSITION_INDEX: number;
  106633. PREPASS_VELOCITY: boolean;
  106634. PREPASS_VELOCITY_INDEX: number;
  106635. PREPASS_REFLECTIVITY: boolean;
  106636. PREPASS_REFLECTIVITY_INDEX: number;
  106637. SCENE_MRT_COUNT: number;
  106638. NUM_BONE_INFLUENCERS: number;
  106639. BonesPerMesh: number;
  106640. BONETEXTURE: boolean;
  106641. BONES_VELOCITY_ENABLED: boolean;
  106642. NONUNIFORMSCALING: boolean;
  106643. MORPHTARGETS: boolean;
  106644. MORPHTARGETS_NORMAL: boolean;
  106645. MORPHTARGETS_TANGENT: boolean;
  106646. MORPHTARGETS_UV: boolean;
  106647. NUM_MORPH_INFLUENCERS: number;
  106648. IMAGEPROCESSING: boolean;
  106649. VIGNETTE: boolean;
  106650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106651. VIGNETTEBLENDMODEOPAQUE: boolean;
  106652. TONEMAPPING: boolean;
  106653. TONEMAPPING_ACES: boolean;
  106654. CONTRAST: boolean;
  106655. COLORCURVES: boolean;
  106656. COLORGRADING: boolean;
  106657. COLORGRADING3D: boolean;
  106658. SAMPLER3DGREENDEPTH: boolean;
  106659. SAMPLER3DBGRMAP: boolean;
  106660. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106661. EXPOSURE: boolean;
  106662. MULTIVIEW: boolean;
  106663. USEPHYSICALLIGHTFALLOFF: boolean;
  106664. USEGLTFLIGHTFALLOFF: boolean;
  106665. TWOSIDEDLIGHTING: boolean;
  106666. SHADOWFLOAT: boolean;
  106667. CLIPPLANE: boolean;
  106668. CLIPPLANE2: boolean;
  106669. CLIPPLANE3: boolean;
  106670. CLIPPLANE4: boolean;
  106671. CLIPPLANE5: boolean;
  106672. CLIPPLANE6: boolean;
  106673. POINTSIZE: boolean;
  106674. FOG: boolean;
  106675. LOGARITHMICDEPTH: boolean;
  106676. FORCENORMALFORWARD: boolean;
  106677. SPECULARAA: boolean;
  106678. CLEARCOAT: boolean;
  106679. CLEARCOAT_DEFAULTIOR: boolean;
  106680. CLEARCOAT_TEXTURE: boolean;
  106681. CLEARCOAT_TEXTUREDIRECTUV: number;
  106682. CLEARCOAT_BUMP: boolean;
  106683. CLEARCOAT_BUMPDIRECTUV: number;
  106684. CLEARCOAT_REMAP_F0: boolean;
  106685. CLEARCOAT_TINT: boolean;
  106686. CLEARCOAT_TINT_TEXTURE: boolean;
  106687. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106688. ANISOTROPIC: boolean;
  106689. ANISOTROPIC_TEXTURE: boolean;
  106690. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106691. BRDF_V_HEIGHT_CORRELATED: boolean;
  106692. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106693. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106694. SHEEN: boolean;
  106695. SHEEN_TEXTURE: boolean;
  106696. SHEEN_TEXTUREDIRECTUV: number;
  106697. SHEEN_LINKWITHALBEDO: boolean;
  106698. SHEEN_ROUGHNESS: boolean;
  106699. SHEEN_ALBEDOSCALING: boolean;
  106700. SUBSURFACE: boolean;
  106701. SS_REFRACTION: boolean;
  106702. SS_TRANSLUCENCY: boolean;
  106703. SS_SCATTERING: boolean;
  106704. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106705. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106706. SS_REFRACTIONMAP_3D: boolean;
  106707. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106708. SS_LODINREFRACTIONALPHA: boolean;
  106709. SS_GAMMAREFRACTION: boolean;
  106710. SS_RGBDREFRACTION: boolean;
  106711. SS_LINEARSPECULARREFRACTION: boolean;
  106712. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106713. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106714. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106715. UNLIT: boolean;
  106716. DEBUGMODE: number;
  106717. /**
  106718. * Initializes the PBR Material defines.
  106719. */
  106720. constructor();
  106721. /**
  106722. * Resets the PBR Material defines.
  106723. */
  106724. reset(): void;
  106725. }
  106726. /**
  106727. * The Physically based material base class of BJS.
  106728. *
  106729. * This offers the main features of a standard PBR material.
  106730. * For more information, please refer to the documentation :
  106731. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106732. */
  106733. export abstract class PBRBaseMaterial extends PushMaterial {
  106734. /**
  106735. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106736. */
  106737. static readonly PBRMATERIAL_OPAQUE: number;
  106738. /**
  106739. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106740. */
  106741. static readonly PBRMATERIAL_ALPHATEST: number;
  106742. /**
  106743. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106744. */
  106745. static readonly PBRMATERIAL_ALPHABLEND: number;
  106746. /**
  106747. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106748. * They are also discarded below the alpha cutoff threshold to improve performances.
  106749. */
  106750. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106751. /**
  106752. * Defines the default value of how much AO map is occluding the analytical lights
  106753. * (point spot...).
  106754. */
  106755. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106756. /**
  106757. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106758. */
  106759. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106760. /**
  106761. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106762. * to enhance interoperability with other engines.
  106763. */
  106764. static readonly LIGHTFALLOFF_GLTF: number;
  106765. /**
  106766. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106767. * to enhance interoperability with other materials.
  106768. */
  106769. static readonly LIGHTFALLOFF_STANDARD: number;
  106770. /**
  106771. * Intensity of the direct lights e.g. the four lights available in your scene.
  106772. * This impacts both the direct diffuse and specular highlights.
  106773. */
  106774. protected _directIntensity: number;
  106775. /**
  106776. * Intensity of the emissive part of the material.
  106777. * This helps controlling the emissive effect without modifying the emissive color.
  106778. */
  106779. protected _emissiveIntensity: number;
  106780. /**
  106781. * Intensity of the environment e.g. how much the environment will light the object
  106782. * either through harmonics for rough material or through the refelction for shiny ones.
  106783. */
  106784. protected _environmentIntensity: number;
  106785. /**
  106786. * This is a special control allowing the reduction of the specular highlights coming from the
  106787. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106788. */
  106789. protected _specularIntensity: number;
  106790. /**
  106791. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106792. */
  106793. private _lightingInfos;
  106794. /**
  106795. * Debug Control allowing disabling the bump map on this material.
  106796. */
  106797. protected _disableBumpMap: boolean;
  106798. /**
  106799. * AKA Diffuse Texture in standard nomenclature.
  106800. */
  106801. protected _albedoTexture: Nullable<BaseTexture>;
  106802. /**
  106803. * AKA Occlusion Texture in other nomenclature.
  106804. */
  106805. protected _ambientTexture: Nullable<BaseTexture>;
  106806. /**
  106807. * AKA Occlusion Texture Intensity in other nomenclature.
  106808. */
  106809. protected _ambientTextureStrength: number;
  106810. /**
  106811. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106812. * 1 means it completely occludes it
  106813. * 0 mean it has no impact
  106814. */
  106815. protected _ambientTextureImpactOnAnalyticalLights: number;
  106816. /**
  106817. * Stores the alpha values in a texture.
  106818. */
  106819. protected _opacityTexture: Nullable<BaseTexture>;
  106820. /**
  106821. * Stores the reflection values in a texture.
  106822. */
  106823. protected _reflectionTexture: Nullable<BaseTexture>;
  106824. /**
  106825. * Stores the emissive values in a texture.
  106826. */
  106827. protected _emissiveTexture: Nullable<BaseTexture>;
  106828. /**
  106829. * AKA Specular texture in other nomenclature.
  106830. */
  106831. protected _reflectivityTexture: Nullable<BaseTexture>;
  106832. /**
  106833. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106834. */
  106835. protected _metallicTexture: Nullable<BaseTexture>;
  106836. /**
  106837. * Specifies the metallic scalar of the metallic/roughness workflow.
  106838. * Can also be used to scale the metalness values of the metallic texture.
  106839. */
  106840. protected _metallic: Nullable<number>;
  106841. /**
  106842. * Specifies the roughness scalar of the metallic/roughness workflow.
  106843. * Can also be used to scale the roughness values of the metallic texture.
  106844. */
  106845. protected _roughness: Nullable<number>;
  106846. /**
  106847. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106848. * By default the indexOfrefraction is used to compute F0;
  106849. *
  106850. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106851. *
  106852. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106853. * F90 = metallicReflectanceColor;
  106854. */
  106855. protected _metallicF0Factor: number;
  106856. /**
  106857. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106858. * By default the F90 is always 1;
  106859. *
  106860. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106861. *
  106862. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106863. * F90 = metallicReflectanceColor;
  106864. */
  106865. protected _metallicReflectanceColor: Color3;
  106866. /**
  106867. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106868. * This is multiply against the scalar values defined in the material.
  106869. */
  106870. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106871. /**
  106872. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106873. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106874. */
  106875. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106876. /**
  106877. * Stores surface normal data used to displace a mesh in a texture.
  106878. */
  106879. protected _bumpTexture: Nullable<BaseTexture>;
  106880. /**
  106881. * Stores the pre-calculated light information of a mesh in a texture.
  106882. */
  106883. protected _lightmapTexture: Nullable<BaseTexture>;
  106884. /**
  106885. * The color of a material in ambient lighting.
  106886. */
  106887. protected _ambientColor: Color3;
  106888. /**
  106889. * AKA Diffuse Color in other nomenclature.
  106890. */
  106891. protected _albedoColor: Color3;
  106892. /**
  106893. * AKA Specular Color in other nomenclature.
  106894. */
  106895. protected _reflectivityColor: Color3;
  106896. /**
  106897. * The color applied when light is reflected from a material.
  106898. */
  106899. protected _reflectionColor: Color3;
  106900. /**
  106901. * The color applied when light is emitted from a material.
  106902. */
  106903. protected _emissiveColor: Color3;
  106904. /**
  106905. * AKA Glossiness in other nomenclature.
  106906. */
  106907. protected _microSurface: number;
  106908. /**
  106909. * Specifies that the material will use the light map as a show map.
  106910. */
  106911. protected _useLightmapAsShadowmap: boolean;
  106912. /**
  106913. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106914. * makes the reflect vector face the model (under horizon).
  106915. */
  106916. protected _useHorizonOcclusion: boolean;
  106917. /**
  106918. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106919. * too much the area relying on ambient texture to define their ambient occlusion.
  106920. */
  106921. protected _useRadianceOcclusion: boolean;
  106922. /**
  106923. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106924. */
  106925. protected _useAlphaFromAlbedoTexture: boolean;
  106926. /**
  106927. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106928. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106929. */
  106930. protected _useSpecularOverAlpha: boolean;
  106931. /**
  106932. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106933. */
  106934. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106935. /**
  106936. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106937. */
  106938. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106939. /**
  106940. * Specifies if the metallic texture contains the roughness information in its green channel.
  106941. */
  106942. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106943. /**
  106944. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106945. */
  106946. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106947. /**
  106948. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106949. */
  106950. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106951. /**
  106952. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106953. */
  106954. protected _useAmbientInGrayScale: boolean;
  106955. /**
  106956. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106957. * The material will try to infer what glossiness each pixel should be.
  106958. */
  106959. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106960. /**
  106961. * Defines the falloff type used in this material.
  106962. * It by default is Physical.
  106963. */
  106964. protected _lightFalloff: number;
  106965. /**
  106966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106968. */
  106969. protected _useRadianceOverAlpha: boolean;
  106970. /**
  106971. * Allows using an object space normal map (instead of tangent space).
  106972. */
  106973. protected _useObjectSpaceNormalMap: boolean;
  106974. /**
  106975. * Allows using the bump map in parallax mode.
  106976. */
  106977. protected _useParallax: boolean;
  106978. /**
  106979. * Allows using the bump map in parallax occlusion mode.
  106980. */
  106981. protected _useParallaxOcclusion: boolean;
  106982. /**
  106983. * Controls the scale bias of the parallax mode.
  106984. */
  106985. protected _parallaxScaleBias: number;
  106986. /**
  106987. * If sets to true, disables all the lights affecting the material.
  106988. */
  106989. protected _disableLighting: boolean;
  106990. /**
  106991. * Number of Simultaneous lights allowed on the material.
  106992. */
  106993. protected _maxSimultaneousLights: number;
  106994. /**
  106995. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106996. */
  106997. protected _invertNormalMapX: boolean;
  106998. /**
  106999. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107000. */
  107001. protected _invertNormalMapY: boolean;
  107002. /**
  107003. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107004. */
  107005. protected _twoSidedLighting: boolean;
  107006. /**
  107007. * Defines the alpha limits in alpha test mode.
  107008. */
  107009. protected _alphaCutOff: number;
  107010. /**
  107011. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107012. */
  107013. protected _forceAlphaTest: boolean;
  107014. /**
  107015. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107016. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107017. */
  107018. protected _useAlphaFresnel: boolean;
  107019. /**
  107020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107021. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107022. */
  107023. protected _useLinearAlphaFresnel: boolean;
  107024. /**
  107025. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107026. * from cos thetav and roughness:
  107027. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107028. */
  107029. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107030. /**
  107031. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107032. */
  107033. protected _forceIrradianceInFragment: boolean;
  107034. private _realTimeFiltering;
  107035. /**
  107036. * Enables realtime filtering on the texture.
  107037. */
  107038. get realTimeFiltering(): boolean;
  107039. set realTimeFiltering(b: boolean);
  107040. private _realTimeFilteringQuality;
  107041. /**
  107042. * Quality switch for realtime filtering
  107043. */
  107044. get realTimeFilteringQuality(): number;
  107045. set realTimeFilteringQuality(n: number);
  107046. /**
  107047. * Can this material render to several textures at once
  107048. */
  107049. get canRenderToMRT(): boolean;
  107050. /**
  107051. * Force normal to face away from face.
  107052. */
  107053. protected _forceNormalForward: boolean;
  107054. /**
  107055. * Enables specular anti aliasing in the PBR shader.
  107056. * It will both interacts on the Geometry for analytical and IBL lighting.
  107057. * It also prefilter the roughness map based on the bump values.
  107058. */
  107059. protected _enableSpecularAntiAliasing: boolean;
  107060. /**
  107061. * Default configuration related to image processing available in the PBR Material.
  107062. */
  107063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107064. /**
  107065. * Keep track of the image processing observer to allow dispose and replace.
  107066. */
  107067. private _imageProcessingObserver;
  107068. /**
  107069. * Attaches a new image processing configuration to the PBR Material.
  107070. * @param configuration
  107071. */
  107072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107073. /**
  107074. * Stores the available render targets.
  107075. */
  107076. private _renderTargets;
  107077. /**
  107078. * Sets the global ambient color for the material used in lighting calculations.
  107079. */
  107080. private _globalAmbientColor;
  107081. /**
  107082. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107083. */
  107084. private _useLogarithmicDepth;
  107085. /**
  107086. * If set to true, no lighting calculations will be applied.
  107087. */
  107088. private _unlit;
  107089. private _debugMode;
  107090. /**
  107091. * @hidden
  107092. * This is reserved for the inspector.
  107093. * Defines the material debug mode.
  107094. * It helps seeing only some components of the material while troubleshooting.
  107095. */
  107096. debugMode: number;
  107097. /**
  107098. * @hidden
  107099. * This is reserved for the inspector.
  107100. * Specify from where on screen the debug mode should start.
  107101. * The value goes from -1 (full screen) to 1 (not visible)
  107102. * It helps with side by side comparison against the final render
  107103. * This defaults to -1
  107104. */
  107105. private debugLimit;
  107106. /**
  107107. * @hidden
  107108. * This is reserved for the inspector.
  107109. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107110. * You can use the factor to better multiply the final value.
  107111. */
  107112. private debugFactor;
  107113. /**
  107114. * Defines the clear coat layer parameters for the material.
  107115. */
  107116. readonly clearCoat: PBRClearCoatConfiguration;
  107117. /**
  107118. * Defines the anisotropic parameters for the material.
  107119. */
  107120. readonly anisotropy: PBRAnisotropicConfiguration;
  107121. /**
  107122. * Defines the BRDF parameters for the material.
  107123. */
  107124. readonly brdf: PBRBRDFConfiguration;
  107125. /**
  107126. * Defines the Sheen parameters for the material.
  107127. */
  107128. readonly sheen: PBRSheenConfiguration;
  107129. /**
  107130. * Defines the SubSurface parameters for the material.
  107131. */
  107132. readonly subSurface: PBRSubSurfaceConfiguration;
  107133. /**
  107134. * Defines additionnal PrePass parameters for the material.
  107135. */
  107136. readonly prePassConfiguration: PrePassConfiguration;
  107137. /**
  107138. * Defines the detail map parameters for the material.
  107139. */
  107140. readonly detailMap: DetailMapConfiguration;
  107141. protected _rebuildInParallel: boolean;
  107142. /**
  107143. * Instantiates a new PBRMaterial instance.
  107144. *
  107145. * @param name The material name
  107146. * @param scene The scene the material will be use in.
  107147. */
  107148. constructor(name: string, scene: Scene);
  107149. /**
  107150. * Gets a boolean indicating that current material needs to register RTT
  107151. */
  107152. get hasRenderTargetTextures(): boolean;
  107153. /**
  107154. * Gets the name of the material class.
  107155. */
  107156. getClassName(): string;
  107157. /**
  107158. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107159. */
  107160. get useLogarithmicDepth(): boolean;
  107161. /**
  107162. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107163. */
  107164. set useLogarithmicDepth(value: boolean);
  107165. /**
  107166. * Returns true if alpha blending should be disabled.
  107167. */
  107168. protected get _disableAlphaBlending(): boolean;
  107169. /**
  107170. * Specifies whether or not this material should be rendered in alpha blend mode.
  107171. */
  107172. needAlphaBlending(): boolean;
  107173. /**
  107174. * Specifies whether or not this material should be rendered in alpha test mode.
  107175. */
  107176. needAlphaTesting(): boolean;
  107177. /**
  107178. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107179. */
  107180. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107181. /**
  107182. * Gets the texture used for the alpha test.
  107183. */
  107184. getAlphaTestTexture(): Nullable<BaseTexture>;
  107185. /**
  107186. * Specifies that the submesh is ready to be used.
  107187. * @param mesh - BJS mesh.
  107188. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107189. * @param useInstances - Specifies that instances should be used.
  107190. * @returns - boolean indicating that the submesh is ready or not.
  107191. */
  107192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107193. /**
  107194. * Specifies if the material uses metallic roughness workflow.
  107195. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107196. */
  107197. isMetallicWorkflow(): boolean;
  107198. private _prepareEffect;
  107199. private _prepareDefines;
  107200. /**
  107201. * Force shader compilation
  107202. */
  107203. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107204. /**
  107205. * Initializes the uniform buffer layout for the shader.
  107206. */
  107207. buildUniformLayout(): void;
  107208. /**
  107209. * Unbinds the material from the mesh
  107210. */
  107211. unbind(): void;
  107212. /**
  107213. * Binds the submesh data.
  107214. * @param world - The world matrix.
  107215. * @param mesh - The BJS mesh.
  107216. * @param subMesh - A submesh of the BJS mesh.
  107217. */
  107218. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107219. /**
  107220. * Returns the animatable textures.
  107221. * @returns - Array of animatable textures.
  107222. */
  107223. getAnimatables(): IAnimatable[];
  107224. /**
  107225. * Returns the texture used for reflections.
  107226. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107227. */
  107228. private _getReflectionTexture;
  107229. /**
  107230. * Returns an array of the actively used textures.
  107231. * @returns - Array of BaseTextures
  107232. */
  107233. getActiveTextures(): BaseTexture[];
  107234. /**
  107235. * Checks to see if a texture is used in the material.
  107236. * @param texture - Base texture to use.
  107237. * @returns - Boolean specifying if a texture is used in the material.
  107238. */
  107239. hasTexture(texture: BaseTexture): boolean;
  107240. /**
  107241. * Sets the required values to the prepass renderer.
  107242. * @param prePassRenderer defines the prepass renderer to setup
  107243. */
  107244. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107245. /**
  107246. * Disposes the resources of the material.
  107247. * @param forceDisposeEffect - Forces the disposal of effects.
  107248. * @param forceDisposeTextures - Forces the disposal of all textures.
  107249. */
  107250. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107251. }
  107252. }
  107253. declare module BABYLON {
  107254. /**
  107255. * The Physically based material of BJS.
  107256. *
  107257. * This offers the main features of a standard PBR material.
  107258. * For more information, please refer to the documentation :
  107259. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107260. */
  107261. export class PBRMaterial extends PBRBaseMaterial {
  107262. /**
  107263. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107264. */
  107265. static readonly PBRMATERIAL_OPAQUE: number;
  107266. /**
  107267. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107268. */
  107269. static readonly PBRMATERIAL_ALPHATEST: number;
  107270. /**
  107271. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107272. */
  107273. static readonly PBRMATERIAL_ALPHABLEND: number;
  107274. /**
  107275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107276. * They are also discarded below the alpha cutoff threshold to improve performances.
  107277. */
  107278. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107279. /**
  107280. * Defines the default value of how much AO map is occluding the analytical lights
  107281. * (point spot...).
  107282. */
  107283. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107284. /**
  107285. * Intensity of the direct lights e.g. the four lights available in your scene.
  107286. * This impacts both the direct diffuse and specular highlights.
  107287. */
  107288. directIntensity: number;
  107289. /**
  107290. * Intensity of the emissive part of the material.
  107291. * This helps controlling the emissive effect without modifying the emissive color.
  107292. */
  107293. emissiveIntensity: number;
  107294. /**
  107295. * Intensity of the environment e.g. how much the environment will light the object
  107296. * either through harmonics for rough material or through the refelction for shiny ones.
  107297. */
  107298. environmentIntensity: number;
  107299. /**
  107300. * This is a special control allowing the reduction of the specular highlights coming from the
  107301. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107302. */
  107303. specularIntensity: number;
  107304. /**
  107305. * Debug Control allowing disabling the bump map on this material.
  107306. */
  107307. disableBumpMap: boolean;
  107308. /**
  107309. * AKA Diffuse Texture in standard nomenclature.
  107310. */
  107311. albedoTexture: BaseTexture;
  107312. /**
  107313. * AKA Occlusion Texture in other nomenclature.
  107314. */
  107315. ambientTexture: BaseTexture;
  107316. /**
  107317. * AKA Occlusion Texture Intensity in other nomenclature.
  107318. */
  107319. ambientTextureStrength: number;
  107320. /**
  107321. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107322. * 1 means it completely occludes it
  107323. * 0 mean it has no impact
  107324. */
  107325. ambientTextureImpactOnAnalyticalLights: number;
  107326. /**
  107327. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107328. */
  107329. opacityTexture: BaseTexture;
  107330. /**
  107331. * Stores the reflection values in a texture.
  107332. */
  107333. reflectionTexture: Nullable<BaseTexture>;
  107334. /**
  107335. * Stores the emissive values in a texture.
  107336. */
  107337. emissiveTexture: BaseTexture;
  107338. /**
  107339. * AKA Specular texture in other nomenclature.
  107340. */
  107341. reflectivityTexture: BaseTexture;
  107342. /**
  107343. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107344. */
  107345. metallicTexture: BaseTexture;
  107346. /**
  107347. * Specifies the metallic scalar of the metallic/roughness workflow.
  107348. * Can also be used to scale the metalness values of the metallic texture.
  107349. */
  107350. metallic: Nullable<number>;
  107351. /**
  107352. * Specifies the roughness scalar of the metallic/roughness workflow.
  107353. * Can also be used to scale the roughness values of the metallic texture.
  107354. */
  107355. roughness: Nullable<number>;
  107356. /**
  107357. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107358. * By default the indexOfrefraction is used to compute F0;
  107359. *
  107360. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107361. *
  107362. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107363. * F90 = metallicReflectanceColor;
  107364. */
  107365. metallicF0Factor: number;
  107366. /**
  107367. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107368. * By default the F90 is always 1;
  107369. *
  107370. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107371. *
  107372. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107373. * F90 = metallicReflectanceColor;
  107374. */
  107375. metallicReflectanceColor: Color3;
  107376. /**
  107377. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107378. * This is multiply against the scalar values defined in the material.
  107379. */
  107380. metallicReflectanceTexture: Nullable<BaseTexture>;
  107381. /**
  107382. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107383. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107384. */
  107385. microSurfaceTexture: BaseTexture;
  107386. /**
  107387. * Stores surface normal data used to displace a mesh in a texture.
  107388. */
  107389. bumpTexture: BaseTexture;
  107390. /**
  107391. * Stores the pre-calculated light information of a mesh in a texture.
  107392. */
  107393. lightmapTexture: BaseTexture;
  107394. /**
  107395. * Stores the refracted light information in a texture.
  107396. */
  107397. get refractionTexture(): Nullable<BaseTexture>;
  107398. set refractionTexture(value: Nullable<BaseTexture>);
  107399. /**
  107400. * The color of a material in ambient lighting.
  107401. */
  107402. ambientColor: Color3;
  107403. /**
  107404. * AKA Diffuse Color in other nomenclature.
  107405. */
  107406. albedoColor: Color3;
  107407. /**
  107408. * AKA Specular Color in other nomenclature.
  107409. */
  107410. reflectivityColor: Color3;
  107411. /**
  107412. * The color reflected from the material.
  107413. */
  107414. reflectionColor: Color3;
  107415. /**
  107416. * The color emitted from the material.
  107417. */
  107418. emissiveColor: Color3;
  107419. /**
  107420. * AKA Glossiness in other nomenclature.
  107421. */
  107422. microSurface: number;
  107423. /**
  107424. * Index of refraction of the material base layer.
  107425. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107426. *
  107427. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107428. *
  107429. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107430. */
  107431. get indexOfRefraction(): number;
  107432. set indexOfRefraction(value: number);
  107433. /**
  107434. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107435. */
  107436. get invertRefractionY(): boolean;
  107437. set invertRefractionY(value: boolean);
  107438. /**
  107439. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107440. * Materials half opaque for instance using refraction could benefit from this control.
  107441. */
  107442. get linkRefractionWithTransparency(): boolean;
  107443. set linkRefractionWithTransparency(value: boolean);
  107444. /**
  107445. * If true, the light map contains occlusion information instead of lighting info.
  107446. */
  107447. useLightmapAsShadowmap: boolean;
  107448. /**
  107449. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107450. */
  107451. useAlphaFromAlbedoTexture: boolean;
  107452. /**
  107453. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107454. */
  107455. forceAlphaTest: boolean;
  107456. /**
  107457. * Defines the alpha limits in alpha test mode.
  107458. */
  107459. alphaCutOff: number;
  107460. /**
  107461. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107462. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107463. */
  107464. useSpecularOverAlpha: boolean;
  107465. /**
  107466. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107467. */
  107468. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107469. /**
  107470. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107471. */
  107472. useRoughnessFromMetallicTextureAlpha: boolean;
  107473. /**
  107474. * Specifies if the metallic texture contains the roughness information in its green channel.
  107475. */
  107476. useRoughnessFromMetallicTextureGreen: boolean;
  107477. /**
  107478. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107479. */
  107480. useMetallnessFromMetallicTextureBlue: boolean;
  107481. /**
  107482. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107483. */
  107484. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107485. /**
  107486. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107487. */
  107488. useAmbientInGrayScale: boolean;
  107489. /**
  107490. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107491. * The material will try to infer what glossiness each pixel should be.
  107492. */
  107493. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107494. /**
  107495. * BJS is using an harcoded light falloff based on a manually sets up range.
  107496. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107497. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107498. */
  107499. get usePhysicalLightFalloff(): boolean;
  107500. /**
  107501. * BJS is using an harcoded light falloff based on a manually sets up range.
  107502. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107503. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107504. */
  107505. set usePhysicalLightFalloff(value: boolean);
  107506. /**
  107507. * In order to support the falloff compatibility with gltf, a special mode has been added
  107508. * to reproduce the gltf light falloff.
  107509. */
  107510. get useGLTFLightFalloff(): boolean;
  107511. /**
  107512. * In order to support the falloff compatibility with gltf, a special mode has been added
  107513. * to reproduce the gltf light falloff.
  107514. */
  107515. set useGLTFLightFalloff(value: boolean);
  107516. /**
  107517. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107518. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107519. */
  107520. useRadianceOverAlpha: boolean;
  107521. /**
  107522. * Allows using an object space normal map (instead of tangent space).
  107523. */
  107524. useObjectSpaceNormalMap: boolean;
  107525. /**
  107526. * Allows using the bump map in parallax mode.
  107527. */
  107528. useParallax: boolean;
  107529. /**
  107530. * Allows using the bump map in parallax occlusion mode.
  107531. */
  107532. useParallaxOcclusion: boolean;
  107533. /**
  107534. * Controls the scale bias of the parallax mode.
  107535. */
  107536. parallaxScaleBias: number;
  107537. /**
  107538. * If sets to true, disables all the lights affecting the material.
  107539. */
  107540. disableLighting: boolean;
  107541. /**
  107542. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107543. */
  107544. forceIrradianceInFragment: boolean;
  107545. /**
  107546. * Number of Simultaneous lights allowed on the material.
  107547. */
  107548. maxSimultaneousLights: number;
  107549. /**
  107550. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107551. */
  107552. invertNormalMapX: boolean;
  107553. /**
  107554. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107555. */
  107556. invertNormalMapY: boolean;
  107557. /**
  107558. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107559. */
  107560. twoSidedLighting: boolean;
  107561. /**
  107562. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107563. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107564. */
  107565. useAlphaFresnel: boolean;
  107566. /**
  107567. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107568. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107569. */
  107570. useLinearAlphaFresnel: boolean;
  107571. /**
  107572. * Let user defines the brdf lookup texture used for IBL.
  107573. * A default 8bit version is embedded but you could point at :
  107574. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107575. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107576. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107577. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107578. */
  107579. environmentBRDFTexture: Nullable<BaseTexture>;
  107580. /**
  107581. * Force normal to face away from face.
  107582. */
  107583. forceNormalForward: boolean;
  107584. /**
  107585. * Enables specular anti aliasing in the PBR shader.
  107586. * It will both interacts on the Geometry for analytical and IBL lighting.
  107587. * It also prefilter the roughness map based on the bump values.
  107588. */
  107589. enableSpecularAntiAliasing: boolean;
  107590. /**
  107591. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107592. * makes the reflect vector face the model (under horizon).
  107593. */
  107594. useHorizonOcclusion: boolean;
  107595. /**
  107596. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107597. * too much the area relying on ambient texture to define their ambient occlusion.
  107598. */
  107599. useRadianceOcclusion: boolean;
  107600. /**
  107601. * If set to true, no lighting calculations will be applied.
  107602. */
  107603. unlit: boolean;
  107604. /**
  107605. * Gets the image processing configuration used either in this material.
  107606. */
  107607. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107608. /**
  107609. * Sets the Default image processing configuration used either in the this material.
  107610. *
  107611. * If sets to null, the scene one is in use.
  107612. */
  107613. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107614. /**
  107615. * Gets wether the color curves effect is enabled.
  107616. */
  107617. get cameraColorCurvesEnabled(): boolean;
  107618. /**
  107619. * Sets wether the color curves effect is enabled.
  107620. */
  107621. set cameraColorCurvesEnabled(value: boolean);
  107622. /**
  107623. * Gets wether the color grading effect is enabled.
  107624. */
  107625. get cameraColorGradingEnabled(): boolean;
  107626. /**
  107627. * Gets wether the color grading effect is enabled.
  107628. */
  107629. set cameraColorGradingEnabled(value: boolean);
  107630. /**
  107631. * Gets wether tonemapping is enabled or not.
  107632. */
  107633. get cameraToneMappingEnabled(): boolean;
  107634. /**
  107635. * Sets wether tonemapping is enabled or not
  107636. */
  107637. set cameraToneMappingEnabled(value: boolean);
  107638. /**
  107639. * The camera exposure used on this material.
  107640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107641. * This corresponds to a photographic exposure.
  107642. */
  107643. get cameraExposure(): number;
  107644. /**
  107645. * The camera exposure used on this material.
  107646. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107647. * This corresponds to a photographic exposure.
  107648. */
  107649. set cameraExposure(value: number);
  107650. /**
  107651. * Gets The camera contrast used on this material.
  107652. */
  107653. get cameraContrast(): number;
  107654. /**
  107655. * Sets The camera contrast used on this material.
  107656. */
  107657. set cameraContrast(value: number);
  107658. /**
  107659. * Gets the Color Grading 2D Lookup Texture.
  107660. */
  107661. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107662. /**
  107663. * Sets the Color Grading 2D Lookup Texture.
  107664. */
  107665. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107666. /**
  107667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107669. * 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;
  107670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107671. */
  107672. get cameraColorCurves(): Nullable<ColorCurves>;
  107673. /**
  107674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107676. * 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;
  107677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107678. */
  107679. set cameraColorCurves(value: Nullable<ColorCurves>);
  107680. /**
  107681. * Instantiates a new PBRMaterial instance.
  107682. *
  107683. * @param name The material name
  107684. * @param scene The scene the material will be use in.
  107685. */
  107686. constructor(name: string, scene: Scene);
  107687. /**
  107688. * Returns the name of this material class.
  107689. */
  107690. getClassName(): string;
  107691. /**
  107692. * Makes a duplicate of the current material.
  107693. * @param name - name to use for the new material.
  107694. */
  107695. clone(name: string): PBRMaterial;
  107696. /**
  107697. * Serializes this PBR Material.
  107698. * @returns - An object with the serialized material.
  107699. */
  107700. serialize(): any;
  107701. /**
  107702. * Parses a PBR Material from a serialized object.
  107703. * @param source - Serialized object.
  107704. * @param scene - BJS scene instance.
  107705. * @param rootUrl - url for the scene object
  107706. * @returns - PBRMaterial
  107707. */
  107708. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107709. }
  107710. }
  107711. declare module BABYLON {
  107712. /** @hidden */
  107713. export var mrtFragmentDeclaration: {
  107714. name: string;
  107715. shader: string;
  107716. };
  107717. }
  107718. declare module BABYLON {
  107719. /** @hidden */
  107720. export var geometryPixelShader: {
  107721. name: string;
  107722. shader: string;
  107723. };
  107724. }
  107725. declare module BABYLON {
  107726. /** @hidden */
  107727. export var geometryVertexShader: {
  107728. name: string;
  107729. shader: string;
  107730. };
  107731. }
  107732. declare module BABYLON {
  107733. /** @hidden */
  107734. interface ISavedTransformationMatrix {
  107735. world: Matrix;
  107736. viewProjection: Matrix;
  107737. }
  107738. /**
  107739. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107740. */
  107741. export class GeometryBufferRenderer {
  107742. /**
  107743. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107744. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107745. */
  107746. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107747. /**
  107748. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107749. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107750. */
  107751. static readonly POSITION_TEXTURE_TYPE: number;
  107752. /**
  107753. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107754. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107755. */
  107756. static readonly VELOCITY_TEXTURE_TYPE: number;
  107757. /**
  107758. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107759. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107760. */
  107761. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107762. /**
  107763. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107764. * in order to compute objects velocities when enableVelocity is set to "true"
  107765. * @hidden
  107766. */
  107767. _previousTransformationMatrices: {
  107768. [index: number]: ISavedTransformationMatrix;
  107769. };
  107770. /**
  107771. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107772. * in order to compute objects velocities when enableVelocity is set to "true"
  107773. * @hidden
  107774. */
  107775. _previousBonesTransformationMatrices: {
  107776. [index: number]: Float32Array;
  107777. };
  107778. /**
  107779. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107780. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107781. */
  107782. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107783. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107784. renderTransparentMeshes: boolean;
  107785. private _scene;
  107786. private _resizeObserver;
  107787. private _multiRenderTarget;
  107788. private _ratio;
  107789. private _enablePosition;
  107790. private _enableVelocity;
  107791. private _enableReflectivity;
  107792. private _positionIndex;
  107793. private _velocityIndex;
  107794. private _reflectivityIndex;
  107795. private _depthNormalIndex;
  107796. private _linkedWithPrePass;
  107797. private _prePassRenderer;
  107798. private _attachments;
  107799. protected _effect: Effect;
  107800. protected _cachedDefines: string;
  107801. /**
  107802. * @hidden
  107803. * Sets up internal structures to share outputs with PrePassRenderer
  107804. * This method should only be called by the PrePassRenderer itself
  107805. */
  107806. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107807. /**
  107808. * @hidden
  107809. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107810. * This method should only be called by the PrePassRenderer itself
  107811. */
  107812. _unlinkPrePassRenderer(): void;
  107813. /**
  107814. * @hidden
  107815. * Resets the geometry buffer layout
  107816. */
  107817. _resetLayout(): void;
  107818. /**
  107819. * @hidden
  107820. * Replaces a texture in the geometry buffer renderer
  107821. * Useful when linking textures of the prepass renderer
  107822. */
  107823. _forceTextureType(geometryBufferType: number, index: number): void;
  107824. /**
  107825. * @hidden
  107826. * Sets texture attachments
  107827. * Useful when linking textures of the prepass renderer
  107828. */
  107829. _setAttachments(attachments: number[]): void;
  107830. /**
  107831. * @hidden
  107832. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107833. * Useful when linking textures of the prepass renderer
  107834. */
  107835. _linkInternalTexture(internalTexture: InternalTexture): void;
  107836. /**
  107837. * Gets the render list (meshes to be rendered) used in the G buffer.
  107838. */
  107839. get renderList(): Nullable<AbstractMesh[]>;
  107840. /**
  107841. * Set the render list (meshes to be rendered) used in the G buffer.
  107842. */
  107843. set renderList(meshes: Nullable<AbstractMesh[]>);
  107844. /**
  107845. * Gets wether or not G buffer are supported by the running hardware.
  107846. * This requires draw buffer supports
  107847. */
  107848. get isSupported(): boolean;
  107849. /**
  107850. * Returns the index of the given texture type in the G-Buffer textures array
  107851. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107852. * @returns the index of the given texture type in the G-Buffer textures array
  107853. */
  107854. getTextureIndex(textureType: number): number;
  107855. /**
  107856. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107857. */
  107858. get enablePosition(): boolean;
  107859. /**
  107860. * Sets whether or not objects positions are enabled for the G buffer.
  107861. */
  107862. set enablePosition(enable: boolean);
  107863. /**
  107864. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107865. */
  107866. get enableVelocity(): boolean;
  107867. /**
  107868. * Sets wether or not objects velocities are enabled for the G buffer.
  107869. */
  107870. set enableVelocity(enable: boolean);
  107871. /**
  107872. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107873. */
  107874. get enableReflectivity(): boolean;
  107875. /**
  107876. * Sets wether or not objects roughness are enabled for the G buffer.
  107877. */
  107878. set enableReflectivity(enable: boolean);
  107879. /**
  107880. * Gets the scene associated with the buffer.
  107881. */
  107882. get scene(): Scene;
  107883. /**
  107884. * Gets the ratio used by the buffer during its creation.
  107885. * How big is the buffer related to the main canvas.
  107886. */
  107887. get ratio(): number;
  107888. /** @hidden */
  107889. static _SceneComponentInitialization: (scene: Scene) => void;
  107890. /**
  107891. * Creates a new G Buffer for the scene
  107892. * @param scene The scene the buffer belongs to
  107893. * @param ratio How big is the buffer related to the main canvas.
  107894. */
  107895. constructor(scene: Scene, ratio?: number);
  107896. /**
  107897. * Checks wether everything is ready to render a submesh to the G buffer.
  107898. * @param subMesh the submesh to check readiness for
  107899. * @param useInstances is the mesh drawn using instance or not
  107900. * @returns true if ready otherwise false
  107901. */
  107902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107903. /**
  107904. * Gets the current underlying G Buffer.
  107905. * @returns the buffer
  107906. */
  107907. getGBuffer(): MultiRenderTarget;
  107908. /**
  107909. * Gets the number of samples used to render the buffer (anti aliasing).
  107910. */
  107911. get samples(): number;
  107912. /**
  107913. * Sets the number of samples used to render the buffer (anti aliasing).
  107914. */
  107915. set samples(value: number);
  107916. /**
  107917. * Disposes the renderer and frees up associated resources.
  107918. */
  107919. dispose(): void;
  107920. private _assignRenderTargetIndices;
  107921. protected _createRenderTargets(): void;
  107922. private _copyBonesTransformationMatrices;
  107923. }
  107924. }
  107925. declare module BABYLON {
  107926. /**
  107927. * Renders a pre pass of the scene
  107928. * This means every mesh in the scene will be rendered to a render target texture
  107929. * And then this texture will be composited to the rendering canvas with post processes
  107930. * It is necessary for effects like subsurface scattering or deferred shading
  107931. */
  107932. export class PrePassRenderer {
  107933. /** @hidden */
  107934. static _SceneComponentInitialization: (scene: Scene) => void;
  107935. private _textureFormats;
  107936. /**
  107937. * To save performance, we can excluded skinned meshes from the prepass
  107938. */
  107939. excludedSkinnedMesh: AbstractMesh[];
  107940. /**
  107941. * Force material to be excluded from the prepass
  107942. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107943. * and you don't want a material to show in the effect.
  107944. */
  107945. excludedMaterials: Material[];
  107946. private _textureIndices;
  107947. private _scene;
  107948. private _engine;
  107949. private _isDirty;
  107950. /**
  107951. * Number of textures in the multi render target texture where the scene is directly rendered
  107952. */
  107953. mrtCount: number;
  107954. /**
  107955. * The render target where the scene is directly rendered
  107956. */
  107957. prePassRT: MultiRenderTarget;
  107958. private _multiRenderAttachments;
  107959. private _defaultAttachments;
  107960. private _clearAttachments;
  107961. private _postProcesses;
  107962. private readonly _clearColor;
  107963. /**
  107964. * Image processing post process for composition
  107965. */
  107966. imageProcessingPostProcess: ImageProcessingPostProcess;
  107967. /**
  107968. * Configuration for prepass effects
  107969. */
  107970. private _effectConfigurations;
  107971. private _mrtFormats;
  107972. private _mrtLayout;
  107973. private _enabled;
  107974. /**
  107975. * Indicates if the prepass is enabled
  107976. */
  107977. get enabled(): boolean;
  107978. /**
  107979. * How many samples are used for MSAA of the scene render target
  107980. */
  107981. get samples(): number;
  107982. set samples(n: number);
  107983. private _geometryBuffer;
  107984. private _useGeometryBufferFallback;
  107985. /**
  107986. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107987. */
  107988. get useGeometryBufferFallback(): boolean;
  107989. set useGeometryBufferFallback(value: boolean);
  107990. /**
  107991. * Instanciates a prepass renderer
  107992. * @param scene The scene
  107993. */
  107994. constructor(scene: Scene);
  107995. private _initializeAttachments;
  107996. private _createCompositionEffect;
  107997. /**
  107998. * Indicates if rendering a prepass is supported
  107999. */
  108000. get isSupported(): boolean;
  108001. /**
  108002. * Sets the proper output textures to draw in the engine.
  108003. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108004. * @param subMesh Submesh on which the effect is applied
  108005. */
  108006. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108007. /**
  108008. * @hidden
  108009. */
  108010. _beforeCameraDraw(): void;
  108011. /**
  108012. * @hidden
  108013. */
  108014. _afterCameraDraw(): void;
  108015. private _checkRTSize;
  108016. private _bindFrameBuffer;
  108017. /**
  108018. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108019. */
  108020. clear(): void;
  108021. private _setState;
  108022. private _updateGeometryBufferLayout;
  108023. /**
  108024. * Adds an effect configuration to the prepass.
  108025. * If an effect has already been added, it won't add it twice and will return the configuration
  108026. * already present.
  108027. * @param cfg the effect configuration
  108028. * @return the effect configuration now used by the prepass
  108029. */
  108030. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108031. /**
  108032. * Returns the index of a texture in the multi render target texture array.
  108033. * @param type Texture type
  108034. * @return The index
  108035. */
  108036. getIndex(type: number): number;
  108037. private _enable;
  108038. private _disable;
  108039. private _resetLayout;
  108040. private _resetPostProcessChain;
  108041. private _bindPostProcessChain;
  108042. /**
  108043. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108044. */
  108045. markAsDirty(): void;
  108046. /**
  108047. * Enables a texture on the MultiRenderTarget for prepass
  108048. */
  108049. private _enableTextures;
  108050. private _update;
  108051. private _markAllMaterialsAsPrePassDirty;
  108052. /**
  108053. * Disposes the prepass renderer.
  108054. */
  108055. dispose(): void;
  108056. }
  108057. }
  108058. declare module BABYLON {
  108059. /**
  108060. * Size options for a post process
  108061. */
  108062. export type PostProcessOptions = {
  108063. width: number;
  108064. height: number;
  108065. };
  108066. /**
  108067. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108068. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108069. */
  108070. export class PostProcess {
  108071. /**
  108072. * Gets or sets the unique id of the post process
  108073. */
  108074. uniqueId: number;
  108075. /** Name of the PostProcess. */
  108076. name: string;
  108077. /**
  108078. * Width of the texture to apply the post process on
  108079. */
  108080. width: number;
  108081. /**
  108082. * Height of the texture to apply the post process on
  108083. */
  108084. height: number;
  108085. /**
  108086. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108087. */
  108088. nodeMaterialSource: Nullable<NodeMaterial>;
  108089. /**
  108090. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108091. * @hidden
  108092. */
  108093. _outputTexture: Nullable<InternalTexture>;
  108094. /**
  108095. * Sampling mode used by the shader
  108096. * See https://doc.babylonjs.com/classes/3.1/texture
  108097. */
  108098. renderTargetSamplingMode: number;
  108099. /**
  108100. * Clear color to use when screen clearing
  108101. */
  108102. clearColor: Color4;
  108103. /**
  108104. * If the buffer needs to be cleared before applying the post process. (default: true)
  108105. * Should be set to false if shader will overwrite all previous pixels.
  108106. */
  108107. autoClear: boolean;
  108108. /**
  108109. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108110. */
  108111. alphaMode: number;
  108112. /**
  108113. * Sets the setAlphaBlendConstants of the babylon engine
  108114. */
  108115. alphaConstants: Color4;
  108116. /**
  108117. * Animations to be used for the post processing
  108118. */
  108119. animations: Animation[];
  108120. /**
  108121. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108122. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108123. */
  108124. enablePixelPerfectMode: boolean;
  108125. /**
  108126. * Force the postprocess to be applied without taking in account viewport
  108127. */
  108128. forceFullscreenViewport: boolean;
  108129. /**
  108130. * List of inspectable custom properties (used by the Inspector)
  108131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108132. */
  108133. inspectableCustomProperties: IInspectable[];
  108134. /**
  108135. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108136. *
  108137. * | Value | Type | Description |
  108138. * | ----- | ----------------------------------- | ----------- |
  108139. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108140. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108141. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108142. *
  108143. */
  108144. scaleMode: number;
  108145. /**
  108146. * Force textures to be a power of two (default: false)
  108147. */
  108148. alwaysForcePOT: boolean;
  108149. private _samples;
  108150. /**
  108151. * Number of sample textures (default: 1)
  108152. */
  108153. get samples(): number;
  108154. set samples(n: number);
  108155. /**
  108156. * Modify the scale of the post process to be the same as the viewport (default: false)
  108157. */
  108158. adaptScaleToCurrentViewport: boolean;
  108159. private _camera;
  108160. protected _scene: Scene;
  108161. private _engine;
  108162. private _options;
  108163. private _reusable;
  108164. private _textureType;
  108165. private _textureFormat;
  108166. /**
  108167. * Smart array of input and output textures for the post process.
  108168. * @hidden
  108169. */
  108170. _textures: SmartArray<InternalTexture>;
  108171. /**
  108172. * The index in _textures that corresponds to the output texture.
  108173. * @hidden
  108174. */
  108175. _currentRenderTextureInd: number;
  108176. private _effect;
  108177. private _samplers;
  108178. private _fragmentUrl;
  108179. private _vertexUrl;
  108180. private _parameters;
  108181. private _scaleRatio;
  108182. protected _indexParameters: any;
  108183. private _shareOutputWithPostProcess;
  108184. private _texelSize;
  108185. private _forcedOutputTexture;
  108186. /**
  108187. * Prepass configuration in case this post process needs a texture from prepass
  108188. * @hidden
  108189. */
  108190. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108191. /**
  108192. * Returns the fragment url or shader name used in the post process.
  108193. * @returns the fragment url or name in the shader store.
  108194. */
  108195. getEffectName(): string;
  108196. /**
  108197. * An event triggered when the postprocess is activated.
  108198. */
  108199. onActivateObservable: Observable<Camera>;
  108200. private _onActivateObserver;
  108201. /**
  108202. * A function that is added to the onActivateObservable
  108203. */
  108204. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108205. /**
  108206. * An event triggered when the postprocess changes its size.
  108207. */
  108208. onSizeChangedObservable: Observable<PostProcess>;
  108209. private _onSizeChangedObserver;
  108210. /**
  108211. * A function that is added to the onSizeChangedObservable
  108212. */
  108213. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108214. /**
  108215. * An event triggered when the postprocess applies its effect.
  108216. */
  108217. onApplyObservable: Observable<Effect>;
  108218. private _onApplyObserver;
  108219. /**
  108220. * A function that is added to the onApplyObservable
  108221. */
  108222. set onApply(callback: (effect: Effect) => void);
  108223. /**
  108224. * An event triggered before rendering the postprocess
  108225. */
  108226. onBeforeRenderObservable: Observable<Effect>;
  108227. private _onBeforeRenderObserver;
  108228. /**
  108229. * A function that is added to the onBeforeRenderObservable
  108230. */
  108231. set onBeforeRender(callback: (effect: Effect) => void);
  108232. /**
  108233. * An event triggered after rendering the postprocess
  108234. */
  108235. onAfterRenderObservable: Observable<Effect>;
  108236. private _onAfterRenderObserver;
  108237. /**
  108238. * A function that is added to the onAfterRenderObservable
  108239. */
  108240. set onAfterRender(callback: (efect: Effect) => void);
  108241. /**
  108242. * 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
  108243. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108244. */
  108245. get inputTexture(): InternalTexture;
  108246. set inputTexture(value: InternalTexture);
  108247. /**
  108248. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108249. * the only way to unset it is to use this function to restore its internal state
  108250. */
  108251. restoreDefaultInputTexture(): void;
  108252. /**
  108253. * Gets the camera which post process is applied to.
  108254. * @returns The camera the post process is applied to.
  108255. */
  108256. getCamera(): Camera;
  108257. /**
  108258. * Gets the texel size of the postprocess.
  108259. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108260. */
  108261. get texelSize(): Vector2;
  108262. /**
  108263. * Creates a new instance PostProcess
  108264. * @param name The name of the PostProcess.
  108265. * @param fragmentUrl The url of the fragment shader to be used.
  108266. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108267. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108268. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108269. * @param camera The camera to apply the render pass to.
  108270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108271. * @param engine The engine which the post process will be applied. (default: current engine)
  108272. * @param reusable If the post process can be reused on the same frame. (default: false)
  108273. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108274. * @param textureType Type of textures used when performing the post process. (default: 0)
  108275. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108276. * @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
  108277. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108278. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108279. */
  108280. 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);
  108281. /**
  108282. * Gets a string identifying the name of the class
  108283. * @returns "PostProcess" string
  108284. */
  108285. getClassName(): string;
  108286. /**
  108287. * Gets the engine which this post process belongs to.
  108288. * @returns The engine the post process was enabled with.
  108289. */
  108290. getEngine(): Engine;
  108291. /**
  108292. * The effect that is created when initializing the post process.
  108293. * @returns The created effect corresponding the the postprocess.
  108294. */
  108295. getEffect(): Effect;
  108296. /**
  108297. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108298. * @param postProcess The post process to share the output with.
  108299. * @returns This post process.
  108300. */
  108301. shareOutputWith(postProcess: PostProcess): PostProcess;
  108302. /**
  108303. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108304. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108305. */
  108306. useOwnOutput(): void;
  108307. /**
  108308. * Updates the effect with the current post process compile time values and recompiles the shader.
  108309. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108310. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108311. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108312. * @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
  108313. * @param onCompiled Called when the shader has been compiled.
  108314. * @param onError Called if there is an error when compiling a shader.
  108315. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108316. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108317. */
  108318. 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;
  108319. /**
  108320. * The post process is reusable if it can be used multiple times within one frame.
  108321. * @returns If the post process is reusable
  108322. */
  108323. isReusable(): boolean;
  108324. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108325. markTextureDirty(): void;
  108326. /**
  108327. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108328. * 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.
  108329. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108330. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108331. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108332. * @returns The target texture that was bound to be written to.
  108333. */
  108334. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108335. /**
  108336. * If the post process is supported.
  108337. */
  108338. get isSupported(): boolean;
  108339. /**
  108340. * The aspect ratio of the output texture.
  108341. */
  108342. get aspectRatio(): number;
  108343. /**
  108344. * Get a value indicating if the post-process is ready to be used
  108345. * @returns true if the post-process is ready (shader is compiled)
  108346. */
  108347. isReady(): boolean;
  108348. /**
  108349. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108350. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108351. */
  108352. apply(): Nullable<Effect>;
  108353. private _disposeTextures;
  108354. /**
  108355. * Sets the required values to the prepass renderer.
  108356. * @param prePassRenderer defines the prepass renderer to setup.
  108357. * @returns true if the pre pass is needed.
  108358. */
  108359. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108360. /**
  108361. * Disposes the post process.
  108362. * @param camera The camera to dispose the post process on.
  108363. */
  108364. dispose(camera?: Camera): void;
  108365. /**
  108366. * Serializes the particle system to a JSON object
  108367. * @returns the JSON object
  108368. */
  108369. serialize(): any;
  108370. /**
  108371. * Creates a material from parsed material data
  108372. * @param parsedPostProcess defines parsed post process data
  108373. * @param scene defines the hosting scene
  108374. * @param rootUrl defines the root URL to use to load textures
  108375. * @returns a new post process
  108376. */
  108377. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108378. }
  108379. }
  108380. declare module BABYLON {
  108381. /** @hidden */
  108382. export var kernelBlurVaryingDeclaration: {
  108383. name: string;
  108384. shader: string;
  108385. };
  108386. }
  108387. declare module BABYLON {
  108388. /** @hidden */
  108389. export var kernelBlurFragment: {
  108390. name: string;
  108391. shader: string;
  108392. };
  108393. }
  108394. declare module BABYLON {
  108395. /** @hidden */
  108396. export var kernelBlurFragment2: {
  108397. name: string;
  108398. shader: string;
  108399. };
  108400. }
  108401. declare module BABYLON {
  108402. /** @hidden */
  108403. export var kernelBlurPixelShader: {
  108404. name: string;
  108405. shader: string;
  108406. };
  108407. }
  108408. declare module BABYLON {
  108409. /** @hidden */
  108410. export var kernelBlurVertex: {
  108411. name: string;
  108412. shader: string;
  108413. };
  108414. }
  108415. declare module BABYLON {
  108416. /** @hidden */
  108417. export var kernelBlurVertexShader: {
  108418. name: string;
  108419. shader: string;
  108420. };
  108421. }
  108422. declare module BABYLON {
  108423. /**
  108424. * The Blur Post Process which blurs an image based on a kernel and direction.
  108425. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108426. */
  108427. export class BlurPostProcess extends PostProcess {
  108428. private blockCompilation;
  108429. protected _kernel: number;
  108430. protected _idealKernel: number;
  108431. protected _packedFloat: boolean;
  108432. private _staticDefines;
  108433. /** The direction in which to blur the image. */
  108434. direction: Vector2;
  108435. /**
  108436. * Sets the length in pixels of the blur sample region
  108437. */
  108438. set kernel(v: number);
  108439. /**
  108440. * Gets the length in pixels of the blur sample region
  108441. */
  108442. get kernel(): number;
  108443. /**
  108444. * Sets wether or not the blur needs to unpack/repack floats
  108445. */
  108446. set packedFloat(v: boolean);
  108447. /**
  108448. * Gets wether or not the blur is unpacking/repacking floats
  108449. */
  108450. get packedFloat(): boolean;
  108451. /**
  108452. * Gets a string identifying the name of the class
  108453. * @returns "BlurPostProcess" string
  108454. */
  108455. getClassName(): string;
  108456. /**
  108457. * Creates a new instance BlurPostProcess
  108458. * @param name The name of the effect.
  108459. * @param direction The direction in which to blur the image.
  108460. * @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.
  108461. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108462. * @param camera The camera to apply the render pass to.
  108463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108464. * @param engine The engine which the post process will be applied. (default: current engine)
  108465. * @param reusable If the post process can be reused on the same frame. (default: false)
  108466. * @param textureType Type of textures used when performing the post process. (default: 0)
  108467. * @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)
  108468. */
  108469. 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);
  108470. /**
  108471. * Updates the effect with the current post process compile time values and recompiles the shader.
  108472. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108473. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108474. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108475. * @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
  108476. * @param onCompiled Called when the shader has been compiled.
  108477. * @param onError Called if there is an error when compiling a shader.
  108478. */
  108479. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108480. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108481. /**
  108482. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108483. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108484. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108485. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108486. * The gaps between physical kernels are compensated for in the weighting of the samples
  108487. * @param idealKernel Ideal blur kernel.
  108488. * @return Nearest best kernel.
  108489. */
  108490. protected _nearestBestKernel(idealKernel: number): number;
  108491. /**
  108492. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108493. * @param x The point on the Gaussian distribution to sample.
  108494. * @return the value of the Gaussian function at x.
  108495. */
  108496. protected _gaussianWeight(x: number): number;
  108497. /**
  108498. * Generates a string that can be used as a floating point number in GLSL.
  108499. * @param x Value to print.
  108500. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108501. * @return GLSL float string.
  108502. */
  108503. protected _glslFloat(x: number, decimalFigures?: number): string;
  108504. /** @hidden */
  108505. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108506. }
  108507. }
  108508. declare module BABYLON {
  108509. /**
  108510. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108511. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108512. * You can then easily use it as a reflectionTexture on a flat surface.
  108513. * In case the surface is not a plane, please consider relying on reflection probes.
  108514. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108515. */
  108516. export class MirrorTexture extends RenderTargetTexture {
  108517. private scene;
  108518. /**
  108519. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108520. * 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.
  108521. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108522. */
  108523. mirrorPlane: Plane;
  108524. /**
  108525. * Define the blur ratio used to blur the reflection if needed.
  108526. */
  108527. set blurRatio(value: number);
  108528. get blurRatio(): number;
  108529. /**
  108530. * Define the adaptive blur kernel used to blur the reflection if needed.
  108531. * This will autocompute the closest best match for the `blurKernel`
  108532. */
  108533. set adaptiveBlurKernel(value: number);
  108534. /**
  108535. * Define the blur kernel used to blur the reflection if needed.
  108536. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108537. */
  108538. set blurKernel(value: number);
  108539. /**
  108540. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108541. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108542. */
  108543. set blurKernelX(value: number);
  108544. get blurKernelX(): number;
  108545. /**
  108546. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108547. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108548. */
  108549. set blurKernelY(value: number);
  108550. get blurKernelY(): number;
  108551. private _autoComputeBlurKernel;
  108552. protected _onRatioRescale(): void;
  108553. private _updateGammaSpace;
  108554. private _imageProcessingConfigChangeObserver;
  108555. private _transformMatrix;
  108556. private _mirrorMatrix;
  108557. private _savedViewMatrix;
  108558. private _blurX;
  108559. private _blurY;
  108560. private _adaptiveBlurKernel;
  108561. private _blurKernelX;
  108562. private _blurKernelY;
  108563. private _blurRatio;
  108564. /**
  108565. * Instantiates a Mirror Texture.
  108566. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108567. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108568. * You can then easily use it as a reflectionTexture on a flat surface.
  108569. * In case the surface is not a plane, please consider relying on reflection probes.
  108570. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108571. * @param name
  108572. * @param size
  108573. * @param scene
  108574. * @param generateMipMaps
  108575. * @param type
  108576. * @param samplingMode
  108577. * @param generateDepthBuffer
  108578. */
  108579. constructor(name: string, size: number | {
  108580. width: number;
  108581. height: number;
  108582. } | {
  108583. ratio: number;
  108584. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108585. private _preparePostProcesses;
  108586. /**
  108587. * Clone the mirror texture.
  108588. * @returns the cloned texture
  108589. */
  108590. clone(): MirrorTexture;
  108591. /**
  108592. * Serialize the texture to a JSON representation you could use in Parse later on
  108593. * @returns the serialized JSON representation
  108594. */
  108595. serialize(): any;
  108596. /**
  108597. * Dispose the texture and release its associated resources.
  108598. */
  108599. dispose(): void;
  108600. }
  108601. }
  108602. declare module BABYLON {
  108603. /**
  108604. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108605. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108606. */
  108607. export class Texture extends BaseTexture {
  108608. /**
  108609. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108610. */
  108611. static SerializeBuffers: boolean;
  108612. /** @hidden */
  108613. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108614. /** @hidden */
  108615. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108616. /** @hidden */
  108617. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108618. /** nearest is mag = nearest and min = nearest and mip = linear */
  108619. static readonly NEAREST_SAMPLINGMODE: number;
  108620. /** nearest is mag = nearest and min = nearest and mip = linear */
  108621. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108622. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108623. static readonly BILINEAR_SAMPLINGMODE: number;
  108624. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108625. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108626. /** Trilinear is mag = linear and min = linear and mip = linear */
  108627. static readonly TRILINEAR_SAMPLINGMODE: number;
  108628. /** Trilinear is mag = linear and min = linear and mip = linear */
  108629. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108630. /** mag = nearest and min = nearest and mip = nearest */
  108631. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108632. /** mag = nearest and min = linear and mip = nearest */
  108633. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108634. /** mag = nearest and min = linear and mip = linear */
  108635. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108636. /** mag = nearest and min = linear and mip = none */
  108637. static readonly NEAREST_LINEAR: number;
  108638. /** mag = nearest and min = nearest and mip = none */
  108639. static readonly NEAREST_NEAREST: number;
  108640. /** mag = linear and min = nearest and mip = nearest */
  108641. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108642. /** mag = linear and min = nearest and mip = linear */
  108643. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108644. /** mag = linear and min = linear and mip = none */
  108645. static readonly LINEAR_LINEAR: number;
  108646. /** mag = linear and min = nearest and mip = none */
  108647. static readonly LINEAR_NEAREST: number;
  108648. /** Explicit coordinates mode */
  108649. static readonly EXPLICIT_MODE: number;
  108650. /** Spherical coordinates mode */
  108651. static readonly SPHERICAL_MODE: number;
  108652. /** Planar coordinates mode */
  108653. static readonly PLANAR_MODE: number;
  108654. /** Cubic coordinates mode */
  108655. static readonly CUBIC_MODE: number;
  108656. /** Projection coordinates mode */
  108657. static readonly PROJECTION_MODE: number;
  108658. /** Inverse Cubic coordinates mode */
  108659. static readonly SKYBOX_MODE: number;
  108660. /** Inverse Cubic coordinates mode */
  108661. static readonly INVCUBIC_MODE: number;
  108662. /** Equirectangular coordinates mode */
  108663. static readonly EQUIRECTANGULAR_MODE: number;
  108664. /** Equirectangular Fixed coordinates mode */
  108665. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108666. /** Equirectangular Fixed Mirrored coordinates mode */
  108667. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108668. /** Texture is not repeating outside of 0..1 UVs */
  108669. static readonly CLAMP_ADDRESSMODE: number;
  108670. /** Texture is repeating outside of 0..1 UVs */
  108671. static readonly WRAP_ADDRESSMODE: number;
  108672. /** Texture is repeating and mirrored */
  108673. static readonly MIRROR_ADDRESSMODE: number;
  108674. /**
  108675. * 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
  108676. */
  108677. static UseSerializedUrlIfAny: boolean;
  108678. /**
  108679. * Define the url of the texture.
  108680. */
  108681. url: Nullable<string>;
  108682. /**
  108683. * Define an offset on the texture to offset the u coordinates of the UVs
  108684. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108685. */
  108686. uOffset: number;
  108687. /**
  108688. * Define an offset on the texture to offset the v coordinates of the UVs
  108689. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108690. */
  108691. vOffset: number;
  108692. /**
  108693. * Define an offset on the texture to scale the u coordinates of the UVs
  108694. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108695. */
  108696. uScale: number;
  108697. /**
  108698. * Define an offset on the texture to scale the v coordinates of the UVs
  108699. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108700. */
  108701. vScale: number;
  108702. /**
  108703. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108704. * @see https://doc.babylonjs.com/how_to/more_materials
  108705. */
  108706. uAng: number;
  108707. /**
  108708. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108709. * @see https://doc.babylonjs.com/how_to/more_materials
  108710. */
  108711. vAng: number;
  108712. /**
  108713. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108714. * @see https://doc.babylonjs.com/how_to/more_materials
  108715. */
  108716. wAng: number;
  108717. /**
  108718. * Defines the center of rotation (U)
  108719. */
  108720. uRotationCenter: number;
  108721. /**
  108722. * Defines the center of rotation (V)
  108723. */
  108724. vRotationCenter: number;
  108725. /**
  108726. * Defines the center of rotation (W)
  108727. */
  108728. wRotationCenter: number;
  108729. /**
  108730. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108731. */
  108732. homogeneousRotationInUVTransform: boolean;
  108733. /**
  108734. * Are mip maps generated for this texture or not.
  108735. */
  108736. get noMipmap(): boolean;
  108737. /**
  108738. * List of inspectable custom properties (used by the Inspector)
  108739. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108740. */
  108741. inspectableCustomProperties: Nullable<IInspectable[]>;
  108742. private _noMipmap;
  108743. /** @hidden */
  108744. _invertY: boolean;
  108745. private _rowGenerationMatrix;
  108746. private _cachedTextureMatrix;
  108747. private _projectionModeMatrix;
  108748. private _t0;
  108749. private _t1;
  108750. private _t2;
  108751. private _cachedUOffset;
  108752. private _cachedVOffset;
  108753. private _cachedUScale;
  108754. private _cachedVScale;
  108755. private _cachedUAng;
  108756. private _cachedVAng;
  108757. private _cachedWAng;
  108758. private _cachedProjectionMatrixId;
  108759. private _cachedURotationCenter;
  108760. private _cachedVRotationCenter;
  108761. private _cachedWRotationCenter;
  108762. private _cachedHomogeneousRotationInUVTransform;
  108763. private _cachedCoordinatesMode;
  108764. /** @hidden */
  108765. protected _initialSamplingMode: number;
  108766. /** @hidden */
  108767. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108768. private _deleteBuffer;
  108769. protected _format: Nullable<number>;
  108770. private _delayedOnLoad;
  108771. private _delayedOnError;
  108772. private _mimeType?;
  108773. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108774. get mimeType(): string | undefined;
  108775. /**
  108776. * Observable triggered once the texture has been loaded.
  108777. */
  108778. onLoadObservable: Observable<Texture>;
  108779. protected _isBlocking: boolean;
  108780. /**
  108781. * Is the texture preventing material to render while loading.
  108782. * If false, a default texture will be used instead of the loading one during the preparation step.
  108783. */
  108784. set isBlocking(value: boolean);
  108785. get isBlocking(): boolean;
  108786. /**
  108787. * Get the current sampling mode associated with the texture.
  108788. */
  108789. get samplingMode(): number;
  108790. /**
  108791. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108792. */
  108793. get invertY(): boolean;
  108794. /**
  108795. * Instantiates a new texture.
  108796. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108797. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108798. * @param url defines the url of the picture to load as a texture
  108799. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108800. * @param noMipmap defines if the texture will require mip maps or not
  108801. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108802. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108803. * @param onLoad defines a callback triggered when the texture has been loaded
  108804. * @param onError defines a callback triggered when an error occurred during the loading session
  108805. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108806. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108807. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108808. * @param mimeType defines an optional mime type information
  108809. */
  108810. 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);
  108811. /**
  108812. * Update the url (and optional buffer) of this texture if url was null during construction.
  108813. * @param url the url of the texture
  108814. * @param buffer the buffer of the texture (defaults to null)
  108815. * @param onLoad callback called when the texture is loaded (defaults to null)
  108816. */
  108817. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108818. /**
  108819. * Finish the loading sequence of a texture flagged as delayed load.
  108820. * @hidden
  108821. */
  108822. delayLoad(): void;
  108823. private _prepareRowForTextureGeneration;
  108824. /**
  108825. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108826. * @returns the transform matrix of the texture.
  108827. */
  108828. getTextureMatrix(uBase?: number): Matrix;
  108829. /**
  108830. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108831. * @returns The reflection texture transform
  108832. */
  108833. getReflectionTextureMatrix(): Matrix;
  108834. /**
  108835. * Clones the texture.
  108836. * @returns the cloned texture
  108837. */
  108838. clone(): Texture;
  108839. /**
  108840. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108841. * @returns The JSON representation of the texture
  108842. */
  108843. serialize(): any;
  108844. /**
  108845. * Get the current class name of the texture useful for serialization or dynamic coding.
  108846. * @returns "Texture"
  108847. */
  108848. getClassName(): string;
  108849. /**
  108850. * Dispose the texture and release its associated resources.
  108851. */
  108852. dispose(): void;
  108853. /**
  108854. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108855. * @param parsedTexture Define the JSON representation of the texture
  108856. * @param scene Define the scene the parsed texture should be instantiated in
  108857. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108858. * @returns The parsed texture if successful
  108859. */
  108860. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108861. /**
  108862. * Creates a texture from its base 64 representation.
  108863. * @param data Define the base64 payload without the data: prefix
  108864. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108865. * @param scene Define the scene the texture should belong to
  108866. * @param noMipmap Forces the texture to not create mip map information if true
  108867. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108868. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108869. * @param onLoad define a callback triggered when the texture has been loaded
  108870. * @param onError define a callback triggered when an error occurred during the loading session
  108871. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108872. * @returns the created texture
  108873. */
  108874. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108875. /**
  108876. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108877. * @param data Define the base64 payload without the data: prefix
  108878. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108879. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108880. * @param scene Define the scene the texture should belong to
  108881. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108882. * @param noMipmap Forces the texture to not create mip map information if true
  108883. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108884. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108885. * @param onLoad define a callback triggered when the texture has been loaded
  108886. * @param onError define a callback triggered when an error occurred during the loading session
  108887. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108888. * @returns the created texture
  108889. */
  108890. 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;
  108891. }
  108892. }
  108893. declare module BABYLON {
  108894. /**
  108895. * PostProcessManager is used to manage one or more post processes or post process pipelines
  108896. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108897. */
  108898. export class PostProcessManager {
  108899. private _scene;
  108900. private _indexBuffer;
  108901. private _vertexBuffers;
  108902. /**
  108903. * Creates a new instance PostProcess
  108904. * @param scene The scene that the post process is associated with.
  108905. */
  108906. constructor(scene: Scene);
  108907. private _prepareBuffers;
  108908. private _buildIndexBuffer;
  108909. /**
  108910. * Rebuilds the vertex buffers of the manager.
  108911. * @hidden
  108912. */
  108913. _rebuild(): void;
  108914. /**
  108915. * Prepares a frame to be run through a post process.
  108916. * @param sourceTexture The input texture to the post procesess. (default: null)
  108917. * @param postProcesses An array of post processes to be run. (default: null)
  108918. * @returns True if the post processes were able to be run.
  108919. * @hidden
  108920. */
  108921. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  108922. /**
  108923. * Manually render a set of post processes to a texture.
  108924. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  108925. * @param postProcesses An array of post processes to be run.
  108926. * @param targetTexture The target texture to render to.
  108927. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  108928. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  108929. * @param lodLevel defines which lod of the texture to render to
  108930. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  108931. */
  108932. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  108933. /**
  108934. * Finalize the result of the output of the postprocesses.
  108935. * @param doNotPresent If true the result will not be displayed to the screen.
  108936. * @param targetTexture The target texture to render to.
  108937. * @param faceIndex The index of the face to bind the target texture to.
  108938. * @param postProcesses The array of post processes to render.
  108939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  108940. * @hidden
  108941. */
  108942. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  108943. /**
  108944. * Disposes of the post process manager.
  108945. */
  108946. dispose(): void;
  108947. }
  108948. }
  108949. declare module BABYLON {
  108950. /**
  108951. * This Helps creating a texture that will be created from a camera in your scene.
  108952. * It is basically a dynamic texture that could be used to create special effects for instance.
  108953. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  108954. */
  108955. export class RenderTargetTexture extends Texture {
  108956. /**
  108957. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  108958. */
  108959. static readonly REFRESHRATE_RENDER_ONCE: number;
  108960. /**
  108961. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  108962. */
  108963. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  108964. /**
  108965. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  108966. * the central point of your effect and can save a lot of performances.
  108967. */
  108968. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  108969. /**
  108970. * Use this predicate to dynamically define the list of mesh you want to render.
  108971. * If set, the renderList property will be overwritten.
  108972. */
  108973. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  108974. private _renderList;
  108975. /**
  108976. * Use this list to define the list of mesh you want to render.
  108977. */
  108978. get renderList(): Nullable<Array<AbstractMesh>>;
  108979. set renderList(value: Nullable<Array<AbstractMesh>>);
  108980. /**
  108981. * Use this function to overload the renderList array at rendering time.
  108982. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  108983. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  108984. * the cube (if the RTT is a cube, else layerOrFace=0).
  108985. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  108986. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  108987. * hold dummy elements!
  108988. */
  108989. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  108990. private _hookArray;
  108991. /**
  108992. * Define if particles should be rendered in your texture.
  108993. */
  108994. renderParticles: boolean;
  108995. /**
  108996. * Define if sprites should be rendered in your texture.
  108997. */
  108998. renderSprites: boolean;
  108999. /**
  109000. * Define the camera used to render the texture.
  109001. */
  109002. activeCamera: Nullable<Camera>;
  109003. /**
  109004. * Override the mesh isReady function with your own one.
  109005. */
  109006. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109007. /**
  109008. * Override the render function of the texture with your own one.
  109009. */
  109010. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109011. /**
  109012. * Define if camera post processes should be use while rendering the texture.
  109013. */
  109014. useCameraPostProcesses: boolean;
  109015. /**
  109016. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109017. */
  109018. ignoreCameraViewport: boolean;
  109019. private _postProcessManager;
  109020. private _postProcesses;
  109021. private _resizeObserver;
  109022. /**
  109023. * An event triggered when the texture is unbind.
  109024. */
  109025. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109026. /**
  109027. * An event triggered when the texture is unbind.
  109028. */
  109029. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109030. private _onAfterUnbindObserver;
  109031. /**
  109032. * Set a after unbind callback in the texture.
  109033. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109034. */
  109035. set onAfterUnbind(callback: () => void);
  109036. /**
  109037. * An event triggered before rendering the texture
  109038. */
  109039. onBeforeRenderObservable: Observable<number>;
  109040. private _onBeforeRenderObserver;
  109041. /**
  109042. * Set a before render callback in the texture.
  109043. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109044. */
  109045. set onBeforeRender(callback: (faceIndex: number) => void);
  109046. /**
  109047. * An event triggered after rendering the texture
  109048. */
  109049. onAfterRenderObservable: Observable<number>;
  109050. private _onAfterRenderObserver;
  109051. /**
  109052. * Set a after render callback in the texture.
  109053. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109054. */
  109055. set onAfterRender(callback: (faceIndex: number) => void);
  109056. /**
  109057. * An event triggered after the texture clear
  109058. */
  109059. onClearObservable: Observable<Engine>;
  109060. private _onClearObserver;
  109061. /**
  109062. * Set a clear callback in the texture.
  109063. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109064. */
  109065. set onClear(callback: (Engine: Engine) => void);
  109066. /**
  109067. * An event triggered when the texture is resized.
  109068. */
  109069. onResizeObservable: Observable<RenderTargetTexture>;
  109070. /**
  109071. * Define the clear color of the Render Target if it should be different from the scene.
  109072. */
  109073. clearColor: Color4;
  109074. protected _size: number | {
  109075. width: number;
  109076. height: number;
  109077. layers?: number;
  109078. };
  109079. protected _initialSizeParameter: number | {
  109080. width: number;
  109081. height: number;
  109082. } | {
  109083. ratio: number;
  109084. };
  109085. protected _sizeRatio: Nullable<number>;
  109086. /** @hidden */
  109087. _generateMipMaps: boolean;
  109088. protected _renderingManager: RenderingManager;
  109089. /** @hidden */
  109090. _waitingRenderList?: string[];
  109091. protected _doNotChangeAspectRatio: boolean;
  109092. protected _currentRefreshId: number;
  109093. protected _refreshRate: number;
  109094. protected _textureMatrix: Matrix;
  109095. protected _samples: number;
  109096. protected _renderTargetOptions: RenderTargetCreationOptions;
  109097. /**
  109098. * Gets render target creation options that were used.
  109099. */
  109100. get renderTargetOptions(): RenderTargetCreationOptions;
  109101. protected _onRatioRescale(): void;
  109102. /**
  109103. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109104. * It must define where the camera used to render the texture is set
  109105. */
  109106. boundingBoxPosition: Vector3;
  109107. private _boundingBoxSize;
  109108. /**
  109109. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109110. * When defined, the cubemap will switch to local mode
  109111. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109112. * @example https://www.babylonjs-playground.com/#RNASML
  109113. */
  109114. set boundingBoxSize(value: Vector3);
  109115. get boundingBoxSize(): Vector3;
  109116. /**
  109117. * In case the RTT has been created with a depth texture, get the associated
  109118. * depth texture.
  109119. * Otherwise, return null.
  109120. */
  109121. get depthStencilTexture(): Nullable<InternalTexture>;
  109122. /**
  109123. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109124. * or used a shadow, depth texture...
  109125. * @param name The friendly name of the texture
  109126. * @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)
  109127. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109128. * @param generateMipMaps True if mip maps need to be generated after render.
  109129. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109130. * @param type The type of the buffer in the RTT (int, half float, float...)
  109131. * @param isCube True if a cube texture needs to be created
  109132. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109133. * @param generateDepthBuffer True to generate a depth buffer
  109134. * @param generateStencilBuffer True to generate a stencil buffer
  109135. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109136. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109137. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109138. */
  109139. constructor(name: string, size: number | {
  109140. width: number;
  109141. height: number;
  109142. layers?: number;
  109143. } | {
  109144. ratio: number;
  109145. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109146. /**
  109147. * Creates a depth stencil texture.
  109148. * This is only available in WebGL 2 or with the depth texture extension available.
  109149. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109150. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109151. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109152. */
  109153. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109154. private _processSizeParameter;
  109155. /**
  109156. * Define the number of samples to use in case of MSAA.
  109157. * It defaults to one meaning no MSAA has been enabled.
  109158. */
  109159. get samples(): number;
  109160. set samples(value: number);
  109161. /**
  109162. * Resets the refresh counter of the texture and start bak from scratch.
  109163. * Could be useful to regenerate the texture if it is setup to render only once.
  109164. */
  109165. resetRefreshCounter(): void;
  109166. /**
  109167. * Define the refresh rate of the texture or the rendering frequency.
  109168. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109169. */
  109170. get refreshRate(): number;
  109171. set refreshRate(value: number);
  109172. /**
  109173. * Adds a post process to the render target rendering passes.
  109174. * @param postProcess define the post process to add
  109175. */
  109176. addPostProcess(postProcess: PostProcess): void;
  109177. /**
  109178. * Clear all the post processes attached to the render target
  109179. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109180. */
  109181. clearPostProcesses(dispose?: boolean): void;
  109182. /**
  109183. * Remove one of the post process from the list of attached post processes to the texture
  109184. * @param postProcess define the post process to remove from the list
  109185. */
  109186. removePostProcess(postProcess: PostProcess): void;
  109187. /** @hidden */
  109188. _shouldRender(): boolean;
  109189. /**
  109190. * Gets the actual render size of the texture.
  109191. * @returns the width of the render size
  109192. */
  109193. getRenderSize(): number;
  109194. /**
  109195. * Gets the actual render width of the texture.
  109196. * @returns the width of the render size
  109197. */
  109198. getRenderWidth(): number;
  109199. /**
  109200. * Gets the actual render height of the texture.
  109201. * @returns the height of the render size
  109202. */
  109203. getRenderHeight(): number;
  109204. /**
  109205. * Gets the actual number of layers of the texture.
  109206. * @returns the number of layers
  109207. */
  109208. getRenderLayers(): number;
  109209. /**
  109210. * Get if the texture can be rescaled or not.
  109211. */
  109212. get canRescale(): boolean;
  109213. /**
  109214. * Resize the texture using a ratio.
  109215. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109216. */
  109217. scale(ratio: number): void;
  109218. /**
  109219. * Get the texture reflection matrix used to rotate/transform the reflection.
  109220. * @returns the reflection matrix
  109221. */
  109222. getReflectionTextureMatrix(): Matrix;
  109223. /**
  109224. * Resize the texture to a new desired size.
  109225. * Be carrefull as it will recreate all the data in the new texture.
  109226. * @param size Define the new size. It can be:
  109227. * - a number for squared texture,
  109228. * - an object containing { width: number, height: number }
  109229. * - or an object containing a ratio { ratio: number }
  109230. */
  109231. resize(size: number | {
  109232. width: number;
  109233. height: number;
  109234. } | {
  109235. ratio: number;
  109236. }): void;
  109237. private _defaultRenderListPrepared;
  109238. /**
  109239. * Renders all the objects from the render list into the texture.
  109240. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109241. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109242. */
  109243. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109244. private _bestReflectionRenderTargetDimension;
  109245. private _prepareRenderingManager;
  109246. /**
  109247. * @hidden
  109248. * @param faceIndex face index to bind to if this is a cubetexture
  109249. * @param layer defines the index of the texture to bind in the array
  109250. */
  109251. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109252. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109253. private renderToTarget;
  109254. /**
  109255. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109256. * This allowed control for front to back rendering or reversly depending of the special needs.
  109257. *
  109258. * @param renderingGroupId The rendering group id corresponding to its index
  109259. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109260. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109261. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109262. */
  109263. 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;
  109264. /**
  109265. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109266. *
  109267. * @param renderingGroupId The rendering group id corresponding to its index
  109268. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109269. */
  109270. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109271. /**
  109272. * Clones the texture.
  109273. * @returns the cloned texture
  109274. */
  109275. clone(): RenderTargetTexture;
  109276. /**
  109277. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109278. * @returns The JSON representation of the texture
  109279. */
  109280. serialize(): any;
  109281. /**
  109282. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109283. */
  109284. disposeFramebufferObjects(): void;
  109285. /**
  109286. * Dispose the texture and release its associated resources.
  109287. */
  109288. dispose(): void;
  109289. /** @hidden */
  109290. _rebuild(): void;
  109291. /**
  109292. * Clear the info related to rendering groups preventing retention point in material dispose.
  109293. */
  109294. freeRenderingGroups(): void;
  109295. /**
  109296. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109297. * @returns the view count
  109298. */
  109299. getViewCount(): number;
  109300. }
  109301. }
  109302. declare module BABYLON {
  109303. /**
  109304. * Class used to manipulate GUIDs
  109305. */
  109306. export class GUID {
  109307. /**
  109308. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109309. * Be aware Math.random() could cause collisions, but:
  109310. * "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"
  109311. * @returns a pseudo random id
  109312. */
  109313. static RandomId(): string;
  109314. }
  109315. }
  109316. declare module BABYLON {
  109317. /**
  109318. * Options to be used when creating a shadow depth material
  109319. */
  109320. export interface IIOptionShadowDepthMaterial {
  109321. /** Variables in the vertex shader code that need to have their names remapped.
  109322. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109323. * "var_name" should be either: worldPos or vNormalW
  109324. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109325. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109326. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109327. */
  109328. remappedVariables?: string[];
  109329. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109330. standalone?: boolean;
  109331. }
  109332. /**
  109333. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109334. */
  109335. export class ShadowDepthWrapper {
  109336. private _scene;
  109337. private _options?;
  109338. private _baseMaterial;
  109339. private _onEffectCreatedObserver;
  109340. private _subMeshToEffect;
  109341. private _subMeshToDepthEffect;
  109342. private _meshes;
  109343. /** @hidden */
  109344. _matriceNames: any;
  109345. /** Gets the standalone status of the wrapper */
  109346. get standalone(): boolean;
  109347. /** Gets the base material the wrapper is built upon */
  109348. get baseMaterial(): Material;
  109349. /**
  109350. * Instantiate a new shadow depth wrapper.
  109351. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109352. * generate the shadow depth map. For more information, please refer to the documentation:
  109353. * https://doc.babylonjs.com/babylon101/shadows
  109354. * @param baseMaterial Material to wrap
  109355. * @param scene Define the scene the material belongs to
  109356. * @param options Options used to create the wrapper
  109357. */
  109358. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109359. /**
  109360. * Gets the effect to use to generate the depth map
  109361. * @param subMesh subMesh to get the effect for
  109362. * @param shadowGenerator shadow generator to get the effect for
  109363. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109364. */
  109365. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109366. /**
  109367. * Specifies that the submesh is ready to be used for depth rendering
  109368. * @param subMesh submesh to check
  109369. * @param defines the list of defines to take into account when checking the effect
  109370. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109371. * @param useInstances specifies that instances should be used
  109372. * @returns a boolean indicating that the submesh is ready or not
  109373. */
  109374. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109375. /**
  109376. * Disposes the resources
  109377. */
  109378. dispose(): void;
  109379. private _makeEffect;
  109380. }
  109381. }
  109382. declare module BABYLON {
  109383. /**
  109384. * Options for compiling materials.
  109385. */
  109386. export interface IMaterialCompilationOptions {
  109387. /**
  109388. * Defines whether clip planes are enabled.
  109389. */
  109390. clipPlane: boolean;
  109391. /**
  109392. * Defines whether instances are enabled.
  109393. */
  109394. useInstances: boolean;
  109395. }
  109396. /**
  109397. * Options passed when calling customShaderNameResolve
  109398. */
  109399. export interface ICustomShaderNameResolveOptions {
  109400. /**
  109401. * 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
  109402. */
  109403. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109404. }
  109405. /**
  109406. * Base class for the main features of a material in Babylon.js
  109407. */
  109408. export class Material implements IAnimatable {
  109409. /**
  109410. * Returns the triangle fill mode
  109411. */
  109412. static readonly TriangleFillMode: number;
  109413. /**
  109414. * Returns the wireframe mode
  109415. */
  109416. static readonly WireFrameFillMode: number;
  109417. /**
  109418. * Returns the point fill mode
  109419. */
  109420. static readonly PointFillMode: number;
  109421. /**
  109422. * Returns the point list draw mode
  109423. */
  109424. static readonly PointListDrawMode: number;
  109425. /**
  109426. * Returns the line list draw mode
  109427. */
  109428. static readonly LineListDrawMode: number;
  109429. /**
  109430. * Returns the line loop draw mode
  109431. */
  109432. static readonly LineLoopDrawMode: number;
  109433. /**
  109434. * Returns the line strip draw mode
  109435. */
  109436. static readonly LineStripDrawMode: number;
  109437. /**
  109438. * Returns the triangle strip draw mode
  109439. */
  109440. static readonly TriangleStripDrawMode: number;
  109441. /**
  109442. * Returns the triangle fan draw mode
  109443. */
  109444. static readonly TriangleFanDrawMode: number;
  109445. /**
  109446. * Stores the clock-wise side orientation
  109447. */
  109448. static readonly ClockWiseSideOrientation: number;
  109449. /**
  109450. * Stores the counter clock-wise side orientation
  109451. */
  109452. static readonly CounterClockWiseSideOrientation: number;
  109453. /**
  109454. * The dirty texture flag value
  109455. */
  109456. static readonly TextureDirtyFlag: number;
  109457. /**
  109458. * The dirty light flag value
  109459. */
  109460. static readonly LightDirtyFlag: number;
  109461. /**
  109462. * The dirty fresnel flag value
  109463. */
  109464. static readonly FresnelDirtyFlag: number;
  109465. /**
  109466. * The dirty attribute flag value
  109467. */
  109468. static readonly AttributesDirtyFlag: number;
  109469. /**
  109470. * The dirty misc flag value
  109471. */
  109472. static readonly MiscDirtyFlag: number;
  109473. /**
  109474. * The dirty prepass flag value
  109475. */
  109476. static readonly PrePassDirtyFlag: number;
  109477. /**
  109478. * The all dirty flag value
  109479. */
  109480. static readonly AllDirtyFlag: number;
  109481. /**
  109482. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109483. */
  109484. static readonly MATERIAL_OPAQUE: number;
  109485. /**
  109486. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109487. */
  109488. static readonly MATERIAL_ALPHATEST: number;
  109489. /**
  109490. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109491. */
  109492. static readonly MATERIAL_ALPHABLEND: number;
  109493. /**
  109494. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109495. * They are also discarded below the alpha cutoff threshold to improve performances.
  109496. */
  109497. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109498. /**
  109499. * The Whiteout method is used to blend normals.
  109500. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109501. */
  109502. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109503. /**
  109504. * The Reoriented Normal Mapping method is used to blend normals.
  109505. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109506. */
  109507. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109508. /**
  109509. * Custom callback helping to override the default shader used in the material.
  109510. */
  109511. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109512. /**
  109513. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109514. */
  109515. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109516. /**
  109517. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109518. * This means that the material can keep using a previous shader while a new one is being compiled.
  109519. * This is mostly used when shader parallel compilation is supported (true by default)
  109520. */
  109521. allowShaderHotSwapping: boolean;
  109522. /**
  109523. * The ID of the material
  109524. */
  109525. id: string;
  109526. /**
  109527. * Gets or sets the unique id of the material
  109528. */
  109529. uniqueId: number;
  109530. /**
  109531. * The name of the material
  109532. */
  109533. name: string;
  109534. /**
  109535. * Gets or sets user defined metadata
  109536. */
  109537. metadata: any;
  109538. /**
  109539. * For internal use only. Please do not use.
  109540. */
  109541. reservedDataStore: any;
  109542. /**
  109543. * Specifies if the ready state should be checked on each call
  109544. */
  109545. checkReadyOnEveryCall: boolean;
  109546. /**
  109547. * Specifies if the ready state should be checked once
  109548. */
  109549. checkReadyOnlyOnce: boolean;
  109550. /**
  109551. * The state of the material
  109552. */
  109553. state: string;
  109554. /**
  109555. * If the material can be rendered to several textures with MRT extension
  109556. */
  109557. get canRenderToMRT(): boolean;
  109558. /**
  109559. * The alpha value of the material
  109560. */
  109561. protected _alpha: number;
  109562. /**
  109563. * List of inspectable custom properties (used by the Inspector)
  109564. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109565. */
  109566. inspectableCustomProperties: IInspectable[];
  109567. /**
  109568. * Sets the alpha value of the material
  109569. */
  109570. set alpha(value: number);
  109571. /**
  109572. * Gets the alpha value of the material
  109573. */
  109574. get alpha(): number;
  109575. /**
  109576. * Specifies if back face culling is enabled
  109577. */
  109578. protected _backFaceCulling: boolean;
  109579. /**
  109580. * Sets the back-face culling state
  109581. */
  109582. set backFaceCulling(value: boolean);
  109583. /**
  109584. * Gets the back-face culling state
  109585. */
  109586. get backFaceCulling(): boolean;
  109587. /**
  109588. * Stores the value for side orientation
  109589. */
  109590. sideOrientation: number;
  109591. /**
  109592. * Callback triggered when the material is compiled
  109593. */
  109594. onCompiled: Nullable<(effect: Effect) => void>;
  109595. /**
  109596. * Callback triggered when an error occurs
  109597. */
  109598. onError: Nullable<(effect: Effect, errors: string) => void>;
  109599. /**
  109600. * Callback triggered to get the render target textures
  109601. */
  109602. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109603. /**
  109604. * Gets a boolean indicating that current material needs to register RTT
  109605. */
  109606. get hasRenderTargetTextures(): boolean;
  109607. /**
  109608. * Specifies if the material should be serialized
  109609. */
  109610. doNotSerialize: boolean;
  109611. /**
  109612. * @hidden
  109613. */
  109614. _storeEffectOnSubMeshes: boolean;
  109615. /**
  109616. * Stores the animations for the material
  109617. */
  109618. animations: Nullable<Array<Animation>>;
  109619. /**
  109620. * An event triggered when the material is disposed
  109621. */
  109622. onDisposeObservable: Observable<Material>;
  109623. /**
  109624. * An observer which watches for dispose events
  109625. */
  109626. private _onDisposeObserver;
  109627. private _onUnBindObservable;
  109628. /**
  109629. * Called during a dispose event
  109630. */
  109631. set onDispose(callback: () => void);
  109632. private _onBindObservable;
  109633. /**
  109634. * An event triggered when the material is bound
  109635. */
  109636. get onBindObservable(): Observable<AbstractMesh>;
  109637. /**
  109638. * An observer which watches for bind events
  109639. */
  109640. private _onBindObserver;
  109641. /**
  109642. * Called during a bind event
  109643. */
  109644. set onBind(callback: (Mesh: AbstractMesh) => void);
  109645. /**
  109646. * An event triggered when the material is unbound
  109647. */
  109648. get onUnBindObservable(): Observable<Material>;
  109649. protected _onEffectCreatedObservable: Nullable<Observable<{
  109650. effect: Effect;
  109651. subMesh: Nullable<SubMesh>;
  109652. }>>;
  109653. /**
  109654. * An event triggered when the effect is (re)created
  109655. */
  109656. get onEffectCreatedObservable(): Observable<{
  109657. effect: Effect;
  109658. subMesh: Nullable<SubMesh>;
  109659. }>;
  109660. /**
  109661. * Stores the value of the alpha mode
  109662. */
  109663. private _alphaMode;
  109664. /**
  109665. * Sets the value of the alpha mode.
  109666. *
  109667. * | Value | Type | Description |
  109668. * | --- | --- | --- |
  109669. * | 0 | ALPHA_DISABLE | |
  109670. * | 1 | ALPHA_ADD | |
  109671. * | 2 | ALPHA_COMBINE | |
  109672. * | 3 | ALPHA_SUBTRACT | |
  109673. * | 4 | ALPHA_MULTIPLY | |
  109674. * | 5 | ALPHA_MAXIMIZED | |
  109675. * | 6 | ALPHA_ONEONE | |
  109676. * | 7 | ALPHA_PREMULTIPLIED | |
  109677. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109678. * | 9 | ALPHA_INTERPOLATE | |
  109679. * | 10 | ALPHA_SCREENMODE | |
  109680. *
  109681. */
  109682. set alphaMode(value: number);
  109683. /**
  109684. * Gets the value of the alpha mode
  109685. */
  109686. get alphaMode(): number;
  109687. /**
  109688. * Stores the state of the need depth pre-pass value
  109689. */
  109690. private _needDepthPrePass;
  109691. /**
  109692. * Sets the need depth pre-pass value
  109693. */
  109694. set needDepthPrePass(value: boolean);
  109695. /**
  109696. * Gets the depth pre-pass value
  109697. */
  109698. get needDepthPrePass(): boolean;
  109699. /**
  109700. * Specifies if depth writing should be disabled
  109701. */
  109702. disableDepthWrite: boolean;
  109703. /**
  109704. * Specifies if color writing should be disabled
  109705. */
  109706. disableColorWrite: boolean;
  109707. /**
  109708. * Specifies if depth writing should be forced
  109709. */
  109710. forceDepthWrite: boolean;
  109711. /**
  109712. * Specifies the depth function that should be used. 0 means the default engine function
  109713. */
  109714. depthFunction: number;
  109715. /**
  109716. * Specifies if there should be a separate pass for culling
  109717. */
  109718. separateCullingPass: boolean;
  109719. /**
  109720. * Stores the state specifing if fog should be enabled
  109721. */
  109722. private _fogEnabled;
  109723. /**
  109724. * Sets the state for enabling fog
  109725. */
  109726. set fogEnabled(value: boolean);
  109727. /**
  109728. * Gets the value of the fog enabled state
  109729. */
  109730. get fogEnabled(): boolean;
  109731. /**
  109732. * Stores the size of points
  109733. */
  109734. pointSize: number;
  109735. /**
  109736. * Stores the z offset value
  109737. */
  109738. zOffset: number;
  109739. get wireframe(): boolean;
  109740. /**
  109741. * Sets the state of wireframe mode
  109742. */
  109743. set wireframe(value: boolean);
  109744. /**
  109745. * Gets the value specifying if point clouds are enabled
  109746. */
  109747. get pointsCloud(): boolean;
  109748. /**
  109749. * Sets the state of point cloud mode
  109750. */
  109751. set pointsCloud(value: boolean);
  109752. /**
  109753. * Gets the material fill mode
  109754. */
  109755. get fillMode(): number;
  109756. /**
  109757. * Sets the material fill mode
  109758. */
  109759. set fillMode(value: number);
  109760. /**
  109761. * @hidden
  109762. * Stores the effects for the material
  109763. */
  109764. _effect: Nullable<Effect>;
  109765. /**
  109766. * Specifies if uniform buffers should be used
  109767. */
  109768. private _useUBO;
  109769. /**
  109770. * Stores a reference to the scene
  109771. */
  109772. private _scene;
  109773. /**
  109774. * Stores the fill mode state
  109775. */
  109776. private _fillMode;
  109777. /**
  109778. * Specifies if the depth write state should be cached
  109779. */
  109780. private _cachedDepthWriteState;
  109781. /**
  109782. * Specifies if the color write state should be cached
  109783. */
  109784. private _cachedColorWriteState;
  109785. /**
  109786. * Specifies if the depth function state should be cached
  109787. */
  109788. private _cachedDepthFunctionState;
  109789. /**
  109790. * Stores the uniform buffer
  109791. */
  109792. protected _uniformBuffer: UniformBuffer;
  109793. /** @hidden */
  109794. _indexInSceneMaterialArray: number;
  109795. /** @hidden */
  109796. meshMap: Nullable<{
  109797. [id: string]: AbstractMesh | undefined;
  109798. }>;
  109799. /**
  109800. * Creates a material instance
  109801. * @param name defines the name of the material
  109802. * @param scene defines the scene to reference
  109803. * @param doNotAdd specifies if the material should be added to the scene
  109804. */
  109805. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  109806. /**
  109807. * Returns a string representation of the current material
  109808. * @param fullDetails defines a boolean indicating which levels of logging is desired
  109809. * @returns a string with material information
  109810. */
  109811. toString(fullDetails?: boolean): string;
  109812. /**
  109813. * Gets the class name of the material
  109814. * @returns a string with the class name of the material
  109815. */
  109816. getClassName(): string;
  109817. /**
  109818. * Specifies if updates for the material been locked
  109819. */
  109820. get isFrozen(): boolean;
  109821. /**
  109822. * Locks updates for the material
  109823. */
  109824. freeze(): void;
  109825. /**
  109826. * Unlocks updates for the material
  109827. */
  109828. unfreeze(): void;
  109829. /**
  109830. * Specifies if the material is ready to be used
  109831. * @param mesh defines the mesh to check
  109832. * @param useInstances specifies if instances should be used
  109833. * @returns a boolean indicating if the material is ready to be used
  109834. */
  109835. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109836. /**
  109837. * Specifies that the submesh is ready to be used
  109838. * @param mesh defines the mesh to check
  109839. * @param subMesh defines which submesh to check
  109840. * @param useInstances specifies that instances should be used
  109841. * @returns a boolean indicating that the submesh is ready or not
  109842. */
  109843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109844. /**
  109845. * Returns the material effect
  109846. * @returns the effect associated with the material
  109847. */
  109848. getEffect(): Nullable<Effect>;
  109849. /**
  109850. * Returns the current scene
  109851. * @returns a Scene
  109852. */
  109853. getScene(): Scene;
  109854. /**
  109855. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109856. */
  109857. protected _forceAlphaTest: boolean;
  109858. /**
  109859. * The transparency mode of the material.
  109860. */
  109861. protected _transparencyMode: Nullable<number>;
  109862. /**
  109863. * Gets the current transparency mode.
  109864. */
  109865. get transparencyMode(): Nullable<number>;
  109866. /**
  109867. * Sets the transparency mode of the material.
  109868. *
  109869. * | Value | Type | Description |
  109870. * | ----- | ----------------------------------- | ----------- |
  109871. * | 0 | OPAQUE | |
  109872. * | 1 | ALPHATEST | |
  109873. * | 2 | ALPHABLEND | |
  109874. * | 3 | ALPHATESTANDBLEND | |
  109875. *
  109876. */
  109877. set transparencyMode(value: Nullable<number>);
  109878. /**
  109879. * Returns true if alpha blending should be disabled.
  109880. */
  109881. protected get _disableAlphaBlending(): boolean;
  109882. /**
  109883. * Specifies whether or not this material should be rendered in alpha blend mode.
  109884. * @returns a boolean specifying if alpha blending is needed
  109885. */
  109886. needAlphaBlending(): boolean;
  109887. /**
  109888. * Specifies if the mesh will require alpha blending
  109889. * @param mesh defines the mesh to check
  109890. * @returns a boolean specifying if alpha blending is needed for the mesh
  109891. */
  109892. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109893. /**
  109894. * Specifies whether or not this material should be rendered in alpha test mode.
  109895. * @returns a boolean specifying if an alpha test is needed.
  109896. */
  109897. needAlphaTesting(): boolean;
  109898. /**
  109899. * Specifies if material alpha testing should be turned on for the mesh
  109900. * @param mesh defines the mesh to check
  109901. */
  109902. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  109903. /**
  109904. * Gets the texture used for the alpha test
  109905. * @returns the texture to use for alpha testing
  109906. */
  109907. getAlphaTestTexture(): Nullable<BaseTexture>;
  109908. /**
  109909. * Marks the material to indicate that it needs to be re-calculated
  109910. */
  109911. markDirty(): void;
  109912. /** @hidden */
  109913. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  109914. /**
  109915. * Binds the material to the mesh
  109916. * @param world defines the world transformation matrix
  109917. * @param mesh defines the mesh to bind the material to
  109918. */
  109919. bind(world: Matrix, mesh?: Mesh): void;
  109920. /**
  109921. * Binds the submesh to the material
  109922. * @param world defines the world transformation matrix
  109923. * @param mesh defines the mesh containing the submesh
  109924. * @param subMesh defines the submesh to bind the material to
  109925. */
  109926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109927. /**
  109928. * Binds the world matrix to the material
  109929. * @param world defines the world transformation matrix
  109930. */
  109931. bindOnlyWorldMatrix(world: Matrix): void;
  109932. /**
  109933. * Binds the scene's uniform buffer to the effect.
  109934. * @param effect defines the effect to bind to the scene uniform buffer
  109935. * @param sceneUbo defines the uniform buffer storing scene data
  109936. */
  109937. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  109938. /**
  109939. * Binds the view matrix to the effect
  109940. * @param effect defines the effect to bind the view matrix to
  109941. */
  109942. bindView(effect: Effect): void;
  109943. /**
  109944. * Binds the view projection matrix to the effect
  109945. * @param effect defines the effect to bind the view projection matrix to
  109946. */
  109947. bindViewProjection(effect: Effect): void;
  109948. /**
  109949. * Processes to execute after binding the material to a mesh
  109950. * @param mesh defines the rendered mesh
  109951. */
  109952. protected _afterBind(mesh?: Mesh): void;
  109953. /**
  109954. * Unbinds the material from the mesh
  109955. */
  109956. unbind(): void;
  109957. /**
  109958. * Gets the active textures from the material
  109959. * @returns an array of textures
  109960. */
  109961. getActiveTextures(): BaseTexture[];
  109962. /**
  109963. * Specifies if the material uses a texture
  109964. * @param texture defines the texture to check against the material
  109965. * @returns a boolean specifying if the material uses the texture
  109966. */
  109967. hasTexture(texture: BaseTexture): boolean;
  109968. /**
  109969. * Makes a duplicate of the material, and gives it a new name
  109970. * @param name defines the new name for the duplicated material
  109971. * @returns the cloned material
  109972. */
  109973. clone(name: string): Nullable<Material>;
  109974. /**
  109975. * Gets the meshes bound to the material
  109976. * @returns an array of meshes bound to the material
  109977. */
  109978. getBindedMeshes(): AbstractMesh[];
  109979. /**
  109980. * Force shader compilation
  109981. * @param mesh defines the mesh associated with this material
  109982. * @param onCompiled defines a function to execute once the material is compiled
  109983. * @param options defines the options to configure the compilation
  109984. * @param onError defines a function to execute if the material fails compiling
  109985. */
  109986. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  109987. /**
  109988. * Force shader compilation
  109989. * @param mesh defines the mesh that will use this material
  109990. * @param options defines additional options for compiling the shaders
  109991. * @returns a promise that resolves when the compilation completes
  109992. */
  109993. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  109994. private static readonly _AllDirtyCallBack;
  109995. private static readonly _ImageProcessingDirtyCallBack;
  109996. private static readonly _TextureDirtyCallBack;
  109997. private static readonly _FresnelDirtyCallBack;
  109998. private static readonly _MiscDirtyCallBack;
  109999. private static readonly _PrePassDirtyCallBack;
  110000. private static readonly _LightsDirtyCallBack;
  110001. private static readonly _AttributeDirtyCallBack;
  110002. private static _FresnelAndMiscDirtyCallBack;
  110003. private static _TextureAndMiscDirtyCallBack;
  110004. private static readonly _DirtyCallbackArray;
  110005. private static readonly _RunDirtyCallBacks;
  110006. /**
  110007. * Marks a define in the material to indicate that it needs to be re-computed
  110008. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110009. */
  110010. markAsDirty(flag: number): void;
  110011. /**
  110012. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110013. * @param func defines a function which checks material defines against the submeshes
  110014. */
  110015. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110016. /**
  110017. * Indicates that the scene should check if the rendering now needs a prepass
  110018. */
  110019. protected _markScenePrePassDirty(): void;
  110020. /**
  110021. * Indicates that we need to re-calculated for all submeshes
  110022. */
  110023. protected _markAllSubMeshesAsAllDirty(): void;
  110024. /**
  110025. * Indicates that image processing needs to be re-calculated for all submeshes
  110026. */
  110027. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110028. /**
  110029. * Indicates that textures need to be re-calculated for all submeshes
  110030. */
  110031. protected _markAllSubMeshesAsTexturesDirty(): void;
  110032. /**
  110033. * Indicates that fresnel needs to be re-calculated for all submeshes
  110034. */
  110035. protected _markAllSubMeshesAsFresnelDirty(): void;
  110036. /**
  110037. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110038. */
  110039. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110040. /**
  110041. * Indicates that lights need to be re-calculated for all submeshes
  110042. */
  110043. protected _markAllSubMeshesAsLightsDirty(): void;
  110044. /**
  110045. * Indicates that attributes need to be re-calculated for all submeshes
  110046. */
  110047. protected _markAllSubMeshesAsAttributesDirty(): void;
  110048. /**
  110049. * Indicates that misc needs to be re-calculated for all submeshes
  110050. */
  110051. protected _markAllSubMeshesAsMiscDirty(): void;
  110052. /**
  110053. * Indicates that prepass needs to be re-calculated for all submeshes
  110054. */
  110055. protected _markAllSubMeshesAsPrePassDirty(): void;
  110056. /**
  110057. * Indicates that textures and misc need to be re-calculated for all submeshes
  110058. */
  110059. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110060. /**
  110061. * Sets the required values to the prepass renderer.
  110062. * @param prePassRenderer defines the prepass renderer to setup.
  110063. * @returns true if the pre pass is needed.
  110064. */
  110065. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110066. /**
  110067. * Disposes the material
  110068. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110069. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110070. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110071. */
  110072. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110073. /** @hidden */
  110074. private releaseVertexArrayObject;
  110075. /**
  110076. * Serializes this material
  110077. * @returns the serialized material object
  110078. */
  110079. serialize(): any;
  110080. /**
  110081. * Creates a material from parsed material data
  110082. * @param parsedMaterial defines parsed material data
  110083. * @param scene defines the hosting scene
  110084. * @param rootUrl defines the root URL to use to load textures
  110085. * @returns a new material
  110086. */
  110087. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110088. }
  110089. }
  110090. declare module BABYLON {
  110091. /**
  110092. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110093. * separate meshes. This can be use to improve performances.
  110094. * @see https://doc.babylonjs.com/how_to/multi_materials
  110095. */
  110096. export class MultiMaterial extends Material {
  110097. private _subMaterials;
  110098. /**
  110099. * Gets or Sets the list of Materials used within the multi material.
  110100. * They need to be ordered according to the submeshes order in the associated mesh
  110101. */
  110102. get subMaterials(): Nullable<Material>[];
  110103. set subMaterials(value: Nullable<Material>[]);
  110104. /**
  110105. * Function used to align with Node.getChildren()
  110106. * @returns the list of Materials used within the multi material
  110107. */
  110108. getChildren(): Nullable<Material>[];
  110109. /**
  110110. * Instantiates a new Multi Material
  110111. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110112. * separate meshes. This can be use to improve performances.
  110113. * @see https://doc.babylonjs.com/how_to/multi_materials
  110114. * @param name Define the name in the scene
  110115. * @param scene Define the scene the material belongs to
  110116. */
  110117. constructor(name: string, scene: Scene);
  110118. private _hookArray;
  110119. /**
  110120. * Get one of the submaterial by its index in the submaterials array
  110121. * @param index The index to look the sub material at
  110122. * @returns The Material if the index has been defined
  110123. */
  110124. getSubMaterial(index: number): Nullable<Material>;
  110125. /**
  110126. * Get the list of active textures for the whole sub materials list.
  110127. * @returns All the textures that will be used during the rendering
  110128. */
  110129. getActiveTextures(): BaseTexture[];
  110130. /**
  110131. * Gets the current class name of the material e.g. "MultiMaterial"
  110132. * Mainly use in serialization.
  110133. * @returns the class name
  110134. */
  110135. getClassName(): string;
  110136. /**
  110137. * Checks if the material is ready to render the requested sub mesh
  110138. * @param mesh Define the mesh the submesh belongs to
  110139. * @param subMesh Define the sub mesh to look readyness for
  110140. * @param useInstances Define whether or not the material is used with instances
  110141. * @returns true if ready, otherwise false
  110142. */
  110143. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110144. /**
  110145. * Clones the current material and its related sub materials
  110146. * @param name Define the name of the newly cloned material
  110147. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110148. * @returns the cloned material
  110149. */
  110150. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110151. /**
  110152. * Serializes the materials into a JSON representation.
  110153. * @returns the JSON representation
  110154. */
  110155. serialize(): any;
  110156. /**
  110157. * Dispose the material and release its associated resources
  110158. * @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)
  110159. * @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)
  110160. * @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)
  110161. */
  110162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110163. /**
  110164. * Creates a MultiMaterial from parsed MultiMaterial data.
  110165. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110166. * @param scene defines the hosting scene
  110167. * @returns a new MultiMaterial
  110168. */
  110169. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /**
  110174. * Defines a subdivision inside a mesh
  110175. */
  110176. export class SubMesh implements ICullable {
  110177. /** the material index to use */
  110178. materialIndex: number;
  110179. /** vertex index start */
  110180. verticesStart: number;
  110181. /** vertices count */
  110182. verticesCount: number;
  110183. /** index start */
  110184. indexStart: number;
  110185. /** indices count */
  110186. indexCount: number;
  110187. /** @hidden */
  110188. _materialDefines: Nullable<MaterialDefines>;
  110189. /** @hidden */
  110190. _materialEffect: Nullable<Effect>;
  110191. /** @hidden */
  110192. _effectOverride: Nullable<Effect>;
  110193. /**
  110194. * Gets material defines used by the effect associated to the sub mesh
  110195. */
  110196. get materialDefines(): Nullable<MaterialDefines>;
  110197. /**
  110198. * Sets material defines used by the effect associated to the sub mesh
  110199. */
  110200. set materialDefines(defines: Nullable<MaterialDefines>);
  110201. /**
  110202. * Gets associated effect
  110203. */
  110204. get effect(): Nullable<Effect>;
  110205. /**
  110206. * Sets associated effect (effect used to render this submesh)
  110207. * @param effect defines the effect to associate with
  110208. * @param defines defines the set of defines used to compile this effect
  110209. */
  110210. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110211. /** @hidden */
  110212. _linesIndexCount: number;
  110213. private _mesh;
  110214. private _renderingMesh;
  110215. private _boundingInfo;
  110216. private _linesIndexBuffer;
  110217. /** @hidden */
  110218. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110219. /** @hidden */
  110220. _trianglePlanes: Plane[];
  110221. /** @hidden */
  110222. _lastColliderTransformMatrix: Nullable<Matrix>;
  110223. /** @hidden */
  110224. _renderId: number;
  110225. /** @hidden */
  110226. _alphaIndex: number;
  110227. /** @hidden */
  110228. _distanceToCamera: number;
  110229. /** @hidden */
  110230. _id: number;
  110231. private _currentMaterial;
  110232. /**
  110233. * Add a new submesh to a mesh
  110234. * @param materialIndex defines the material index to use
  110235. * @param verticesStart defines vertex index start
  110236. * @param verticesCount defines vertices count
  110237. * @param indexStart defines index start
  110238. * @param indexCount defines indices count
  110239. * @param mesh defines the parent mesh
  110240. * @param renderingMesh defines an optional rendering mesh
  110241. * @param createBoundingBox defines if bounding box should be created for this submesh
  110242. * @returns the new submesh
  110243. */
  110244. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110245. /**
  110246. * Creates a new submesh
  110247. * @param materialIndex defines the material index to use
  110248. * @param verticesStart defines vertex index start
  110249. * @param verticesCount defines vertices count
  110250. * @param indexStart defines index start
  110251. * @param indexCount defines indices count
  110252. * @param mesh defines the parent mesh
  110253. * @param renderingMesh defines an optional rendering mesh
  110254. * @param createBoundingBox defines if bounding box should be created for this submesh
  110255. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110256. */
  110257. constructor(
  110258. /** the material index to use */
  110259. materialIndex: number,
  110260. /** vertex index start */
  110261. verticesStart: number,
  110262. /** vertices count */
  110263. verticesCount: number,
  110264. /** index start */
  110265. indexStart: number,
  110266. /** indices count */
  110267. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110268. /**
  110269. * Returns true if this submesh covers the entire parent mesh
  110270. * @ignorenaming
  110271. */
  110272. get IsGlobal(): boolean;
  110273. /**
  110274. * Returns the submesh BoudingInfo object
  110275. * @returns current bounding info (or mesh's one if the submesh is global)
  110276. */
  110277. getBoundingInfo(): BoundingInfo;
  110278. /**
  110279. * Sets the submesh BoundingInfo
  110280. * @param boundingInfo defines the new bounding info to use
  110281. * @returns the SubMesh
  110282. */
  110283. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110284. /**
  110285. * Returns the mesh of the current submesh
  110286. * @return the parent mesh
  110287. */
  110288. getMesh(): AbstractMesh;
  110289. /**
  110290. * Returns the rendering mesh of the submesh
  110291. * @returns the rendering mesh (could be different from parent mesh)
  110292. */
  110293. getRenderingMesh(): Mesh;
  110294. /**
  110295. * Returns the replacement mesh of the submesh
  110296. * @returns the replacement mesh (could be different from parent mesh)
  110297. */
  110298. getReplacementMesh(): Nullable<AbstractMesh>;
  110299. /**
  110300. * Returns the effective mesh of the submesh
  110301. * @returns the effective mesh (could be different from parent mesh)
  110302. */
  110303. getEffectiveMesh(): AbstractMesh;
  110304. /**
  110305. * Returns the submesh material
  110306. * @returns null or the current material
  110307. */
  110308. getMaterial(): Nullable<Material>;
  110309. private _IsMultiMaterial;
  110310. /**
  110311. * Sets a new updated BoundingInfo object to the submesh
  110312. * @param data defines an optional position array to use to determine the bounding info
  110313. * @returns the SubMesh
  110314. */
  110315. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110316. /** @hidden */
  110317. _checkCollision(collider: Collider): boolean;
  110318. /**
  110319. * Updates the submesh BoundingInfo
  110320. * @param world defines the world matrix to use to update the bounding info
  110321. * @returns the submesh
  110322. */
  110323. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110324. /**
  110325. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110326. * @param frustumPlanes defines the frustum planes
  110327. * @returns true if the submesh is intersecting with the frustum
  110328. */
  110329. isInFrustum(frustumPlanes: Plane[]): boolean;
  110330. /**
  110331. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110332. * @param frustumPlanes defines the frustum planes
  110333. * @returns true if the submesh is inside the frustum
  110334. */
  110335. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110336. /**
  110337. * Renders the submesh
  110338. * @param enableAlphaMode defines if alpha needs to be used
  110339. * @returns the submesh
  110340. */
  110341. render(enableAlphaMode: boolean): SubMesh;
  110342. /**
  110343. * @hidden
  110344. */
  110345. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110346. /**
  110347. * Checks if the submesh intersects with a ray
  110348. * @param ray defines the ray to test
  110349. * @returns true is the passed ray intersects the submesh bounding box
  110350. */
  110351. canIntersects(ray: Ray): boolean;
  110352. /**
  110353. * Intersects current submesh with a ray
  110354. * @param ray defines the ray to test
  110355. * @param positions defines mesh's positions array
  110356. * @param indices defines mesh's indices array
  110357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110359. * @returns intersection info or null if no intersection
  110360. */
  110361. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110362. /** @hidden */
  110363. private _intersectLines;
  110364. /** @hidden */
  110365. private _intersectUnIndexedLines;
  110366. /** @hidden */
  110367. private _intersectTriangles;
  110368. /** @hidden */
  110369. private _intersectUnIndexedTriangles;
  110370. /** @hidden */
  110371. _rebuild(): void;
  110372. /**
  110373. * Creates a new submesh from the passed mesh
  110374. * @param newMesh defines the new hosting mesh
  110375. * @param newRenderingMesh defines an optional rendering mesh
  110376. * @returns the new submesh
  110377. */
  110378. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110379. /**
  110380. * Release associated resources
  110381. */
  110382. dispose(): void;
  110383. /**
  110384. * Gets the class name
  110385. * @returns the string "SubMesh".
  110386. */
  110387. getClassName(): string;
  110388. /**
  110389. * Creates a new submesh from indices data
  110390. * @param materialIndex the index of the main mesh material
  110391. * @param startIndex the index where to start the copy in the mesh indices array
  110392. * @param indexCount the number of indices to copy then from the startIndex
  110393. * @param mesh the main mesh to create the submesh from
  110394. * @param renderingMesh the optional rendering mesh
  110395. * @returns a new submesh
  110396. */
  110397. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110398. }
  110399. }
  110400. declare module BABYLON {
  110401. /**
  110402. * Class used to represent data loading progression
  110403. */
  110404. export class SceneLoaderFlags {
  110405. private static _ForceFullSceneLoadingForIncremental;
  110406. private static _ShowLoadingScreen;
  110407. private static _CleanBoneMatrixWeights;
  110408. private static _loggingLevel;
  110409. /**
  110410. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110411. */
  110412. static get ForceFullSceneLoadingForIncremental(): boolean;
  110413. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110414. /**
  110415. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110416. */
  110417. static get ShowLoadingScreen(): boolean;
  110418. static set ShowLoadingScreen(value: boolean);
  110419. /**
  110420. * Defines the current logging level (while loading the scene)
  110421. * @ignorenaming
  110422. */
  110423. static get loggingLevel(): number;
  110424. static set loggingLevel(value: number);
  110425. /**
  110426. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110427. */
  110428. static get CleanBoneMatrixWeights(): boolean;
  110429. static set CleanBoneMatrixWeights(value: boolean);
  110430. }
  110431. }
  110432. declare module BABYLON {
  110433. /**
  110434. * Class used to store geometry data (vertex buffers + index buffer)
  110435. */
  110436. export class Geometry implements IGetSetVerticesData {
  110437. /**
  110438. * Gets or sets the ID of the geometry
  110439. */
  110440. id: string;
  110441. /**
  110442. * Gets or sets the unique ID of the geometry
  110443. */
  110444. uniqueId: number;
  110445. /**
  110446. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110447. */
  110448. delayLoadState: number;
  110449. /**
  110450. * Gets the file containing the data to load when running in delay load state
  110451. */
  110452. delayLoadingFile: Nullable<string>;
  110453. /**
  110454. * Callback called when the geometry is updated
  110455. */
  110456. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110457. private _scene;
  110458. private _engine;
  110459. private _meshes;
  110460. private _totalVertices;
  110461. /** @hidden */
  110462. _indices: IndicesArray;
  110463. /** @hidden */
  110464. _vertexBuffers: {
  110465. [key: string]: VertexBuffer;
  110466. };
  110467. private _isDisposed;
  110468. private _extend;
  110469. private _boundingBias;
  110470. /** @hidden */
  110471. _delayInfo: Array<string>;
  110472. private _indexBuffer;
  110473. private _indexBufferIsUpdatable;
  110474. /** @hidden */
  110475. _boundingInfo: Nullable<BoundingInfo>;
  110476. /** @hidden */
  110477. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110478. /** @hidden */
  110479. _softwareSkinningFrameId: number;
  110480. private _vertexArrayObjects;
  110481. private _updatable;
  110482. /** @hidden */
  110483. _positions: Nullable<Vector3[]>;
  110484. /**
  110485. * 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
  110486. */
  110487. get boundingBias(): Vector2;
  110488. /**
  110489. * 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
  110490. */
  110491. set boundingBias(value: Vector2);
  110492. /**
  110493. * Static function used to attach a new empty geometry to a mesh
  110494. * @param mesh defines the mesh to attach the geometry to
  110495. * @returns the new Geometry
  110496. */
  110497. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110498. /** Get the list of meshes using this geometry */
  110499. get meshes(): Mesh[];
  110500. /**
  110501. * 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
  110502. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110503. */
  110504. useBoundingInfoFromGeometry: boolean;
  110505. /**
  110506. * Creates a new geometry
  110507. * @param id defines the unique ID
  110508. * @param scene defines the hosting scene
  110509. * @param vertexData defines the VertexData used to get geometry data
  110510. * @param updatable defines if geometry must be updatable (false by default)
  110511. * @param mesh defines the mesh that will be associated with the geometry
  110512. */
  110513. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110514. /**
  110515. * Gets the current extend of the geometry
  110516. */
  110517. get extend(): {
  110518. minimum: Vector3;
  110519. maximum: Vector3;
  110520. };
  110521. /**
  110522. * Gets the hosting scene
  110523. * @returns the hosting Scene
  110524. */
  110525. getScene(): Scene;
  110526. /**
  110527. * Gets the hosting engine
  110528. * @returns the hosting Engine
  110529. */
  110530. getEngine(): Engine;
  110531. /**
  110532. * Defines if the geometry is ready to use
  110533. * @returns true if the geometry is ready to be used
  110534. */
  110535. isReady(): boolean;
  110536. /**
  110537. * Gets a value indicating that the geometry should not be serialized
  110538. */
  110539. get doNotSerialize(): boolean;
  110540. /** @hidden */
  110541. _rebuild(): void;
  110542. /**
  110543. * Affects all geometry data in one call
  110544. * @param vertexData defines the geometry data
  110545. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110546. */
  110547. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110548. /**
  110549. * Set specific vertex data
  110550. * @param kind defines the data kind (Position, normal, etc...)
  110551. * @param data defines the vertex data to use
  110552. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110553. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110554. */
  110555. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110556. /**
  110557. * Removes a specific vertex data
  110558. * @param kind defines the data kind (Position, normal, etc...)
  110559. */
  110560. removeVerticesData(kind: string): void;
  110561. /**
  110562. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110563. * @param buffer defines the vertex buffer to use
  110564. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110565. */
  110566. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110567. /**
  110568. * Update a specific vertex buffer
  110569. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110570. * It will do nothing if the buffer is not updatable
  110571. * @param kind defines the data kind (Position, normal, etc...)
  110572. * @param data defines the data to use
  110573. * @param offset defines the offset in the target buffer where to store the data
  110574. * @param useBytes set to true if the offset is in bytes
  110575. */
  110576. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110577. /**
  110578. * Update a specific vertex buffer
  110579. * This function will create a new buffer if the current one is not updatable
  110580. * @param kind defines the data kind (Position, normal, etc...)
  110581. * @param data defines the data to use
  110582. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110583. */
  110584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110585. private _updateBoundingInfo;
  110586. /** @hidden */
  110587. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110588. /**
  110589. * Gets total number of vertices
  110590. * @returns the total number of vertices
  110591. */
  110592. getTotalVertices(): number;
  110593. /**
  110594. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110595. * @param kind defines the data kind (Position, normal, etc...)
  110596. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110597. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110598. * @returns a float array containing vertex data
  110599. */
  110600. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110601. /**
  110602. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110603. * @param kind defines the data kind (Position, normal, etc...)
  110604. * @returns true if the vertex buffer with the specified kind is updatable
  110605. */
  110606. isVertexBufferUpdatable(kind: string): boolean;
  110607. /**
  110608. * Gets a specific vertex buffer
  110609. * @param kind defines the data kind (Position, normal, etc...)
  110610. * @returns a VertexBuffer
  110611. */
  110612. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110613. /**
  110614. * Returns all vertex buffers
  110615. * @return an object holding all vertex buffers indexed by kind
  110616. */
  110617. getVertexBuffers(): Nullable<{
  110618. [key: string]: VertexBuffer;
  110619. }>;
  110620. /**
  110621. * Gets a boolean indicating if specific vertex buffer is present
  110622. * @param kind defines the data kind (Position, normal, etc...)
  110623. * @returns true if data is present
  110624. */
  110625. isVerticesDataPresent(kind: string): boolean;
  110626. /**
  110627. * Gets a list of all attached data kinds (Position, normal, etc...)
  110628. * @returns a list of string containing all kinds
  110629. */
  110630. getVerticesDataKinds(): string[];
  110631. /**
  110632. * Update index buffer
  110633. * @param indices defines the indices to store in the index buffer
  110634. * @param offset defines the offset in the target buffer where to store the data
  110635. * @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)
  110636. */
  110637. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110638. /**
  110639. * Creates a new index buffer
  110640. * @param indices defines the indices to store in the index buffer
  110641. * @param totalVertices defines the total number of vertices (could be null)
  110642. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110643. */
  110644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110645. /**
  110646. * Return the total number of indices
  110647. * @returns the total number of indices
  110648. */
  110649. getTotalIndices(): number;
  110650. /**
  110651. * Gets the index buffer array
  110652. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110653. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110654. * @returns the index buffer array
  110655. */
  110656. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110657. /**
  110658. * Gets the index buffer
  110659. * @return the index buffer
  110660. */
  110661. getIndexBuffer(): Nullable<DataBuffer>;
  110662. /** @hidden */
  110663. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110664. /**
  110665. * Release the associated resources for a specific mesh
  110666. * @param mesh defines the source mesh
  110667. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110668. */
  110669. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110670. /**
  110671. * Apply current geometry to a given mesh
  110672. * @param mesh defines the mesh to apply geometry to
  110673. */
  110674. applyToMesh(mesh: Mesh): void;
  110675. private _updateExtend;
  110676. private _applyToMesh;
  110677. private notifyUpdate;
  110678. /**
  110679. * Load the geometry if it was flagged as delay loaded
  110680. * @param scene defines the hosting scene
  110681. * @param onLoaded defines a callback called when the geometry is loaded
  110682. */
  110683. load(scene: Scene, onLoaded?: () => void): void;
  110684. private _queueLoad;
  110685. /**
  110686. * Invert the geometry to move from a right handed system to a left handed one.
  110687. */
  110688. toLeftHanded(): void;
  110689. /** @hidden */
  110690. _resetPointsArrayCache(): void;
  110691. /** @hidden */
  110692. _generatePointsArray(): boolean;
  110693. /**
  110694. * Gets a value indicating if the geometry is disposed
  110695. * @returns true if the geometry was disposed
  110696. */
  110697. isDisposed(): boolean;
  110698. private _disposeVertexArrayObjects;
  110699. /**
  110700. * Free all associated resources
  110701. */
  110702. dispose(): void;
  110703. /**
  110704. * Clone the current geometry into a new geometry
  110705. * @param id defines the unique ID of the new geometry
  110706. * @returns a new geometry object
  110707. */
  110708. copy(id: string): Geometry;
  110709. /**
  110710. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110711. * @return a JSON representation of the current geometry data (without the vertices data)
  110712. */
  110713. serialize(): any;
  110714. private toNumberArray;
  110715. /**
  110716. * Serialize all vertices data into a JSON oject
  110717. * @returns a JSON representation of the current geometry data
  110718. */
  110719. serializeVerticeData(): any;
  110720. /**
  110721. * Extracts a clone of a mesh geometry
  110722. * @param mesh defines the source mesh
  110723. * @param id defines the unique ID of the new geometry object
  110724. * @returns the new geometry object
  110725. */
  110726. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110727. /**
  110728. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110729. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110730. * Be aware Math.random() could cause collisions, but:
  110731. * "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"
  110732. * @returns a string containing a new GUID
  110733. */
  110734. static RandomId(): string;
  110735. /** @hidden */
  110736. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110737. private static _CleanMatricesWeights;
  110738. /**
  110739. * Create a new geometry from persisted data (Using .babylon file format)
  110740. * @param parsedVertexData defines the persisted data
  110741. * @param scene defines the hosting scene
  110742. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110743. * @returns the new geometry object
  110744. */
  110745. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110746. }
  110747. }
  110748. declare module BABYLON {
  110749. /**
  110750. * Define an interface for all classes that will get and set the data on vertices
  110751. */
  110752. export interface IGetSetVerticesData {
  110753. /**
  110754. * Gets a boolean indicating if specific vertex data is present
  110755. * @param kind defines the vertex data kind to use
  110756. * @returns true is data kind is present
  110757. */
  110758. isVerticesDataPresent(kind: string): boolean;
  110759. /**
  110760. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110761. * @param kind defines the data kind (Position, normal, etc...)
  110762. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110764. * @returns a float array containing vertex data
  110765. */
  110766. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110767. /**
  110768. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110769. * @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.
  110770. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110771. * @returns the indices array or an empty array if the mesh has no geometry
  110772. */
  110773. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110774. /**
  110775. * Set specific vertex data
  110776. * @param kind defines the data kind (Position, normal, etc...)
  110777. * @param data defines the vertex data to use
  110778. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110779. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110780. */
  110781. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110782. /**
  110783. * Update a specific associated vertex buffer
  110784. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110785. * - VertexBuffer.PositionKind
  110786. * - VertexBuffer.UVKind
  110787. * - VertexBuffer.UV2Kind
  110788. * - VertexBuffer.UV3Kind
  110789. * - VertexBuffer.UV4Kind
  110790. * - VertexBuffer.UV5Kind
  110791. * - VertexBuffer.UV6Kind
  110792. * - VertexBuffer.ColorKind
  110793. * - VertexBuffer.MatricesIndicesKind
  110794. * - VertexBuffer.MatricesIndicesExtraKind
  110795. * - VertexBuffer.MatricesWeightsKind
  110796. * - VertexBuffer.MatricesWeightsExtraKind
  110797. * @param data defines the data source
  110798. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110799. * @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)
  110800. */
  110801. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  110802. /**
  110803. * Creates a new index buffer
  110804. * @param indices defines the indices to store in the index buffer
  110805. * @param totalVertices defines the total number of vertices (could be null)
  110806. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110807. */
  110808. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  110809. }
  110810. /**
  110811. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  110812. */
  110813. export class VertexData {
  110814. /**
  110815. * Mesh side orientation : usually the external or front surface
  110816. */
  110817. static readonly FRONTSIDE: number;
  110818. /**
  110819. * Mesh side orientation : usually the internal or back surface
  110820. */
  110821. static readonly BACKSIDE: number;
  110822. /**
  110823. * Mesh side orientation : both internal and external or front and back surfaces
  110824. */
  110825. static readonly DOUBLESIDE: number;
  110826. /**
  110827. * Mesh side orientation : by default, `FRONTSIDE`
  110828. */
  110829. static readonly DEFAULTSIDE: number;
  110830. /**
  110831. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  110832. */
  110833. positions: Nullable<FloatArray>;
  110834. /**
  110835. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  110836. */
  110837. normals: Nullable<FloatArray>;
  110838. /**
  110839. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  110840. */
  110841. tangents: Nullable<FloatArray>;
  110842. /**
  110843. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110844. */
  110845. uvs: Nullable<FloatArray>;
  110846. /**
  110847. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110848. */
  110849. uvs2: Nullable<FloatArray>;
  110850. /**
  110851. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110852. */
  110853. uvs3: Nullable<FloatArray>;
  110854. /**
  110855. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110856. */
  110857. uvs4: Nullable<FloatArray>;
  110858. /**
  110859. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110860. */
  110861. uvs5: Nullable<FloatArray>;
  110862. /**
  110863. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110864. */
  110865. uvs6: Nullable<FloatArray>;
  110866. /**
  110867. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  110868. */
  110869. colors: Nullable<FloatArray>;
  110870. /**
  110871. * 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).
  110872. */
  110873. matricesIndices: Nullable<FloatArray>;
  110874. /**
  110875. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  110876. */
  110877. matricesWeights: Nullable<FloatArray>;
  110878. /**
  110879. * An array extending the number of possible indices
  110880. */
  110881. matricesIndicesExtra: Nullable<FloatArray>;
  110882. /**
  110883. * An array extending the number of possible weights when the number of indices is extended
  110884. */
  110885. matricesWeightsExtra: Nullable<FloatArray>;
  110886. /**
  110887. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  110888. */
  110889. indices: Nullable<IndicesArray>;
  110890. /**
  110891. * Uses the passed data array to set the set the values for the specified kind of data
  110892. * @param data a linear array of floating numbers
  110893. * @param kind the type of data that is being set, eg positions, colors etc
  110894. */
  110895. set(data: FloatArray, kind: string): void;
  110896. /**
  110897. * Associates the vertexData to the passed Mesh.
  110898. * Sets it as updatable or not (default `false`)
  110899. * @param mesh the mesh the vertexData is applied to
  110900. * @param updatable when used and having the value true allows new data to update the vertexData
  110901. * @returns the VertexData
  110902. */
  110903. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  110904. /**
  110905. * Associates the vertexData to the passed Geometry.
  110906. * Sets it as updatable or not (default `false`)
  110907. * @param geometry the geometry the vertexData is applied to
  110908. * @param updatable when used and having the value true allows new data to update the vertexData
  110909. * @returns VertexData
  110910. */
  110911. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  110912. /**
  110913. * Updates the associated mesh
  110914. * @param mesh the mesh to be updated
  110915. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110916. * @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
  110917. * @returns VertexData
  110918. */
  110919. updateMesh(mesh: Mesh): VertexData;
  110920. /**
  110921. * Updates the associated geometry
  110922. * @param geometry the geometry to be updated
  110923. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  110924. * @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
  110925. * @returns VertexData.
  110926. */
  110927. updateGeometry(geometry: Geometry): VertexData;
  110928. private _applyTo;
  110929. private _update;
  110930. /**
  110931. * Transforms each position and each normal of the vertexData according to the passed Matrix
  110932. * @param matrix the transforming matrix
  110933. * @returns the VertexData
  110934. */
  110935. transform(matrix: Matrix): VertexData;
  110936. /**
  110937. * Merges the passed VertexData into the current one
  110938. * @param other the VertexData to be merged into the current one
  110939. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  110940. * @returns the modified VertexData
  110941. */
  110942. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  110943. private _mergeElement;
  110944. private _validate;
  110945. /**
  110946. * Serializes the VertexData
  110947. * @returns a serialized object
  110948. */
  110949. serialize(): any;
  110950. /**
  110951. * Extracts the vertexData from a mesh
  110952. * @param mesh the mesh from which to extract the VertexData
  110953. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  110954. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110955. * @returns the object VertexData associated to the passed mesh
  110956. */
  110957. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110958. /**
  110959. * Extracts the vertexData from the geometry
  110960. * @param geometry the geometry from which to extract the VertexData
  110961. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  110962. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  110963. * @returns the object VertexData associated to the passed mesh
  110964. */
  110965. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  110966. private static _ExtractFrom;
  110967. /**
  110968. * Creates the VertexData for a Ribbon
  110969. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  110970. * * pathArray array of paths, each of which an array of successive Vector3
  110971. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  110972. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  110973. * * 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
  110974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110975. * * 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)
  110976. * * 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)
  110977. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  110978. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  110979. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  110980. * @returns the VertexData of the ribbon
  110981. */
  110982. static CreateRibbon(options: {
  110983. pathArray: Vector3[][];
  110984. closeArray?: boolean;
  110985. closePath?: boolean;
  110986. offset?: number;
  110987. sideOrientation?: number;
  110988. frontUVs?: Vector4;
  110989. backUVs?: Vector4;
  110990. invertUV?: boolean;
  110991. uvs?: Vector2[];
  110992. colors?: Color4[];
  110993. }): VertexData;
  110994. /**
  110995. * Creates the VertexData for a box
  110996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  110997. * * size sets the width, height and depth of the box to the value of size, optional default 1
  110998. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  110999. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111000. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111001. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111002. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111004. * * 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)
  111005. * * 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)
  111006. * @returns the VertexData of the box
  111007. */
  111008. static CreateBox(options: {
  111009. size?: number;
  111010. width?: number;
  111011. height?: number;
  111012. depth?: number;
  111013. faceUV?: Vector4[];
  111014. faceColors?: Color4[];
  111015. sideOrientation?: number;
  111016. frontUVs?: Vector4;
  111017. backUVs?: Vector4;
  111018. }): VertexData;
  111019. /**
  111020. * Creates the VertexData for a tiled box
  111021. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111022. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111023. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111024. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111026. * @returns the VertexData of the box
  111027. */
  111028. static CreateTiledBox(options: {
  111029. pattern?: number;
  111030. width?: number;
  111031. height?: number;
  111032. depth?: number;
  111033. tileSize?: number;
  111034. tileWidth?: number;
  111035. tileHeight?: number;
  111036. alignHorizontal?: number;
  111037. alignVertical?: number;
  111038. faceUV?: Vector4[];
  111039. faceColors?: Color4[];
  111040. sideOrientation?: number;
  111041. }): VertexData;
  111042. /**
  111043. * Creates the VertexData for a tiled plane
  111044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111045. * * pattern a limited pattern arrangement depending on the number
  111046. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111047. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111048. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111050. * * 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)
  111051. * * 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)
  111052. * @returns the VertexData of the tiled plane
  111053. */
  111054. static CreateTiledPlane(options: {
  111055. pattern?: number;
  111056. tileSize?: number;
  111057. tileWidth?: number;
  111058. tileHeight?: number;
  111059. size?: number;
  111060. width?: number;
  111061. height?: number;
  111062. alignHorizontal?: number;
  111063. alignVertical?: number;
  111064. sideOrientation?: number;
  111065. frontUVs?: Vector4;
  111066. backUVs?: Vector4;
  111067. }): VertexData;
  111068. /**
  111069. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111070. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111071. * * segments sets the number of horizontal strips optional, default 32
  111072. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111073. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111074. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111075. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111076. * * 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
  111077. * * 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
  111078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111079. * * 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)
  111080. * * 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)
  111081. * @returns the VertexData of the ellipsoid
  111082. */
  111083. static CreateSphere(options: {
  111084. segments?: number;
  111085. diameter?: number;
  111086. diameterX?: number;
  111087. diameterY?: number;
  111088. diameterZ?: number;
  111089. arc?: number;
  111090. slice?: number;
  111091. sideOrientation?: number;
  111092. frontUVs?: Vector4;
  111093. backUVs?: Vector4;
  111094. }): VertexData;
  111095. /**
  111096. * Creates the VertexData for a cylinder, cone or prism
  111097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111098. * * height sets the height (y direction) of the cylinder, optional, default 2
  111099. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111100. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111101. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111102. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111103. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111104. * * 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
  111105. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111106. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111107. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111108. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111110. * * 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)
  111111. * * 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)
  111112. * @returns the VertexData of the cylinder, cone or prism
  111113. */
  111114. static CreateCylinder(options: {
  111115. height?: number;
  111116. diameterTop?: number;
  111117. diameterBottom?: number;
  111118. diameter?: number;
  111119. tessellation?: number;
  111120. subdivisions?: number;
  111121. arc?: number;
  111122. faceColors?: Color4[];
  111123. faceUV?: Vector4[];
  111124. hasRings?: boolean;
  111125. enclose?: boolean;
  111126. sideOrientation?: number;
  111127. frontUVs?: Vector4;
  111128. backUVs?: Vector4;
  111129. }): VertexData;
  111130. /**
  111131. * Creates the VertexData for a torus
  111132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111133. * * diameter the diameter of the torus, optional default 1
  111134. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111135. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111137. * * 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)
  111138. * * 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)
  111139. * @returns the VertexData of the torus
  111140. */
  111141. static CreateTorus(options: {
  111142. diameter?: number;
  111143. thickness?: number;
  111144. tessellation?: number;
  111145. sideOrientation?: number;
  111146. frontUVs?: Vector4;
  111147. backUVs?: Vector4;
  111148. }): VertexData;
  111149. /**
  111150. * Creates the VertexData of the LineSystem
  111151. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111152. * - lines an array of lines, each line being an array of successive Vector3
  111153. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111154. * @returns the VertexData of the LineSystem
  111155. */
  111156. static CreateLineSystem(options: {
  111157. lines: Vector3[][];
  111158. colors?: Nullable<Color4[][]>;
  111159. }): VertexData;
  111160. /**
  111161. * Create the VertexData for a DashedLines
  111162. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111163. * - points an array successive Vector3
  111164. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111165. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111166. * - dashNb the intended total number of dashes, optional, default 200
  111167. * @returns the VertexData for the DashedLines
  111168. */
  111169. static CreateDashedLines(options: {
  111170. points: Vector3[];
  111171. dashSize?: number;
  111172. gapSize?: number;
  111173. dashNb?: number;
  111174. }): VertexData;
  111175. /**
  111176. * Creates the VertexData for a Ground
  111177. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111178. * - width the width (x direction) of the ground, optional, default 1
  111179. * - height the height (z direction) of the ground, optional, default 1
  111180. * - subdivisions the number of subdivisions per side, optional, default 1
  111181. * @returns the VertexData of the Ground
  111182. */
  111183. static CreateGround(options: {
  111184. width?: number;
  111185. height?: number;
  111186. subdivisions?: number;
  111187. subdivisionsX?: number;
  111188. subdivisionsY?: number;
  111189. }): VertexData;
  111190. /**
  111191. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111192. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111193. * * xmin the ground minimum X coordinate, optional, default -1
  111194. * * zmin the ground minimum Z coordinate, optional, default -1
  111195. * * xmax the ground maximum X coordinate, optional, default 1
  111196. * * zmax the ground maximum Z coordinate, optional, default 1
  111197. * * 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}
  111198. * * 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}
  111199. * @returns the VertexData of the TiledGround
  111200. */
  111201. static CreateTiledGround(options: {
  111202. xmin: number;
  111203. zmin: number;
  111204. xmax: number;
  111205. zmax: number;
  111206. subdivisions?: {
  111207. w: number;
  111208. h: number;
  111209. };
  111210. precision?: {
  111211. w: number;
  111212. h: number;
  111213. };
  111214. }): VertexData;
  111215. /**
  111216. * Creates the VertexData of the Ground designed from a heightmap
  111217. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111218. * * width the width (x direction) of the ground
  111219. * * height the height (z direction) of the ground
  111220. * * subdivisions the number of subdivisions per side
  111221. * * minHeight the minimum altitude on the ground, optional, default 0
  111222. * * maxHeight the maximum altitude on the ground, optional default 1
  111223. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111224. * * buffer the array holding the image color data
  111225. * * bufferWidth the width of image
  111226. * * bufferHeight the height of image
  111227. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111228. * @returns the VertexData of the Ground designed from a heightmap
  111229. */
  111230. static CreateGroundFromHeightMap(options: {
  111231. width: number;
  111232. height: number;
  111233. subdivisions: number;
  111234. minHeight: number;
  111235. maxHeight: number;
  111236. colorFilter: Color3;
  111237. buffer: Uint8Array;
  111238. bufferWidth: number;
  111239. bufferHeight: number;
  111240. alphaFilter: number;
  111241. }): VertexData;
  111242. /**
  111243. * Creates the VertexData for a Plane
  111244. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111245. * * size sets the width and height of the plane to the value of size, optional default 1
  111246. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111247. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111249. * * 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)
  111250. * * 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)
  111251. * @returns the VertexData of the box
  111252. */
  111253. static CreatePlane(options: {
  111254. size?: number;
  111255. width?: number;
  111256. height?: number;
  111257. sideOrientation?: number;
  111258. frontUVs?: Vector4;
  111259. backUVs?: Vector4;
  111260. }): VertexData;
  111261. /**
  111262. * Creates the VertexData of the Disc or regular Polygon
  111263. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111264. * * radius the radius of the disc, optional default 0.5
  111265. * * tessellation the number of polygon sides, optional, default 64
  111266. * * 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
  111267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111268. * * 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)
  111269. * * 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)
  111270. * @returns the VertexData of the box
  111271. */
  111272. static CreateDisc(options: {
  111273. radius?: number;
  111274. tessellation?: number;
  111275. arc?: number;
  111276. sideOrientation?: number;
  111277. frontUVs?: Vector4;
  111278. backUVs?: Vector4;
  111279. }): VertexData;
  111280. /**
  111281. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111282. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111283. * @param polygon a mesh built from polygonTriangulation.build()
  111284. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111285. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111286. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111287. * @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)
  111288. * @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)
  111289. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111290. * @returns the VertexData of the Polygon
  111291. */
  111292. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111293. /**
  111294. * Creates the VertexData of the IcoSphere
  111295. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111296. * * radius the radius of the IcoSphere, optional default 1
  111297. * * radiusX allows stretching in the x direction, optional, default radius
  111298. * * radiusY allows stretching in the y direction, optional, default radius
  111299. * * radiusZ allows stretching in the z direction, optional, default radius
  111300. * * flat when true creates a flat shaded mesh, optional, default true
  111301. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111303. * * 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)
  111304. * * 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)
  111305. * @returns the VertexData of the IcoSphere
  111306. */
  111307. static CreateIcoSphere(options: {
  111308. radius?: number;
  111309. radiusX?: number;
  111310. radiusY?: number;
  111311. radiusZ?: number;
  111312. flat?: boolean;
  111313. subdivisions?: number;
  111314. sideOrientation?: number;
  111315. frontUVs?: Vector4;
  111316. backUVs?: Vector4;
  111317. }): VertexData;
  111318. /**
  111319. * Creates the VertexData for a Polyhedron
  111320. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111321. * * type provided types are:
  111322. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111323. * * 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)
  111324. * * size the size of the IcoSphere, optional default 1
  111325. * * sizeX allows stretching in the x direction, optional, default size
  111326. * * sizeY allows stretching in the y direction, optional, default size
  111327. * * sizeZ allows stretching in the z direction, optional, default size
  111328. * * 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
  111329. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111330. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111331. * * flat when true creates a flat shaded mesh, optional, default true
  111332. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111334. * * 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)
  111335. * * 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)
  111336. * @returns the VertexData of the Polyhedron
  111337. */
  111338. static CreatePolyhedron(options: {
  111339. type?: number;
  111340. size?: number;
  111341. sizeX?: number;
  111342. sizeY?: number;
  111343. sizeZ?: number;
  111344. custom?: any;
  111345. faceUV?: Vector4[];
  111346. faceColors?: Color4[];
  111347. flat?: boolean;
  111348. sideOrientation?: number;
  111349. frontUVs?: Vector4;
  111350. backUVs?: Vector4;
  111351. }): VertexData;
  111352. /**
  111353. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111354. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111355. * @returns the VertexData of the Capsule
  111356. */
  111357. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111358. /**
  111359. * Creates the VertexData for a TorusKnot
  111360. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111361. * * radius the radius of the torus knot, optional, default 2
  111362. * * tube the thickness of the tube, optional, default 0.5
  111363. * * radialSegments the number of sides on each tube segments, optional, default 32
  111364. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111365. * * p the number of windings around the z axis, optional, default 2
  111366. * * q the number of windings around the x axis, optional, default 3
  111367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111368. * * 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)
  111369. * * 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)
  111370. * @returns the VertexData of the Torus Knot
  111371. */
  111372. static CreateTorusKnot(options: {
  111373. radius?: number;
  111374. tube?: number;
  111375. radialSegments?: number;
  111376. tubularSegments?: number;
  111377. p?: number;
  111378. q?: number;
  111379. sideOrientation?: number;
  111380. frontUVs?: Vector4;
  111381. backUVs?: Vector4;
  111382. }): VertexData;
  111383. /**
  111384. * Compute normals for given positions and indices
  111385. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111386. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111387. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111388. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111389. * * facetNormals : optional array of facet normals (vector3)
  111390. * * facetPositions : optional array of facet positions (vector3)
  111391. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111392. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111393. * * bInfo : optional bounding info, required for facetPartitioning computation
  111394. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111395. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111396. * * useRightHandedSystem: optional boolean to for right handed system computation
  111397. * * depthSort : optional boolean to enable the facet depth sort computation
  111398. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111399. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111400. */
  111401. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111402. facetNormals?: any;
  111403. facetPositions?: any;
  111404. facetPartitioning?: any;
  111405. ratio?: number;
  111406. bInfo?: any;
  111407. bbSize?: Vector3;
  111408. subDiv?: any;
  111409. useRightHandedSystem?: boolean;
  111410. depthSort?: boolean;
  111411. distanceTo?: Vector3;
  111412. depthSortedFacets?: any;
  111413. }): void;
  111414. /** @hidden */
  111415. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111416. /**
  111417. * Applies VertexData created from the imported parameters to the geometry
  111418. * @param parsedVertexData the parsed data from an imported file
  111419. * @param geometry the geometry to apply the VertexData to
  111420. */
  111421. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111422. }
  111423. }
  111424. declare module BABYLON {
  111425. /**
  111426. * Defines a target to use with MorphTargetManager
  111427. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111428. */
  111429. export class MorphTarget implements IAnimatable {
  111430. /** defines the name of the target */
  111431. name: string;
  111432. /**
  111433. * Gets or sets the list of animations
  111434. */
  111435. animations: Animation[];
  111436. private _scene;
  111437. private _positions;
  111438. private _normals;
  111439. private _tangents;
  111440. private _uvs;
  111441. private _influence;
  111442. private _uniqueId;
  111443. /**
  111444. * Observable raised when the influence changes
  111445. */
  111446. onInfluenceChanged: Observable<boolean>;
  111447. /** @hidden */
  111448. _onDataLayoutChanged: Observable<void>;
  111449. /**
  111450. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111451. */
  111452. get influence(): number;
  111453. set influence(influence: number);
  111454. /**
  111455. * Gets or sets the id of the morph Target
  111456. */
  111457. id: string;
  111458. private _animationPropertiesOverride;
  111459. /**
  111460. * Gets or sets the animation properties override
  111461. */
  111462. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111463. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111464. /**
  111465. * Creates a new MorphTarget
  111466. * @param name defines the name of the target
  111467. * @param influence defines the influence to use
  111468. * @param scene defines the scene the morphtarget belongs to
  111469. */
  111470. constructor(
  111471. /** defines the name of the target */
  111472. name: string, influence?: number, scene?: Nullable<Scene>);
  111473. /**
  111474. * Gets the unique ID of this manager
  111475. */
  111476. get uniqueId(): number;
  111477. /**
  111478. * Gets a boolean defining if the target contains position data
  111479. */
  111480. get hasPositions(): boolean;
  111481. /**
  111482. * Gets a boolean defining if the target contains normal data
  111483. */
  111484. get hasNormals(): boolean;
  111485. /**
  111486. * Gets a boolean defining if the target contains tangent data
  111487. */
  111488. get hasTangents(): boolean;
  111489. /**
  111490. * Gets a boolean defining if the target contains texture coordinates data
  111491. */
  111492. get hasUVs(): boolean;
  111493. /**
  111494. * Affects position data to this target
  111495. * @param data defines the position data to use
  111496. */
  111497. setPositions(data: Nullable<FloatArray>): void;
  111498. /**
  111499. * Gets the position data stored in this target
  111500. * @returns a FloatArray containing the position data (or null if not present)
  111501. */
  111502. getPositions(): Nullable<FloatArray>;
  111503. /**
  111504. * Affects normal data to this target
  111505. * @param data defines the normal data to use
  111506. */
  111507. setNormals(data: Nullable<FloatArray>): void;
  111508. /**
  111509. * Gets the normal data stored in this target
  111510. * @returns a FloatArray containing the normal data (or null if not present)
  111511. */
  111512. getNormals(): Nullable<FloatArray>;
  111513. /**
  111514. * Affects tangent data to this target
  111515. * @param data defines the tangent data to use
  111516. */
  111517. setTangents(data: Nullable<FloatArray>): void;
  111518. /**
  111519. * Gets the tangent data stored in this target
  111520. * @returns a FloatArray containing the tangent data (or null if not present)
  111521. */
  111522. getTangents(): Nullable<FloatArray>;
  111523. /**
  111524. * Affects texture coordinates data to this target
  111525. * @param data defines the texture coordinates data to use
  111526. */
  111527. setUVs(data: Nullable<FloatArray>): void;
  111528. /**
  111529. * Gets the texture coordinates data stored in this target
  111530. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111531. */
  111532. getUVs(): Nullable<FloatArray>;
  111533. /**
  111534. * Clone the current target
  111535. * @returns a new MorphTarget
  111536. */
  111537. clone(): MorphTarget;
  111538. /**
  111539. * Serializes the current target into a Serialization object
  111540. * @returns the serialized object
  111541. */
  111542. serialize(): any;
  111543. /**
  111544. * Returns the string "MorphTarget"
  111545. * @returns "MorphTarget"
  111546. */
  111547. getClassName(): string;
  111548. /**
  111549. * Creates a new target from serialized data
  111550. * @param serializationObject defines the serialized data to use
  111551. * @returns a new MorphTarget
  111552. */
  111553. static Parse(serializationObject: any): MorphTarget;
  111554. /**
  111555. * Creates a MorphTarget from mesh data
  111556. * @param mesh defines the source mesh
  111557. * @param name defines the name to use for the new target
  111558. * @param influence defines the influence to attach to the target
  111559. * @returns a new MorphTarget
  111560. */
  111561. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111562. }
  111563. }
  111564. declare module BABYLON {
  111565. /**
  111566. * This class is used to deform meshes using morphing between different targets
  111567. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111568. */
  111569. export class MorphTargetManager {
  111570. private _targets;
  111571. private _targetInfluenceChangedObservers;
  111572. private _targetDataLayoutChangedObservers;
  111573. private _activeTargets;
  111574. private _scene;
  111575. private _influences;
  111576. private _supportsNormals;
  111577. private _supportsTangents;
  111578. private _supportsUVs;
  111579. private _vertexCount;
  111580. private _uniqueId;
  111581. private _tempInfluences;
  111582. /**
  111583. * Gets or sets a boolean indicating if normals must be morphed
  111584. */
  111585. enableNormalMorphing: boolean;
  111586. /**
  111587. * Gets or sets a boolean indicating if tangents must be morphed
  111588. */
  111589. enableTangentMorphing: boolean;
  111590. /**
  111591. * Gets or sets a boolean indicating if UV must be morphed
  111592. */
  111593. enableUVMorphing: boolean;
  111594. /**
  111595. * Creates a new MorphTargetManager
  111596. * @param scene defines the current scene
  111597. */
  111598. constructor(scene?: Nullable<Scene>);
  111599. /**
  111600. * Gets the unique ID of this manager
  111601. */
  111602. get uniqueId(): number;
  111603. /**
  111604. * Gets the number of vertices handled by this manager
  111605. */
  111606. get vertexCount(): number;
  111607. /**
  111608. * Gets a boolean indicating if this manager supports morphing of normals
  111609. */
  111610. get supportsNormals(): boolean;
  111611. /**
  111612. * Gets a boolean indicating if this manager supports morphing of tangents
  111613. */
  111614. get supportsTangents(): boolean;
  111615. /**
  111616. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111617. */
  111618. get supportsUVs(): boolean;
  111619. /**
  111620. * Gets the number of targets stored in this manager
  111621. */
  111622. get numTargets(): number;
  111623. /**
  111624. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111625. */
  111626. get numInfluencers(): number;
  111627. /**
  111628. * Gets the list of influences (one per target)
  111629. */
  111630. get influences(): Float32Array;
  111631. /**
  111632. * Gets the active target at specified index. An active target is a target with an influence > 0
  111633. * @param index defines the index to check
  111634. * @returns the requested target
  111635. */
  111636. getActiveTarget(index: number): MorphTarget;
  111637. /**
  111638. * Gets the target at specified index
  111639. * @param index defines the index to check
  111640. * @returns the requested target
  111641. */
  111642. getTarget(index: number): MorphTarget;
  111643. /**
  111644. * Add a new target to this manager
  111645. * @param target defines the target to add
  111646. */
  111647. addTarget(target: MorphTarget): void;
  111648. /**
  111649. * Removes a target from the manager
  111650. * @param target defines the target to remove
  111651. */
  111652. removeTarget(target: MorphTarget): void;
  111653. /**
  111654. * Clone the current manager
  111655. * @returns a new MorphTargetManager
  111656. */
  111657. clone(): MorphTargetManager;
  111658. /**
  111659. * Serializes the current manager into a Serialization object
  111660. * @returns the serialized object
  111661. */
  111662. serialize(): any;
  111663. private _syncActiveTargets;
  111664. /**
  111665. * Syncrhonize the targets with all the meshes using this morph target manager
  111666. */
  111667. synchronize(): void;
  111668. /**
  111669. * Creates a new MorphTargetManager from serialized data
  111670. * @param serializationObject defines the serialized data
  111671. * @param scene defines the hosting scene
  111672. * @returns the new MorphTargetManager
  111673. */
  111674. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111675. }
  111676. }
  111677. declare module BABYLON {
  111678. /**
  111679. * Class used to represent a specific level of detail of a mesh
  111680. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111681. */
  111682. export class MeshLODLevel {
  111683. /** Defines the distance where this level should start being displayed */
  111684. distance: number;
  111685. /** Defines the mesh to use to render this level */
  111686. mesh: Nullable<Mesh>;
  111687. /**
  111688. * Creates a new LOD level
  111689. * @param distance defines the distance where this level should star being displayed
  111690. * @param mesh defines the mesh to use to render this level
  111691. */
  111692. constructor(
  111693. /** Defines the distance where this level should start being displayed */
  111694. distance: number,
  111695. /** Defines the mesh to use to render this level */
  111696. mesh: Nullable<Mesh>);
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /**
  111701. * Helper class used to generate a canvas to manipulate images
  111702. */
  111703. export class CanvasGenerator {
  111704. /**
  111705. * Create a new canvas (or offscreen canvas depending on the context)
  111706. * @param width defines the expected width
  111707. * @param height defines the expected height
  111708. * @return a new canvas or offscreen canvas
  111709. */
  111710. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111711. }
  111712. }
  111713. declare module BABYLON {
  111714. /**
  111715. * Mesh representing the gorund
  111716. */
  111717. export class GroundMesh extends Mesh {
  111718. /** If octree should be generated */
  111719. generateOctree: boolean;
  111720. private _heightQuads;
  111721. /** @hidden */
  111722. _subdivisionsX: number;
  111723. /** @hidden */
  111724. _subdivisionsY: number;
  111725. /** @hidden */
  111726. _width: number;
  111727. /** @hidden */
  111728. _height: number;
  111729. /** @hidden */
  111730. _minX: number;
  111731. /** @hidden */
  111732. _maxX: number;
  111733. /** @hidden */
  111734. _minZ: number;
  111735. /** @hidden */
  111736. _maxZ: number;
  111737. constructor(name: string, scene: Scene);
  111738. /**
  111739. * "GroundMesh"
  111740. * @returns "GroundMesh"
  111741. */
  111742. getClassName(): string;
  111743. /**
  111744. * The minimum of x and y subdivisions
  111745. */
  111746. get subdivisions(): number;
  111747. /**
  111748. * X subdivisions
  111749. */
  111750. get subdivisionsX(): number;
  111751. /**
  111752. * Y subdivisions
  111753. */
  111754. get subdivisionsY(): number;
  111755. /**
  111756. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111757. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111758. * @param chunksCount the number of subdivisions for x and y
  111759. * @param octreeBlocksSize (Default: 32)
  111760. */
  111761. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111762. /**
  111763. * Returns a height (y) value in the Worl system :
  111764. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111765. * @param x x coordinate
  111766. * @param z z coordinate
  111767. * @returns the ground y position if (x, z) are outside the ground surface.
  111768. */
  111769. getHeightAtCoordinates(x: number, z: number): number;
  111770. /**
  111771. * Returns a normalized vector (Vector3) orthogonal to the ground
  111772. * at the ground coordinates (x, z) expressed in the World system.
  111773. * @param x x coordinate
  111774. * @param z z coordinate
  111775. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111776. */
  111777. getNormalAtCoordinates(x: number, z: number): Vector3;
  111778. /**
  111779. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111780. * at the ground coordinates (x, z) expressed in the World system.
  111781. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111782. * @param x x coordinate
  111783. * @param z z coordinate
  111784. * @param ref vector to store the result
  111785. * @returns the GroundMesh.
  111786. */
  111787. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111788. /**
  111789. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111790. * if the ground has been updated.
  111791. * This can be used in the render loop.
  111792. * @returns the GroundMesh.
  111793. */
  111794. updateCoordinateHeights(): GroundMesh;
  111795. private _getFacetAt;
  111796. private _initHeightQuads;
  111797. private _computeHeightQuads;
  111798. /**
  111799. * Serializes this ground mesh
  111800. * @param serializationObject object to write serialization to
  111801. */
  111802. serialize(serializationObject: any): void;
  111803. /**
  111804. * Parses a serialized ground mesh
  111805. * @param parsedMesh the serialized mesh
  111806. * @param scene the scene to create the ground mesh in
  111807. * @returns the created ground mesh
  111808. */
  111809. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  111810. }
  111811. }
  111812. declare module BABYLON {
  111813. /**
  111814. * Interface for Physics-Joint data
  111815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111816. */
  111817. export interface PhysicsJointData {
  111818. /**
  111819. * The main pivot of the joint
  111820. */
  111821. mainPivot?: Vector3;
  111822. /**
  111823. * The connected pivot of the joint
  111824. */
  111825. connectedPivot?: Vector3;
  111826. /**
  111827. * The main axis of the joint
  111828. */
  111829. mainAxis?: Vector3;
  111830. /**
  111831. * The connected axis of the joint
  111832. */
  111833. connectedAxis?: Vector3;
  111834. /**
  111835. * The collision of the joint
  111836. */
  111837. collision?: boolean;
  111838. /**
  111839. * Native Oimo/Cannon/Energy data
  111840. */
  111841. nativeParams?: any;
  111842. }
  111843. /**
  111844. * This is a holder class for the physics joint created by the physics plugin
  111845. * It holds a set of functions to control the underlying joint
  111846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111847. */
  111848. export class PhysicsJoint {
  111849. /**
  111850. * The type of the physics joint
  111851. */
  111852. type: number;
  111853. /**
  111854. * The data for the physics joint
  111855. */
  111856. jointData: PhysicsJointData;
  111857. private _physicsJoint;
  111858. protected _physicsPlugin: IPhysicsEnginePlugin;
  111859. /**
  111860. * Initializes the physics joint
  111861. * @param type The type of the physics joint
  111862. * @param jointData The data for the physics joint
  111863. */
  111864. constructor(
  111865. /**
  111866. * The type of the physics joint
  111867. */
  111868. type: number,
  111869. /**
  111870. * The data for the physics joint
  111871. */
  111872. jointData: PhysicsJointData);
  111873. /**
  111874. * Gets the physics joint
  111875. */
  111876. get physicsJoint(): any;
  111877. /**
  111878. * Sets the physics joint
  111879. */
  111880. set physicsJoint(newJoint: any);
  111881. /**
  111882. * Sets the physics plugin
  111883. */
  111884. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  111885. /**
  111886. * Execute a function that is physics-plugin specific.
  111887. * @param {Function} func the function that will be executed.
  111888. * It accepts two parameters: the physics world and the physics joint
  111889. */
  111890. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  111891. /**
  111892. * Distance-Joint type
  111893. */
  111894. static DistanceJoint: number;
  111895. /**
  111896. * Hinge-Joint type
  111897. */
  111898. static HingeJoint: number;
  111899. /**
  111900. * Ball-and-Socket joint type
  111901. */
  111902. static BallAndSocketJoint: number;
  111903. /**
  111904. * Wheel-Joint type
  111905. */
  111906. static WheelJoint: number;
  111907. /**
  111908. * Slider-Joint type
  111909. */
  111910. static SliderJoint: number;
  111911. /**
  111912. * Prismatic-Joint type
  111913. */
  111914. static PrismaticJoint: number;
  111915. /**
  111916. * Universal-Joint type
  111917. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111918. */
  111919. static UniversalJoint: number;
  111920. /**
  111921. * Hinge-Joint 2 type
  111922. */
  111923. static Hinge2Joint: number;
  111924. /**
  111925. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111926. */
  111927. static PointToPointJoint: number;
  111928. /**
  111929. * Spring-Joint type
  111930. */
  111931. static SpringJoint: number;
  111932. /**
  111933. * Lock-Joint type
  111934. */
  111935. static LockJoint: number;
  111936. }
  111937. /**
  111938. * A class representing a physics distance joint
  111939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111940. */
  111941. export class DistanceJoint extends PhysicsJoint {
  111942. /**
  111943. *
  111944. * @param jointData The data for the Distance-Joint
  111945. */
  111946. constructor(jointData: DistanceJointData);
  111947. /**
  111948. * Update the predefined distance.
  111949. * @param maxDistance The maximum preferred distance
  111950. * @param minDistance The minimum preferred distance
  111951. */
  111952. updateDistance(maxDistance: number, minDistance?: number): void;
  111953. }
  111954. /**
  111955. * Represents a Motor-Enabled Joint
  111956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111957. */
  111958. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  111959. /**
  111960. * Initializes the Motor-Enabled Joint
  111961. * @param type The type of the joint
  111962. * @param jointData The physica joint data for the joint
  111963. */
  111964. constructor(type: number, jointData: PhysicsJointData);
  111965. /**
  111966. * Set the motor values.
  111967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111968. * @param force the force to apply
  111969. * @param maxForce max force for this motor.
  111970. */
  111971. setMotor(force?: number, maxForce?: number): void;
  111972. /**
  111973. * Set the motor's limits.
  111974. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111975. * @param upperLimit The upper limit of the motor
  111976. * @param lowerLimit The lower limit of the motor
  111977. */
  111978. setLimit(upperLimit: number, lowerLimit?: number): void;
  111979. }
  111980. /**
  111981. * This class represents a single physics Hinge-Joint
  111982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111983. */
  111984. export class HingeJoint extends MotorEnabledJoint {
  111985. /**
  111986. * Initializes the Hinge-Joint
  111987. * @param jointData The joint data for the Hinge-Joint
  111988. */
  111989. constructor(jointData: PhysicsJointData);
  111990. /**
  111991. * Set the motor values.
  111992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111993. * @param {number} force the force to apply
  111994. * @param {number} maxForce max force for this motor.
  111995. */
  111996. setMotor(force?: number, maxForce?: number): void;
  111997. /**
  111998. * Set the motor's limits.
  111999. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112000. * @param upperLimit The upper limit of the motor
  112001. * @param lowerLimit The lower limit of the motor
  112002. */
  112003. setLimit(upperLimit: number, lowerLimit?: number): void;
  112004. }
  112005. /**
  112006. * This class represents a dual hinge physics joint (same as wheel joint)
  112007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112008. */
  112009. export class Hinge2Joint extends MotorEnabledJoint {
  112010. /**
  112011. * Initializes the Hinge2-Joint
  112012. * @param jointData The joint data for the Hinge2-Joint
  112013. */
  112014. constructor(jointData: PhysicsJointData);
  112015. /**
  112016. * Set the motor values.
  112017. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112018. * @param {number} targetSpeed the speed the motor is to reach
  112019. * @param {number} maxForce max force for this motor.
  112020. * @param {motorIndex} the motor's index, 0 or 1.
  112021. */
  112022. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112023. /**
  112024. * Set the motor limits.
  112025. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112026. * @param {number} upperLimit the upper limit
  112027. * @param {number} lowerLimit lower limit
  112028. * @param {motorIndex} the motor's index, 0 or 1.
  112029. */
  112030. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112031. }
  112032. /**
  112033. * Interface for a motor enabled joint
  112034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112035. */
  112036. export interface IMotorEnabledJoint {
  112037. /**
  112038. * Physics joint
  112039. */
  112040. physicsJoint: any;
  112041. /**
  112042. * Sets the motor of the motor-enabled joint
  112043. * @param force The force of the motor
  112044. * @param maxForce The maximum force of the motor
  112045. * @param motorIndex The index of the motor
  112046. */
  112047. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112048. /**
  112049. * Sets the limit of the motor
  112050. * @param upperLimit The upper limit of the motor
  112051. * @param lowerLimit The lower limit of the motor
  112052. * @param motorIndex The index of the motor
  112053. */
  112054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112055. }
  112056. /**
  112057. * Joint data for a Distance-Joint
  112058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112059. */
  112060. export interface DistanceJointData extends PhysicsJointData {
  112061. /**
  112062. * Max distance the 2 joint objects can be apart
  112063. */
  112064. maxDistance: number;
  112065. }
  112066. /**
  112067. * Joint data from a spring joint
  112068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112069. */
  112070. export interface SpringJointData extends PhysicsJointData {
  112071. /**
  112072. * Length of the spring
  112073. */
  112074. length: number;
  112075. /**
  112076. * Stiffness of the spring
  112077. */
  112078. stiffness: number;
  112079. /**
  112080. * Damping of the spring
  112081. */
  112082. damping: number;
  112083. /** this callback will be called when applying the force to the impostors. */
  112084. forceApplicationCallback: () => void;
  112085. }
  112086. }
  112087. declare module BABYLON {
  112088. /**
  112089. * Holds the data for the raycast result
  112090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112091. */
  112092. export class PhysicsRaycastResult {
  112093. private _hasHit;
  112094. private _hitDistance;
  112095. private _hitNormalWorld;
  112096. private _hitPointWorld;
  112097. private _rayFromWorld;
  112098. private _rayToWorld;
  112099. /**
  112100. * Gets if there was a hit
  112101. */
  112102. get hasHit(): boolean;
  112103. /**
  112104. * Gets the distance from the hit
  112105. */
  112106. get hitDistance(): number;
  112107. /**
  112108. * Gets the hit normal/direction in the world
  112109. */
  112110. get hitNormalWorld(): Vector3;
  112111. /**
  112112. * Gets the hit point in the world
  112113. */
  112114. get hitPointWorld(): Vector3;
  112115. /**
  112116. * Gets the ray "start point" of the ray in the world
  112117. */
  112118. get rayFromWorld(): Vector3;
  112119. /**
  112120. * Gets the ray "end point" of the ray in the world
  112121. */
  112122. get rayToWorld(): Vector3;
  112123. /**
  112124. * Sets the hit data (normal & point in world space)
  112125. * @param hitNormalWorld defines the normal in world space
  112126. * @param hitPointWorld defines the point in world space
  112127. */
  112128. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112129. /**
  112130. * Sets the distance from the start point to the hit point
  112131. * @param distance
  112132. */
  112133. setHitDistance(distance: number): void;
  112134. /**
  112135. * Calculates the distance manually
  112136. */
  112137. calculateHitDistance(): void;
  112138. /**
  112139. * Resets all the values to default
  112140. * @param from The from point on world space
  112141. * @param to The to point on world space
  112142. */
  112143. reset(from?: Vector3, to?: Vector3): void;
  112144. }
  112145. /**
  112146. * Interface for the size containing width and height
  112147. */
  112148. interface IXYZ {
  112149. /**
  112150. * X
  112151. */
  112152. x: number;
  112153. /**
  112154. * Y
  112155. */
  112156. y: number;
  112157. /**
  112158. * Z
  112159. */
  112160. z: number;
  112161. }
  112162. }
  112163. declare module BABYLON {
  112164. /**
  112165. * Interface used to describe a physics joint
  112166. */
  112167. export interface PhysicsImpostorJoint {
  112168. /** Defines the main impostor to which the joint is linked */
  112169. mainImpostor: PhysicsImpostor;
  112170. /** Defines the impostor that is connected to the main impostor using this joint */
  112171. connectedImpostor: PhysicsImpostor;
  112172. /** Defines the joint itself */
  112173. joint: PhysicsJoint;
  112174. }
  112175. /** @hidden */
  112176. export interface IPhysicsEnginePlugin {
  112177. world: any;
  112178. name: string;
  112179. setGravity(gravity: Vector3): void;
  112180. setTimeStep(timeStep: number): void;
  112181. getTimeStep(): number;
  112182. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112183. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112184. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112185. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112186. removePhysicsBody(impostor: PhysicsImpostor): void;
  112187. generateJoint(joint: PhysicsImpostorJoint): void;
  112188. removeJoint(joint: PhysicsImpostorJoint): void;
  112189. isSupported(): boolean;
  112190. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112191. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112192. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112193. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112194. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112195. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112196. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112197. getBodyMass(impostor: PhysicsImpostor): number;
  112198. getBodyFriction(impostor: PhysicsImpostor): number;
  112199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112200. getBodyRestitution(impostor: PhysicsImpostor): number;
  112201. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112202. getBodyPressure?(impostor: PhysicsImpostor): number;
  112203. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112204. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112205. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112206. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112207. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112208. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112209. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112210. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112211. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112212. sleepBody(impostor: PhysicsImpostor): void;
  112213. wakeUpBody(impostor: PhysicsImpostor): void;
  112214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112216. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112218. getRadius(impostor: PhysicsImpostor): number;
  112219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112221. dispose(): void;
  112222. }
  112223. /**
  112224. * Interface used to define a physics engine
  112225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112226. */
  112227. export interface IPhysicsEngine {
  112228. /**
  112229. * Gets the gravity vector used by the simulation
  112230. */
  112231. gravity: Vector3;
  112232. /**
  112233. * Sets the gravity vector used by the simulation
  112234. * @param gravity defines the gravity vector to use
  112235. */
  112236. setGravity(gravity: Vector3): void;
  112237. /**
  112238. * Set the time step of the physics engine.
  112239. * Default is 1/60.
  112240. * To slow it down, enter 1/600 for example.
  112241. * To speed it up, 1/30
  112242. * @param newTimeStep the new timestep to apply to this world.
  112243. */
  112244. setTimeStep(newTimeStep: number): void;
  112245. /**
  112246. * Get the time step of the physics engine.
  112247. * @returns the current time step
  112248. */
  112249. getTimeStep(): number;
  112250. /**
  112251. * Set the sub time step of the physics engine.
  112252. * Default is 0 meaning there is no sub steps
  112253. * To increase physics resolution precision, set a small value (like 1 ms)
  112254. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112255. */
  112256. setSubTimeStep(subTimeStep: number): void;
  112257. /**
  112258. * Get the sub time step of the physics engine.
  112259. * @returns the current sub time step
  112260. */
  112261. getSubTimeStep(): number;
  112262. /**
  112263. * Release all resources
  112264. */
  112265. dispose(): void;
  112266. /**
  112267. * Gets the name of the current physics plugin
  112268. * @returns the name of the plugin
  112269. */
  112270. getPhysicsPluginName(): string;
  112271. /**
  112272. * Adding a new impostor for the impostor tracking.
  112273. * This will be done by the impostor itself.
  112274. * @param impostor the impostor to add
  112275. */
  112276. addImpostor(impostor: PhysicsImpostor): void;
  112277. /**
  112278. * Remove an impostor from the engine.
  112279. * This impostor and its mesh will not longer be updated by the physics engine.
  112280. * @param impostor the impostor to remove
  112281. */
  112282. removeImpostor(impostor: PhysicsImpostor): void;
  112283. /**
  112284. * Add a joint to the physics engine
  112285. * @param mainImpostor defines the main impostor to which the joint is added.
  112286. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112287. * @param joint defines the joint that will connect both impostors.
  112288. */
  112289. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112290. /**
  112291. * Removes a joint from the simulation
  112292. * @param mainImpostor defines the impostor used with the joint
  112293. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112294. * @param joint defines the joint to remove
  112295. */
  112296. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112297. /**
  112298. * Gets the current plugin used to run the simulation
  112299. * @returns current plugin
  112300. */
  112301. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112302. /**
  112303. * Gets the list of physic impostors
  112304. * @returns an array of PhysicsImpostor
  112305. */
  112306. getImpostors(): Array<PhysicsImpostor>;
  112307. /**
  112308. * Gets the impostor for a physics enabled object
  112309. * @param object defines the object impersonated by the impostor
  112310. * @returns the PhysicsImpostor or null if not found
  112311. */
  112312. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112313. /**
  112314. * Gets the impostor for a physics body object
  112315. * @param body defines physics body used by the impostor
  112316. * @returns the PhysicsImpostor or null if not found
  112317. */
  112318. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112319. /**
  112320. * Does a raycast in the physics world
  112321. * @param from when should the ray start?
  112322. * @param to when should the ray end?
  112323. * @returns PhysicsRaycastResult
  112324. */
  112325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112326. /**
  112327. * Called by the scene. No need to call it.
  112328. * @param delta defines the timespam between frames
  112329. */
  112330. _step(delta: number): void;
  112331. }
  112332. }
  112333. declare module BABYLON {
  112334. /**
  112335. * The interface for the physics imposter parameters
  112336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112337. */
  112338. export interface PhysicsImpostorParameters {
  112339. /**
  112340. * The mass of the physics imposter
  112341. */
  112342. mass: number;
  112343. /**
  112344. * The friction of the physics imposter
  112345. */
  112346. friction?: number;
  112347. /**
  112348. * The coefficient of restitution of the physics imposter
  112349. */
  112350. restitution?: number;
  112351. /**
  112352. * The native options of the physics imposter
  112353. */
  112354. nativeOptions?: any;
  112355. /**
  112356. * Specifies if the parent should be ignored
  112357. */
  112358. ignoreParent?: boolean;
  112359. /**
  112360. * Specifies if bi-directional transformations should be disabled
  112361. */
  112362. disableBidirectionalTransformation?: boolean;
  112363. /**
  112364. * The pressure inside the physics imposter, soft object only
  112365. */
  112366. pressure?: number;
  112367. /**
  112368. * The stiffness the physics imposter, soft object only
  112369. */
  112370. stiffness?: number;
  112371. /**
  112372. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112373. */
  112374. velocityIterations?: number;
  112375. /**
  112376. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112377. */
  112378. positionIterations?: number;
  112379. /**
  112380. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112381. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112382. * Add to fix multiple points
  112383. */
  112384. fixedPoints?: number;
  112385. /**
  112386. * The collision margin around a soft object
  112387. */
  112388. margin?: number;
  112389. /**
  112390. * The collision margin around a soft object
  112391. */
  112392. damping?: number;
  112393. /**
  112394. * The path for a rope based on an extrusion
  112395. */
  112396. path?: any;
  112397. /**
  112398. * The shape of an extrusion used for a rope based on an extrusion
  112399. */
  112400. shape?: any;
  112401. }
  112402. /**
  112403. * Interface for a physics-enabled object
  112404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112405. */
  112406. export interface IPhysicsEnabledObject {
  112407. /**
  112408. * The position of the physics-enabled object
  112409. */
  112410. position: Vector3;
  112411. /**
  112412. * The rotation of the physics-enabled object
  112413. */
  112414. rotationQuaternion: Nullable<Quaternion>;
  112415. /**
  112416. * The scale of the physics-enabled object
  112417. */
  112418. scaling: Vector3;
  112419. /**
  112420. * The rotation of the physics-enabled object
  112421. */
  112422. rotation?: Vector3;
  112423. /**
  112424. * The parent of the physics-enabled object
  112425. */
  112426. parent?: any;
  112427. /**
  112428. * The bounding info of the physics-enabled object
  112429. * @returns The bounding info of the physics-enabled object
  112430. */
  112431. getBoundingInfo(): BoundingInfo;
  112432. /**
  112433. * Computes the world matrix
  112434. * @param force Specifies if the world matrix should be computed by force
  112435. * @returns A world matrix
  112436. */
  112437. computeWorldMatrix(force: boolean): Matrix;
  112438. /**
  112439. * Gets the world matrix
  112440. * @returns A world matrix
  112441. */
  112442. getWorldMatrix?(): Matrix;
  112443. /**
  112444. * Gets the child meshes
  112445. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112446. * @returns An array of abstract meshes
  112447. */
  112448. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112449. /**
  112450. * Gets the vertex data
  112451. * @param kind The type of vertex data
  112452. * @returns A nullable array of numbers, or a float32 array
  112453. */
  112454. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112455. /**
  112456. * Gets the indices from the mesh
  112457. * @returns A nullable array of index arrays
  112458. */
  112459. getIndices?(): Nullable<IndicesArray>;
  112460. /**
  112461. * Gets the scene from the mesh
  112462. * @returns the indices array or null
  112463. */
  112464. getScene?(): Scene;
  112465. /**
  112466. * Gets the absolute position from the mesh
  112467. * @returns the absolute position
  112468. */
  112469. getAbsolutePosition(): Vector3;
  112470. /**
  112471. * Gets the absolute pivot point from the mesh
  112472. * @returns the absolute pivot point
  112473. */
  112474. getAbsolutePivotPoint(): Vector3;
  112475. /**
  112476. * Rotates the mesh
  112477. * @param axis The axis of rotation
  112478. * @param amount The amount of rotation
  112479. * @param space The space of the rotation
  112480. * @returns The rotation transform node
  112481. */
  112482. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112483. /**
  112484. * Translates the mesh
  112485. * @param axis The axis of translation
  112486. * @param distance The distance of translation
  112487. * @param space The space of the translation
  112488. * @returns The transform node
  112489. */
  112490. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112491. /**
  112492. * Sets the absolute position of the mesh
  112493. * @param absolutePosition The absolute position of the mesh
  112494. * @returns The transform node
  112495. */
  112496. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112497. /**
  112498. * Gets the class name of the mesh
  112499. * @returns The class name
  112500. */
  112501. getClassName(): string;
  112502. }
  112503. /**
  112504. * Represents a physics imposter
  112505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112506. */
  112507. export class PhysicsImpostor {
  112508. /**
  112509. * The physics-enabled object used as the physics imposter
  112510. */
  112511. object: IPhysicsEnabledObject;
  112512. /**
  112513. * The type of the physics imposter
  112514. */
  112515. type: number;
  112516. private _options;
  112517. private _scene?;
  112518. /**
  112519. * The default object size of the imposter
  112520. */
  112521. static DEFAULT_OBJECT_SIZE: Vector3;
  112522. /**
  112523. * The identity quaternion of the imposter
  112524. */
  112525. static IDENTITY_QUATERNION: Quaternion;
  112526. /** @hidden */
  112527. _pluginData: any;
  112528. private _physicsEngine;
  112529. private _physicsBody;
  112530. private _bodyUpdateRequired;
  112531. private _onBeforePhysicsStepCallbacks;
  112532. private _onAfterPhysicsStepCallbacks;
  112533. /** @hidden */
  112534. _onPhysicsCollideCallbacks: Array<{
  112535. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  112536. otherImpostors: Array<PhysicsImpostor>;
  112537. }>;
  112538. private _deltaPosition;
  112539. private _deltaRotation;
  112540. private _deltaRotationConjugated;
  112541. /** @hidden */
  112542. _isFromLine: boolean;
  112543. private _parent;
  112544. private _isDisposed;
  112545. private static _tmpVecs;
  112546. private static _tmpQuat;
  112547. /**
  112548. * Specifies if the physics imposter is disposed
  112549. */
  112550. get isDisposed(): boolean;
  112551. /**
  112552. * Gets the mass of the physics imposter
  112553. */
  112554. get mass(): number;
  112555. set mass(value: number);
  112556. /**
  112557. * Gets the coefficient of friction
  112558. */
  112559. get friction(): number;
  112560. /**
  112561. * Sets the coefficient of friction
  112562. */
  112563. set friction(value: number);
  112564. /**
  112565. * Gets the coefficient of restitution
  112566. */
  112567. get restitution(): number;
  112568. /**
  112569. * Sets the coefficient of restitution
  112570. */
  112571. set restitution(value: number);
  112572. /**
  112573. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112574. */
  112575. get pressure(): number;
  112576. /**
  112577. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112578. */
  112579. set pressure(value: number);
  112580. /**
  112581. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112582. */
  112583. get stiffness(): number;
  112584. /**
  112585. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112586. */
  112587. set stiffness(value: number);
  112588. /**
  112589. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112590. */
  112591. get velocityIterations(): number;
  112592. /**
  112593. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112594. */
  112595. set velocityIterations(value: number);
  112596. /**
  112597. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112598. */
  112599. get positionIterations(): number;
  112600. /**
  112601. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112602. */
  112603. set positionIterations(value: number);
  112604. /**
  112605. * The unique id of the physics imposter
  112606. * set by the physics engine when adding this impostor to the array
  112607. */
  112608. uniqueId: number;
  112609. /**
  112610. * @hidden
  112611. */
  112612. soft: boolean;
  112613. /**
  112614. * @hidden
  112615. */
  112616. segments: number;
  112617. private _joints;
  112618. /**
  112619. * Initializes the physics imposter
  112620. * @param object The physics-enabled object used as the physics imposter
  112621. * @param type The type of the physics imposter
  112622. * @param _options The options for the physics imposter
  112623. * @param _scene The Babylon scene
  112624. */
  112625. constructor(
  112626. /**
  112627. * The physics-enabled object used as the physics imposter
  112628. */
  112629. object: IPhysicsEnabledObject,
  112630. /**
  112631. * The type of the physics imposter
  112632. */
  112633. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112634. /**
  112635. * This function will completly initialize this impostor.
  112636. * It will create a new body - but only if this mesh has no parent.
  112637. * If it has, this impostor will not be used other than to define the impostor
  112638. * of the child mesh.
  112639. * @hidden
  112640. */
  112641. _init(): void;
  112642. private _getPhysicsParent;
  112643. /**
  112644. * Should a new body be generated.
  112645. * @returns boolean specifying if body initialization is required
  112646. */
  112647. isBodyInitRequired(): boolean;
  112648. /**
  112649. * Sets the updated scaling
  112650. * @param updated Specifies if the scaling is updated
  112651. */
  112652. setScalingUpdated(): void;
  112653. /**
  112654. * Force a regeneration of this or the parent's impostor's body.
  112655. * Use under cautious - This will remove all joints already implemented.
  112656. */
  112657. forceUpdate(): void;
  112658. /**
  112659. * Gets the body that holds this impostor. Either its own, or its parent.
  112660. */
  112661. get physicsBody(): any;
  112662. /**
  112663. * Get the parent of the physics imposter
  112664. * @returns Physics imposter or null
  112665. */
  112666. get parent(): Nullable<PhysicsImpostor>;
  112667. /**
  112668. * Sets the parent of the physics imposter
  112669. */
  112670. set parent(value: Nullable<PhysicsImpostor>);
  112671. /**
  112672. * Set the physics body. Used mainly by the physics engine/plugin
  112673. */
  112674. set physicsBody(physicsBody: any);
  112675. /**
  112676. * Resets the update flags
  112677. */
  112678. resetUpdateFlags(): void;
  112679. /**
  112680. * Gets the object extend size
  112681. * @returns the object extend size
  112682. */
  112683. getObjectExtendSize(): Vector3;
  112684. /**
  112685. * Gets the object center
  112686. * @returns The object center
  112687. */
  112688. getObjectCenter(): Vector3;
  112689. /**
  112690. * Get a specific parameter from the options parameters
  112691. * @param paramName The object parameter name
  112692. * @returns The object parameter
  112693. */
  112694. getParam(paramName: string): any;
  112695. /**
  112696. * Sets a specific parameter in the options given to the physics plugin
  112697. * @param paramName The parameter name
  112698. * @param value The value of the parameter
  112699. */
  112700. setParam(paramName: string, value: number): void;
  112701. /**
  112702. * Specifically change the body's mass option. Won't recreate the physics body object
  112703. * @param mass The mass of the physics imposter
  112704. */
  112705. setMass(mass: number): void;
  112706. /**
  112707. * Gets the linear velocity
  112708. * @returns linear velocity or null
  112709. */
  112710. getLinearVelocity(): Nullable<Vector3>;
  112711. /**
  112712. * Sets the linear velocity
  112713. * @param velocity linear velocity or null
  112714. */
  112715. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112716. /**
  112717. * Gets the angular velocity
  112718. * @returns angular velocity or null
  112719. */
  112720. getAngularVelocity(): Nullable<Vector3>;
  112721. /**
  112722. * Sets the angular velocity
  112723. * @param velocity The velocity or null
  112724. */
  112725. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112726. /**
  112727. * Execute a function with the physics plugin native code
  112728. * Provide a function the will have two variables - the world object and the physics body object
  112729. * @param func The function to execute with the physics plugin native code
  112730. */
  112731. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112732. /**
  112733. * Register a function that will be executed before the physics world is stepping forward
  112734. * @param func The function to execute before the physics world is stepped forward
  112735. */
  112736. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112737. /**
  112738. * Unregister a function that will be executed before the physics world is stepping forward
  112739. * @param func The function to execute before the physics world is stepped forward
  112740. */
  112741. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112742. /**
  112743. * Register a function that will be executed after the physics step
  112744. * @param func The function to execute after physics step
  112745. */
  112746. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112747. /**
  112748. * Unregisters a function that will be executed after the physics step
  112749. * @param func The function to execute after physics step
  112750. */
  112751. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112752. /**
  112753. * register a function that will be executed when this impostor collides against a different body
  112754. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112755. * @param func Callback that is executed on collision
  112756. */
  112757. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112758. /**
  112759. * Unregisters the physics imposter on contact
  112760. * @param collideAgainst The physics object to collide against
  112761. * @param func Callback to execute on collision
  112762. */
  112763. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112764. private _tmpQuat;
  112765. private _tmpQuat2;
  112766. /**
  112767. * Get the parent rotation
  112768. * @returns The parent rotation
  112769. */
  112770. getParentsRotation(): Quaternion;
  112771. /**
  112772. * this function is executed by the physics engine.
  112773. */
  112774. beforeStep: () => void;
  112775. /**
  112776. * this function is executed by the physics engine
  112777. */
  112778. afterStep: () => void;
  112779. /**
  112780. * Legacy collision detection event support
  112781. */
  112782. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112783. /**
  112784. * event and body object due to cannon's event-based architecture.
  112785. */
  112786. onCollide: (e: {
  112787. body: any;
  112788. }) => void;
  112789. /**
  112790. * Apply a force
  112791. * @param force The force to apply
  112792. * @param contactPoint The contact point for the force
  112793. * @returns The physics imposter
  112794. */
  112795. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112796. /**
  112797. * Apply an impulse
  112798. * @param force The impulse force
  112799. * @param contactPoint The contact point for the impulse force
  112800. * @returns The physics imposter
  112801. */
  112802. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112803. /**
  112804. * A help function to create a joint
  112805. * @param otherImpostor A physics imposter used to create a joint
  112806. * @param jointType The type of joint
  112807. * @param jointData The data for the joint
  112808. * @returns The physics imposter
  112809. */
  112810. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  112811. /**
  112812. * Add a joint to this impostor with a different impostor
  112813. * @param otherImpostor A physics imposter used to add a joint
  112814. * @param joint The joint to add
  112815. * @returns The physics imposter
  112816. */
  112817. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  112818. /**
  112819. * Add an anchor to a cloth impostor
  112820. * @param otherImpostor rigid impostor to anchor to
  112821. * @param width ratio across width from 0 to 1
  112822. * @param height ratio up height from 0 to 1
  112823. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112824. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  112825. * @returns impostor the soft imposter
  112826. */
  112827. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112828. /**
  112829. * Add a hook to a rope impostor
  112830. * @param otherImpostor rigid impostor to anchor to
  112831. * @param length ratio across rope from 0 to 1
  112832. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  112833. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112834. * @returns impostor the rope imposter
  112835. */
  112836. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112837. /**
  112838. * Will keep this body still, in a sleep mode.
  112839. * @returns the physics imposter
  112840. */
  112841. sleep(): PhysicsImpostor;
  112842. /**
  112843. * Wake the body up.
  112844. * @returns The physics imposter
  112845. */
  112846. wakeUp(): PhysicsImpostor;
  112847. /**
  112848. * Clones the physics imposter
  112849. * @param newObject The physics imposter clones to this physics-enabled object
  112850. * @returns A nullable physics imposter
  112851. */
  112852. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112853. /**
  112854. * Disposes the physics imposter
  112855. */
  112856. dispose(): void;
  112857. /**
  112858. * Sets the delta position
  112859. * @param position The delta position amount
  112860. */
  112861. setDeltaPosition(position: Vector3): void;
  112862. /**
  112863. * Sets the delta rotation
  112864. * @param rotation The delta rotation amount
  112865. */
  112866. setDeltaRotation(rotation: Quaternion): void;
  112867. /**
  112868. * Gets the box size of the physics imposter and stores the result in the input parameter
  112869. * @param result Stores the box size
  112870. * @returns The physics imposter
  112871. */
  112872. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  112873. /**
  112874. * Gets the radius of the physics imposter
  112875. * @returns Radius of the physics imposter
  112876. */
  112877. getRadius(): number;
  112878. /**
  112879. * Sync a bone with this impostor
  112880. * @param bone The bone to sync to the impostor.
  112881. * @param boneMesh The mesh that the bone is influencing.
  112882. * @param jointPivot The pivot of the joint / bone in local space.
  112883. * @param distToJoint Optional distance from the impostor to the joint.
  112884. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112885. */
  112886. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  112887. /**
  112888. * Sync impostor to a bone
  112889. * @param bone The bone that the impostor will be synced to.
  112890. * @param boneMesh The mesh that the bone is influencing.
  112891. * @param jointPivot The pivot of the joint / bone in local space.
  112892. * @param distToJoint Optional distance from the impostor to the joint.
  112893. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112894. * @param boneAxis Optional vector3 axis the bone is aligned with
  112895. */
  112896. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  112897. /**
  112898. * No-Imposter type
  112899. */
  112900. static NoImpostor: number;
  112901. /**
  112902. * Sphere-Imposter type
  112903. */
  112904. static SphereImpostor: number;
  112905. /**
  112906. * Box-Imposter type
  112907. */
  112908. static BoxImpostor: number;
  112909. /**
  112910. * Plane-Imposter type
  112911. */
  112912. static PlaneImpostor: number;
  112913. /**
  112914. * Mesh-imposter type
  112915. */
  112916. static MeshImpostor: number;
  112917. /**
  112918. * Capsule-Impostor type (Ammo.js plugin only)
  112919. */
  112920. static CapsuleImpostor: number;
  112921. /**
  112922. * Cylinder-Imposter type
  112923. */
  112924. static CylinderImpostor: number;
  112925. /**
  112926. * Particle-Imposter type
  112927. */
  112928. static ParticleImpostor: number;
  112929. /**
  112930. * Heightmap-Imposter type
  112931. */
  112932. static HeightmapImpostor: number;
  112933. /**
  112934. * ConvexHull-Impostor type (Ammo.js plugin only)
  112935. */
  112936. static ConvexHullImpostor: number;
  112937. /**
  112938. * Custom-Imposter type (Ammo.js plugin only)
  112939. */
  112940. static CustomImpostor: number;
  112941. /**
  112942. * Rope-Imposter type
  112943. */
  112944. static RopeImpostor: number;
  112945. /**
  112946. * Cloth-Imposter type
  112947. */
  112948. static ClothImpostor: number;
  112949. /**
  112950. * Softbody-Imposter type
  112951. */
  112952. static SoftbodyImpostor: number;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /**
  112957. * @hidden
  112958. **/
  112959. export class _CreationDataStorage {
  112960. closePath?: boolean;
  112961. closeArray?: boolean;
  112962. idx: number[];
  112963. dashSize: number;
  112964. gapSize: number;
  112965. path3D: Path3D;
  112966. pathArray: Vector3[][];
  112967. arc: number;
  112968. radius: number;
  112969. cap: number;
  112970. tessellation: number;
  112971. }
  112972. /**
  112973. * @hidden
  112974. **/
  112975. class _InstanceDataStorage {
  112976. visibleInstances: any;
  112977. batchCache: _InstancesBatch;
  112978. instancesBufferSize: number;
  112979. instancesBuffer: Nullable<Buffer>;
  112980. instancesData: Float32Array;
  112981. overridenInstanceCount: number;
  112982. isFrozen: boolean;
  112983. previousBatch: Nullable<_InstancesBatch>;
  112984. hardwareInstancedRendering: boolean;
  112985. sideOrientation: number;
  112986. manualUpdate: boolean;
  112987. previousRenderId: number;
  112988. }
  112989. /**
  112990. * @hidden
  112991. **/
  112992. export class _InstancesBatch {
  112993. mustReturn: boolean;
  112994. visibleInstances: Nullable<InstancedMesh[]>[];
  112995. renderSelf: boolean[];
  112996. hardwareInstancedRendering: boolean[];
  112997. }
  112998. /**
  112999. * @hidden
  113000. **/
  113001. class _ThinInstanceDataStorage {
  113002. instancesCount: number;
  113003. matrixBuffer: Nullable<Buffer>;
  113004. matrixBufferSize: number;
  113005. matrixData: Nullable<Float32Array>;
  113006. boundingVectors: Array<Vector3>;
  113007. worldMatrices: Nullable<Matrix[]>;
  113008. }
  113009. /**
  113010. * Class used to represent renderable models
  113011. */
  113012. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113013. /**
  113014. * Mesh side orientation : usually the external or front surface
  113015. */
  113016. static readonly FRONTSIDE: number;
  113017. /**
  113018. * Mesh side orientation : usually the internal or back surface
  113019. */
  113020. static readonly BACKSIDE: number;
  113021. /**
  113022. * Mesh side orientation : both internal and external or front and back surfaces
  113023. */
  113024. static readonly DOUBLESIDE: number;
  113025. /**
  113026. * Mesh side orientation : by default, `FRONTSIDE`
  113027. */
  113028. static readonly DEFAULTSIDE: number;
  113029. /**
  113030. * Mesh cap setting : no cap
  113031. */
  113032. static readonly NO_CAP: number;
  113033. /**
  113034. * Mesh cap setting : one cap at the beginning of the mesh
  113035. */
  113036. static readonly CAP_START: number;
  113037. /**
  113038. * Mesh cap setting : one cap at the end of the mesh
  113039. */
  113040. static readonly CAP_END: number;
  113041. /**
  113042. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113043. */
  113044. static readonly CAP_ALL: number;
  113045. /**
  113046. * Mesh pattern setting : no flip or rotate
  113047. */
  113048. static readonly NO_FLIP: number;
  113049. /**
  113050. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113051. */
  113052. static readonly FLIP_TILE: number;
  113053. /**
  113054. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113055. */
  113056. static readonly ROTATE_TILE: number;
  113057. /**
  113058. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113059. */
  113060. static readonly FLIP_ROW: number;
  113061. /**
  113062. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113063. */
  113064. static readonly ROTATE_ROW: number;
  113065. /**
  113066. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113067. */
  113068. static readonly FLIP_N_ROTATE_TILE: number;
  113069. /**
  113070. * Mesh pattern setting : rotate pattern and rotate
  113071. */
  113072. static readonly FLIP_N_ROTATE_ROW: number;
  113073. /**
  113074. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113075. */
  113076. static readonly CENTER: number;
  113077. /**
  113078. * Mesh tile positioning : part tiles on left
  113079. */
  113080. static readonly LEFT: number;
  113081. /**
  113082. * Mesh tile positioning : part tiles on right
  113083. */
  113084. static readonly RIGHT: number;
  113085. /**
  113086. * Mesh tile positioning : part tiles on top
  113087. */
  113088. static readonly TOP: number;
  113089. /**
  113090. * Mesh tile positioning : part tiles on bottom
  113091. */
  113092. static readonly BOTTOM: number;
  113093. /**
  113094. * Gets the default side orientation.
  113095. * @param orientation the orientation to value to attempt to get
  113096. * @returns the default orientation
  113097. * @hidden
  113098. */
  113099. static _GetDefaultSideOrientation(orientation?: number): number;
  113100. private _internalMeshDataInfo;
  113101. get computeBonesUsingShaders(): boolean;
  113102. set computeBonesUsingShaders(value: boolean);
  113103. /**
  113104. * An event triggered before rendering the mesh
  113105. */
  113106. get onBeforeRenderObservable(): Observable<Mesh>;
  113107. /**
  113108. * An event triggered before binding the mesh
  113109. */
  113110. get onBeforeBindObservable(): Observable<Mesh>;
  113111. /**
  113112. * An event triggered after rendering the mesh
  113113. */
  113114. get onAfterRenderObservable(): Observable<Mesh>;
  113115. /**
  113116. * An event triggered before drawing the mesh
  113117. */
  113118. get onBeforeDrawObservable(): Observable<Mesh>;
  113119. private _onBeforeDrawObserver;
  113120. /**
  113121. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113122. */
  113123. set onBeforeDraw(callback: () => void);
  113124. get hasInstances(): boolean;
  113125. get hasThinInstances(): boolean;
  113126. /**
  113127. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113128. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113129. */
  113130. delayLoadState: number;
  113131. /**
  113132. * Gets the list of instances created from this mesh
  113133. * it is not supposed to be modified manually.
  113134. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113135. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113136. */
  113137. instances: InstancedMesh[];
  113138. /**
  113139. * Gets the file containing delay loading data for this mesh
  113140. */
  113141. delayLoadingFile: string;
  113142. /** @hidden */
  113143. _binaryInfo: any;
  113144. /**
  113145. * User defined function used to change how LOD level selection is done
  113146. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113147. */
  113148. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113149. /**
  113150. * Gets or sets the morph target manager
  113151. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113152. */
  113153. get morphTargetManager(): Nullable<MorphTargetManager>;
  113154. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113155. /** @hidden */
  113156. _creationDataStorage: Nullable<_CreationDataStorage>;
  113157. /** @hidden */
  113158. _geometry: Nullable<Geometry>;
  113159. /** @hidden */
  113160. _delayInfo: Array<string>;
  113161. /** @hidden */
  113162. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113163. /** @hidden */
  113164. _instanceDataStorage: _InstanceDataStorage;
  113165. /** @hidden */
  113166. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113167. private _effectiveMaterial;
  113168. /** @hidden */
  113169. _shouldGenerateFlatShading: boolean;
  113170. /** @hidden */
  113171. _originalBuilderSideOrientation: number;
  113172. /**
  113173. * Use this property to change the original side orientation defined at construction time
  113174. */
  113175. overrideMaterialSideOrientation: Nullable<number>;
  113176. /**
  113177. * Gets the source mesh (the one used to clone this one from)
  113178. */
  113179. get source(): Nullable<Mesh>;
  113180. /**
  113181. * Gets the list of clones of this mesh
  113182. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113183. * Note that useClonedMeshMap=true is the default setting
  113184. */
  113185. get cloneMeshMap(): Nullable<{
  113186. [id: string]: Mesh | undefined;
  113187. }>;
  113188. /**
  113189. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113190. */
  113191. get isUnIndexed(): boolean;
  113192. set isUnIndexed(value: boolean);
  113193. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113194. get worldMatrixInstancedBuffer(): Float32Array;
  113195. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113196. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113197. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113198. /**
  113199. * @constructor
  113200. * @param name The value used by scene.getMeshByName() to do a lookup.
  113201. * @param scene The scene to add this mesh to.
  113202. * @param parent The parent of this mesh, if it has one
  113203. * @param source An optional Mesh from which geometry is shared, cloned.
  113204. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113205. * When false, achieved by calling a clone(), also passing False.
  113206. * This will make creation of children, recursive.
  113207. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113208. */
  113209. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113210. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113211. doNotInstantiate: boolean;
  113212. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113213. /**
  113214. * Gets the class name
  113215. * @returns the string "Mesh".
  113216. */
  113217. getClassName(): string;
  113218. /** @hidden */
  113219. get _isMesh(): boolean;
  113220. /**
  113221. * Returns a description of this mesh
  113222. * @param fullDetails define if full details about this mesh must be used
  113223. * @returns a descriptive string representing this mesh
  113224. */
  113225. toString(fullDetails?: boolean): string;
  113226. /** @hidden */
  113227. _unBindEffect(): void;
  113228. /**
  113229. * Gets a boolean indicating if this mesh has LOD
  113230. */
  113231. get hasLODLevels(): boolean;
  113232. /**
  113233. * Gets the list of MeshLODLevel associated with the current mesh
  113234. * @returns an array of MeshLODLevel
  113235. */
  113236. getLODLevels(): MeshLODLevel[];
  113237. private _sortLODLevels;
  113238. /**
  113239. * Add a mesh as LOD level triggered at the given distance.
  113240. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113241. * @param distance The distance from the center of the object to show this level
  113242. * @param mesh The mesh to be added as LOD level (can be null)
  113243. * @return This mesh (for chaining)
  113244. */
  113245. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113246. /**
  113247. * Returns the LOD level mesh at the passed distance or null if not found.
  113248. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113249. * @param distance The distance from the center of the object to show this level
  113250. * @returns a Mesh or `null`
  113251. */
  113252. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113253. /**
  113254. * Remove a mesh from the LOD array
  113255. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113256. * @param mesh defines the mesh to be removed
  113257. * @return This mesh (for chaining)
  113258. */
  113259. removeLODLevel(mesh: Mesh): Mesh;
  113260. /**
  113261. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113262. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113263. * @param camera defines the camera to use to compute distance
  113264. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113265. * @return This mesh (for chaining)
  113266. */
  113267. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113268. /**
  113269. * Gets the mesh internal Geometry object
  113270. */
  113271. get geometry(): Nullable<Geometry>;
  113272. /**
  113273. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113274. * @returns the total number of vertices
  113275. */
  113276. getTotalVertices(): number;
  113277. /**
  113278. * Returns the content of an associated vertex buffer
  113279. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113280. * - VertexBuffer.PositionKind
  113281. * - VertexBuffer.UVKind
  113282. * - VertexBuffer.UV2Kind
  113283. * - VertexBuffer.UV3Kind
  113284. * - VertexBuffer.UV4Kind
  113285. * - VertexBuffer.UV5Kind
  113286. * - VertexBuffer.UV6Kind
  113287. * - VertexBuffer.ColorKind
  113288. * - VertexBuffer.MatricesIndicesKind
  113289. * - VertexBuffer.MatricesIndicesExtraKind
  113290. * - VertexBuffer.MatricesWeightsKind
  113291. * - VertexBuffer.MatricesWeightsExtraKind
  113292. * @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
  113293. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113294. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113295. */
  113296. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113297. /**
  113298. * Returns the mesh VertexBuffer object from the requested `kind`
  113299. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113300. * - VertexBuffer.PositionKind
  113301. * - VertexBuffer.NormalKind
  113302. * - VertexBuffer.UVKind
  113303. * - VertexBuffer.UV2Kind
  113304. * - VertexBuffer.UV3Kind
  113305. * - VertexBuffer.UV4Kind
  113306. * - VertexBuffer.UV5Kind
  113307. * - VertexBuffer.UV6Kind
  113308. * - VertexBuffer.ColorKind
  113309. * - VertexBuffer.MatricesIndicesKind
  113310. * - VertexBuffer.MatricesIndicesExtraKind
  113311. * - VertexBuffer.MatricesWeightsKind
  113312. * - VertexBuffer.MatricesWeightsExtraKind
  113313. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113314. */
  113315. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113316. /**
  113317. * Tests if a specific vertex buffer is associated with this mesh
  113318. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113319. * - VertexBuffer.PositionKind
  113320. * - VertexBuffer.NormalKind
  113321. * - VertexBuffer.UVKind
  113322. * - VertexBuffer.UV2Kind
  113323. * - VertexBuffer.UV3Kind
  113324. * - VertexBuffer.UV4Kind
  113325. * - VertexBuffer.UV5Kind
  113326. * - VertexBuffer.UV6Kind
  113327. * - VertexBuffer.ColorKind
  113328. * - VertexBuffer.MatricesIndicesKind
  113329. * - VertexBuffer.MatricesIndicesExtraKind
  113330. * - VertexBuffer.MatricesWeightsKind
  113331. * - VertexBuffer.MatricesWeightsExtraKind
  113332. * @returns a boolean
  113333. */
  113334. isVerticesDataPresent(kind: string): boolean;
  113335. /**
  113336. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113337. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113338. * - VertexBuffer.PositionKind
  113339. * - VertexBuffer.UVKind
  113340. * - VertexBuffer.UV2Kind
  113341. * - VertexBuffer.UV3Kind
  113342. * - VertexBuffer.UV4Kind
  113343. * - VertexBuffer.UV5Kind
  113344. * - VertexBuffer.UV6Kind
  113345. * - VertexBuffer.ColorKind
  113346. * - VertexBuffer.MatricesIndicesKind
  113347. * - VertexBuffer.MatricesIndicesExtraKind
  113348. * - VertexBuffer.MatricesWeightsKind
  113349. * - VertexBuffer.MatricesWeightsExtraKind
  113350. * @returns a boolean
  113351. */
  113352. isVertexBufferUpdatable(kind: string): boolean;
  113353. /**
  113354. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113355. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113356. * - VertexBuffer.PositionKind
  113357. * - VertexBuffer.NormalKind
  113358. * - VertexBuffer.UVKind
  113359. * - VertexBuffer.UV2Kind
  113360. * - VertexBuffer.UV3Kind
  113361. * - VertexBuffer.UV4Kind
  113362. * - VertexBuffer.UV5Kind
  113363. * - VertexBuffer.UV6Kind
  113364. * - VertexBuffer.ColorKind
  113365. * - VertexBuffer.MatricesIndicesKind
  113366. * - VertexBuffer.MatricesIndicesExtraKind
  113367. * - VertexBuffer.MatricesWeightsKind
  113368. * - VertexBuffer.MatricesWeightsExtraKind
  113369. * @returns an array of strings
  113370. */
  113371. getVerticesDataKinds(): string[];
  113372. /**
  113373. * Returns a positive integer : the total number of indices in this mesh geometry.
  113374. * @returns the numner of indices or zero if the mesh has no geometry.
  113375. */
  113376. getTotalIndices(): number;
  113377. /**
  113378. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113379. * @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.
  113380. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113381. * @returns the indices array or an empty array if the mesh has no geometry
  113382. */
  113383. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113384. get isBlocked(): boolean;
  113385. /**
  113386. * Determine if the current mesh is ready to be rendered
  113387. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113388. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113389. * @returns true if all associated assets are ready (material, textures, shaders)
  113390. */
  113391. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113392. /**
  113393. * 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.
  113394. */
  113395. get areNormalsFrozen(): boolean;
  113396. /**
  113397. * 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.
  113398. * @returns the current mesh
  113399. */
  113400. freezeNormals(): Mesh;
  113401. /**
  113402. * 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
  113403. * @returns the current mesh
  113404. */
  113405. unfreezeNormals(): Mesh;
  113406. /**
  113407. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113408. */
  113409. set overridenInstanceCount(count: number);
  113410. /** @hidden */
  113411. _preActivate(): Mesh;
  113412. /** @hidden */
  113413. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113414. /** @hidden */
  113415. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113416. protected _afterComputeWorldMatrix(): void;
  113417. /** @hidden */
  113418. _postActivate(): void;
  113419. /**
  113420. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113421. * This means the mesh underlying bounding box and sphere are recomputed.
  113422. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113423. * @returns the current mesh
  113424. */
  113425. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113426. /** @hidden */
  113427. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113428. /**
  113429. * This function will subdivide the mesh into multiple submeshes
  113430. * @param count defines the expected number of submeshes
  113431. */
  113432. subdivide(count: number): void;
  113433. /**
  113434. * Copy a FloatArray into a specific associated vertex buffer
  113435. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113436. * - VertexBuffer.PositionKind
  113437. * - VertexBuffer.UVKind
  113438. * - VertexBuffer.UV2Kind
  113439. * - VertexBuffer.UV3Kind
  113440. * - VertexBuffer.UV4Kind
  113441. * - VertexBuffer.UV5Kind
  113442. * - VertexBuffer.UV6Kind
  113443. * - VertexBuffer.ColorKind
  113444. * - VertexBuffer.MatricesIndicesKind
  113445. * - VertexBuffer.MatricesIndicesExtraKind
  113446. * - VertexBuffer.MatricesWeightsKind
  113447. * - VertexBuffer.MatricesWeightsExtraKind
  113448. * @param data defines the data source
  113449. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113450. * @param stride defines the data stride size (can be null)
  113451. * @returns the current mesh
  113452. */
  113453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113454. /**
  113455. * Delete a vertex buffer associated with this mesh
  113456. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113457. * - VertexBuffer.PositionKind
  113458. * - VertexBuffer.UVKind
  113459. * - VertexBuffer.UV2Kind
  113460. * - VertexBuffer.UV3Kind
  113461. * - VertexBuffer.UV4Kind
  113462. * - VertexBuffer.UV5Kind
  113463. * - VertexBuffer.UV6Kind
  113464. * - VertexBuffer.ColorKind
  113465. * - VertexBuffer.MatricesIndicesKind
  113466. * - VertexBuffer.MatricesIndicesExtraKind
  113467. * - VertexBuffer.MatricesWeightsKind
  113468. * - VertexBuffer.MatricesWeightsExtraKind
  113469. */
  113470. removeVerticesData(kind: string): void;
  113471. /**
  113472. * Flags an associated vertex buffer as updatable
  113473. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113474. * - VertexBuffer.PositionKind
  113475. * - VertexBuffer.UVKind
  113476. * - VertexBuffer.UV2Kind
  113477. * - VertexBuffer.UV3Kind
  113478. * - VertexBuffer.UV4Kind
  113479. * - VertexBuffer.UV5Kind
  113480. * - VertexBuffer.UV6Kind
  113481. * - VertexBuffer.ColorKind
  113482. * - VertexBuffer.MatricesIndicesKind
  113483. * - VertexBuffer.MatricesIndicesExtraKind
  113484. * - VertexBuffer.MatricesWeightsKind
  113485. * - VertexBuffer.MatricesWeightsExtraKind
  113486. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113487. */
  113488. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113489. /**
  113490. * Sets the mesh global Vertex Buffer
  113491. * @param buffer defines the buffer to use
  113492. * @returns the current mesh
  113493. */
  113494. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113495. /**
  113496. * Update a specific associated vertex buffer
  113497. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113498. * - VertexBuffer.PositionKind
  113499. * - VertexBuffer.UVKind
  113500. * - VertexBuffer.UV2Kind
  113501. * - VertexBuffer.UV3Kind
  113502. * - VertexBuffer.UV4Kind
  113503. * - VertexBuffer.UV5Kind
  113504. * - VertexBuffer.UV6Kind
  113505. * - VertexBuffer.ColorKind
  113506. * - VertexBuffer.MatricesIndicesKind
  113507. * - VertexBuffer.MatricesIndicesExtraKind
  113508. * - VertexBuffer.MatricesWeightsKind
  113509. * - VertexBuffer.MatricesWeightsExtraKind
  113510. * @param data defines the data source
  113511. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113512. * @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)
  113513. * @returns the current mesh
  113514. */
  113515. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113516. /**
  113517. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113518. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113519. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113520. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113521. * @returns the current mesh
  113522. */
  113523. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113524. /**
  113525. * Creates a un-shared specific occurence of the geometry for the mesh.
  113526. * @returns the current mesh
  113527. */
  113528. makeGeometryUnique(): Mesh;
  113529. /**
  113530. * Set the index buffer of this mesh
  113531. * @param indices defines the source data
  113532. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113533. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113534. * @returns the current mesh
  113535. */
  113536. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113537. /**
  113538. * Update the current index buffer
  113539. * @param indices defines the source data
  113540. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113541. * @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)
  113542. * @returns the current mesh
  113543. */
  113544. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113545. /**
  113546. * Invert the geometry to move from a right handed system to a left handed one.
  113547. * @returns the current mesh
  113548. */
  113549. toLeftHanded(): Mesh;
  113550. /** @hidden */
  113551. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113552. /** @hidden */
  113553. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113554. /**
  113555. * Registers for this mesh a javascript function called just before the rendering process
  113556. * @param func defines the function to call before rendering this mesh
  113557. * @returns the current mesh
  113558. */
  113559. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113560. /**
  113561. * Disposes a previously registered javascript function called before the rendering
  113562. * @param func defines the function to remove
  113563. * @returns the current mesh
  113564. */
  113565. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113566. /**
  113567. * Registers for this mesh a javascript function called just after the rendering is complete
  113568. * @param func defines the function to call after rendering this mesh
  113569. * @returns the current mesh
  113570. */
  113571. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113572. /**
  113573. * Disposes a previously registered javascript function called after the rendering.
  113574. * @param func defines the function to remove
  113575. * @returns the current mesh
  113576. */
  113577. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113578. /** @hidden */
  113579. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113580. /** @hidden */
  113581. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113582. /** @hidden */
  113583. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113584. /** @hidden */
  113585. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113586. /** @hidden */
  113587. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113588. /** @hidden */
  113589. _rebuild(): void;
  113590. /** @hidden */
  113591. _freeze(): void;
  113592. /** @hidden */
  113593. _unFreeze(): void;
  113594. /**
  113595. * 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
  113596. * @param subMesh defines the subMesh to render
  113597. * @param enableAlphaMode defines if alpha mode can be changed
  113598. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113599. * @returns the current mesh
  113600. */
  113601. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113602. private _onBeforeDraw;
  113603. /**
  113604. * Renormalize the mesh and patch it up if there are no weights
  113605. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113606. * However in the case of zero weights then we set just a single influence to 1.
  113607. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113608. */
  113609. cleanMatrixWeights(): void;
  113610. private normalizeSkinFourWeights;
  113611. private normalizeSkinWeightsAndExtra;
  113612. /**
  113613. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113614. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113615. * the user know there was an issue with importing the mesh
  113616. * @returns a validation object with skinned, valid and report string
  113617. */
  113618. validateSkinning(): {
  113619. skinned: boolean;
  113620. valid: boolean;
  113621. report: string;
  113622. };
  113623. /** @hidden */
  113624. _checkDelayState(): Mesh;
  113625. private _queueLoad;
  113626. /**
  113627. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113628. * A mesh is in the frustum if its bounding box intersects the frustum
  113629. * @param frustumPlanes defines the frustum to test
  113630. * @returns true if the mesh is in the frustum planes
  113631. */
  113632. isInFrustum(frustumPlanes: Plane[]): boolean;
  113633. /**
  113634. * Sets the mesh material by the material or multiMaterial `id` property
  113635. * @param id is a string identifying the material or the multiMaterial
  113636. * @returns the current mesh
  113637. */
  113638. setMaterialByID(id: string): Mesh;
  113639. /**
  113640. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113641. * @returns an array of IAnimatable
  113642. */
  113643. getAnimatables(): IAnimatable[];
  113644. /**
  113645. * Modifies the mesh geometry according to the passed transformation matrix.
  113646. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113647. * The mesh normals are modified using the same transformation.
  113648. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113649. * @param transform defines the transform matrix to use
  113650. * @see https://doc.babylonjs.com/resources/baking_transformations
  113651. * @returns the current mesh
  113652. */
  113653. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113654. /**
  113655. * Modifies the mesh geometry according to its own current World Matrix.
  113656. * The mesh World Matrix is then reset.
  113657. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113658. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113659. * @see https://doc.babylonjs.com/resources/baking_transformations
  113660. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113661. * @returns the current mesh
  113662. */
  113663. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113664. /** @hidden */
  113665. get _positions(): Nullable<Vector3[]>;
  113666. /** @hidden */
  113667. _resetPointsArrayCache(): Mesh;
  113668. /** @hidden */
  113669. _generatePointsArray(): boolean;
  113670. /**
  113671. * Returns a new Mesh object generated from the current mesh properties.
  113672. * This method must not get confused with createInstance()
  113673. * @param name is a string, the name given to the new mesh
  113674. * @param newParent can be any Node object (default `null`)
  113675. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113676. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113677. * @returns a new mesh
  113678. */
  113679. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113680. /**
  113681. * Releases resources associated with this mesh.
  113682. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113683. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113684. */
  113685. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113686. /** @hidden */
  113687. _disposeInstanceSpecificData(): void;
  113688. /** @hidden */
  113689. _disposeThinInstanceSpecificData(): void;
  113690. /**
  113691. * Modifies the mesh geometry according to a displacement map.
  113692. * 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.
  113693. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113694. * @param url is a string, the URL from the image file is to be downloaded.
  113695. * @param minHeight is the lower limit of the displacement.
  113696. * @param maxHeight is the upper limit of the displacement.
  113697. * @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.
  113698. * @param uvOffset is an optional vector2 used to offset UV.
  113699. * @param uvScale is an optional vector2 used to scale UV.
  113700. * @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.
  113701. * @returns the Mesh.
  113702. */
  113703. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113704. /**
  113705. * Modifies the mesh geometry according to a displacementMap buffer.
  113706. * 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.
  113707. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113708. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113709. * @param heightMapWidth is the width of the buffer image.
  113710. * @param heightMapHeight is the height of the buffer image.
  113711. * @param minHeight is the lower limit of the displacement.
  113712. * @param maxHeight is the upper limit of the displacement.
  113713. * @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.
  113714. * @param uvOffset is an optional vector2 used to offset UV.
  113715. * @param uvScale is an optional vector2 used to scale UV.
  113716. * @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.
  113717. * @returns the Mesh.
  113718. */
  113719. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113720. /**
  113721. * Modify the mesh to get a flat shading rendering.
  113722. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113723. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113724. * @returns current mesh
  113725. */
  113726. convertToFlatShadedMesh(): Mesh;
  113727. /**
  113728. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113729. * In other words, more vertices, no more indices and a single bigger VBO.
  113730. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113731. * @returns current mesh
  113732. */
  113733. convertToUnIndexedMesh(): Mesh;
  113734. /**
  113735. * Inverses facet orientations.
  113736. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113737. * @param flipNormals will also inverts the normals
  113738. * @returns current mesh
  113739. */
  113740. flipFaces(flipNormals?: boolean): Mesh;
  113741. /**
  113742. * Increase the number of facets and hence vertices in a mesh
  113743. * Vertex normals are interpolated from existing vertex normals
  113744. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113745. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113746. */
  113747. increaseVertices(numberPerEdge: number): void;
  113748. /**
  113749. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113750. * This will undo any application of covertToFlatShadedMesh
  113751. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113752. */
  113753. forceSharedVertices(): void;
  113754. /** @hidden */
  113755. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113756. /** @hidden */
  113757. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113758. /**
  113759. * Creates a new InstancedMesh object from the mesh model.
  113760. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113761. * @param name defines the name of the new instance
  113762. * @returns a new InstancedMesh
  113763. */
  113764. createInstance(name: string): InstancedMesh;
  113765. /**
  113766. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113767. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113768. * @returns the current mesh
  113769. */
  113770. synchronizeInstances(): Mesh;
  113771. /**
  113772. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113773. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113774. * This should be used together with the simplification to avoid disappearing triangles.
  113775. * @param successCallback an optional success callback to be called after the optimization finished.
  113776. * @returns the current mesh
  113777. */
  113778. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113779. /**
  113780. * Serialize current mesh
  113781. * @param serializationObject defines the object which will receive the serialization data
  113782. */
  113783. serialize(serializationObject: any): void;
  113784. /** @hidden */
  113785. _syncGeometryWithMorphTargetManager(): void;
  113786. /** @hidden */
  113787. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113788. /**
  113789. * Returns a new Mesh object parsed from the source provided.
  113790. * @param parsedMesh is the source
  113791. * @param scene defines the hosting scene
  113792. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113793. * @returns a new Mesh
  113794. */
  113795. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113796. /**
  113797. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113799. * @param name defines the name of the mesh to create
  113800. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  113801. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  113802. * @param closePath creates a seam between the first and the last points of each path of the path array
  113803. * @param offset is taken in account only if the `pathArray` is containing a single path
  113804. * @param scene defines the hosting scene
  113805. * @param updatable defines if the mesh must be flagged as updatable
  113806. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113807. * @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)
  113808. * @returns a new Mesh
  113809. */
  113810. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113811. /**
  113812. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  113813. * @param name defines the name of the mesh to create
  113814. * @param radius sets the radius size (float) of the polygon (default 0.5)
  113815. * @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
  113816. * @param scene defines the hosting scene
  113817. * @param updatable defines if the mesh must be flagged as updatable
  113818. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113819. * @returns a new Mesh
  113820. */
  113821. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113822. /**
  113823. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  113824. * @param name defines the name of the mesh to create
  113825. * @param size sets the size (float) of each box side (default 1)
  113826. * @param scene defines the hosting scene
  113827. * @param updatable defines if the mesh must be flagged as updatable
  113828. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113829. * @returns a new Mesh
  113830. */
  113831. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113832. /**
  113833. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  113834. * @param name defines the name of the mesh to create
  113835. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113836. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113837. * @param scene defines the hosting scene
  113838. * @param updatable defines if the mesh must be flagged as updatable
  113839. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113840. * @returns a new Mesh
  113841. */
  113842. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113843. /**
  113844. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  113845. * @param name defines the name of the mesh to create
  113846. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113847. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113848. * @param scene defines the hosting scene
  113849. * @returns a new Mesh
  113850. */
  113851. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  113852. /**
  113853. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  113854. * @param name defines the name of the mesh to create
  113855. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  113856. * @param diameterTop set the top cap diameter (floats, default 1)
  113857. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  113858. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  113859. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  113860. * @param scene defines the hosting scene
  113861. * @param updatable defines if the mesh must be flagged as updatable
  113862. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113863. * @returns a new Mesh
  113864. */
  113865. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  113866. /**
  113867. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  113868. * @param name defines the name of the mesh to create
  113869. * @param diameter sets the diameter size (float) of the torus (default 1)
  113870. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  113871. * @param tessellation sets the number of torus sides (postive integer, default 16)
  113872. * @param scene defines the hosting scene
  113873. * @param updatable defines if the mesh must be flagged as updatable
  113874. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113875. * @returns a new Mesh
  113876. */
  113877. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113878. /**
  113879. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  113880. * @param name defines the name of the mesh to create
  113881. * @param radius sets the global radius size (float) of the torus knot (default 2)
  113882. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  113883. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  113884. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  113885. * @param p the number of windings on X axis (positive integers, default 2)
  113886. * @param q the number of windings on Y axis (positive integers, default 3)
  113887. * @param scene defines the hosting scene
  113888. * @param updatable defines if the mesh must be flagged as updatable
  113889. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113890. * @returns a new Mesh
  113891. */
  113892. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113893. /**
  113894. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  113895. * @param name defines the name of the mesh to create
  113896. * @param points is an array successive Vector3
  113897. * @param scene defines the hosting scene
  113898. * @param updatable defines if the mesh must be flagged as updatable
  113899. * @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).
  113900. * @returns a new Mesh
  113901. */
  113902. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  113903. /**
  113904. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  113905. * @param name defines the name of the mesh to create
  113906. * @param points is an array successive Vector3
  113907. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  113908. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113909. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  113910. * @param scene defines the hosting scene
  113911. * @param updatable defines if the mesh must be flagged as updatable
  113912. * @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)
  113913. * @returns a new Mesh
  113914. */
  113915. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  113916. /**
  113917. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  113918. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  113919. * 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.
  113920. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  113921. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113922. * Remember you can only change the shape positions, not their number when updating a polygon.
  113923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  113924. * @param name defines the name of the mesh to create
  113925. * @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
  113926. * @param scene defines the hosting scene
  113927. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113928. * @param updatable defines if the mesh must be flagged as updatable
  113929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113930. * @param earcutInjection can be used to inject your own earcut reference
  113931. * @returns a new Mesh
  113932. */
  113933. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113934. /**
  113935. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  113936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  113937. * @param name defines the name of the mesh to create
  113938. * @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
  113939. * @param depth defines the height of extrusion
  113940. * @param scene defines the hosting scene
  113941. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  113942. * @param updatable defines if the mesh must be flagged as updatable
  113943. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113944. * @param earcutInjection can be used to inject your own earcut reference
  113945. * @returns a new Mesh
  113946. */
  113947. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  113948. /**
  113949. * Creates an extruded shape mesh.
  113950. * 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
  113951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113953. * @param name defines the name of the mesh to create
  113954. * @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
  113955. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113956. * @param scale is the value to scale the shape
  113957. * @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
  113958. * @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
  113959. * @param scene defines the hosting scene
  113960. * @param updatable defines if the mesh must be flagged as updatable
  113961. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113962. * @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)
  113963. * @returns a new Mesh
  113964. */
  113965. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113966. /**
  113967. * Creates an custom extruded shape mesh.
  113968. * The custom extrusion is a parametric shape.
  113969. * It has no predefined shape. Its final shape will depend on the input parameters.
  113970. * Please consider using the same method from the MeshBuilder class instead
  113971. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113972. * @param name defines the name of the mesh to create
  113973. * @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
  113974. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  113975. * @param scaleFunction is a custom Javascript function called on each path point
  113976. * @param rotationFunction is a custom Javascript function called on each path point
  113977. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113978. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  113979. * @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
  113980. * @param scene defines the hosting scene
  113981. * @param updatable defines if the mesh must be flagged as updatable
  113982. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113983. * @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)
  113984. * @returns a new Mesh
  113985. */
  113986. 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;
  113987. /**
  113988. * Creates lathe mesh.
  113989. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  113990. * Please consider using the same method from the MeshBuilder class instead
  113991. * @param name defines the name of the mesh to create
  113992. * @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
  113993. * @param radius is the radius value of the lathe
  113994. * @param tessellation is the side number of the lathe.
  113995. * @param scene defines the hosting scene
  113996. * @param updatable defines if the mesh must be flagged as updatable
  113997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113998. * @returns a new Mesh
  113999. */
  114000. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114001. /**
  114002. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114003. * @param name defines the name of the mesh to create
  114004. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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. * @returns a new Mesh
  114009. */
  114010. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114011. /**
  114012. * Creates a ground mesh.
  114013. * Please consider using the same method from the MeshBuilder class instead
  114014. * @param name defines the name of the mesh to create
  114015. * @param width set the width of the ground
  114016. * @param height set the height of the ground
  114017. * @param subdivisions sets the number of subdivisions per side
  114018. * @param scene defines the hosting scene
  114019. * @param updatable defines if the mesh must be flagged as updatable
  114020. * @returns a new Mesh
  114021. */
  114022. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114023. /**
  114024. * Creates a tiled ground mesh.
  114025. * Please consider using the same method from the MeshBuilder class instead
  114026. * @param name defines the name of the mesh to create
  114027. * @param xmin set the ground minimum X coordinate
  114028. * @param zmin set the ground minimum Y coordinate
  114029. * @param xmax set the ground maximum X coordinate
  114030. * @param zmax set the ground maximum Z coordinate
  114031. * @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
  114032. * @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
  114033. * @param scene defines the hosting scene
  114034. * @param updatable defines if the mesh must be flagged as updatable
  114035. * @returns a new Mesh
  114036. */
  114037. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114038. w: number;
  114039. h: number;
  114040. }, precision: {
  114041. w: number;
  114042. h: number;
  114043. }, scene: Scene, updatable?: boolean): Mesh;
  114044. /**
  114045. * Creates a ground mesh from a height map.
  114046. * Please consider using the same method from the MeshBuilder class instead
  114047. * @see https://doc.babylonjs.com/babylon101/height_map
  114048. * @param name defines the name of the mesh to create
  114049. * @param url sets the URL of the height map image resource
  114050. * @param width set the ground width size
  114051. * @param height set the ground height size
  114052. * @param subdivisions sets the number of subdivision per side
  114053. * @param minHeight is the minimum altitude on the ground
  114054. * @param maxHeight is the maximum altitude on the ground
  114055. * @param scene defines the hosting scene
  114056. * @param updatable defines if the mesh must be flagged as updatable
  114057. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114058. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114059. * @returns a new Mesh
  114060. */
  114061. 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;
  114062. /**
  114063. * Creates a tube mesh.
  114064. * The tube is a parametric shape.
  114065. * It has no predefined shape. Its final shape will depend on the input parameters.
  114066. * Please consider using the same method from the MeshBuilder class instead
  114067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114068. * @param name defines the name of the mesh to create
  114069. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114070. * @param radius sets the tube radius size
  114071. * @param tessellation is the number of sides on the tubular surface
  114072. * @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
  114073. * @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
  114074. * @param scene defines the hosting scene
  114075. * @param updatable defines if the mesh must be flagged as updatable
  114076. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114077. * @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)
  114078. * @returns a new Mesh
  114079. */
  114080. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114081. (i: number, distance: number): number;
  114082. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114083. /**
  114084. * Creates a polyhedron mesh.
  114085. * Please consider using the same method from the MeshBuilder class instead.
  114086. * * 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
  114087. * * The parameter `size` (positive float, default 1) sets the polygon size
  114088. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114089. * * 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`
  114090. * * 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
  114091. * * 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)`)
  114092. * * 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
  114093. * * 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
  114094. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114097. * @param name defines the name of the mesh to create
  114098. * @param options defines the options used to create the mesh
  114099. * @param scene defines the hosting scene
  114100. * @returns a new Mesh
  114101. */
  114102. static CreatePolyhedron(name: string, options: {
  114103. type?: number;
  114104. size?: number;
  114105. sizeX?: number;
  114106. sizeY?: number;
  114107. sizeZ?: number;
  114108. custom?: any;
  114109. faceUV?: Vector4[];
  114110. faceColors?: Color4[];
  114111. updatable?: boolean;
  114112. sideOrientation?: number;
  114113. }, scene: Scene): Mesh;
  114114. /**
  114115. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114116. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114117. * * 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`)
  114118. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114119. * * 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
  114120. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  114124. * @param options defines the options used to create the mesh
  114125. * @param scene defines the hosting scene
  114126. * @returns a new Mesh
  114127. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114128. */
  114129. static CreateIcoSphere(name: string, options: {
  114130. radius?: number;
  114131. flat?: boolean;
  114132. subdivisions?: number;
  114133. sideOrientation?: number;
  114134. updatable?: boolean;
  114135. }, scene: Scene): Mesh;
  114136. /**
  114137. * Creates a decal mesh.
  114138. * Please consider using the same method from the MeshBuilder class instead.
  114139. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114140. * @param name defines the name of the mesh
  114141. * @param sourceMesh defines the mesh receiving the decal
  114142. * @param position sets the position of the decal in world coordinates
  114143. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114144. * @param size sets the decal scaling
  114145. * @param angle sets the angle to rotate the decal
  114146. * @returns a new Mesh
  114147. */
  114148. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114149. /** Creates a Capsule Mesh
  114150. * @param name defines the name of the mesh.
  114151. * @param options the constructors options used to shape the mesh.
  114152. * @param scene defines the scene the mesh is scoped to.
  114153. * @returns the capsule mesh
  114154. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114155. */
  114156. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114157. /**
  114158. * Prepare internal position array for software CPU skinning
  114159. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114160. */
  114161. setPositionsForCPUSkinning(): Float32Array;
  114162. /**
  114163. * Prepare internal normal array for software CPU skinning
  114164. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114165. */
  114166. setNormalsForCPUSkinning(): Float32Array;
  114167. /**
  114168. * Updates the vertex buffer by applying transformation from the bones
  114169. * @param skeleton defines the skeleton to apply to current mesh
  114170. * @returns the current mesh
  114171. */
  114172. applySkeleton(skeleton: Skeleton): Mesh;
  114173. /**
  114174. * 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
  114175. * @param meshes defines the list of meshes to scan
  114176. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114177. */
  114178. static MinMax(meshes: AbstractMesh[]): {
  114179. min: Vector3;
  114180. max: Vector3;
  114181. };
  114182. /**
  114183. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114184. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114185. * @returns a vector3
  114186. */
  114187. static Center(meshesOrMinMaxVector: {
  114188. min: Vector3;
  114189. max: Vector3;
  114190. } | AbstractMesh[]): Vector3;
  114191. /**
  114192. * Merge the array of meshes into a single mesh for performance reasons.
  114193. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114194. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114195. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114196. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114197. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114198. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114199. * @returns a new mesh
  114200. */
  114201. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114202. /** @hidden */
  114203. addInstance(instance: InstancedMesh): void;
  114204. /** @hidden */
  114205. removeInstance(instance: InstancedMesh): void;
  114206. }
  114207. }
  114208. declare module BABYLON {
  114209. /**
  114210. * This is the base class of all the camera used in the application.
  114211. * @see https://doc.babylonjs.com/features/cameras
  114212. */
  114213. export class Camera extends Node {
  114214. /** @hidden */
  114215. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114216. /**
  114217. * This is the default projection mode used by the cameras.
  114218. * It helps recreating a feeling of perspective and better appreciate depth.
  114219. * This is the best way to simulate real life cameras.
  114220. */
  114221. static readonly PERSPECTIVE_CAMERA: number;
  114222. /**
  114223. * This helps creating camera with an orthographic mode.
  114224. * 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.
  114225. */
  114226. static readonly ORTHOGRAPHIC_CAMERA: number;
  114227. /**
  114228. * This is the default FOV mode for perspective cameras.
  114229. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114230. */
  114231. static readonly FOVMODE_VERTICAL_FIXED: number;
  114232. /**
  114233. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114234. */
  114235. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114236. /**
  114237. * This specifies ther is no need for a camera rig.
  114238. * Basically only one eye is rendered corresponding to the camera.
  114239. */
  114240. static readonly RIG_MODE_NONE: number;
  114241. /**
  114242. * Simulates a camera Rig with one blue eye and one red eye.
  114243. * This can be use with 3d blue and red glasses.
  114244. */
  114245. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114246. /**
  114247. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114248. */
  114249. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114250. /**
  114251. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114252. */
  114253. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114254. /**
  114255. * Defines that both eyes of the camera will be rendered over under each other.
  114256. */
  114257. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114258. /**
  114259. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114260. */
  114261. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114262. /**
  114263. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114264. */
  114265. static readonly RIG_MODE_VR: number;
  114266. /**
  114267. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114268. */
  114269. static readonly RIG_MODE_WEBVR: number;
  114270. /**
  114271. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114272. */
  114273. static readonly RIG_MODE_CUSTOM: number;
  114274. /**
  114275. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114276. */
  114277. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114278. /**
  114279. * Define the input manager associated with the camera.
  114280. */
  114281. inputs: CameraInputsManager<Camera>;
  114282. /** @hidden */
  114283. _position: Vector3;
  114284. /**
  114285. * Define the current local position of the camera in the scene
  114286. */
  114287. get position(): Vector3;
  114288. set position(newPosition: Vector3);
  114289. protected _upVector: Vector3;
  114290. /**
  114291. * The vector the camera should consider as up.
  114292. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114293. */
  114294. set upVector(vec: Vector3);
  114295. get upVector(): Vector3;
  114296. /**
  114297. * Define the current limit on the left side for an orthographic camera
  114298. * In scene unit
  114299. */
  114300. orthoLeft: Nullable<number>;
  114301. /**
  114302. * Define the current limit on the right side for an orthographic camera
  114303. * In scene unit
  114304. */
  114305. orthoRight: Nullable<number>;
  114306. /**
  114307. * Define the current limit on the bottom side for an orthographic camera
  114308. * In scene unit
  114309. */
  114310. orthoBottom: Nullable<number>;
  114311. /**
  114312. * Define the current limit on the top side for an orthographic camera
  114313. * In scene unit
  114314. */
  114315. orthoTop: Nullable<number>;
  114316. /**
  114317. * Field Of View is set in Radians. (default is 0.8)
  114318. */
  114319. fov: number;
  114320. /**
  114321. * Define the minimum distance the camera can see from.
  114322. * This is important to note that the depth buffer are not infinite and the closer it starts
  114323. * the more your scene might encounter depth fighting issue.
  114324. */
  114325. minZ: number;
  114326. /**
  114327. * Define the maximum distance the camera can see to.
  114328. * This is important to note that the depth buffer are not infinite and the further it end
  114329. * the more your scene might encounter depth fighting issue.
  114330. */
  114331. maxZ: number;
  114332. /**
  114333. * Define the default inertia of the camera.
  114334. * This helps giving a smooth feeling to the camera movement.
  114335. */
  114336. inertia: number;
  114337. /**
  114338. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114339. */
  114340. mode: number;
  114341. /**
  114342. * Define whether the camera is intermediate.
  114343. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114344. */
  114345. isIntermediate: boolean;
  114346. /**
  114347. * Define the viewport of the camera.
  114348. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114349. */
  114350. viewport: Viewport;
  114351. /**
  114352. * Restricts the camera to viewing objects with the same layerMask.
  114353. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114354. */
  114355. layerMask: number;
  114356. /**
  114357. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114358. */
  114359. fovMode: number;
  114360. /**
  114361. * Rig mode of the camera.
  114362. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114363. * This is normally controlled byt the camera themselves as internal use.
  114364. */
  114365. cameraRigMode: number;
  114366. /**
  114367. * Defines the distance between both "eyes" in case of a RIG
  114368. */
  114369. interaxialDistance: number;
  114370. /**
  114371. * Defines if stereoscopic rendering is done side by side or over under.
  114372. */
  114373. isStereoscopicSideBySide: boolean;
  114374. /**
  114375. * 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
  114376. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114377. * else in the scene. (Eg. security camera)
  114378. *
  114379. * 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)
  114380. */
  114381. customRenderTargets: RenderTargetTexture[];
  114382. /**
  114383. * When set, the camera will render to this render target instead of the default canvas
  114384. *
  114385. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114386. */
  114387. outputRenderTarget: Nullable<RenderTargetTexture>;
  114388. /**
  114389. * Observable triggered when the camera view matrix has changed.
  114390. */
  114391. onViewMatrixChangedObservable: Observable<Camera>;
  114392. /**
  114393. * Observable triggered when the camera Projection matrix has changed.
  114394. */
  114395. onProjectionMatrixChangedObservable: Observable<Camera>;
  114396. /**
  114397. * Observable triggered when the inputs have been processed.
  114398. */
  114399. onAfterCheckInputsObservable: Observable<Camera>;
  114400. /**
  114401. * Observable triggered when reset has been called and applied to the camera.
  114402. */
  114403. onRestoreStateObservable: Observable<Camera>;
  114404. /**
  114405. * Is this camera a part of a rig system?
  114406. */
  114407. isRigCamera: boolean;
  114408. /**
  114409. * If isRigCamera set to true this will be set with the parent camera.
  114410. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114411. */
  114412. rigParent?: Camera;
  114413. /** @hidden */
  114414. _cameraRigParams: any;
  114415. /** @hidden */
  114416. _rigCameras: Camera[];
  114417. /** @hidden */
  114418. _rigPostProcess: Nullable<PostProcess>;
  114419. protected _webvrViewMatrix: Matrix;
  114420. /** @hidden */
  114421. _skipRendering: boolean;
  114422. /** @hidden */
  114423. _projectionMatrix: Matrix;
  114424. /** @hidden */
  114425. _postProcesses: Nullable<PostProcess>[];
  114426. /** @hidden */
  114427. _activeMeshes: SmartArray<AbstractMesh>;
  114428. protected _globalPosition: Vector3;
  114429. /** @hidden */
  114430. _computedViewMatrix: Matrix;
  114431. private _doNotComputeProjectionMatrix;
  114432. private _transformMatrix;
  114433. private _frustumPlanes;
  114434. private _refreshFrustumPlanes;
  114435. private _storedFov;
  114436. private _stateStored;
  114437. /**
  114438. * Instantiates a new camera object.
  114439. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114440. * @see https://doc.babylonjs.com/features/cameras
  114441. * @param name Defines the name of the camera in the scene
  114442. * @param position Defines the position of the camera
  114443. * @param scene Defines the scene the camera belongs too
  114444. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114445. */
  114446. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114447. /**
  114448. * Store current camera state (fov, position, etc..)
  114449. * @returns the camera
  114450. */
  114451. storeState(): Camera;
  114452. /**
  114453. * Restores the camera state values if it has been stored. You must call storeState() first
  114454. */
  114455. protected _restoreStateValues(): boolean;
  114456. /**
  114457. * Restored camera state. You must call storeState() first.
  114458. * @returns true if restored and false otherwise
  114459. */
  114460. restoreState(): boolean;
  114461. /**
  114462. * Gets the class name of the camera.
  114463. * @returns the class name
  114464. */
  114465. getClassName(): string;
  114466. /** @hidden */
  114467. readonly _isCamera: boolean;
  114468. /**
  114469. * Gets a string representation of the camera useful for debug purpose.
  114470. * @param fullDetails Defines that a more verboe level of logging is required
  114471. * @returns the string representation
  114472. */
  114473. toString(fullDetails?: boolean): string;
  114474. /**
  114475. * Gets the current world space position of the camera.
  114476. */
  114477. get globalPosition(): Vector3;
  114478. /**
  114479. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114480. * @returns the active meshe list
  114481. */
  114482. getActiveMeshes(): SmartArray<AbstractMesh>;
  114483. /**
  114484. * Check whether a mesh is part of the current active mesh list of the camera
  114485. * @param mesh Defines the mesh to check
  114486. * @returns true if active, false otherwise
  114487. */
  114488. isActiveMesh(mesh: Mesh): boolean;
  114489. /**
  114490. * Is this camera ready to be used/rendered
  114491. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114492. * @return true if the camera is ready
  114493. */
  114494. isReady(completeCheck?: boolean): boolean;
  114495. /** @hidden */
  114496. _initCache(): void;
  114497. /** @hidden */
  114498. _updateCache(ignoreParentClass?: boolean): void;
  114499. /** @hidden */
  114500. _isSynchronized(): boolean;
  114501. /** @hidden */
  114502. _isSynchronizedViewMatrix(): boolean;
  114503. /** @hidden */
  114504. _isSynchronizedProjectionMatrix(): boolean;
  114505. /**
  114506. * Attach the input controls to a specific dom element to get the input from.
  114507. * @param element Defines the element the controls should be listened from
  114508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114509. */
  114510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114511. /**
  114512. * Detach the current controls from the specified dom element.
  114513. * @param element Defines the element to stop listening the inputs from
  114514. */
  114515. detachControl(element: HTMLElement): void;
  114516. /**
  114517. * Update the camera state according to the different inputs gathered during the frame.
  114518. */
  114519. update(): void;
  114520. /** @hidden */
  114521. _checkInputs(): void;
  114522. /** @hidden */
  114523. get rigCameras(): Camera[];
  114524. /**
  114525. * Gets the post process used by the rig cameras
  114526. */
  114527. get rigPostProcess(): Nullable<PostProcess>;
  114528. /**
  114529. * Internal, gets the first post proces.
  114530. * @returns the first post process to be run on this camera.
  114531. */
  114532. _getFirstPostProcess(): Nullable<PostProcess>;
  114533. private _cascadePostProcessesToRigCams;
  114534. /**
  114535. * Attach a post process to the camera.
  114536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114537. * @param postProcess The post process to attach to the camera
  114538. * @param insertAt The position of the post process in case several of them are in use in the scene
  114539. * @returns the position the post process has been inserted at
  114540. */
  114541. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114542. /**
  114543. * Detach a post process to the camera.
  114544. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114545. * @param postProcess The post process to detach from the camera
  114546. */
  114547. detachPostProcess(postProcess: PostProcess): void;
  114548. /**
  114549. * Gets the current world matrix of the camera
  114550. */
  114551. getWorldMatrix(): Matrix;
  114552. /** @hidden */
  114553. _getViewMatrix(): Matrix;
  114554. /**
  114555. * Gets the current view matrix of the camera.
  114556. * @param force forces the camera to recompute the matrix without looking at the cached state
  114557. * @returns the view matrix
  114558. */
  114559. getViewMatrix(force?: boolean): Matrix;
  114560. /**
  114561. * Freeze the projection matrix.
  114562. * It will prevent the cache check of the camera projection compute and can speed up perf
  114563. * if no parameter of the camera are meant to change
  114564. * @param projection Defines manually a projection if necessary
  114565. */
  114566. freezeProjectionMatrix(projection?: Matrix): void;
  114567. /**
  114568. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114569. */
  114570. unfreezeProjectionMatrix(): void;
  114571. /**
  114572. * Gets the current projection matrix of the camera.
  114573. * @param force forces the camera to recompute the matrix without looking at the cached state
  114574. * @returns the projection matrix
  114575. */
  114576. getProjectionMatrix(force?: boolean): Matrix;
  114577. /**
  114578. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114579. * @returns a Matrix
  114580. */
  114581. getTransformationMatrix(): Matrix;
  114582. private _updateFrustumPlanes;
  114583. /**
  114584. * Checks if a cullable object (mesh...) is in the camera frustum
  114585. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114586. * @param target The object to check
  114587. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114588. * @returns true if the object is in frustum otherwise false
  114589. */
  114590. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114591. /**
  114592. * Checks if a cullable object (mesh...) is in the camera frustum
  114593. * Unlike isInFrustum this cheks the full bounding box
  114594. * @param target The object to check
  114595. * @returns true if the object is in frustum otherwise false
  114596. */
  114597. isCompletelyInFrustum(target: ICullable): boolean;
  114598. /**
  114599. * Gets a ray in the forward direction from the camera.
  114600. * @param length Defines the length of the ray to create
  114601. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114602. * @param origin Defines the start point of the ray which defaults to the camera position
  114603. * @returns the forward ray
  114604. */
  114605. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114606. /**
  114607. * Gets a ray in the forward direction from the camera.
  114608. * @param refRay the ray to (re)use when setting the values
  114609. * @param length Defines the length of the ray to create
  114610. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114611. * @param origin Defines the start point of the ray which defaults to the camera position
  114612. * @returns the forward ray
  114613. */
  114614. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114615. /**
  114616. * Releases resources associated with this node.
  114617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114619. */
  114620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114621. /** @hidden */
  114622. _isLeftCamera: boolean;
  114623. /**
  114624. * Gets the left camera of a rig setup in case of Rigged Camera
  114625. */
  114626. get isLeftCamera(): boolean;
  114627. /** @hidden */
  114628. _isRightCamera: boolean;
  114629. /**
  114630. * Gets the right camera of a rig setup in case of Rigged Camera
  114631. */
  114632. get isRightCamera(): boolean;
  114633. /**
  114634. * Gets the left camera of a rig setup in case of Rigged Camera
  114635. */
  114636. get leftCamera(): Nullable<FreeCamera>;
  114637. /**
  114638. * Gets the right camera of a rig setup in case of Rigged Camera
  114639. */
  114640. get rightCamera(): Nullable<FreeCamera>;
  114641. /**
  114642. * Gets the left camera target of a rig setup in case of Rigged Camera
  114643. * @returns the target position
  114644. */
  114645. getLeftTarget(): Nullable<Vector3>;
  114646. /**
  114647. * Gets the right camera target of a rig setup in case of Rigged Camera
  114648. * @returns the target position
  114649. */
  114650. getRightTarget(): Nullable<Vector3>;
  114651. /**
  114652. * @hidden
  114653. */
  114654. setCameraRigMode(mode: number, rigParams: any): void;
  114655. /** @hidden */
  114656. static _setStereoscopicRigMode(camera: Camera): void;
  114657. /** @hidden */
  114658. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114659. /** @hidden */
  114660. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114661. /** @hidden */
  114662. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114663. /** @hidden */
  114664. _getVRProjectionMatrix(): Matrix;
  114665. protected _updateCameraRotationMatrix(): void;
  114666. protected _updateWebVRCameraRotationMatrix(): void;
  114667. /**
  114668. * This function MUST be overwritten by the different WebVR cameras available.
  114669. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114670. * @hidden
  114671. */
  114672. _getWebVRProjectionMatrix(): Matrix;
  114673. /**
  114674. * This function MUST be overwritten by the different WebVR cameras available.
  114675. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114676. * @hidden
  114677. */
  114678. _getWebVRViewMatrix(): Matrix;
  114679. /** @hidden */
  114680. setCameraRigParameter(name: string, value: any): void;
  114681. /**
  114682. * needs to be overridden by children so sub has required properties to be copied
  114683. * @hidden
  114684. */
  114685. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114686. /**
  114687. * May need to be overridden by children
  114688. * @hidden
  114689. */
  114690. _updateRigCameras(): void;
  114691. /** @hidden */
  114692. _setupInputs(): void;
  114693. /**
  114694. * Serialiaze the camera setup to a json represention
  114695. * @returns the JSON representation
  114696. */
  114697. serialize(): any;
  114698. /**
  114699. * Clones the current camera.
  114700. * @param name The cloned camera name
  114701. * @returns the cloned camera
  114702. */
  114703. clone(name: string): Camera;
  114704. /**
  114705. * Gets the direction of the camera relative to a given local axis.
  114706. * @param localAxis Defines the reference axis to provide a relative direction.
  114707. * @return the direction
  114708. */
  114709. getDirection(localAxis: Vector3): Vector3;
  114710. /**
  114711. * Returns the current camera absolute rotation
  114712. */
  114713. get absoluteRotation(): Quaternion;
  114714. /**
  114715. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114716. * @param localAxis Defines the reference axis to provide a relative direction.
  114717. * @param result Defines the vector to store the result in
  114718. */
  114719. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114720. /**
  114721. * Gets a camera constructor for a given camera type
  114722. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114723. * @param name The name of the camera the result will be able to instantiate
  114724. * @param scene The scene the result will construct the camera in
  114725. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114726. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114727. * @returns a factory method to construc the camera
  114728. */
  114729. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114730. /**
  114731. * Compute the world matrix of the camera.
  114732. * @returns the camera world matrix
  114733. */
  114734. computeWorldMatrix(): Matrix;
  114735. /**
  114736. * Parse a JSON and creates the camera from the parsed information
  114737. * @param parsedCamera The JSON to parse
  114738. * @param scene The scene to instantiate the camera in
  114739. * @returns the newly constructed camera
  114740. */
  114741. static Parse(parsedCamera: any, scene: Scene): Camera;
  114742. }
  114743. }
  114744. declare module BABYLON {
  114745. /**
  114746. * Class containing static functions to help procedurally build meshes
  114747. */
  114748. export class DiscBuilder {
  114749. /**
  114750. * Creates a plane polygonal mesh. By default, this is a disc
  114751. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114752. * * 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
  114753. * * 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
  114754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114757. * @param name defines the name of the mesh
  114758. * @param options defines the options used to create the mesh
  114759. * @param scene defines the hosting scene
  114760. * @returns the plane polygonal mesh
  114761. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114762. */
  114763. static CreateDisc(name: string, options: {
  114764. radius?: number;
  114765. tessellation?: number;
  114766. arc?: number;
  114767. updatable?: boolean;
  114768. sideOrientation?: number;
  114769. frontUVs?: Vector4;
  114770. backUVs?: Vector4;
  114771. }, scene?: Nullable<Scene>): Mesh;
  114772. }
  114773. }
  114774. declare module BABYLON {
  114775. /**
  114776. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114777. *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.
  114778. * The SPS is also a particle system. It provides some methods to manage the particles.
  114779. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114780. *
  114781. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114782. */
  114783. export class SolidParticleSystem implements IDisposable {
  114784. /**
  114785. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114786. * Example : var p = SPS.particles[i];
  114787. */
  114788. particles: SolidParticle[];
  114789. /**
  114790. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114791. */
  114792. nbParticles: number;
  114793. /**
  114794. * If the particles must ever face the camera (default false). Useful for planar particles.
  114795. */
  114796. billboard: boolean;
  114797. /**
  114798. * Recompute normals when adding a shape
  114799. */
  114800. recomputeNormals: boolean;
  114801. /**
  114802. * This a counter ofr your own usage. It's not set by any SPS functions.
  114803. */
  114804. counter: number;
  114805. /**
  114806. * The SPS name. This name is also given to the underlying mesh.
  114807. */
  114808. name: string;
  114809. /**
  114810. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  114811. */
  114812. mesh: Mesh;
  114813. /**
  114814. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114815. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  114816. */
  114817. vars: any;
  114818. /**
  114819. * This array is populated when the SPS is set as 'pickable'.
  114820. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  114821. * Each element of this array is an object `{idx: int, faceId: int}`.
  114822. * `idx` is the picked particle index in the `SPS.particles` array
  114823. * `faceId` is the picked face index counted within this particle.
  114824. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  114825. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  114826. * Use the method SPS.pickedParticle(pickingInfo) instead.
  114827. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114828. */
  114829. pickedParticles: {
  114830. idx: number;
  114831. faceId: number;
  114832. }[];
  114833. /**
  114834. * This array is populated when the SPS is set as 'pickable'
  114835. * Each key of this array is a submesh index.
  114836. * Each element of this array is a second array defined like this :
  114837. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  114838. * Each element of this second array is an object `{idx: int, faceId: int}`.
  114839. * `idx` is the picked particle index in the `SPS.particles` array
  114840. * `faceId` is the picked face index counted within this particle.
  114841. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  114842. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114843. */
  114844. pickedBySubMesh: {
  114845. idx: number;
  114846. faceId: number;
  114847. }[][];
  114848. /**
  114849. * This array is populated when `enableDepthSort` is set to true.
  114850. * Each element of this array is an instance of the class DepthSortedParticle.
  114851. */
  114852. depthSortedParticles: DepthSortedParticle[];
  114853. /**
  114854. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114855. * @hidden
  114856. */
  114857. _bSphereOnly: boolean;
  114858. /**
  114859. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114860. * @hidden
  114861. */
  114862. _bSphereRadiusFactor: number;
  114863. private _scene;
  114864. private _positions;
  114865. private _indices;
  114866. private _normals;
  114867. private _colors;
  114868. private _uvs;
  114869. private _indices32;
  114870. private _positions32;
  114871. private _normals32;
  114872. private _fixedNormal32;
  114873. private _colors32;
  114874. private _uvs32;
  114875. private _index;
  114876. private _updatable;
  114877. private _pickable;
  114878. private _isVisibilityBoxLocked;
  114879. private _alwaysVisible;
  114880. private _depthSort;
  114881. private _expandable;
  114882. private _shapeCounter;
  114883. private _copy;
  114884. private _color;
  114885. private _computeParticleColor;
  114886. private _computeParticleTexture;
  114887. private _computeParticleRotation;
  114888. private _computeParticleVertex;
  114889. private _computeBoundingBox;
  114890. private _depthSortParticles;
  114891. private _camera;
  114892. private _mustUnrotateFixedNormals;
  114893. private _particlesIntersect;
  114894. private _needs32Bits;
  114895. private _isNotBuilt;
  114896. private _lastParticleId;
  114897. private _idxOfId;
  114898. private _multimaterialEnabled;
  114899. private _useModelMaterial;
  114900. private _indicesByMaterial;
  114901. private _materialIndexes;
  114902. private _depthSortFunction;
  114903. private _materialSortFunction;
  114904. private _materials;
  114905. private _multimaterial;
  114906. private _materialIndexesById;
  114907. private _defaultMaterial;
  114908. private _autoUpdateSubMeshes;
  114909. private _tmpVertex;
  114910. /**
  114911. * Creates a SPS (Solid Particle System) object.
  114912. * @param name (String) is the SPS name, this will be the underlying mesh name.
  114913. * @param scene (Scene) is the scene in which the SPS is added.
  114914. * @param options defines the options of the sps e.g.
  114915. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  114916. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  114917. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  114918. * * 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.
  114919. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  114920. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  114921. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  114922. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  114923. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  114924. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  114925. */
  114926. constructor(name: string, scene: Scene, options?: {
  114927. updatable?: boolean;
  114928. isPickable?: boolean;
  114929. enableDepthSort?: boolean;
  114930. particleIntersection?: boolean;
  114931. boundingSphereOnly?: boolean;
  114932. bSphereRadiusFactor?: number;
  114933. expandable?: boolean;
  114934. useModelMaterial?: boolean;
  114935. enableMultiMaterial?: boolean;
  114936. });
  114937. /**
  114938. * Builds the SPS underlying mesh. Returns a standard Mesh.
  114939. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  114940. * @returns the created mesh
  114941. */
  114942. buildMesh(): Mesh;
  114943. /**
  114944. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  114945. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  114946. * Thus the particles generated from `digest()` have their property `position` set yet.
  114947. * @param mesh ( Mesh ) is the mesh to be digested
  114948. * @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
  114949. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  114950. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  114951. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  114952. * @returns the current SPS
  114953. */
  114954. digest(mesh: Mesh, options?: {
  114955. facetNb?: number;
  114956. number?: number;
  114957. delta?: number;
  114958. storage?: [];
  114959. }): SolidParticleSystem;
  114960. /**
  114961. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  114962. * @hidden
  114963. */
  114964. private _unrotateFixedNormals;
  114965. /**
  114966. * Resets the temporary working copy particle
  114967. * @hidden
  114968. */
  114969. private _resetCopy;
  114970. /**
  114971. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  114972. * @param p the current index in the positions array to be updated
  114973. * @param ind the current index in the indices array
  114974. * @param shape a Vector3 array, the shape geometry
  114975. * @param positions the positions array to be updated
  114976. * @param meshInd the shape indices array
  114977. * @param indices the indices array to be updated
  114978. * @param meshUV the shape uv array
  114979. * @param uvs the uv array to be updated
  114980. * @param meshCol the shape color array
  114981. * @param colors the color array to be updated
  114982. * @param meshNor the shape normals array
  114983. * @param normals the normals array to be updated
  114984. * @param idx the particle index
  114985. * @param idxInShape the particle index in its shape
  114986. * @param options the addShape() method passed options
  114987. * @model the particle model
  114988. * @hidden
  114989. */
  114990. private _meshBuilder;
  114991. /**
  114992. * Returns a shape Vector3 array from positions float array
  114993. * @param positions float array
  114994. * @returns a vector3 array
  114995. * @hidden
  114996. */
  114997. private _posToShape;
  114998. /**
  114999. * Returns a shapeUV array from a float uvs (array deep copy)
  115000. * @param uvs as a float array
  115001. * @returns a shapeUV array
  115002. * @hidden
  115003. */
  115004. private _uvsToShapeUV;
  115005. /**
  115006. * Adds a new particle object in the particles array
  115007. * @param idx particle index in particles array
  115008. * @param id particle id
  115009. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115010. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115011. * @param model particle ModelShape object
  115012. * @param shapeId model shape identifier
  115013. * @param idxInShape index of the particle in the current model
  115014. * @param bInfo model bounding info object
  115015. * @param storage target storage array, if any
  115016. * @hidden
  115017. */
  115018. private _addParticle;
  115019. /**
  115020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115021. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115023. * @param nb (positive integer) the number of particles to be created from this model
  115024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115026. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115027. * @returns the number of shapes in the system
  115028. */
  115029. addShape(mesh: Mesh, nb: number, options?: {
  115030. positionFunction?: any;
  115031. vertexFunction?: any;
  115032. storage?: [];
  115033. }): number;
  115034. /**
  115035. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115036. * @hidden
  115037. */
  115038. private _rebuildParticle;
  115039. /**
  115040. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115041. * @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.
  115042. * @returns the SPS.
  115043. */
  115044. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115045. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115046. * Returns an array with the removed particles.
  115047. * 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.
  115048. * The SPS can't be empty so at least one particle needs to remain in place.
  115049. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115050. * @param start index of the first particle to remove
  115051. * @param end index of the last particle to remove (included)
  115052. * @returns an array populated with the removed particles
  115053. */
  115054. removeParticles(start: number, end: number): SolidParticle[];
  115055. /**
  115056. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115057. * @param solidParticleArray an array populated with Solid Particles objects
  115058. * @returns the SPS
  115059. */
  115060. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115061. /**
  115062. * Creates a new particle and modifies the SPS mesh geometry :
  115063. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115064. * - calls _addParticle() to populate the particle array
  115065. * factorized code from addShape() and insertParticlesFromArray()
  115066. * @param idx particle index in the particles array
  115067. * @param i particle index in its shape
  115068. * @param modelShape particle ModelShape object
  115069. * @param shape shape vertex array
  115070. * @param meshInd shape indices array
  115071. * @param meshUV shape uv array
  115072. * @param meshCol shape color array
  115073. * @param meshNor shape normals array
  115074. * @param bbInfo shape bounding info
  115075. * @param storage target particle storage
  115076. * @options addShape() passed options
  115077. * @hidden
  115078. */
  115079. private _insertNewParticle;
  115080. /**
  115081. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115082. * This method calls `updateParticle()` for each particle of the SPS.
  115083. * For an animated SPS, it is usually called within the render loop.
  115084. * 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.
  115085. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115086. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115087. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115088. * @returns the SPS.
  115089. */
  115090. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115091. /**
  115092. * Disposes the SPS.
  115093. */
  115094. dispose(): void;
  115095. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115096. * idx is the particle index in the SPS
  115097. * faceId is the picked face index counted within this particle.
  115098. * Returns null if the pickInfo can't identify a picked particle.
  115099. * @param pickingInfo (PickingInfo object)
  115100. * @returns {idx: number, faceId: number} or null
  115101. */
  115102. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115103. idx: number;
  115104. faceId: number;
  115105. }>;
  115106. /**
  115107. * Returns a SolidParticle object from its identifier : particle.id
  115108. * @param id (integer) the particle Id
  115109. * @returns the searched particle or null if not found in the SPS.
  115110. */
  115111. getParticleById(id: number): Nullable<SolidParticle>;
  115112. /**
  115113. * Returns a new array populated with the particles having the passed shapeId.
  115114. * @param shapeId (integer) the shape identifier
  115115. * @returns a new solid particle array
  115116. */
  115117. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115118. /**
  115119. * Populates the passed array "ref" with the particles having the passed shapeId.
  115120. * @param shapeId the shape identifier
  115121. * @returns the SPS
  115122. * @param ref
  115123. */
  115124. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115125. /**
  115126. * Computes the required SubMeshes according the materials assigned to the particles.
  115127. * @returns the solid particle system.
  115128. * Does nothing if called before the SPS mesh is built.
  115129. */
  115130. computeSubMeshes(): SolidParticleSystem;
  115131. /**
  115132. * Sorts the solid particles by material when MultiMaterial is enabled.
  115133. * Updates the indices32 array.
  115134. * Updates the indicesByMaterial array.
  115135. * Updates the mesh indices array.
  115136. * @returns the SPS
  115137. * @hidden
  115138. */
  115139. private _sortParticlesByMaterial;
  115140. /**
  115141. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115142. * @hidden
  115143. */
  115144. private _setMaterialIndexesById;
  115145. /**
  115146. * Returns an array with unique values of Materials from the passed array
  115147. * @param array the material array to be checked and filtered
  115148. * @hidden
  115149. */
  115150. private _filterUniqueMaterialId;
  115151. /**
  115152. * Sets a new Standard Material as _defaultMaterial if not already set.
  115153. * @hidden
  115154. */
  115155. private _setDefaultMaterial;
  115156. /**
  115157. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115158. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115159. * @returns the SPS.
  115160. */
  115161. refreshVisibleSize(): SolidParticleSystem;
  115162. /**
  115163. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115164. * @param size the size (float) of the visibility box
  115165. * note : this doesn't lock the SPS mesh bounding box.
  115166. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115167. */
  115168. setVisibilityBox(size: number): void;
  115169. /**
  115170. * Gets whether the SPS as always visible or not
  115171. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115172. */
  115173. get isAlwaysVisible(): boolean;
  115174. /**
  115175. * Sets the SPS as always visible or not
  115176. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115177. */
  115178. set isAlwaysVisible(val: boolean);
  115179. /**
  115180. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115181. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115182. */
  115183. set isVisibilityBoxLocked(val: boolean);
  115184. /**
  115185. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115186. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115187. */
  115188. get isVisibilityBoxLocked(): boolean;
  115189. /**
  115190. * Tells to `setParticles()` to compute the particle rotations or not.
  115191. * Default value : true. The SPS is faster when it's set to false.
  115192. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115193. */
  115194. set computeParticleRotation(val: boolean);
  115195. /**
  115196. * Tells to `setParticles()` to compute the particle colors or not.
  115197. * Default value : true. The SPS is faster when it's set to false.
  115198. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115199. */
  115200. set computeParticleColor(val: boolean);
  115201. set computeParticleTexture(val: boolean);
  115202. /**
  115203. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115204. * Default value : false. The SPS is faster when it's set to false.
  115205. * Note : the particle custom vertex positions aren't stored values.
  115206. */
  115207. set computeParticleVertex(val: boolean);
  115208. /**
  115209. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115210. */
  115211. set computeBoundingBox(val: boolean);
  115212. /**
  115213. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115214. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115215. * Default : `true`
  115216. */
  115217. set depthSortParticles(val: boolean);
  115218. /**
  115219. * Gets if `setParticles()` computes the particle rotations or not.
  115220. * Default value : true. The SPS is faster when it's set to false.
  115221. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115222. */
  115223. get computeParticleRotation(): boolean;
  115224. /**
  115225. * Gets if `setParticles()` computes the particle colors or not.
  115226. * Default value : true. The SPS is faster when it's set to false.
  115227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115228. */
  115229. get computeParticleColor(): boolean;
  115230. /**
  115231. * Gets if `setParticles()` computes the particle textures or not.
  115232. * Default value : true. The SPS is faster when it's set to false.
  115233. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115234. */
  115235. get computeParticleTexture(): boolean;
  115236. /**
  115237. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115238. * Default value : false. The SPS is faster when it's set to false.
  115239. * Note : the particle custom vertex positions aren't stored values.
  115240. */
  115241. get computeParticleVertex(): boolean;
  115242. /**
  115243. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115244. */
  115245. get computeBoundingBox(): boolean;
  115246. /**
  115247. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115248. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115249. * Default : `true`
  115250. */
  115251. get depthSortParticles(): boolean;
  115252. /**
  115253. * Gets if the SPS is created as expandable at construction time.
  115254. * Default : `false`
  115255. */
  115256. get expandable(): boolean;
  115257. /**
  115258. * Gets if the SPS supports the Multi Materials
  115259. */
  115260. get multimaterialEnabled(): boolean;
  115261. /**
  115262. * Gets if the SPS uses the model materials for its own multimaterial.
  115263. */
  115264. get useModelMaterial(): boolean;
  115265. /**
  115266. * The SPS used material array.
  115267. */
  115268. get materials(): Material[];
  115269. /**
  115270. * Sets the SPS MultiMaterial from the passed materials.
  115271. * Note : the passed array is internally copied and not used then by reference.
  115272. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115273. */
  115274. setMultiMaterial(materials: Material[]): void;
  115275. /**
  115276. * The SPS computed multimaterial object
  115277. */
  115278. get multimaterial(): MultiMaterial;
  115279. set multimaterial(mm: MultiMaterial);
  115280. /**
  115281. * If the subMeshes must be updated on the next call to setParticles()
  115282. */
  115283. get autoUpdateSubMeshes(): boolean;
  115284. set autoUpdateSubMeshes(val: boolean);
  115285. /**
  115286. * This function does nothing. It may be overwritten to set all the particle first values.
  115287. * The SPS doesn't call this function, you may have to call it by your own.
  115288. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115289. */
  115290. initParticles(): void;
  115291. /**
  115292. * This function does nothing. It may be overwritten to recycle a particle.
  115293. * The SPS doesn't call this function, you may have to call it by your own.
  115294. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115295. * @param particle The particle to recycle
  115296. * @returns the recycled particle
  115297. */
  115298. recycleParticle(particle: SolidParticle): SolidParticle;
  115299. /**
  115300. * Updates a particle : this function should be overwritten by the user.
  115301. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115302. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115303. * @example : just set a particle position or velocity and recycle conditions
  115304. * @param particle The particle to update
  115305. * @returns the updated particle
  115306. */
  115307. updateParticle(particle: SolidParticle): SolidParticle;
  115308. /**
  115309. * Updates a vertex of a particle : it can be overwritten by the user.
  115310. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115311. * @param particle the current particle
  115312. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115313. * @param pt the index of the current vertex in the particle shape
  115314. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115315. * @example : just set a vertex particle position or color
  115316. * @returns the sps
  115317. */
  115318. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115319. /**
  115320. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115321. * This does nothing and may be overwritten by the user.
  115322. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115323. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115324. * @param update the boolean update value actually passed to setParticles()
  115325. */
  115326. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115327. /**
  115328. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115329. * This will be passed three parameters.
  115330. * This does nothing and may be overwritten by the user.
  115331. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115332. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115333. * @param update the boolean update value actually passed to setParticles()
  115334. */
  115335. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115336. }
  115337. }
  115338. declare module BABYLON {
  115339. /**
  115340. * Represents one particle of a solid particle system.
  115341. */
  115342. export class SolidParticle {
  115343. /**
  115344. * particle global index
  115345. */
  115346. idx: number;
  115347. /**
  115348. * particle identifier
  115349. */
  115350. id: number;
  115351. /**
  115352. * The color of the particle
  115353. */
  115354. color: Nullable<Color4>;
  115355. /**
  115356. * The world space position of the particle.
  115357. */
  115358. position: Vector3;
  115359. /**
  115360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115361. */
  115362. rotation: Vector3;
  115363. /**
  115364. * The world space rotation quaternion of the particle.
  115365. */
  115366. rotationQuaternion: Nullable<Quaternion>;
  115367. /**
  115368. * The scaling of the particle.
  115369. */
  115370. scaling: Vector3;
  115371. /**
  115372. * The uvs of the particle.
  115373. */
  115374. uvs: Vector4;
  115375. /**
  115376. * The current speed of the particle.
  115377. */
  115378. velocity: Vector3;
  115379. /**
  115380. * The pivot point in the particle local space.
  115381. */
  115382. pivot: Vector3;
  115383. /**
  115384. * Must the particle be translated from its pivot point in its local space ?
  115385. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115386. * Default : false
  115387. */
  115388. translateFromPivot: boolean;
  115389. /**
  115390. * Is the particle active or not ?
  115391. */
  115392. alive: boolean;
  115393. /**
  115394. * Is the particle visible or not ?
  115395. */
  115396. isVisible: boolean;
  115397. /**
  115398. * Index of this particle in the global "positions" array (Internal use)
  115399. * @hidden
  115400. */
  115401. _pos: number;
  115402. /**
  115403. * @hidden Index of this particle in the global "indices" array (Internal use)
  115404. */
  115405. _ind: number;
  115406. /**
  115407. * @hidden ModelShape of this particle (Internal use)
  115408. */
  115409. _model: ModelShape;
  115410. /**
  115411. * ModelShape id of this particle
  115412. */
  115413. shapeId: number;
  115414. /**
  115415. * Index of the particle in its shape id
  115416. */
  115417. idxInShape: number;
  115418. /**
  115419. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115420. */
  115421. _modelBoundingInfo: BoundingInfo;
  115422. /**
  115423. * @hidden Particle BoundingInfo object (Internal use)
  115424. */
  115425. _boundingInfo: BoundingInfo;
  115426. /**
  115427. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115428. */
  115429. _sps: SolidParticleSystem;
  115430. /**
  115431. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115432. */
  115433. _stillInvisible: boolean;
  115434. /**
  115435. * @hidden Last computed particle rotation matrix
  115436. */
  115437. _rotationMatrix: number[];
  115438. /**
  115439. * Parent particle Id, if any.
  115440. * Default null.
  115441. */
  115442. parentId: Nullable<number>;
  115443. /**
  115444. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115445. */
  115446. materialIndex: Nullable<number>;
  115447. /**
  115448. * Custom object or properties.
  115449. */
  115450. props: Nullable<any>;
  115451. /**
  115452. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115453. * The possible values are :
  115454. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115455. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115456. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115457. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115458. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115459. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115460. * */
  115461. cullingStrategy: number;
  115462. /**
  115463. * @hidden Internal global position in the SPS.
  115464. */
  115465. _globalPosition: Vector3;
  115466. /**
  115467. * Creates a Solid Particle object.
  115468. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115469. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115470. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115471. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115472. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115473. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115474. * @param shapeId (integer) is the model shape identifier in the SPS.
  115475. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115476. * @param sps defines the sps it is associated to
  115477. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115478. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115479. */
  115480. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115481. /**
  115482. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115483. * @param target the particle target
  115484. * @returns the current particle
  115485. */
  115486. copyToRef(target: SolidParticle): SolidParticle;
  115487. /**
  115488. * Legacy support, changed scale to scaling
  115489. */
  115490. get scale(): Vector3;
  115491. /**
  115492. * Legacy support, changed scale to scaling
  115493. */
  115494. set scale(scale: Vector3);
  115495. /**
  115496. * Legacy support, changed quaternion to rotationQuaternion
  115497. */
  115498. get quaternion(): Nullable<Quaternion>;
  115499. /**
  115500. * Legacy support, changed quaternion to rotationQuaternion
  115501. */
  115502. set quaternion(q: Nullable<Quaternion>);
  115503. /**
  115504. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115505. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115506. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115507. * @returns true if it intersects
  115508. */
  115509. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115510. /**
  115511. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115512. * A particle is in the frustum if its bounding box intersects the frustum
  115513. * @param frustumPlanes defines the frustum to test
  115514. * @returns true if the particle is in the frustum planes
  115515. */
  115516. isInFrustum(frustumPlanes: Plane[]): boolean;
  115517. /**
  115518. * get the rotation matrix of the particle
  115519. * @hidden
  115520. */
  115521. getRotationMatrix(m: Matrix): void;
  115522. }
  115523. /**
  115524. * Represents the shape of the model used by one particle of a solid particle system.
  115525. * SPS internal tool, don't use it manually.
  115526. */
  115527. export class ModelShape {
  115528. /**
  115529. * The shape id
  115530. * @hidden
  115531. */
  115532. shapeID: number;
  115533. /**
  115534. * flat array of model positions (internal use)
  115535. * @hidden
  115536. */
  115537. _shape: Vector3[];
  115538. /**
  115539. * flat array of model UVs (internal use)
  115540. * @hidden
  115541. */
  115542. _shapeUV: number[];
  115543. /**
  115544. * color array of the model
  115545. * @hidden
  115546. */
  115547. _shapeColors: number[];
  115548. /**
  115549. * indices array of the model
  115550. * @hidden
  115551. */
  115552. _indices: number[];
  115553. /**
  115554. * normals array of the model
  115555. * @hidden
  115556. */
  115557. _normals: number[];
  115558. /**
  115559. * length of the shape in the model indices array (internal use)
  115560. * @hidden
  115561. */
  115562. _indicesLength: number;
  115563. /**
  115564. * Custom position function (internal use)
  115565. * @hidden
  115566. */
  115567. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115568. /**
  115569. * Custom vertex function (internal use)
  115570. * @hidden
  115571. */
  115572. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115573. /**
  115574. * Model material (internal use)
  115575. * @hidden
  115576. */
  115577. _material: Nullable<Material>;
  115578. /**
  115579. * 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.
  115580. * SPS internal tool, don't use it manually.
  115581. * @hidden
  115582. */
  115583. 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>);
  115584. }
  115585. /**
  115586. * Represents a Depth Sorted Particle in the solid particle system.
  115587. * @hidden
  115588. */
  115589. export class DepthSortedParticle {
  115590. /**
  115591. * Particle index
  115592. */
  115593. idx: number;
  115594. /**
  115595. * Index of the particle in the "indices" array
  115596. */
  115597. ind: number;
  115598. /**
  115599. * Length of the particle shape in the "indices" array
  115600. */
  115601. indicesLength: number;
  115602. /**
  115603. * Squared distance from the particle to the camera
  115604. */
  115605. sqDistance: number;
  115606. /**
  115607. * Material index when used with MultiMaterials
  115608. */
  115609. materialIndex: number;
  115610. /**
  115611. * Creates a new sorted particle
  115612. * @param materialIndex
  115613. */
  115614. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115615. }
  115616. /**
  115617. * Represents a solid particle vertex
  115618. */
  115619. export class SolidParticleVertex {
  115620. /**
  115621. * Vertex position
  115622. */
  115623. position: Vector3;
  115624. /**
  115625. * Vertex color
  115626. */
  115627. color: Color4;
  115628. /**
  115629. * Vertex UV
  115630. */
  115631. uv: Vector2;
  115632. /**
  115633. * Creates a new solid particle vertex
  115634. */
  115635. constructor();
  115636. /** Vertex x coordinate */
  115637. get x(): number;
  115638. set x(val: number);
  115639. /** Vertex y coordinate */
  115640. get y(): number;
  115641. set y(val: number);
  115642. /** Vertex z coordinate */
  115643. get z(): number;
  115644. set z(val: number);
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * @hidden
  115650. */
  115651. export class _MeshCollisionData {
  115652. _checkCollisions: boolean;
  115653. _collisionMask: number;
  115654. _collisionGroup: number;
  115655. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115656. _collider: Nullable<Collider>;
  115657. _oldPositionForCollisions: Vector3;
  115658. _diffPositionForCollisions: Vector3;
  115659. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115660. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115661. _collisionResponse: boolean;
  115662. }
  115663. }
  115664. declare module BABYLON {
  115665. /** @hidden */
  115666. class _FacetDataStorage {
  115667. facetPositions: Vector3[];
  115668. facetNormals: Vector3[];
  115669. facetPartitioning: number[][];
  115670. facetNb: number;
  115671. partitioningSubdivisions: number;
  115672. partitioningBBoxRatio: number;
  115673. facetDataEnabled: boolean;
  115674. facetParameters: any;
  115675. bbSize: Vector3;
  115676. subDiv: {
  115677. max: number;
  115678. X: number;
  115679. Y: number;
  115680. Z: number;
  115681. };
  115682. facetDepthSort: boolean;
  115683. facetDepthSortEnabled: boolean;
  115684. depthSortedIndices: IndicesArray;
  115685. depthSortedFacets: {
  115686. ind: number;
  115687. sqDistance: number;
  115688. }[];
  115689. facetDepthSortFunction: (f1: {
  115690. ind: number;
  115691. sqDistance: number;
  115692. }, f2: {
  115693. ind: number;
  115694. sqDistance: number;
  115695. }) => number;
  115696. facetDepthSortFrom: Vector3;
  115697. facetDepthSortOrigin: Vector3;
  115698. invertedMatrix: Matrix;
  115699. }
  115700. /**
  115701. * @hidden
  115702. **/
  115703. class _InternalAbstractMeshDataInfo {
  115704. _hasVertexAlpha: boolean;
  115705. _useVertexColors: boolean;
  115706. _numBoneInfluencers: number;
  115707. _applyFog: boolean;
  115708. _receiveShadows: boolean;
  115709. _facetData: _FacetDataStorage;
  115710. _visibility: number;
  115711. _skeleton: Nullable<Skeleton>;
  115712. _layerMask: number;
  115713. _computeBonesUsingShaders: boolean;
  115714. _isActive: boolean;
  115715. _onlyForInstances: boolean;
  115716. _isActiveIntermediate: boolean;
  115717. _onlyForInstancesIntermediate: boolean;
  115718. _actAsRegularMesh: boolean;
  115719. }
  115720. /**
  115721. * Class used to store all common mesh properties
  115722. */
  115723. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115724. /** No occlusion */
  115725. static OCCLUSION_TYPE_NONE: number;
  115726. /** Occlusion set to optimisitic */
  115727. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115728. /** Occlusion set to strict */
  115729. static OCCLUSION_TYPE_STRICT: number;
  115730. /** Use an accurante occlusion algorithm */
  115731. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115732. /** Use a conservative occlusion algorithm */
  115733. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115734. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115735. * Test order :
  115736. * Is the bounding sphere outside the frustum ?
  115737. * If not, are the bounding box vertices outside the frustum ?
  115738. * It not, then the cullable object is in the frustum.
  115739. */
  115740. static readonly CULLINGSTRATEGY_STANDARD: number;
  115741. /** Culling strategy : Bounding Sphere Only.
  115742. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115743. * It's also less accurate than the standard because some not visible objects can still be selected.
  115744. * Test : is the bounding sphere outside the frustum ?
  115745. * If not, then the cullable object is in the frustum.
  115746. */
  115747. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115748. /** Culling strategy : Optimistic Inclusion.
  115749. * This in an inclusion test first, then the standard exclusion test.
  115750. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115751. * 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.
  115752. * Anyway, it's as accurate as the standard strategy.
  115753. * Test :
  115754. * Is the cullable object bounding sphere center in the frustum ?
  115755. * If not, apply the default culling strategy.
  115756. */
  115757. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115758. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115759. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115760. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115761. * 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.
  115762. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115763. * Test :
  115764. * Is the cullable object bounding sphere center in the frustum ?
  115765. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115766. */
  115767. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115768. /**
  115769. * No billboard
  115770. */
  115771. static get BILLBOARDMODE_NONE(): number;
  115772. /** Billboard on X axis */
  115773. static get BILLBOARDMODE_X(): number;
  115774. /** Billboard on Y axis */
  115775. static get BILLBOARDMODE_Y(): number;
  115776. /** Billboard on Z axis */
  115777. static get BILLBOARDMODE_Z(): number;
  115778. /** Billboard on all axes */
  115779. static get BILLBOARDMODE_ALL(): number;
  115780. /** Billboard on using position instead of orientation */
  115781. static get BILLBOARDMODE_USE_POSITION(): number;
  115782. /** @hidden */
  115783. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115784. /**
  115785. * The culling strategy to use to check whether the mesh must be rendered or not.
  115786. * This value can be changed at any time and will be used on the next render mesh selection.
  115787. * The possible values are :
  115788. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115789. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115791. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115792. * Please read each static variable documentation to get details about the culling process.
  115793. * */
  115794. cullingStrategy: number;
  115795. /**
  115796. * Gets the number of facets in the mesh
  115797. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115798. */
  115799. get facetNb(): number;
  115800. /**
  115801. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  115802. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115803. */
  115804. get partitioningSubdivisions(): number;
  115805. set partitioningSubdivisions(nb: number);
  115806. /**
  115807. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  115808. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  115809. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115810. */
  115811. get partitioningBBoxRatio(): number;
  115812. set partitioningBBoxRatio(ratio: number);
  115813. /**
  115814. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  115815. * Works only for updatable meshes.
  115816. * Doesn't work with multi-materials
  115817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115818. */
  115819. get mustDepthSortFacets(): boolean;
  115820. set mustDepthSortFacets(sort: boolean);
  115821. /**
  115822. * The location (Vector3) where the facet depth sort must be computed from.
  115823. * By default, the active camera position.
  115824. * Used only when facet depth sort is enabled
  115825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115826. */
  115827. get facetDepthSortFrom(): Vector3;
  115828. set facetDepthSortFrom(location: Vector3);
  115829. /**
  115830. * gets a boolean indicating if facetData is enabled
  115831. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115832. */
  115833. get isFacetDataEnabled(): boolean;
  115834. /** @hidden */
  115835. _updateNonUniformScalingState(value: boolean): boolean;
  115836. /**
  115837. * An event triggered when this mesh collides with another one
  115838. */
  115839. onCollideObservable: Observable<AbstractMesh>;
  115840. /** Set a function to call when this mesh collides with another one */
  115841. set onCollide(callback: () => void);
  115842. /**
  115843. * An event triggered when the collision's position changes
  115844. */
  115845. onCollisionPositionChangeObservable: Observable<Vector3>;
  115846. /** Set a function to call when the collision's position changes */
  115847. set onCollisionPositionChange(callback: () => void);
  115848. /**
  115849. * An event triggered when material is changed
  115850. */
  115851. onMaterialChangedObservable: Observable<AbstractMesh>;
  115852. /**
  115853. * Gets or sets the orientation for POV movement & rotation
  115854. */
  115855. definedFacingForward: boolean;
  115856. /** @hidden */
  115857. _occlusionQuery: Nullable<WebGLQuery>;
  115858. /** @hidden */
  115859. _renderingGroup: Nullable<RenderingGroup>;
  115860. /**
  115861. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115862. */
  115863. get visibility(): number;
  115864. /**
  115865. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115866. */
  115867. set visibility(value: number);
  115868. /** Gets or sets the alpha index used to sort transparent meshes
  115869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  115870. */
  115871. alphaIndex: number;
  115872. /**
  115873. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  115874. */
  115875. isVisible: boolean;
  115876. /**
  115877. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  115878. */
  115879. isPickable: boolean;
  115880. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  115881. showSubMeshesBoundingBox: boolean;
  115882. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  115883. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115884. */
  115885. isBlocker: boolean;
  115886. /**
  115887. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  115888. */
  115889. enablePointerMoveEvents: boolean;
  115890. private _renderingGroupId;
  115891. /**
  115892. * Specifies the rendering group id for this mesh (0 by default)
  115893. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  115894. */
  115895. get renderingGroupId(): number;
  115896. set renderingGroupId(value: number);
  115897. private _material;
  115898. /** Gets or sets current material */
  115899. get material(): Nullable<Material>;
  115900. set material(value: Nullable<Material>);
  115901. /**
  115902. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  115903. * @see https://doc.babylonjs.com/babylon101/shadows
  115904. */
  115905. get receiveShadows(): boolean;
  115906. set receiveShadows(value: boolean);
  115907. /** Defines color to use when rendering outline */
  115908. outlineColor: Color3;
  115909. /** Define width to use when rendering outline */
  115910. outlineWidth: number;
  115911. /** Defines color to use when rendering overlay */
  115912. overlayColor: Color3;
  115913. /** Defines alpha to use when rendering overlay */
  115914. overlayAlpha: number;
  115915. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  115916. get hasVertexAlpha(): boolean;
  115917. set hasVertexAlpha(value: boolean);
  115918. /** 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) */
  115919. get useVertexColors(): boolean;
  115920. set useVertexColors(value: boolean);
  115921. /**
  115922. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  115923. */
  115924. get computeBonesUsingShaders(): boolean;
  115925. set computeBonesUsingShaders(value: boolean);
  115926. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  115927. get numBoneInfluencers(): number;
  115928. set numBoneInfluencers(value: number);
  115929. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  115930. get applyFog(): boolean;
  115931. set applyFog(value: boolean);
  115932. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  115933. useOctreeForRenderingSelection: boolean;
  115934. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  115935. useOctreeForPicking: boolean;
  115936. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  115937. useOctreeForCollisions: boolean;
  115938. /**
  115939. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  115940. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  115941. */
  115942. get layerMask(): number;
  115943. set layerMask(value: number);
  115944. /**
  115945. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  115946. */
  115947. alwaysSelectAsActiveMesh: boolean;
  115948. /**
  115949. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  115950. */
  115951. doNotSyncBoundingInfo: boolean;
  115952. /**
  115953. * Gets or sets the current action manager
  115954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  115955. */
  115956. actionManager: Nullable<AbstractActionManager>;
  115957. private _meshCollisionData;
  115958. /**
  115959. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  115960. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115961. */
  115962. ellipsoid: Vector3;
  115963. /**
  115964. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  115965. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115966. */
  115967. ellipsoidOffset: Vector3;
  115968. /**
  115969. * Gets or sets a collision mask used to mask collisions (default is -1).
  115970. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115971. */
  115972. get collisionMask(): number;
  115973. set collisionMask(mask: number);
  115974. /**
  115975. * Gets or sets a collision response flag (default is true).
  115976. * when collisionResponse is false, events are still triggered but colliding entity has no response
  115977. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  115978. * to respond to the collision.
  115979. */
  115980. get collisionResponse(): boolean;
  115981. set collisionResponse(response: boolean);
  115982. /**
  115983. * Gets or sets the current collision group mask (-1 by default).
  115984. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  115985. */
  115986. get collisionGroup(): number;
  115987. set collisionGroup(mask: number);
  115988. /**
  115989. * Gets or sets current surrounding meshes (null by default).
  115990. *
  115991. * By default collision detection is tested against every mesh in the scene.
  115992. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  115993. * meshes will be tested for the collision.
  115994. *
  115995. * Note: if set to an empty array no collision will happen when this mesh is moved.
  115996. */
  115997. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  115998. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  115999. /**
  116000. * Defines edge width used when edgesRenderer is enabled
  116001. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116002. */
  116003. edgesWidth: number;
  116004. /**
  116005. * Defines edge color used when edgesRenderer is enabled
  116006. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116007. */
  116008. edgesColor: Color4;
  116009. /** @hidden */
  116010. _edgesRenderer: Nullable<IEdgesRenderer>;
  116011. /** @hidden */
  116012. _masterMesh: Nullable<AbstractMesh>;
  116013. /** @hidden */
  116014. _boundingInfo: Nullable<BoundingInfo>;
  116015. /** @hidden */
  116016. _renderId: number;
  116017. /**
  116018. * Gets or sets the list of subMeshes
  116019. * @see https://doc.babylonjs.com/how_to/multi_materials
  116020. */
  116021. subMeshes: SubMesh[];
  116022. /** @hidden */
  116023. _intersectionsInProgress: AbstractMesh[];
  116024. /** @hidden */
  116025. _unIndexed: boolean;
  116026. /** @hidden */
  116027. _lightSources: Light[];
  116028. /** Gets the list of lights affecting that mesh */
  116029. get lightSources(): Light[];
  116030. /** @hidden */
  116031. get _positions(): Nullable<Vector3[]>;
  116032. /** @hidden */
  116033. _waitingData: {
  116034. lods: Nullable<any>;
  116035. actions: Nullable<any>;
  116036. freezeWorldMatrix: Nullable<boolean>;
  116037. };
  116038. /** @hidden */
  116039. _bonesTransformMatrices: Nullable<Float32Array>;
  116040. /** @hidden */
  116041. _transformMatrixTexture: Nullable<RawTexture>;
  116042. /**
  116043. * Gets or sets a skeleton to apply skining transformations
  116044. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116045. */
  116046. set skeleton(value: Nullable<Skeleton>);
  116047. get skeleton(): Nullable<Skeleton>;
  116048. /**
  116049. * An event triggered when the mesh is rebuilt.
  116050. */
  116051. onRebuildObservable: Observable<AbstractMesh>;
  116052. /**
  116053. * Creates a new AbstractMesh
  116054. * @param name defines the name of the mesh
  116055. * @param scene defines the hosting scene
  116056. */
  116057. constructor(name: string, scene?: Nullable<Scene>);
  116058. /**
  116059. * Returns the string "AbstractMesh"
  116060. * @returns "AbstractMesh"
  116061. */
  116062. getClassName(): string;
  116063. /**
  116064. * Gets a string representation of the current mesh
  116065. * @param fullDetails defines a boolean indicating if full details must be included
  116066. * @returns a string representation of the current mesh
  116067. */
  116068. toString(fullDetails?: boolean): string;
  116069. /**
  116070. * @hidden
  116071. */
  116072. protected _getEffectiveParent(): Nullable<Node>;
  116073. /** @hidden */
  116074. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116075. /** @hidden */
  116076. _rebuild(): void;
  116077. /** @hidden */
  116078. _resyncLightSources(): void;
  116079. /** @hidden */
  116080. _resyncLightSource(light: Light): void;
  116081. /** @hidden */
  116082. _unBindEffect(): void;
  116083. /** @hidden */
  116084. _removeLightSource(light: Light, dispose: boolean): void;
  116085. private _markSubMeshesAsDirty;
  116086. /** @hidden */
  116087. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116088. /** @hidden */
  116089. _markSubMeshesAsAttributesDirty(): void;
  116090. /** @hidden */
  116091. _markSubMeshesAsMiscDirty(): void;
  116092. /**
  116093. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116094. */
  116095. get scaling(): Vector3;
  116096. set scaling(newScaling: Vector3);
  116097. /**
  116098. * Returns true if the mesh is blocked. Implemented by child classes
  116099. */
  116100. get isBlocked(): boolean;
  116101. /**
  116102. * Returns the mesh itself by default. Implemented by child classes
  116103. * @param camera defines the camera to use to pick the right LOD level
  116104. * @returns the currentAbstractMesh
  116105. */
  116106. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116107. /**
  116108. * Returns 0 by default. Implemented by child classes
  116109. * @returns an integer
  116110. */
  116111. getTotalVertices(): number;
  116112. /**
  116113. * Returns a positive integer : the total number of indices in this mesh geometry.
  116114. * @returns the numner of indices or zero if the mesh has no geometry.
  116115. */
  116116. getTotalIndices(): number;
  116117. /**
  116118. * Returns null by default. Implemented by child classes
  116119. * @returns null
  116120. */
  116121. getIndices(): Nullable<IndicesArray>;
  116122. /**
  116123. * Returns the array of the requested vertex data kind. Implemented by child classes
  116124. * @param kind defines the vertex data kind to use
  116125. * @returns null
  116126. */
  116127. getVerticesData(kind: string): Nullable<FloatArray>;
  116128. /**
  116129. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116130. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116131. * Note that a new underlying VertexBuffer object is created each call.
  116132. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116133. * @param kind defines vertex data kind:
  116134. * * VertexBuffer.PositionKind
  116135. * * VertexBuffer.UVKind
  116136. * * VertexBuffer.UV2Kind
  116137. * * VertexBuffer.UV3Kind
  116138. * * VertexBuffer.UV4Kind
  116139. * * VertexBuffer.UV5Kind
  116140. * * VertexBuffer.UV6Kind
  116141. * * VertexBuffer.ColorKind
  116142. * * VertexBuffer.MatricesIndicesKind
  116143. * * VertexBuffer.MatricesIndicesExtraKind
  116144. * * VertexBuffer.MatricesWeightsKind
  116145. * * VertexBuffer.MatricesWeightsExtraKind
  116146. * @param data defines the data source
  116147. * @param updatable defines if the data must be flagged as updatable (or static)
  116148. * @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
  116149. * @returns the current mesh
  116150. */
  116151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116152. /**
  116153. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116154. * If the mesh has no geometry, it is simply returned as it is.
  116155. * @param kind defines vertex data kind:
  116156. * * VertexBuffer.PositionKind
  116157. * * VertexBuffer.UVKind
  116158. * * VertexBuffer.UV2Kind
  116159. * * VertexBuffer.UV3Kind
  116160. * * VertexBuffer.UV4Kind
  116161. * * VertexBuffer.UV5Kind
  116162. * * VertexBuffer.UV6Kind
  116163. * * VertexBuffer.ColorKind
  116164. * * VertexBuffer.MatricesIndicesKind
  116165. * * VertexBuffer.MatricesIndicesExtraKind
  116166. * * VertexBuffer.MatricesWeightsKind
  116167. * * VertexBuffer.MatricesWeightsExtraKind
  116168. * @param data defines the data source
  116169. * @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
  116170. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116171. * @returns the current mesh
  116172. */
  116173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116174. /**
  116175. * Sets the mesh indices,
  116176. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116177. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116178. * @param totalVertices Defines the total number of vertices
  116179. * @returns the current mesh
  116180. */
  116181. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116182. /**
  116183. * Gets a boolean indicating if specific vertex data is present
  116184. * @param kind defines the vertex data kind to use
  116185. * @returns true is data kind is present
  116186. */
  116187. isVerticesDataPresent(kind: string): boolean;
  116188. /**
  116189. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116190. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116191. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116192. * @returns a BoundingInfo
  116193. */
  116194. getBoundingInfo(): BoundingInfo;
  116195. /**
  116196. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116197. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116198. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116199. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116200. * @returns the current mesh
  116201. */
  116202. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116203. /**
  116204. * Overwrite the current bounding info
  116205. * @param boundingInfo defines the new bounding info
  116206. * @returns the current mesh
  116207. */
  116208. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116209. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116210. get useBones(): boolean;
  116211. /** @hidden */
  116212. _preActivate(): void;
  116213. /** @hidden */
  116214. _preActivateForIntermediateRendering(renderId: number): void;
  116215. /** @hidden */
  116216. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116217. /** @hidden */
  116218. _postActivate(): void;
  116219. /** @hidden */
  116220. _freeze(): void;
  116221. /** @hidden */
  116222. _unFreeze(): void;
  116223. /**
  116224. * Gets the current world matrix
  116225. * @returns a Matrix
  116226. */
  116227. getWorldMatrix(): Matrix;
  116228. /** @hidden */
  116229. _getWorldMatrixDeterminant(): number;
  116230. /**
  116231. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116232. */
  116233. get isAnInstance(): boolean;
  116234. /**
  116235. * Gets a boolean indicating if this mesh has instances
  116236. */
  116237. get hasInstances(): boolean;
  116238. /**
  116239. * Gets a boolean indicating if this mesh has thin instances
  116240. */
  116241. get hasThinInstances(): boolean;
  116242. /**
  116243. * Perform relative position change from the point of view of behind the front of the mesh.
  116244. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116245. * Supports definition of mesh facing forward or backward
  116246. * @param amountRight defines the distance on the right axis
  116247. * @param amountUp defines the distance on the up axis
  116248. * @param amountForward defines the distance on the forward axis
  116249. * @returns the current mesh
  116250. */
  116251. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116252. /**
  116253. * Calculate relative position change from the point of view of behind the front of the mesh.
  116254. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116255. * Supports definition of mesh facing forward or backward
  116256. * @param amountRight defines the distance on the right axis
  116257. * @param amountUp defines the distance on the up axis
  116258. * @param amountForward defines the distance on the forward axis
  116259. * @returns the new displacement vector
  116260. */
  116261. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116262. /**
  116263. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116264. * Supports definition of mesh facing forward or backward
  116265. * @param flipBack defines the flip
  116266. * @param twirlClockwise defines the twirl
  116267. * @param tiltRight defines the tilt
  116268. * @returns the current mesh
  116269. */
  116270. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116271. /**
  116272. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116273. * Supports definition of mesh facing forward or backward.
  116274. * @param flipBack defines the flip
  116275. * @param twirlClockwise defines the twirl
  116276. * @param tiltRight defines the tilt
  116277. * @returns the new rotation vector
  116278. */
  116279. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116280. /**
  116281. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116282. * This means the mesh underlying bounding box and sphere are recomputed.
  116283. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116284. * @returns the current mesh
  116285. */
  116286. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116287. /** @hidden */
  116288. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116289. /** @hidden */
  116290. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116291. /** @hidden */
  116292. _updateBoundingInfo(): AbstractMesh;
  116293. /** @hidden */
  116294. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116295. /** @hidden */
  116296. protected _afterComputeWorldMatrix(): void;
  116297. /** @hidden */
  116298. get _effectiveMesh(): AbstractMesh;
  116299. /**
  116300. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116301. * A mesh is in the frustum if its bounding box intersects the frustum
  116302. * @param frustumPlanes defines the frustum to test
  116303. * @returns true if the mesh is in the frustum planes
  116304. */
  116305. isInFrustum(frustumPlanes: Plane[]): boolean;
  116306. /**
  116307. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116308. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116309. * @param frustumPlanes defines the frustum to test
  116310. * @returns true if the mesh is completely in the frustum planes
  116311. */
  116312. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116313. /**
  116314. * True if the mesh intersects another mesh or a SolidParticle object
  116315. * @param mesh defines a target mesh or SolidParticle to test
  116316. * @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)
  116317. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116318. * @returns true if there is an intersection
  116319. */
  116320. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116321. /**
  116322. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116323. * @param point defines the point to test
  116324. * @returns true if there is an intersection
  116325. */
  116326. intersectsPoint(point: Vector3): boolean;
  116327. /**
  116328. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116329. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116330. */
  116331. get checkCollisions(): boolean;
  116332. set checkCollisions(collisionEnabled: boolean);
  116333. /**
  116334. * Gets Collider object used to compute collisions (not physics)
  116335. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116336. */
  116337. get collider(): Nullable<Collider>;
  116338. /**
  116339. * Move the mesh using collision engine
  116340. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116341. * @param displacement defines the requested displacement vector
  116342. * @returns the current mesh
  116343. */
  116344. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116345. private _onCollisionPositionChange;
  116346. /** @hidden */
  116347. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116348. /** @hidden */
  116349. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116350. /** @hidden */
  116351. _checkCollision(collider: Collider): AbstractMesh;
  116352. /** @hidden */
  116353. _generatePointsArray(): boolean;
  116354. /**
  116355. * Checks if the passed Ray intersects with the mesh
  116356. * @param ray defines the ray to use
  116357. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116359. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116360. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116361. * @returns the picking info
  116362. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116363. */
  116364. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116365. /**
  116366. * Clones the current mesh
  116367. * @param name defines the mesh name
  116368. * @param newParent defines the new mesh parent
  116369. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116370. * @returns the new mesh
  116371. */
  116372. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116373. /**
  116374. * Disposes all the submeshes of the current meshnp
  116375. * @returns the current mesh
  116376. */
  116377. releaseSubMeshes(): AbstractMesh;
  116378. /**
  116379. * Releases resources associated with this abstract mesh.
  116380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116382. */
  116383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116384. /**
  116385. * Adds the passed mesh as a child to the current mesh
  116386. * @param mesh defines the child mesh
  116387. * @returns the current mesh
  116388. */
  116389. addChild(mesh: AbstractMesh): AbstractMesh;
  116390. /**
  116391. * Removes the passed mesh from the current mesh children list
  116392. * @param mesh defines the child mesh
  116393. * @returns the current mesh
  116394. */
  116395. removeChild(mesh: AbstractMesh): AbstractMesh;
  116396. /** @hidden */
  116397. private _initFacetData;
  116398. /**
  116399. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116400. * This method can be called within the render loop.
  116401. * 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
  116402. * @returns the current mesh
  116403. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116404. */
  116405. updateFacetData(): AbstractMesh;
  116406. /**
  116407. * Returns the facetLocalNormals array.
  116408. * The normals are expressed in the mesh local spac
  116409. * @returns an array of Vector3
  116410. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116411. */
  116412. getFacetLocalNormals(): Vector3[];
  116413. /**
  116414. * Returns the facetLocalPositions array.
  116415. * The facet positions are expressed in the mesh local space
  116416. * @returns an array of Vector3
  116417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116418. */
  116419. getFacetLocalPositions(): Vector3[];
  116420. /**
  116421. * Returns the facetLocalPartioning array
  116422. * @returns an array of array of numbers
  116423. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116424. */
  116425. getFacetLocalPartitioning(): number[][];
  116426. /**
  116427. * Returns the i-th facet position in the world system.
  116428. * This method allocates a new Vector3 per call
  116429. * @param i defines the facet index
  116430. * @returns a new Vector3
  116431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116432. */
  116433. getFacetPosition(i: number): Vector3;
  116434. /**
  116435. * Sets the reference Vector3 with the i-th facet position in the world system
  116436. * @param i defines the facet index
  116437. * @param ref defines the target vector
  116438. * @returns the current mesh
  116439. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116440. */
  116441. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116442. /**
  116443. * Returns the i-th facet normal in the world system.
  116444. * This method allocates a new Vector3 per call
  116445. * @param i defines the facet index
  116446. * @returns a new Vector3
  116447. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116448. */
  116449. getFacetNormal(i: number): Vector3;
  116450. /**
  116451. * Sets the reference Vector3 with the i-th facet normal in the world system
  116452. * @param i defines the facet index
  116453. * @param ref defines the target vector
  116454. * @returns the current mesh
  116455. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116456. */
  116457. getFacetNormalToRef(i: number, ref: Vector3): this;
  116458. /**
  116459. * 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)
  116460. * @param x defines x coordinate
  116461. * @param y defines y coordinate
  116462. * @param z defines z coordinate
  116463. * @returns the array of facet indexes
  116464. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116465. */
  116466. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116467. /**
  116468. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116469. * @param projected sets as the (x,y,z) world projection on the facet
  116470. * @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
  116471. * @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
  116472. * @param x defines x coordinate
  116473. * @param y defines y coordinate
  116474. * @param z defines z coordinate
  116475. * @returns the face index if found (or null instead)
  116476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116477. */
  116478. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116479. /**
  116480. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116481. * @param projected sets as the (x,y,z) local projection on the facet
  116482. * @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
  116483. * @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
  116484. * @param x defines x coordinate
  116485. * @param y defines y coordinate
  116486. * @param z defines z coordinate
  116487. * @returns the face index if found (or null instead)
  116488. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116489. */
  116490. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116491. /**
  116492. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116493. * @returns the parameters
  116494. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116495. */
  116496. getFacetDataParameters(): any;
  116497. /**
  116498. * Disables the feature FacetData and frees the related memory
  116499. * @returns the current mesh
  116500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116501. */
  116502. disableFacetData(): AbstractMesh;
  116503. /**
  116504. * Updates the AbstractMesh indices array
  116505. * @param indices defines the data source
  116506. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116507. * @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)
  116508. * @returns the current mesh
  116509. */
  116510. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116511. /**
  116512. * Creates new normals data for the mesh
  116513. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116514. * @returns the current mesh
  116515. */
  116516. createNormals(updatable: boolean): AbstractMesh;
  116517. /**
  116518. * Align the mesh with a normal
  116519. * @param normal defines the normal to use
  116520. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116521. * @returns the current mesh
  116522. */
  116523. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116524. /** @hidden */
  116525. _checkOcclusionQuery(): boolean;
  116526. /**
  116527. * Disables the mesh edge rendering mode
  116528. * @returns the currentAbstractMesh
  116529. */
  116530. disableEdgesRendering(): AbstractMesh;
  116531. /**
  116532. * Enables the edge rendering mode on the mesh.
  116533. * This mode makes the mesh edges visible
  116534. * @param epsilon defines the maximal distance between two angles to detect a face
  116535. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116536. * @returns the currentAbstractMesh
  116537. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116538. */
  116539. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116540. /**
  116541. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116542. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116543. */
  116544. getConnectedParticleSystems(): IParticleSystem[];
  116545. }
  116546. }
  116547. declare module BABYLON {
  116548. /**
  116549. * Interface used to define ActionEvent
  116550. */
  116551. export interface IActionEvent {
  116552. /** The mesh or sprite that triggered the action */
  116553. source: any;
  116554. /** The X mouse cursor position at the time of the event */
  116555. pointerX: number;
  116556. /** The Y mouse cursor position at the time of the event */
  116557. pointerY: number;
  116558. /** The mesh that is currently pointed at (can be null) */
  116559. meshUnderPointer: Nullable<AbstractMesh>;
  116560. /** the original (browser) event that triggered the ActionEvent */
  116561. sourceEvent?: any;
  116562. /** additional data for the event */
  116563. additionalData?: any;
  116564. }
  116565. /**
  116566. * ActionEvent is the event being sent when an action is triggered.
  116567. */
  116568. export class ActionEvent implements IActionEvent {
  116569. /** The mesh or sprite that triggered the action */
  116570. source: any;
  116571. /** The X mouse cursor position at the time of the event */
  116572. pointerX: number;
  116573. /** The Y mouse cursor position at the time of the event */
  116574. pointerY: number;
  116575. /** The mesh that is currently pointed at (can be null) */
  116576. meshUnderPointer: Nullable<AbstractMesh>;
  116577. /** the original (browser) event that triggered the ActionEvent */
  116578. sourceEvent?: any;
  116579. /** additional data for the event */
  116580. additionalData?: any;
  116581. /**
  116582. * Creates a new ActionEvent
  116583. * @param source The mesh or sprite that triggered the action
  116584. * @param pointerX The X mouse cursor position at the time of the event
  116585. * @param pointerY The Y mouse cursor position at the time of the event
  116586. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116587. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116588. * @param additionalData additional data for the event
  116589. */
  116590. constructor(
  116591. /** The mesh or sprite that triggered the action */
  116592. source: any,
  116593. /** The X mouse cursor position at the time of the event */
  116594. pointerX: number,
  116595. /** The Y mouse cursor position at the time of the event */
  116596. pointerY: number,
  116597. /** The mesh that is currently pointed at (can be null) */
  116598. meshUnderPointer: Nullable<AbstractMesh>,
  116599. /** the original (browser) event that triggered the ActionEvent */
  116600. sourceEvent?: any,
  116601. /** additional data for the event */
  116602. additionalData?: any);
  116603. /**
  116604. * Helper function to auto-create an ActionEvent from a source mesh.
  116605. * @param source The source mesh that triggered the event
  116606. * @param evt The original (browser) event
  116607. * @param additionalData additional data for the event
  116608. * @returns the new ActionEvent
  116609. */
  116610. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116611. /**
  116612. * Helper function to auto-create an ActionEvent from a source sprite
  116613. * @param source The source sprite that triggered the event
  116614. * @param scene Scene associated with the sprite
  116615. * @param evt The original (browser) event
  116616. * @param additionalData additional data for the event
  116617. * @returns the new ActionEvent
  116618. */
  116619. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116620. /**
  116621. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116622. * @param scene the scene where the event occurred
  116623. * @param evt The original (browser) event
  116624. * @returns the new ActionEvent
  116625. */
  116626. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116627. /**
  116628. * Helper function to auto-create an ActionEvent from a primitive
  116629. * @param prim defines the target primitive
  116630. * @param pointerPos defines the pointer position
  116631. * @param evt The original (browser) event
  116632. * @param additionalData additional data for the event
  116633. * @returns the new ActionEvent
  116634. */
  116635. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116636. }
  116637. }
  116638. declare module BABYLON {
  116639. /**
  116640. * Abstract class used to decouple action Manager from scene and meshes.
  116641. * Do not instantiate.
  116642. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116643. */
  116644. export abstract class AbstractActionManager implements IDisposable {
  116645. /** Gets the list of active triggers */
  116646. static Triggers: {
  116647. [key: string]: number;
  116648. };
  116649. /** Gets the cursor to use when hovering items */
  116650. hoverCursor: string;
  116651. /** Gets the list of actions */
  116652. actions: IAction[];
  116653. /**
  116654. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116655. */
  116656. isRecursive: boolean;
  116657. /**
  116658. * Releases all associated resources
  116659. */
  116660. abstract dispose(): void;
  116661. /**
  116662. * Does this action manager has pointer triggers
  116663. */
  116664. abstract get hasPointerTriggers(): boolean;
  116665. /**
  116666. * Does this action manager has pick triggers
  116667. */
  116668. abstract get hasPickTriggers(): boolean;
  116669. /**
  116670. * Process a specific trigger
  116671. * @param trigger defines the trigger to process
  116672. * @param evt defines the event details to be processed
  116673. */
  116674. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116675. /**
  116676. * Does this action manager handles actions of any of the given triggers
  116677. * @param triggers defines the triggers to be tested
  116678. * @return a boolean indicating whether one (or more) of the triggers is handled
  116679. */
  116680. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116681. /**
  116682. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116683. * speed.
  116684. * @param triggerA defines the trigger to be tested
  116685. * @param triggerB defines the trigger to be tested
  116686. * @return a boolean indicating whether one (or more) of the triggers is handled
  116687. */
  116688. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116689. /**
  116690. * Does this action manager handles actions of a given trigger
  116691. * @param trigger defines the trigger to be tested
  116692. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116693. * @return whether the trigger is handled
  116694. */
  116695. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116696. /**
  116697. * Serialize this manager to a JSON object
  116698. * @param name defines the property name to store this manager
  116699. * @returns a JSON representation of this manager
  116700. */
  116701. abstract serialize(name: string): any;
  116702. /**
  116703. * Registers an action to this action manager
  116704. * @param action defines the action to be registered
  116705. * @return the action amended (prepared) after registration
  116706. */
  116707. abstract registerAction(action: IAction): Nullable<IAction>;
  116708. /**
  116709. * Unregisters an action to this action manager
  116710. * @param action defines the action to be unregistered
  116711. * @return a boolean indicating whether the action has been unregistered
  116712. */
  116713. abstract unregisterAction(action: IAction): Boolean;
  116714. /**
  116715. * Does exist one action manager with at least one trigger
  116716. **/
  116717. static get HasTriggers(): boolean;
  116718. /**
  116719. * Does exist one action manager with at least one pick trigger
  116720. **/
  116721. static get HasPickTriggers(): boolean;
  116722. /**
  116723. * Does exist one action manager that handles actions of a given trigger
  116724. * @param trigger defines the trigger to be tested
  116725. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116726. **/
  116727. static HasSpecificTrigger(trigger: number): boolean;
  116728. }
  116729. }
  116730. declare module BABYLON {
  116731. /**
  116732. * Defines how a node can be built from a string name.
  116733. */
  116734. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116735. /**
  116736. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116737. */
  116738. export class Node implements IBehaviorAware<Node> {
  116739. /** @hidden */
  116740. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116741. private static _NodeConstructors;
  116742. /**
  116743. * Add a new node constructor
  116744. * @param type defines the type name of the node to construct
  116745. * @param constructorFunc defines the constructor function
  116746. */
  116747. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116748. /**
  116749. * Returns a node constructor based on type name
  116750. * @param type defines the type name
  116751. * @param name defines the new node name
  116752. * @param scene defines the hosting scene
  116753. * @param options defines optional options to transmit to constructors
  116754. * @returns the new constructor or null
  116755. */
  116756. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116757. /**
  116758. * Gets or sets the name of the node
  116759. */
  116760. name: string;
  116761. /**
  116762. * Gets or sets the id of the node
  116763. */
  116764. id: string;
  116765. /**
  116766. * Gets or sets the unique id of the node
  116767. */
  116768. uniqueId: number;
  116769. /**
  116770. * Gets or sets a string used to store user defined state for the node
  116771. */
  116772. state: string;
  116773. /**
  116774. * Gets or sets an object used to store user defined information for the node
  116775. */
  116776. metadata: any;
  116777. /**
  116778. * For internal use only. Please do not use.
  116779. */
  116780. reservedDataStore: any;
  116781. /**
  116782. * List of inspectable custom properties (used by the Inspector)
  116783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116784. */
  116785. inspectableCustomProperties: IInspectable[];
  116786. private _doNotSerialize;
  116787. /**
  116788. * Gets or sets a boolean used to define if the node must be serialized
  116789. */
  116790. get doNotSerialize(): boolean;
  116791. set doNotSerialize(value: boolean);
  116792. /** @hidden */
  116793. _isDisposed: boolean;
  116794. /**
  116795. * Gets a list of Animations associated with the node
  116796. */
  116797. animations: Animation[];
  116798. protected _ranges: {
  116799. [name: string]: Nullable<AnimationRange>;
  116800. };
  116801. /**
  116802. * Callback raised when the node is ready to be used
  116803. */
  116804. onReady: Nullable<(node: Node) => void>;
  116805. private _isEnabled;
  116806. private _isParentEnabled;
  116807. private _isReady;
  116808. /** @hidden */
  116809. _currentRenderId: number;
  116810. private _parentUpdateId;
  116811. /** @hidden */
  116812. _childUpdateId: number;
  116813. /** @hidden */
  116814. _waitingParentId: Nullable<string>;
  116815. /** @hidden */
  116816. _scene: Scene;
  116817. /** @hidden */
  116818. _cache: any;
  116819. private _parentNode;
  116820. private _children;
  116821. /** @hidden */
  116822. _worldMatrix: Matrix;
  116823. /** @hidden */
  116824. _worldMatrixDeterminant: number;
  116825. /** @hidden */
  116826. _worldMatrixDeterminantIsDirty: boolean;
  116827. /** @hidden */
  116828. private _sceneRootNodesIndex;
  116829. /**
  116830. * Gets a boolean indicating if the node has been disposed
  116831. * @returns true if the node was disposed
  116832. */
  116833. isDisposed(): boolean;
  116834. /**
  116835. * Gets or sets the parent of the node (without keeping the current position in the scene)
  116836. * @see https://doc.babylonjs.com/how_to/parenting
  116837. */
  116838. set parent(parent: Nullable<Node>);
  116839. get parent(): Nullable<Node>;
  116840. /** @hidden */
  116841. _addToSceneRootNodes(): void;
  116842. /** @hidden */
  116843. _removeFromSceneRootNodes(): void;
  116844. private _animationPropertiesOverride;
  116845. /**
  116846. * Gets or sets the animation properties override
  116847. */
  116848. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116849. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116850. /**
  116851. * Gets a string identifying the name of the class
  116852. * @returns "Node" string
  116853. */
  116854. getClassName(): string;
  116855. /** @hidden */
  116856. readonly _isNode: boolean;
  116857. /**
  116858. * An event triggered when the mesh is disposed
  116859. */
  116860. onDisposeObservable: Observable<Node>;
  116861. private _onDisposeObserver;
  116862. /**
  116863. * Sets a callback that will be raised when the node will be disposed
  116864. */
  116865. set onDispose(callback: () => void);
  116866. /**
  116867. * Creates a new Node
  116868. * @param name the name and id to be given to this node
  116869. * @param scene the scene this node will be added to
  116870. */
  116871. constructor(name: string, scene?: Nullable<Scene>);
  116872. /**
  116873. * Gets the scene of the node
  116874. * @returns a scene
  116875. */
  116876. getScene(): Scene;
  116877. /**
  116878. * Gets the engine of the node
  116879. * @returns a Engine
  116880. */
  116881. getEngine(): Engine;
  116882. private _behaviors;
  116883. /**
  116884. * Attach a behavior to the node
  116885. * @see https://doc.babylonjs.com/features/behaviour
  116886. * @param behavior defines the behavior to attach
  116887. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  116888. * @returns the current Node
  116889. */
  116890. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  116891. /**
  116892. * Remove an attached behavior
  116893. * @see https://doc.babylonjs.com/features/behaviour
  116894. * @param behavior defines the behavior to attach
  116895. * @returns the current Node
  116896. */
  116897. removeBehavior(behavior: Behavior<Node>): Node;
  116898. /**
  116899. * Gets the list of attached behaviors
  116900. * @see https://doc.babylonjs.com/features/behaviour
  116901. */
  116902. get behaviors(): Behavior<Node>[];
  116903. /**
  116904. * Gets an attached behavior by name
  116905. * @param name defines the name of the behavior to look for
  116906. * @see https://doc.babylonjs.com/features/behaviour
  116907. * @returns null if behavior was not found else the requested behavior
  116908. */
  116909. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  116910. /**
  116911. * Returns the latest update of the World matrix
  116912. * @returns a Matrix
  116913. */
  116914. getWorldMatrix(): Matrix;
  116915. /** @hidden */
  116916. _getWorldMatrixDeterminant(): number;
  116917. /**
  116918. * Returns directly the latest state of the mesh World matrix.
  116919. * A Matrix is returned.
  116920. */
  116921. get worldMatrixFromCache(): Matrix;
  116922. /** @hidden */
  116923. _initCache(): void;
  116924. /** @hidden */
  116925. updateCache(force?: boolean): void;
  116926. /** @hidden */
  116927. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116928. /** @hidden */
  116929. _updateCache(ignoreParentClass?: boolean): void;
  116930. /** @hidden */
  116931. _isSynchronized(): boolean;
  116932. /** @hidden */
  116933. _markSyncedWithParent(): void;
  116934. /** @hidden */
  116935. isSynchronizedWithParent(): boolean;
  116936. /** @hidden */
  116937. isSynchronized(): boolean;
  116938. /**
  116939. * Is this node ready to be used/rendered
  116940. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  116941. * @return true if the node is ready
  116942. */
  116943. isReady(completeCheck?: boolean): boolean;
  116944. /**
  116945. * Is this node enabled?
  116946. * 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
  116947. * @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
  116948. * @return whether this node (and its parent) is enabled
  116949. */
  116950. isEnabled(checkAncestors?: boolean): boolean;
  116951. /** @hidden */
  116952. protected _syncParentEnabledState(): void;
  116953. /**
  116954. * Set the enabled state of this node
  116955. * @param value defines the new enabled state
  116956. */
  116957. setEnabled(value: boolean): void;
  116958. /**
  116959. * Is this node a descendant of the given node?
  116960. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  116961. * @param ancestor defines the parent node to inspect
  116962. * @returns a boolean indicating if this node is a descendant of the given node
  116963. */
  116964. isDescendantOf(ancestor: Node): boolean;
  116965. /** @hidden */
  116966. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  116967. /**
  116968. * Will return all nodes that have this node as ascendant
  116969. * @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
  116970. * @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
  116971. * @return all children nodes of all types
  116972. */
  116973. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  116974. /**
  116975. * Get all child-meshes of this node
  116976. * @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)
  116977. * @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
  116978. * @returns an array of AbstractMesh
  116979. */
  116980. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  116981. /**
  116982. * Get all direct children of this node
  116983. * @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
  116984. * @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)
  116985. * @returns an array of Node
  116986. */
  116987. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  116988. /** @hidden */
  116989. _setReady(state: boolean): void;
  116990. /**
  116991. * Get an animation by name
  116992. * @param name defines the name of the animation to look for
  116993. * @returns null if not found else the requested animation
  116994. */
  116995. getAnimationByName(name: string): Nullable<Animation>;
  116996. /**
  116997. * Creates an animation range for this node
  116998. * @param name defines the name of the range
  116999. * @param from defines the starting key
  117000. * @param to defines the end key
  117001. */
  117002. createAnimationRange(name: string, from: number, to: number): void;
  117003. /**
  117004. * Delete a specific animation range
  117005. * @param name defines the name of the range to delete
  117006. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117007. */
  117008. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117009. /**
  117010. * Get an animation range by name
  117011. * @param name defines the name of the animation range to look for
  117012. * @returns null if not found else the requested animation range
  117013. */
  117014. getAnimationRange(name: string): Nullable<AnimationRange>;
  117015. /**
  117016. * Gets the list of all animation ranges defined on this node
  117017. * @returns an array
  117018. */
  117019. getAnimationRanges(): Nullable<AnimationRange>[];
  117020. /**
  117021. * Will start the animation sequence
  117022. * @param name defines the range frames for animation sequence
  117023. * @param loop defines if the animation should loop (false by default)
  117024. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117025. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117026. * @returns the object created for this animation. If range does not exist, it will return null
  117027. */
  117028. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117029. /**
  117030. * Serialize animation ranges into a JSON compatible object
  117031. * @returns serialization object
  117032. */
  117033. serializeAnimationRanges(): any;
  117034. /**
  117035. * Computes the world matrix of the node
  117036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117037. * @returns the world matrix
  117038. */
  117039. computeWorldMatrix(force?: boolean): Matrix;
  117040. /**
  117041. * Releases resources associated with this node.
  117042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117044. */
  117045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117046. /**
  117047. * Parse animation range data from a serialization object and store them into a given node
  117048. * @param node defines where to store the animation ranges
  117049. * @param parsedNode defines the serialization object to read data from
  117050. * @param scene defines the hosting scene
  117051. */
  117052. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117053. /**
  117054. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117055. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117056. * @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
  117057. * @returns the new bounding vectors
  117058. */
  117059. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117060. min: Vector3;
  117061. max: Vector3;
  117062. };
  117063. }
  117064. }
  117065. declare module BABYLON {
  117066. /**
  117067. * @hidden
  117068. */
  117069. export class _IAnimationState {
  117070. key: number;
  117071. repeatCount: number;
  117072. workValue?: any;
  117073. loopMode?: number;
  117074. offsetValue?: any;
  117075. highLimitValue?: any;
  117076. }
  117077. /**
  117078. * Class used to store any kind of animation
  117079. */
  117080. export class Animation {
  117081. /**Name of the animation */
  117082. name: string;
  117083. /**Property to animate */
  117084. targetProperty: string;
  117085. /**The frames per second of the animation */
  117086. framePerSecond: number;
  117087. /**The data type of the animation */
  117088. dataType: number;
  117089. /**The loop mode of the animation */
  117090. loopMode?: number | undefined;
  117091. /**Specifies if blending should be enabled */
  117092. enableBlending?: boolean | undefined;
  117093. /**
  117094. * Use matrix interpolation instead of using direct key value when animating matrices
  117095. */
  117096. static AllowMatricesInterpolation: boolean;
  117097. /**
  117098. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117099. */
  117100. static AllowMatrixDecomposeForInterpolation: boolean;
  117101. /** Define the Url to load snippets */
  117102. static SnippetUrl: string;
  117103. /** Snippet ID if the animation was created from the snippet server */
  117104. snippetId: string;
  117105. /**
  117106. * Stores the key frames of the animation
  117107. */
  117108. private _keys;
  117109. /**
  117110. * Stores the easing function of the animation
  117111. */
  117112. private _easingFunction;
  117113. /**
  117114. * @hidden Internal use only
  117115. */
  117116. _runtimeAnimations: RuntimeAnimation[];
  117117. /**
  117118. * The set of event that will be linked to this animation
  117119. */
  117120. private _events;
  117121. /**
  117122. * Stores an array of target property paths
  117123. */
  117124. targetPropertyPath: string[];
  117125. /**
  117126. * Stores the blending speed of the animation
  117127. */
  117128. blendingSpeed: number;
  117129. /**
  117130. * Stores the animation ranges for the animation
  117131. */
  117132. private _ranges;
  117133. /**
  117134. * @hidden Internal use
  117135. */
  117136. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117137. /**
  117138. * Sets up an animation
  117139. * @param property The property to animate
  117140. * @param animationType The animation type to apply
  117141. * @param framePerSecond The frames per second of the animation
  117142. * @param easingFunction The easing function used in the animation
  117143. * @returns The created animation
  117144. */
  117145. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117146. /**
  117147. * Create and start an animation on a node
  117148. * @param name defines the name of the global animation that will be run on all nodes
  117149. * @param node defines the root node where the animation will take place
  117150. * @param targetProperty defines property to animate
  117151. * @param framePerSecond defines the number of frame per second yo use
  117152. * @param totalFrame defines the number of frames in total
  117153. * @param from defines the initial value
  117154. * @param to defines the final value
  117155. * @param loopMode defines which loop mode you want to use (off by default)
  117156. * @param easingFunction defines the easing function to use (linear by default)
  117157. * @param onAnimationEnd defines the callback to call when animation end
  117158. * @returns the animatable created for this animation
  117159. */
  117160. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117161. /**
  117162. * Create and start an animation on a node and its descendants
  117163. * @param name defines the name of the global animation that will be run on all nodes
  117164. * @param node defines the root node where the animation will take place
  117165. * @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
  117166. * @param targetProperty defines property to animate
  117167. * @param framePerSecond defines the number of frame per second to use
  117168. * @param totalFrame defines the number of frames in total
  117169. * @param from defines the initial value
  117170. * @param to defines the final value
  117171. * @param loopMode defines which loop mode you want to use (off by default)
  117172. * @param easingFunction defines the easing function to use (linear by default)
  117173. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117174. * @returns the list of animatables created for all nodes
  117175. * @example https://www.babylonjs-playground.com/#MH0VLI
  117176. */
  117177. 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[]>;
  117178. /**
  117179. * Creates a new animation, merges it with the existing animations and starts it
  117180. * @param name Name of the animation
  117181. * @param node Node which contains the scene that begins the animations
  117182. * @param targetProperty Specifies which property to animate
  117183. * @param framePerSecond The frames per second of the animation
  117184. * @param totalFrame The total number of frames
  117185. * @param from The frame at the beginning of the animation
  117186. * @param to The frame at the end of the animation
  117187. * @param loopMode Specifies the loop mode of the animation
  117188. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117189. * @param onAnimationEnd Callback to run once the animation is complete
  117190. * @returns Nullable animation
  117191. */
  117192. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117193. /**
  117194. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117195. * @param sourceAnimation defines the Animation containing keyframes to convert
  117196. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117197. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117198. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117199. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117200. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117201. */
  117202. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117203. /**
  117204. * Transition property of an host to the target Value
  117205. * @param property The property to transition
  117206. * @param targetValue The target Value of the property
  117207. * @param host The object where the property to animate belongs
  117208. * @param scene Scene used to run the animation
  117209. * @param frameRate Framerate (in frame/s) to use
  117210. * @param transition The transition type we want to use
  117211. * @param duration The duration of the animation, in milliseconds
  117212. * @param onAnimationEnd Callback trigger at the end of the animation
  117213. * @returns Nullable animation
  117214. */
  117215. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117216. /**
  117217. * Return the array of runtime animations currently using this animation
  117218. */
  117219. get runtimeAnimations(): RuntimeAnimation[];
  117220. /**
  117221. * Specifies if any of the runtime animations are currently running
  117222. */
  117223. get hasRunningRuntimeAnimations(): boolean;
  117224. /**
  117225. * Initializes the animation
  117226. * @param name Name of the animation
  117227. * @param targetProperty Property to animate
  117228. * @param framePerSecond The frames per second of the animation
  117229. * @param dataType The data type of the animation
  117230. * @param loopMode The loop mode of the animation
  117231. * @param enableBlending Specifies if blending should be enabled
  117232. */
  117233. constructor(
  117234. /**Name of the animation */
  117235. name: string,
  117236. /**Property to animate */
  117237. targetProperty: string,
  117238. /**The frames per second of the animation */
  117239. framePerSecond: number,
  117240. /**The data type of the animation */
  117241. dataType: number,
  117242. /**The loop mode of the animation */
  117243. loopMode?: number | undefined,
  117244. /**Specifies if blending should be enabled */
  117245. enableBlending?: boolean | undefined);
  117246. /**
  117247. * Converts the animation to a string
  117248. * @param fullDetails support for multiple levels of logging within scene loading
  117249. * @returns String form of the animation
  117250. */
  117251. toString(fullDetails?: boolean): string;
  117252. /**
  117253. * Add an event to this animation
  117254. * @param event Event to add
  117255. */
  117256. addEvent(event: AnimationEvent): void;
  117257. /**
  117258. * Remove all events found at the given frame
  117259. * @param frame The frame to remove events from
  117260. */
  117261. removeEvents(frame: number): void;
  117262. /**
  117263. * Retrieves all the events from the animation
  117264. * @returns Events from the animation
  117265. */
  117266. getEvents(): AnimationEvent[];
  117267. /**
  117268. * Creates an animation range
  117269. * @param name Name of the animation range
  117270. * @param from Starting frame of the animation range
  117271. * @param to Ending frame of the animation
  117272. */
  117273. createRange(name: string, from: number, to: number): void;
  117274. /**
  117275. * Deletes an animation range by name
  117276. * @param name Name of the animation range to delete
  117277. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117278. */
  117279. deleteRange(name: string, deleteFrames?: boolean): void;
  117280. /**
  117281. * Gets the animation range by name, or null if not defined
  117282. * @param name Name of the animation range
  117283. * @returns Nullable animation range
  117284. */
  117285. getRange(name: string): Nullable<AnimationRange>;
  117286. /**
  117287. * Gets the key frames from the animation
  117288. * @returns The key frames of the animation
  117289. */
  117290. getKeys(): Array<IAnimationKey>;
  117291. /**
  117292. * Gets the highest frame rate of the animation
  117293. * @returns Highest frame rate of the animation
  117294. */
  117295. getHighestFrame(): number;
  117296. /**
  117297. * Gets the easing function of the animation
  117298. * @returns Easing function of the animation
  117299. */
  117300. getEasingFunction(): IEasingFunction;
  117301. /**
  117302. * Sets the easing function of the animation
  117303. * @param easingFunction A custom mathematical formula for animation
  117304. */
  117305. setEasingFunction(easingFunction: EasingFunction): void;
  117306. /**
  117307. * Interpolates a scalar linearly
  117308. * @param startValue Start value of the animation curve
  117309. * @param endValue End value of the animation curve
  117310. * @param gradient Scalar amount to interpolate
  117311. * @returns Interpolated scalar value
  117312. */
  117313. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117314. /**
  117315. * Interpolates a scalar cubically
  117316. * @param startValue Start value of the animation curve
  117317. * @param outTangent End tangent of the animation
  117318. * @param endValue End value of the animation curve
  117319. * @param inTangent Start tangent of the animation curve
  117320. * @param gradient Scalar amount to interpolate
  117321. * @returns Interpolated scalar value
  117322. */
  117323. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117324. /**
  117325. * Interpolates a quaternion using a spherical linear interpolation
  117326. * @param startValue Start value of the animation curve
  117327. * @param endValue End value of the animation curve
  117328. * @param gradient Scalar amount to interpolate
  117329. * @returns Interpolated quaternion value
  117330. */
  117331. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117332. /**
  117333. * Interpolates a quaternion cubically
  117334. * @param startValue Start value of the animation curve
  117335. * @param outTangent End tangent of the animation curve
  117336. * @param endValue End value of the animation curve
  117337. * @param inTangent Start tangent of the animation curve
  117338. * @param gradient Scalar amount to interpolate
  117339. * @returns Interpolated quaternion value
  117340. */
  117341. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117342. /**
  117343. * Interpolates a Vector3 linearl
  117344. * @param startValue Start value of the animation curve
  117345. * @param endValue End value of the animation curve
  117346. * @param gradient Scalar amount to interpolate
  117347. * @returns Interpolated scalar value
  117348. */
  117349. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117350. /**
  117351. * Interpolates a Vector3 cubically
  117352. * @param startValue Start value of the animation curve
  117353. * @param outTangent End tangent of the animation
  117354. * @param endValue End value of the animation curve
  117355. * @param inTangent Start tangent of the animation curve
  117356. * @param gradient Scalar amount to interpolate
  117357. * @returns InterpolatedVector3 value
  117358. */
  117359. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117360. /**
  117361. * Interpolates a Vector2 linearly
  117362. * @param startValue Start value of the animation curve
  117363. * @param endValue End value of the animation curve
  117364. * @param gradient Scalar amount to interpolate
  117365. * @returns Interpolated Vector2 value
  117366. */
  117367. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117368. /**
  117369. * Interpolates a Vector2 cubically
  117370. * @param startValue Start value of the animation curve
  117371. * @param outTangent End tangent of the animation
  117372. * @param endValue End value of the animation curve
  117373. * @param inTangent Start tangent of the animation curve
  117374. * @param gradient Scalar amount to interpolate
  117375. * @returns Interpolated Vector2 value
  117376. */
  117377. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117378. /**
  117379. * Interpolates a size linearly
  117380. * @param startValue Start value of the animation curve
  117381. * @param endValue End value of the animation curve
  117382. * @param gradient Scalar amount to interpolate
  117383. * @returns Interpolated Size value
  117384. */
  117385. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117386. /**
  117387. * Interpolates a Color3 linearly
  117388. * @param startValue Start value of the animation curve
  117389. * @param endValue End value of the animation curve
  117390. * @param gradient Scalar amount to interpolate
  117391. * @returns Interpolated Color3 value
  117392. */
  117393. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117394. /**
  117395. * Interpolates a Color4 linearly
  117396. * @param startValue Start value of the animation curve
  117397. * @param endValue End value of the animation curve
  117398. * @param gradient Scalar amount to interpolate
  117399. * @returns Interpolated Color3 value
  117400. */
  117401. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117402. /**
  117403. * @hidden Internal use only
  117404. */
  117405. _getKeyValue(value: any): any;
  117406. /**
  117407. * @hidden Internal use only
  117408. */
  117409. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117410. /**
  117411. * Defines the function to use to interpolate matrices
  117412. * @param startValue defines the start matrix
  117413. * @param endValue defines the end matrix
  117414. * @param gradient defines the gradient between both matrices
  117415. * @param result defines an optional target matrix where to store the interpolation
  117416. * @returns the interpolated matrix
  117417. */
  117418. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117419. /**
  117420. * Makes a copy of the animation
  117421. * @returns Cloned animation
  117422. */
  117423. clone(): Animation;
  117424. /**
  117425. * Sets the key frames of the animation
  117426. * @param values The animation key frames to set
  117427. */
  117428. setKeys(values: Array<IAnimationKey>): void;
  117429. /**
  117430. * Serializes the animation to an object
  117431. * @returns Serialized object
  117432. */
  117433. serialize(): any;
  117434. /**
  117435. * Float animation type
  117436. */
  117437. static readonly ANIMATIONTYPE_FLOAT: number;
  117438. /**
  117439. * Vector3 animation type
  117440. */
  117441. static readonly ANIMATIONTYPE_VECTOR3: number;
  117442. /**
  117443. * Quaternion animation type
  117444. */
  117445. static readonly ANIMATIONTYPE_QUATERNION: number;
  117446. /**
  117447. * Matrix animation type
  117448. */
  117449. static readonly ANIMATIONTYPE_MATRIX: number;
  117450. /**
  117451. * Color3 animation type
  117452. */
  117453. static readonly ANIMATIONTYPE_COLOR3: number;
  117454. /**
  117455. * Color3 animation type
  117456. */
  117457. static readonly ANIMATIONTYPE_COLOR4: number;
  117458. /**
  117459. * Vector2 animation type
  117460. */
  117461. static readonly ANIMATIONTYPE_VECTOR2: number;
  117462. /**
  117463. * Size animation type
  117464. */
  117465. static readonly ANIMATIONTYPE_SIZE: number;
  117466. /**
  117467. * Relative Loop Mode
  117468. */
  117469. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117470. /**
  117471. * Cycle Loop Mode
  117472. */
  117473. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117474. /**
  117475. * Constant Loop Mode
  117476. */
  117477. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117478. /** @hidden */
  117479. static _UniversalLerp(left: any, right: any, amount: number): any;
  117480. /**
  117481. * Parses an animation object and creates an animation
  117482. * @param parsedAnimation Parsed animation object
  117483. * @returns Animation object
  117484. */
  117485. static Parse(parsedAnimation: any): Animation;
  117486. /**
  117487. * Appends the serialized animations from the source animations
  117488. * @param source Source containing the animations
  117489. * @param destination Target to store the animations
  117490. */
  117491. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117492. /**
  117493. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117494. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117495. * @param url defines the url to load from
  117496. * @returns a promise that will resolve to the new animation or an array of animations
  117497. */
  117498. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117499. /**
  117500. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117501. * @param snippetId defines the snippet to load
  117502. * @returns a promise that will resolve to the new animation or a new array of animations
  117503. */
  117504. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117505. }
  117506. }
  117507. declare module BABYLON {
  117508. /**
  117509. * Interface containing an array of animations
  117510. */
  117511. export interface IAnimatable {
  117512. /**
  117513. * Array of animations
  117514. */
  117515. animations: Nullable<Array<Animation>>;
  117516. }
  117517. }
  117518. declare module BABYLON {
  117519. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117520. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117521. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117522. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117523. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117524. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117525. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117526. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117527. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117528. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117529. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117530. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117531. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117532. /**
  117533. * Decorator used to define property that can be serialized as reference to a camera
  117534. * @param sourceName defines the name of the property to decorate
  117535. */
  117536. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117537. /**
  117538. * Class used to help serialization objects
  117539. */
  117540. export class SerializationHelper {
  117541. /** @hidden */
  117542. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117543. /** @hidden */
  117544. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117545. /** @hidden */
  117546. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117547. /** @hidden */
  117548. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117549. /**
  117550. * Appends the serialized animations from the source animations
  117551. * @param source Source containing the animations
  117552. * @param destination Target to store the animations
  117553. */
  117554. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117555. /**
  117556. * Static function used to serialized a specific entity
  117557. * @param entity defines the entity to serialize
  117558. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117559. * @returns a JSON compatible object representing the serialization of the entity
  117560. */
  117561. static Serialize<T>(entity: T, serializationObject?: any): any;
  117562. /**
  117563. * Creates a new entity from a serialization data object
  117564. * @param creationFunction defines a function used to instanciated the new entity
  117565. * @param source defines the source serialization data
  117566. * @param scene defines the hosting scene
  117567. * @param rootUrl defines the root url for resources
  117568. * @returns a new entity
  117569. */
  117570. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117571. /**
  117572. * Clones an object
  117573. * @param creationFunction defines the function used to instanciate the new object
  117574. * @param source defines the source object
  117575. * @returns the cloned object
  117576. */
  117577. static Clone<T>(creationFunction: () => T, source: T): T;
  117578. /**
  117579. * Instanciates a new object based on a source one (some data will be shared between both object)
  117580. * @param creationFunction defines the function used to instanciate the new object
  117581. * @param source defines the source object
  117582. * @returns the new object
  117583. */
  117584. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117585. }
  117586. }
  117587. declare module BABYLON {
  117588. /**
  117589. * Base class of all the textures in babylon.
  117590. * It groups all the common properties the materials, post process, lights... might need
  117591. * in order to make a correct use of the texture.
  117592. */
  117593. export class BaseTexture implements IAnimatable {
  117594. /**
  117595. * Default anisotropic filtering level for the application.
  117596. * It is set to 4 as a good tradeoff between perf and quality.
  117597. */
  117598. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117599. /**
  117600. * Gets or sets the unique id of the texture
  117601. */
  117602. uniqueId: number;
  117603. /**
  117604. * Define the name of the texture.
  117605. */
  117606. name: string;
  117607. /**
  117608. * Gets or sets an object used to store user defined information.
  117609. */
  117610. metadata: any;
  117611. /**
  117612. * For internal use only. Please do not use.
  117613. */
  117614. reservedDataStore: any;
  117615. private _hasAlpha;
  117616. /**
  117617. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117618. */
  117619. set hasAlpha(value: boolean);
  117620. get hasAlpha(): boolean;
  117621. /**
  117622. * Defines if the alpha value should be determined via the rgb values.
  117623. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117624. */
  117625. getAlphaFromRGB: boolean;
  117626. /**
  117627. * Intensity or strength of the texture.
  117628. * It is commonly used by materials to fine tune the intensity of the texture
  117629. */
  117630. level: number;
  117631. /**
  117632. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117633. * This is part of the texture as textures usually maps to one uv set.
  117634. */
  117635. coordinatesIndex: number;
  117636. protected _coordinatesMode: number;
  117637. /**
  117638. * How a texture is mapped.
  117639. *
  117640. * | Value | Type | Description |
  117641. * | ----- | ----------------------------------- | ----------- |
  117642. * | 0 | EXPLICIT_MODE | |
  117643. * | 1 | SPHERICAL_MODE | |
  117644. * | 2 | PLANAR_MODE | |
  117645. * | 3 | CUBIC_MODE | |
  117646. * | 4 | PROJECTION_MODE | |
  117647. * | 5 | SKYBOX_MODE | |
  117648. * | 6 | INVCUBIC_MODE | |
  117649. * | 7 | EQUIRECTANGULAR_MODE | |
  117650. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117651. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117652. */
  117653. set coordinatesMode(value: number);
  117654. get coordinatesMode(): number;
  117655. private _wrapU;
  117656. /**
  117657. * | Value | Type | Description |
  117658. * | ----- | ------------------ | ----------- |
  117659. * | 0 | CLAMP_ADDRESSMODE | |
  117660. * | 1 | WRAP_ADDRESSMODE | |
  117661. * | 2 | MIRROR_ADDRESSMODE | |
  117662. */
  117663. get wrapU(): number;
  117664. set wrapU(value: number);
  117665. private _wrapV;
  117666. /**
  117667. * | Value | Type | Description |
  117668. * | ----- | ------------------ | ----------- |
  117669. * | 0 | CLAMP_ADDRESSMODE | |
  117670. * | 1 | WRAP_ADDRESSMODE | |
  117671. * | 2 | MIRROR_ADDRESSMODE | |
  117672. */
  117673. get wrapV(): number;
  117674. set wrapV(value: number);
  117675. /**
  117676. * | Value | Type | Description |
  117677. * | ----- | ------------------ | ----------- |
  117678. * | 0 | CLAMP_ADDRESSMODE | |
  117679. * | 1 | WRAP_ADDRESSMODE | |
  117680. * | 2 | MIRROR_ADDRESSMODE | |
  117681. */
  117682. wrapR: number;
  117683. /**
  117684. * With compliant hardware and browser (supporting anisotropic filtering)
  117685. * this defines the level of anisotropic filtering in the texture.
  117686. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117687. */
  117688. anisotropicFilteringLevel: number;
  117689. /**
  117690. * Define if the texture is a cube texture or if false a 2d texture.
  117691. */
  117692. get isCube(): boolean;
  117693. set isCube(value: boolean);
  117694. /**
  117695. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117696. */
  117697. get is3D(): boolean;
  117698. set is3D(value: boolean);
  117699. /**
  117700. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117701. */
  117702. get is2DArray(): boolean;
  117703. set is2DArray(value: boolean);
  117704. private _gammaSpace;
  117705. /**
  117706. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117707. * HDR texture are usually stored in linear space.
  117708. * This only impacts the PBR and Background materials
  117709. */
  117710. get gammaSpace(): boolean;
  117711. set gammaSpace(gamma: boolean);
  117712. /**
  117713. * Gets or sets whether or not the texture contains RGBD data.
  117714. */
  117715. get isRGBD(): boolean;
  117716. set isRGBD(value: boolean);
  117717. /**
  117718. * Is Z inverted in the texture (useful in a cube texture).
  117719. */
  117720. invertZ: boolean;
  117721. /**
  117722. * Are mip maps generated for this texture or not.
  117723. */
  117724. get noMipmap(): boolean;
  117725. /**
  117726. * @hidden
  117727. */
  117728. lodLevelInAlpha: boolean;
  117729. /**
  117730. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117731. */
  117732. get lodGenerationOffset(): number;
  117733. set lodGenerationOffset(value: number);
  117734. /**
  117735. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117736. */
  117737. get lodGenerationScale(): number;
  117738. set lodGenerationScale(value: number);
  117739. /**
  117740. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117741. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117742. * average roughness values.
  117743. */
  117744. get linearSpecularLOD(): boolean;
  117745. set linearSpecularLOD(value: boolean);
  117746. /**
  117747. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117748. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117749. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117750. */
  117751. get irradianceTexture(): Nullable<BaseTexture>;
  117752. set irradianceTexture(value: Nullable<BaseTexture>);
  117753. /**
  117754. * Define if the texture is a render target.
  117755. */
  117756. isRenderTarget: boolean;
  117757. /**
  117758. * Define the unique id of the texture in the scene.
  117759. */
  117760. get uid(): string;
  117761. /** @hidden */
  117762. _prefiltered: boolean;
  117763. /**
  117764. * Return a string representation of the texture.
  117765. * @returns the texture as a string
  117766. */
  117767. toString(): string;
  117768. /**
  117769. * Get the class name of the texture.
  117770. * @returns "BaseTexture"
  117771. */
  117772. getClassName(): string;
  117773. /**
  117774. * Define the list of animation attached to the texture.
  117775. */
  117776. animations: Animation[];
  117777. /**
  117778. * An event triggered when the texture is disposed.
  117779. */
  117780. onDisposeObservable: Observable<BaseTexture>;
  117781. private _onDisposeObserver;
  117782. /**
  117783. * Callback triggered when the texture has been disposed.
  117784. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117785. */
  117786. set onDispose(callback: () => void);
  117787. /**
  117788. * Define the current state of the loading sequence when in delayed load mode.
  117789. */
  117790. delayLoadState: number;
  117791. protected _scene: Nullable<Scene>;
  117792. protected _engine: Nullable<ThinEngine>;
  117793. /** @hidden */
  117794. _texture: Nullable<InternalTexture>;
  117795. private _uid;
  117796. /**
  117797. * Define if the texture is preventinga material to render or not.
  117798. * If not and the texture is not ready, the engine will use a default black texture instead.
  117799. */
  117800. get isBlocking(): boolean;
  117801. /**
  117802. * Instantiates a new BaseTexture.
  117803. * Base class of all the textures in babylon.
  117804. * It groups all the common properties the materials, post process, lights... might need
  117805. * in order to make a correct use of the texture.
  117806. * @param sceneOrEngine Define the scene or engine the texture blongs to
  117807. */
  117808. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  117809. /**
  117810. * Get the scene the texture belongs to.
  117811. * @returns the scene or null if undefined
  117812. */
  117813. getScene(): Nullable<Scene>;
  117814. /** @hidden */
  117815. protected _getEngine(): Nullable<ThinEngine>;
  117816. /**
  117817. * Get the texture transform matrix used to offset tile the texture for istance.
  117818. * @returns the transformation matrix
  117819. */
  117820. getTextureMatrix(): Matrix;
  117821. /**
  117822. * Get the texture reflection matrix used to rotate/transform the reflection.
  117823. * @returns the reflection matrix
  117824. */
  117825. getReflectionTextureMatrix(): Matrix;
  117826. /**
  117827. * Get the underlying lower level texture from Babylon.
  117828. * @returns the insternal texture
  117829. */
  117830. getInternalTexture(): Nullable<InternalTexture>;
  117831. /**
  117832. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  117833. * @returns true if ready or not blocking
  117834. */
  117835. isReadyOrNotBlocking(): boolean;
  117836. /**
  117837. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  117838. * @returns true if fully ready
  117839. */
  117840. isReady(): boolean;
  117841. private _cachedSize;
  117842. /**
  117843. * Get the size of the texture.
  117844. * @returns the texture size.
  117845. */
  117846. getSize(): ISize;
  117847. /**
  117848. * Get the base size of the texture.
  117849. * It can be different from the size if the texture has been resized for POT for instance
  117850. * @returns the base size
  117851. */
  117852. getBaseSize(): ISize;
  117853. /**
  117854. * Update the sampling mode of the texture.
  117855. * Default is Trilinear mode.
  117856. *
  117857. * | Value | Type | Description |
  117858. * | ----- | ------------------ | ----------- |
  117859. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  117860. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  117861. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  117862. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  117863. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  117864. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  117865. * | 7 | NEAREST_LINEAR | |
  117866. * | 8 | NEAREST_NEAREST | |
  117867. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  117868. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  117869. * | 11 | LINEAR_LINEAR | |
  117870. * | 12 | LINEAR_NEAREST | |
  117871. *
  117872. * > _mag_: magnification filter (close to the viewer)
  117873. * > _min_: minification filter (far from the viewer)
  117874. * > _mip_: filter used between mip map levels
  117875. *@param samplingMode Define the new sampling mode of the texture
  117876. */
  117877. updateSamplingMode(samplingMode: number): void;
  117878. /**
  117879. * Scales the texture if is `canRescale()`
  117880. * @param ratio the resize factor we want to use to rescale
  117881. */
  117882. scale(ratio: number): void;
  117883. /**
  117884. * Get if the texture can rescale.
  117885. */
  117886. get canRescale(): boolean;
  117887. /** @hidden */
  117888. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  117889. /** @hidden */
  117890. _rebuild(): void;
  117891. /**
  117892. * Triggers the load sequence in delayed load mode.
  117893. */
  117894. delayLoad(): void;
  117895. /**
  117896. * Clones the texture.
  117897. * @returns the cloned texture
  117898. */
  117899. clone(): Nullable<BaseTexture>;
  117900. /**
  117901. * Get the texture underlying type (INT, FLOAT...)
  117902. */
  117903. get textureType(): number;
  117904. /**
  117905. * Get the texture underlying format (RGB, RGBA...)
  117906. */
  117907. get textureFormat(): number;
  117908. /**
  117909. * Indicates that textures need to be re-calculated for all materials
  117910. */
  117911. protected _markAllSubMeshesAsTexturesDirty(): void;
  117912. /**
  117913. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  117914. * This will returns an RGBA array buffer containing either in values (0-255) or
  117915. * float values (0-1) depending of the underlying buffer type.
  117916. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  117917. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  117918. * @param buffer defines a user defined buffer to fill with data (can be null)
  117919. * @returns The Array buffer containing the pixels data.
  117920. */
  117921. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  117922. /**
  117923. * Release and destroy the underlying lower level texture aka internalTexture.
  117924. */
  117925. releaseInternalTexture(): void;
  117926. /** @hidden */
  117927. get _lodTextureHigh(): Nullable<BaseTexture>;
  117928. /** @hidden */
  117929. get _lodTextureMid(): Nullable<BaseTexture>;
  117930. /** @hidden */
  117931. get _lodTextureLow(): Nullable<BaseTexture>;
  117932. /**
  117933. * Dispose the texture and release its associated resources.
  117934. */
  117935. dispose(): void;
  117936. /**
  117937. * Serialize the texture into a JSON representation that can be parsed later on.
  117938. * @returns the JSON representation of the texture
  117939. */
  117940. serialize(): any;
  117941. /**
  117942. * Helper function to be called back once a list of texture contains only ready textures.
  117943. * @param textures Define the list of textures to wait for
  117944. * @param callback Define the callback triggered once the entire list will be ready
  117945. */
  117946. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  117947. private static _isScene;
  117948. }
  117949. }
  117950. declare module BABYLON {
  117951. /**
  117952. * Options to be used when creating an effect.
  117953. */
  117954. export interface IEffectCreationOptions {
  117955. /**
  117956. * Atrributes that will be used in the shader.
  117957. */
  117958. attributes: string[];
  117959. /**
  117960. * Uniform varible names that will be set in the shader.
  117961. */
  117962. uniformsNames: string[];
  117963. /**
  117964. * Uniform buffer variable names that will be set in the shader.
  117965. */
  117966. uniformBuffersNames: string[];
  117967. /**
  117968. * Sampler texture variable names that will be set in the shader.
  117969. */
  117970. samplers: string[];
  117971. /**
  117972. * Define statements that will be set in the shader.
  117973. */
  117974. defines: any;
  117975. /**
  117976. * Possible fallbacks for this effect to improve performance when needed.
  117977. */
  117978. fallbacks: Nullable<IEffectFallbacks>;
  117979. /**
  117980. * Callback that will be called when the shader is compiled.
  117981. */
  117982. onCompiled: Nullable<(effect: Effect) => void>;
  117983. /**
  117984. * Callback that will be called if an error occurs during shader compilation.
  117985. */
  117986. onError: Nullable<(effect: Effect, errors: string) => void>;
  117987. /**
  117988. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  117989. */
  117990. indexParameters?: any;
  117991. /**
  117992. * Max number of lights that can be used in the shader.
  117993. */
  117994. maxSimultaneousLights?: number;
  117995. /**
  117996. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  117997. */
  117998. transformFeedbackVaryings?: Nullable<string[]>;
  117999. /**
  118000. * 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
  118001. */
  118002. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118003. /**
  118004. * Is this effect rendering to several color attachments ?
  118005. */
  118006. multiTarget?: boolean;
  118007. }
  118008. /**
  118009. * Effect containing vertex and fragment shader that can be executed on an object.
  118010. */
  118011. export class Effect implements IDisposable {
  118012. /**
  118013. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118014. */
  118015. static ShadersRepository: string;
  118016. /**
  118017. * Enable logging of the shader code when a compilation error occurs
  118018. */
  118019. static LogShaderCodeOnCompilationError: boolean;
  118020. /**
  118021. * Name of the effect.
  118022. */
  118023. name: any;
  118024. /**
  118025. * String container all the define statements that should be set on the shader.
  118026. */
  118027. defines: string;
  118028. /**
  118029. * Callback that will be called when the shader is compiled.
  118030. */
  118031. onCompiled: Nullable<(effect: Effect) => void>;
  118032. /**
  118033. * Callback that will be called if an error occurs during shader compilation.
  118034. */
  118035. onError: Nullable<(effect: Effect, errors: string) => void>;
  118036. /**
  118037. * Callback that will be called when effect is bound.
  118038. */
  118039. onBind: Nullable<(effect: Effect) => void>;
  118040. /**
  118041. * Unique ID of the effect.
  118042. */
  118043. uniqueId: number;
  118044. /**
  118045. * Observable that will be called when the shader is compiled.
  118046. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118047. */
  118048. onCompileObservable: Observable<Effect>;
  118049. /**
  118050. * Observable that will be called if an error occurs during shader compilation.
  118051. */
  118052. onErrorObservable: Observable<Effect>;
  118053. /** @hidden */
  118054. _onBindObservable: Nullable<Observable<Effect>>;
  118055. /**
  118056. * @hidden
  118057. * Specifies if the effect was previously ready
  118058. */
  118059. _wasPreviouslyReady: boolean;
  118060. /**
  118061. * Observable that will be called when effect is bound.
  118062. */
  118063. get onBindObservable(): Observable<Effect>;
  118064. /** @hidden */
  118065. _bonesComputationForcedToCPU: boolean;
  118066. /** @hidden */
  118067. _multiTarget: boolean;
  118068. private static _uniqueIdSeed;
  118069. private _engine;
  118070. private _uniformBuffersNames;
  118071. private _uniformBuffersNamesList;
  118072. private _uniformsNames;
  118073. private _samplerList;
  118074. private _samplers;
  118075. private _isReady;
  118076. private _compilationError;
  118077. private _allFallbacksProcessed;
  118078. private _attributesNames;
  118079. private _attributes;
  118080. private _attributeLocationByName;
  118081. private _uniforms;
  118082. /**
  118083. * Key for the effect.
  118084. * @hidden
  118085. */
  118086. _key: string;
  118087. private _indexParameters;
  118088. private _fallbacks;
  118089. private _vertexSourceCode;
  118090. private _fragmentSourceCode;
  118091. private _vertexSourceCodeOverride;
  118092. private _fragmentSourceCodeOverride;
  118093. private _transformFeedbackVaryings;
  118094. /**
  118095. * Compiled shader to webGL program.
  118096. * @hidden
  118097. */
  118098. _pipelineContext: Nullable<IPipelineContext>;
  118099. private _valueCache;
  118100. private static _baseCache;
  118101. /**
  118102. * Instantiates an effect.
  118103. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118104. * @param baseName Name of the effect.
  118105. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118106. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118107. * @param samplers List of sampler variables that will be passed to the shader.
  118108. * @param engine Engine to be used to render the effect
  118109. * @param defines Define statements to be added to the shader.
  118110. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118111. * @param onCompiled Callback that will be called when the shader is compiled.
  118112. * @param onError Callback that will be called if an error occurs during shader compilation.
  118113. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118114. */
  118115. 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);
  118116. private _useFinalCode;
  118117. /**
  118118. * Unique key for this effect
  118119. */
  118120. get key(): string;
  118121. /**
  118122. * If the effect has been compiled and prepared.
  118123. * @returns if the effect is compiled and prepared.
  118124. */
  118125. isReady(): boolean;
  118126. private _isReadyInternal;
  118127. /**
  118128. * The engine the effect was initialized with.
  118129. * @returns the engine.
  118130. */
  118131. getEngine(): Engine;
  118132. /**
  118133. * The pipeline context for this effect
  118134. * @returns the associated pipeline context
  118135. */
  118136. getPipelineContext(): Nullable<IPipelineContext>;
  118137. /**
  118138. * The set of names of attribute variables for the shader.
  118139. * @returns An array of attribute names.
  118140. */
  118141. getAttributesNames(): string[];
  118142. /**
  118143. * Returns the attribute at the given index.
  118144. * @param index The index of the attribute.
  118145. * @returns The location of the attribute.
  118146. */
  118147. getAttributeLocation(index: number): number;
  118148. /**
  118149. * Returns the attribute based on the name of the variable.
  118150. * @param name of the attribute to look up.
  118151. * @returns the attribute location.
  118152. */
  118153. getAttributeLocationByName(name: string): number;
  118154. /**
  118155. * The number of attributes.
  118156. * @returns the numnber of attributes.
  118157. */
  118158. getAttributesCount(): number;
  118159. /**
  118160. * Gets the index of a uniform variable.
  118161. * @param uniformName of the uniform to look up.
  118162. * @returns the index.
  118163. */
  118164. getUniformIndex(uniformName: string): number;
  118165. /**
  118166. * Returns the attribute based on the name of the variable.
  118167. * @param uniformName of the uniform to look up.
  118168. * @returns the location of the uniform.
  118169. */
  118170. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118171. /**
  118172. * Returns an array of sampler variable names
  118173. * @returns The array of sampler variable names.
  118174. */
  118175. getSamplers(): string[];
  118176. /**
  118177. * Returns an array of uniform variable names
  118178. * @returns The array of uniform variable names.
  118179. */
  118180. getUniformNames(): string[];
  118181. /**
  118182. * Returns an array of uniform buffer variable names
  118183. * @returns The array of uniform buffer variable names.
  118184. */
  118185. getUniformBuffersNames(): string[];
  118186. /**
  118187. * Returns the index parameters used to create the effect
  118188. * @returns The index parameters object
  118189. */
  118190. getIndexParameters(): any;
  118191. /**
  118192. * The error from the last compilation.
  118193. * @returns the error string.
  118194. */
  118195. getCompilationError(): string;
  118196. /**
  118197. * Gets a boolean indicating that all fallbacks were used during compilation
  118198. * @returns true if all fallbacks were used
  118199. */
  118200. allFallbacksProcessed(): boolean;
  118201. /**
  118202. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118203. * @param func The callback to be used.
  118204. */
  118205. executeWhenCompiled(func: (effect: Effect) => void): void;
  118206. private _checkIsReady;
  118207. private _loadShader;
  118208. /**
  118209. * Gets the vertex shader source code of this effect
  118210. */
  118211. get vertexSourceCode(): string;
  118212. /**
  118213. * Gets the fragment shader source code of this effect
  118214. */
  118215. get fragmentSourceCode(): string;
  118216. /**
  118217. * Recompiles the webGL program
  118218. * @param vertexSourceCode The source code for the vertex shader.
  118219. * @param fragmentSourceCode The source code for the fragment shader.
  118220. * @param onCompiled Callback called when completed.
  118221. * @param onError Callback called on error.
  118222. * @hidden
  118223. */
  118224. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118225. /**
  118226. * Prepares the effect
  118227. * @hidden
  118228. */
  118229. _prepareEffect(): void;
  118230. private _getShaderCodeAndErrorLine;
  118231. private _processCompilationErrors;
  118232. /**
  118233. * Checks if the effect is supported. (Must be called after compilation)
  118234. */
  118235. get isSupported(): boolean;
  118236. /**
  118237. * Binds a texture to the engine to be used as output of the shader.
  118238. * @param channel Name of the output variable.
  118239. * @param texture Texture to bind.
  118240. * @hidden
  118241. */
  118242. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118243. /**
  118244. * Sets a texture on the engine to be used in the shader.
  118245. * @param channel Name of the sampler variable.
  118246. * @param texture Texture to set.
  118247. */
  118248. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118249. /**
  118250. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118251. * @param channel Name of the sampler variable.
  118252. * @param texture Texture to set.
  118253. */
  118254. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118255. /**
  118256. * Sets an array of textures on the engine to be used in the shader.
  118257. * @param channel Name of the variable.
  118258. * @param textures Textures to set.
  118259. */
  118260. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118261. /**
  118262. * 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)
  118263. * @param channel Name of the sampler variable.
  118264. * @param postProcess Post process to get the input texture from.
  118265. */
  118266. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118267. /**
  118268. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118269. * 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)
  118270. * @param channel Name of the sampler variable.
  118271. * @param postProcess Post process to get the output texture from.
  118272. */
  118273. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118274. /** @hidden */
  118275. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118276. /** @hidden */
  118277. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118278. /** @hidden */
  118279. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118280. /** @hidden */
  118281. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118282. /**
  118283. * Binds a buffer to a uniform.
  118284. * @param buffer Buffer to bind.
  118285. * @param name Name of the uniform variable to bind to.
  118286. */
  118287. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118288. /**
  118289. * Binds block to a uniform.
  118290. * @param blockName Name of the block to bind.
  118291. * @param index Index to bind.
  118292. */
  118293. bindUniformBlock(blockName: string, index: number): void;
  118294. /**
  118295. * Sets an interger value on a uniform variable.
  118296. * @param uniformName Name of the variable.
  118297. * @param value Value to be set.
  118298. * @returns this effect.
  118299. */
  118300. setInt(uniformName: string, value: number): Effect;
  118301. /**
  118302. * Sets an int array on a uniform variable.
  118303. * @param uniformName Name of the variable.
  118304. * @param array array to be set.
  118305. * @returns this effect.
  118306. */
  118307. setIntArray(uniformName: string, array: Int32Array): Effect;
  118308. /**
  118309. * 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)
  118310. * @param uniformName Name of the variable.
  118311. * @param array array to be set.
  118312. * @returns this effect.
  118313. */
  118314. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118315. /**
  118316. * 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)
  118317. * @param uniformName Name of the variable.
  118318. * @param array array to be set.
  118319. * @returns this effect.
  118320. */
  118321. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118322. /**
  118323. * 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)
  118324. * @param uniformName Name of the variable.
  118325. * @param array array to be set.
  118326. * @returns this effect.
  118327. */
  118328. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118329. /**
  118330. * Sets an float array on a uniform variable.
  118331. * @param uniformName Name of the variable.
  118332. * @param array array to be set.
  118333. * @returns this effect.
  118334. */
  118335. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118336. /**
  118337. * 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)
  118338. * @param uniformName Name of the variable.
  118339. * @param array array to be set.
  118340. * @returns this effect.
  118341. */
  118342. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118343. /**
  118344. * 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)
  118345. * @param uniformName Name of the variable.
  118346. * @param array array to be set.
  118347. * @returns this effect.
  118348. */
  118349. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118350. /**
  118351. * 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)
  118352. * @param uniformName Name of the variable.
  118353. * @param array array to be set.
  118354. * @returns this effect.
  118355. */
  118356. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118357. /**
  118358. * Sets an array on a uniform variable.
  118359. * @param uniformName Name of the variable.
  118360. * @param array array to be set.
  118361. * @returns this effect.
  118362. */
  118363. setArray(uniformName: string, array: number[]): Effect;
  118364. /**
  118365. * 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)
  118366. * @param uniformName Name of the variable.
  118367. * @param array array to be set.
  118368. * @returns this effect.
  118369. */
  118370. setArray2(uniformName: string, array: number[]): Effect;
  118371. /**
  118372. * 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)
  118373. * @param uniformName Name of the variable.
  118374. * @param array array to be set.
  118375. * @returns this effect.
  118376. */
  118377. setArray3(uniformName: string, array: number[]): Effect;
  118378. /**
  118379. * 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)
  118380. * @param uniformName Name of the variable.
  118381. * @param array array to be set.
  118382. * @returns this effect.
  118383. */
  118384. setArray4(uniformName: string, array: number[]): Effect;
  118385. /**
  118386. * Sets matrices on a uniform variable.
  118387. * @param uniformName Name of the variable.
  118388. * @param matrices matrices to be set.
  118389. * @returns this effect.
  118390. */
  118391. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118392. /**
  118393. * Sets matrix on a uniform variable.
  118394. * @param uniformName Name of the variable.
  118395. * @param matrix matrix to be set.
  118396. * @returns this effect.
  118397. */
  118398. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118399. /**
  118400. * 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)
  118401. * @param uniformName Name of the variable.
  118402. * @param matrix matrix to be set.
  118403. * @returns this effect.
  118404. */
  118405. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118406. /**
  118407. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118408. * @param uniformName Name of the variable.
  118409. * @param matrix matrix to be set.
  118410. * @returns this effect.
  118411. */
  118412. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118413. /**
  118414. * Sets a float on a uniform variable.
  118415. * @param uniformName Name of the variable.
  118416. * @param value value to be set.
  118417. * @returns this effect.
  118418. */
  118419. setFloat(uniformName: string, value: number): Effect;
  118420. /**
  118421. * Sets a boolean on a uniform variable.
  118422. * @param uniformName Name of the variable.
  118423. * @param bool value to be set.
  118424. * @returns this effect.
  118425. */
  118426. setBool(uniformName: string, bool: boolean): Effect;
  118427. /**
  118428. * Sets a Vector2 on a uniform variable.
  118429. * @param uniformName Name of the variable.
  118430. * @param vector2 vector2 to be set.
  118431. * @returns this effect.
  118432. */
  118433. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118434. /**
  118435. * Sets a float2 on a uniform variable.
  118436. * @param uniformName Name of the variable.
  118437. * @param x First float in float2.
  118438. * @param y Second float in float2.
  118439. * @returns this effect.
  118440. */
  118441. setFloat2(uniformName: string, x: number, y: number): Effect;
  118442. /**
  118443. * Sets a Vector3 on a uniform variable.
  118444. * @param uniformName Name of the variable.
  118445. * @param vector3 Value to be set.
  118446. * @returns this effect.
  118447. */
  118448. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118449. /**
  118450. * Sets a float3 on a uniform variable.
  118451. * @param uniformName Name of the variable.
  118452. * @param x First float in float3.
  118453. * @param y Second float in float3.
  118454. * @param z Third float in float3.
  118455. * @returns this effect.
  118456. */
  118457. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118458. /**
  118459. * Sets a Vector4 on a uniform variable.
  118460. * @param uniformName Name of the variable.
  118461. * @param vector4 Value to be set.
  118462. * @returns this effect.
  118463. */
  118464. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118465. /**
  118466. * Sets a float4 on a uniform variable.
  118467. * @param uniformName Name of the variable.
  118468. * @param x First float in float4.
  118469. * @param y Second float in float4.
  118470. * @param z Third float in float4.
  118471. * @param w Fourth float in float4.
  118472. * @returns this effect.
  118473. */
  118474. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118475. /**
  118476. * Sets a Color3 on a uniform variable.
  118477. * @param uniformName Name of the variable.
  118478. * @param color3 Value to be set.
  118479. * @returns this effect.
  118480. */
  118481. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118482. /**
  118483. * Sets a Color4 on a uniform variable.
  118484. * @param uniformName Name of the variable.
  118485. * @param color3 Value to be set.
  118486. * @param alpha Alpha value to be set.
  118487. * @returns this effect.
  118488. */
  118489. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118490. /**
  118491. * Sets a Color4 on a uniform variable
  118492. * @param uniformName defines the name of the variable
  118493. * @param color4 defines the value to be set
  118494. * @returns this effect.
  118495. */
  118496. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118497. /** Release all associated resources */
  118498. dispose(): void;
  118499. /**
  118500. * This function will add a new shader to the shader store
  118501. * @param name the name of the shader
  118502. * @param pixelShader optional pixel shader content
  118503. * @param vertexShader optional vertex shader content
  118504. */
  118505. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118506. /**
  118507. * Store of each shader (The can be looked up using effect.key)
  118508. */
  118509. static ShadersStore: {
  118510. [key: string]: string;
  118511. };
  118512. /**
  118513. * Store of each included file for a shader (The can be looked up using effect.key)
  118514. */
  118515. static IncludesShadersStore: {
  118516. [key: string]: string;
  118517. };
  118518. /**
  118519. * Resets the cache of effects.
  118520. */
  118521. static ResetCache(): void;
  118522. }
  118523. }
  118524. declare module BABYLON {
  118525. /**
  118526. * Interface used to describe the capabilities of the engine relatively to the current browser
  118527. */
  118528. export interface EngineCapabilities {
  118529. /** Maximum textures units per fragment shader */
  118530. maxTexturesImageUnits: number;
  118531. /** Maximum texture units per vertex shader */
  118532. maxVertexTextureImageUnits: number;
  118533. /** Maximum textures units in the entire pipeline */
  118534. maxCombinedTexturesImageUnits: number;
  118535. /** Maximum texture size */
  118536. maxTextureSize: number;
  118537. /** Maximum texture samples */
  118538. maxSamples?: number;
  118539. /** Maximum cube texture size */
  118540. maxCubemapTextureSize: number;
  118541. /** Maximum render texture size */
  118542. maxRenderTextureSize: number;
  118543. /** Maximum number of vertex attributes */
  118544. maxVertexAttribs: number;
  118545. /** Maximum number of varyings */
  118546. maxVaryingVectors: number;
  118547. /** Maximum number of uniforms per vertex shader */
  118548. maxVertexUniformVectors: number;
  118549. /** Maximum number of uniforms per fragment shader */
  118550. maxFragmentUniformVectors: number;
  118551. /** Defines if standard derivates (dx/dy) are supported */
  118552. standardDerivatives: boolean;
  118553. /** Defines if s3tc texture compression is supported */
  118554. s3tc?: WEBGL_compressed_texture_s3tc;
  118555. /** Defines if pvrtc texture compression is supported */
  118556. pvrtc: any;
  118557. /** Defines if etc1 texture compression is supported */
  118558. etc1: any;
  118559. /** Defines if etc2 texture compression is supported */
  118560. etc2: any;
  118561. /** Defines if astc texture compression is supported */
  118562. astc: any;
  118563. /** Defines if bptc texture compression is supported */
  118564. bptc: any;
  118565. /** Defines if float textures are supported */
  118566. textureFloat: boolean;
  118567. /** Defines if vertex array objects are supported */
  118568. vertexArrayObject: boolean;
  118569. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118570. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118571. /** Gets the maximum level of anisotropy supported */
  118572. maxAnisotropy: number;
  118573. /** Defines if instancing is supported */
  118574. instancedArrays: boolean;
  118575. /** Defines if 32 bits indices are supported */
  118576. uintIndices: boolean;
  118577. /** Defines if high precision shaders are supported */
  118578. highPrecisionShaderSupported: boolean;
  118579. /** Defines if depth reading in the fragment shader is supported */
  118580. fragmentDepthSupported: boolean;
  118581. /** Defines if float texture linear filtering is supported*/
  118582. textureFloatLinearFiltering: boolean;
  118583. /** Defines if rendering to float textures is supported */
  118584. textureFloatRender: boolean;
  118585. /** Defines if half float textures are supported*/
  118586. textureHalfFloat: boolean;
  118587. /** Defines if half float texture linear filtering is supported*/
  118588. textureHalfFloatLinearFiltering: boolean;
  118589. /** Defines if rendering to half float textures is supported */
  118590. textureHalfFloatRender: boolean;
  118591. /** Defines if textureLOD shader command is supported */
  118592. textureLOD: boolean;
  118593. /** Defines if draw buffers extension is supported */
  118594. drawBuffersExtension: boolean;
  118595. /** Defines if depth textures are supported */
  118596. depthTextureExtension: boolean;
  118597. /** Defines if float color buffer are supported */
  118598. colorBufferFloat: boolean;
  118599. /** Gets disjoint timer query extension (null if not supported) */
  118600. timerQuery?: EXT_disjoint_timer_query;
  118601. /** Defines if timestamp can be used with timer query */
  118602. canUseTimestampForTimerQuery: boolean;
  118603. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118604. multiview?: any;
  118605. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118606. oculusMultiview?: any;
  118607. /** Function used to let the system compiles shaders in background */
  118608. parallelShaderCompile?: {
  118609. COMPLETION_STATUS_KHR: number;
  118610. };
  118611. /** Max number of texture samples for MSAA */
  118612. maxMSAASamples: number;
  118613. /** Defines if the blend min max extension is supported */
  118614. blendMinMax: boolean;
  118615. }
  118616. }
  118617. declare module BABYLON {
  118618. /**
  118619. * @hidden
  118620. **/
  118621. export class DepthCullingState {
  118622. private _isDepthTestDirty;
  118623. private _isDepthMaskDirty;
  118624. private _isDepthFuncDirty;
  118625. private _isCullFaceDirty;
  118626. private _isCullDirty;
  118627. private _isZOffsetDirty;
  118628. private _isFrontFaceDirty;
  118629. private _depthTest;
  118630. private _depthMask;
  118631. private _depthFunc;
  118632. private _cull;
  118633. private _cullFace;
  118634. private _zOffset;
  118635. private _frontFace;
  118636. /**
  118637. * Initializes the state.
  118638. */
  118639. constructor();
  118640. get isDirty(): boolean;
  118641. get zOffset(): number;
  118642. set zOffset(value: number);
  118643. get cullFace(): Nullable<number>;
  118644. set cullFace(value: Nullable<number>);
  118645. get cull(): Nullable<boolean>;
  118646. set cull(value: Nullable<boolean>);
  118647. get depthFunc(): Nullable<number>;
  118648. set depthFunc(value: Nullable<number>);
  118649. get depthMask(): boolean;
  118650. set depthMask(value: boolean);
  118651. get depthTest(): boolean;
  118652. set depthTest(value: boolean);
  118653. get frontFace(): Nullable<number>;
  118654. set frontFace(value: Nullable<number>);
  118655. reset(): void;
  118656. apply(gl: WebGLRenderingContext): void;
  118657. }
  118658. }
  118659. declare module BABYLON {
  118660. /**
  118661. * @hidden
  118662. **/
  118663. export class StencilState {
  118664. /** 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 */
  118665. static readonly ALWAYS: number;
  118666. /** Passed to stencilOperation to specify that stencil value must be kept */
  118667. static readonly KEEP: number;
  118668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118669. static readonly REPLACE: number;
  118670. private _isStencilTestDirty;
  118671. private _isStencilMaskDirty;
  118672. private _isStencilFuncDirty;
  118673. private _isStencilOpDirty;
  118674. private _stencilTest;
  118675. private _stencilMask;
  118676. private _stencilFunc;
  118677. private _stencilFuncRef;
  118678. private _stencilFuncMask;
  118679. private _stencilOpStencilFail;
  118680. private _stencilOpDepthFail;
  118681. private _stencilOpStencilDepthPass;
  118682. get isDirty(): boolean;
  118683. get stencilFunc(): number;
  118684. set stencilFunc(value: number);
  118685. get stencilFuncRef(): number;
  118686. set stencilFuncRef(value: number);
  118687. get stencilFuncMask(): number;
  118688. set stencilFuncMask(value: number);
  118689. get stencilOpStencilFail(): number;
  118690. set stencilOpStencilFail(value: number);
  118691. get stencilOpDepthFail(): number;
  118692. set stencilOpDepthFail(value: number);
  118693. get stencilOpStencilDepthPass(): number;
  118694. set stencilOpStencilDepthPass(value: number);
  118695. get stencilMask(): number;
  118696. set stencilMask(value: number);
  118697. get stencilTest(): boolean;
  118698. set stencilTest(value: boolean);
  118699. constructor();
  118700. reset(): void;
  118701. apply(gl: WebGLRenderingContext): void;
  118702. }
  118703. }
  118704. declare module BABYLON {
  118705. /**
  118706. * @hidden
  118707. **/
  118708. export class AlphaState {
  118709. private _isAlphaBlendDirty;
  118710. private _isBlendFunctionParametersDirty;
  118711. private _isBlendEquationParametersDirty;
  118712. private _isBlendConstantsDirty;
  118713. private _alphaBlend;
  118714. private _blendFunctionParameters;
  118715. private _blendEquationParameters;
  118716. private _blendConstants;
  118717. /**
  118718. * Initializes the state.
  118719. */
  118720. constructor();
  118721. get isDirty(): boolean;
  118722. get alphaBlend(): boolean;
  118723. set alphaBlend(value: boolean);
  118724. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118725. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118726. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118727. reset(): void;
  118728. apply(gl: WebGLRenderingContext): void;
  118729. }
  118730. }
  118731. declare module BABYLON {
  118732. /** @hidden */
  118733. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118734. attributeProcessor(attribute: string): string;
  118735. varyingProcessor(varying: string, isFragment: boolean): string;
  118736. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Interface for attribute information associated with buffer instanciation
  118742. */
  118743. export interface InstancingAttributeInfo {
  118744. /**
  118745. * Name of the GLSL attribute
  118746. * if attribute index is not specified, this is used to retrieve the index from the effect
  118747. */
  118748. attributeName: string;
  118749. /**
  118750. * Index/offset of the attribute in the vertex shader
  118751. * if not specified, this will be computes from the name.
  118752. */
  118753. index?: number;
  118754. /**
  118755. * size of the attribute, 1, 2, 3 or 4
  118756. */
  118757. attributeSize: number;
  118758. /**
  118759. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118760. */
  118761. offset: number;
  118762. /**
  118763. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118764. * default to 1
  118765. */
  118766. divisor?: number;
  118767. /**
  118768. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118769. * default is FLOAT
  118770. */
  118771. attributeType?: number;
  118772. /**
  118773. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118774. */
  118775. normalized?: boolean;
  118776. }
  118777. }
  118778. declare module BABYLON {
  118779. interface ThinEngine {
  118780. /**
  118781. * Update a video texture
  118782. * @param texture defines the texture to update
  118783. * @param video defines the video element to use
  118784. * @param invertY defines if data must be stored with Y axis inverted
  118785. */
  118786. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118787. }
  118788. }
  118789. declare module BABYLON {
  118790. interface ThinEngine {
  118791. /**
  118792. * Creates a dynamic texture
  118793. * @param width defines the width of the texture
  118794. * @param height defines the height of the texture
  118795. * @param generateMipMaps defines if the engine should generate the mip levels
  118796. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  118797. * @returns the dynamic texture inside an InternalTexture
  118798. */
  118799. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  118800. /**
  118801. * Update the content of a dynamic texture
  118802. * @param texture defines the texture to update
  118803. * @param canvas defines the canvas containing the source
  118804. * @param invertY defines if data must be stored with Y axis inverted
  118805. * @param premulAlpha defines if alpha is stored as premultiplied
  118806. * @param format defines the format of the data
  118807. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  118808. */
  118809. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  118810. }
  118811. }
  118812. declare module BABYLON {
  118813. /**
  118814. * Settings for finer control over video usage
  118815. */
  118816. export interface VideoTextureSettings {
  118817. /**
  118818. * Applies `autoplay` to video, if specified
  118819. */
  118820. autoPlay?: boolean;
  118821. /**
  118822. * Applies `muted` to video, if specified
  118823. */
  118824. muted?: boolean;
  118825. /**
  118826. * Applies `loop` to video, if specified
  118827. */
  118828. loop?: boolean;
  118829. /**
  118830. * Automatically updates internal texture from video at every frame in the render loop
  118831. */
  118832. autoUpdateTexture: boolean;
  118833. /**
  118834. * Image src displayed during the video loading or until the user interacts with the video.
  118835. */
  118836. poster?: string;
  118837. }
  118838. /**
  118839. * If you want to display a video in your scene, this is the special texture for that.
  118840. * This special texture works similar to other textures, with the exception of a few parameters.
  118841. * @see https://doc.babylonjs.com/how_to/video_texture
  118842. */
  118843. export class VideoTexture extends Texture {
  118844. /**
  118845. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  118846. */
  118847. readonly autoUpdateTexture: boolean;
  118848. /**
  118849. * The video instance used by the texture internally
  118850. */
  118851. readonly video: HTMLVideoElement;
  118852. private _onUserActionRequestedObservable;
  118853. /**
  118854. * Event triggerd when a dom action is required by the user to play the video.
  118855. * This happens due to recent changes in browser policies preventing video to auto start.
  118856. */
  118857. get onUserActionRequestedObservable(): Observable<Texture>;
  118858. private _generateMipMaps;
  118859. private _stillImageCaptured;
  118860. private _displayingPosterTexture;
  118861. private _settings;
  118862. private _createInternalTextureOnEvent;
  118863. private _frameId;
  118864. private _currentSrc;
  118865. /**
  118866. * Creates a video texture.
  118867. * If you want to display a video in your scene, this is the special texture for that.
  118868. * This special texture works similar to other textures, with the exception of a few parameters.
  118869. * @see https://doc.babylonjs.com/how_to/video_texture
  118870. * @param name optional name, will detect from video source, if not defined
  118871. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  118872. * @param scene is obviously the current scene.
  118873. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  118874. * @param invertY is false by default but can be used to invert video on Y axis
  118875. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  118876. * @param settings allows finer control over video usage
  118877. */
  118878. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  118879. private _getName;
  118880. private _getVideo;
  118881. private _createInternalTexture;
  118882. private reset;
  118883. /**
  118884. * @hidden Internal method to initiate `update`.
  118885. */
  118886. _rebuild(): void;
  118887. /**
  118888. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  118889. */
  118890. update(): void;
  118891. /**
  118892. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  118893. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  118894. */
  118895. updateTexture(isVisible: boolean): void;
  118896. protected _updateInternalTexture: () => void;
  118897. /**
  118898. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  118899. * @param url New url.
  118900. */
  118901. updateURL(url: string): void;
  118902. /**
  118903. * Clones the texture.
  118904. * @returns the cloned texture
  118905. */
  118906. clone(): VideoTexture;
  118907. /**
  118908. * Dispose the texture and release its associated resources.
  118909. */
  118910. dispose(): void;
  118911. /**
  118912. * Creates a video texture straight from a stream.
  118913. * @param scene Define the scene the texture should be created in
  118914. * @param stream Define the stream the texture should be created from
  118915. * @returns The created video texture as a promise
  118916. */
  118917. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  118918. /**
  118919. * Creates a video texture straight from your WebCam video feed.
  118920. * @param scene Define the scene the texture should be created in
  118921. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118922. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118923. * @returns The created video texture as a promise
  118924. */
  118925. static CreateFromWebCamAsync(scene: Scene, constraints: {
  118926. minWidth: number;
  118927. maxWidth: number;
  118928. minHeight: number;
  118929. maxHeight: number;
  118930. deviceId: string;
  118931. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  118932. /**
  118933. * Creates a video texture straight from your WebCam video feed.
  118934. * @param scene Define the scene the texture should be created in
  118935. * @param onReady Define a callback to triggered once the texture will be ready
  118936. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  118937. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  118938. */
  118939. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  118940. minWidth: number;
  118941. maxWidth: number;
  118942. minHeight: number;
  118943. maxHeight: number;
  118944. deviceId: string;
  118945. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  118946. }
  118947. }
  118948. declare module BABYLON {
  118949. /**
  118950. * Defines the interface used by objects working like Scene
  118951. * @hidden
  118952. */
  118953. export interface ISceneLike {
  118954. _addPendingData(data: any): void;
  118955. _removePendingData(data: any): void;
  118956. offlineProvider: IOfflineProvider;
  118957. }
  118958. /**
  118959. * Information about the current host
  118960. */
  118961. export interface HostInformation {
  118962. /**
  118963. * Defines if the current host is a mobile
  118964. */
  118965. isMobile: boolean;
  118966. }
  118967. /** Interface defining initialization parameters for Engine class */
  118968. export interface EngineOptions extends WebGLContextAttributes {
  118969. /**
  118970. * Defines if the engine should no exceed a specified device ratio
  118971. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  118972. */
  118973. limitDeviceRatio?: number;
  118974. /**
  118975. * Defines if webvr should be enabled automatically
  118976. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118977. */
  118978. autoEnableWebVR?: boolean;
  118979. /**
  118980. * Defines if webgl2 should be turned off even if supported
  118981. * @see https://doc.babylonjs.com/features/webgl2
  118982. */
  118983. disableWebGL2Support?: boolean;
  118984. /**
  118985. * Defines if webaudio should be initialized as well
  118986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118987. */
  118988. audioEngine?: boolean;
  118989. /**
  118990. * Defines if animations should run using a deterministic lock step
  118991. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118992. */
  118993. deterministicLockstep?: boolean;
  118994. /** Defines the maximum steps to use with deterministic lock step mode */
  118995. lockstepMaxSteps?: number;
  118996. /** Defines the seconds between each deterministic lock step */
  118997. timeStep?: number;
  118998. /**
  118999. * Defines that engine should ignore context lost events
  119000. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119001. */
  119002. doNotHandleContextLost?: boolean;
  119003. /**
  119004. * Defines that engine should ignore modifying touch action attribute and style
  119005. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119006. */
  119007. doNotHandleTouchAction?: boolean;
  119008. /**
  119009. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119010. */
  119011. useHighPrecisionFloats?: boolean;
  119012. /**
  119013. * Make the canvas XR Compatible for XR sessions
  119014. */
  119015. xrCompatible?: boolean;
  119016. /**
  119017. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119018. */
  119019. useHighPrecisionMatrix?: boolean;
  119020. /**
  119021. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119022. */
  119023. failIfMajorPerformanceCaveat?: boolean;
  119024. }
  119025. /**
  119026. * The base engine class (root of all engines)
  119027. */
  119028. export class ThinEngine {
  119029. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119030. static ExceptionList: ({
  119031. key: string;
  119032. capture: string;
  119033. captureConstraint: number;
  119034. targets: string[];
  119035. } | {
  119036. key: string;
  119037. capture: null;
  119038. captureConstraint: null;
  119039. targets: string[];
  119040. })[];
  119041. /** @hidden */
  119042. static _TextureLoaders: IInternalTextureLoader[];
  119043. /**
  119044. * Returns the current npm package of the sdk
  119045. */
  119046. static get NpmPackage(): string;
  119047. /**
  119048. * Returns the current version of the framework
  119049. */
  119050. static get Version(): string;
  119051. /**
  119052. * Returns a string describing the current engine
  119053. */
  119054. get description(): string;
  119055. /**
  119056. * Gets or sets the epsilon value used by collision engine
  119057. */
  119058. static CollisionsEpsilon: number;
  119059. /**
  119060. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119061. */
  119062. static get ShadersRepository(): string;
  119063. static set ShadersRepository(value: string);
  119064. /** @hidden */
  119065. _shaderProcessor: IShaderProcessor;
  119066. /**
  119067. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119068. */
  119069. forcePOTTextures: boolean;
  119070. /**
  119071. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119072. */
  119073. isFullscreen: boolean;
  119074. /**
  119075. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119076. */
  119077. cullBackFaces: boolean;
  119078. /**
  119079. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119080. */
  119081. renderEvenInBackground: boolean;
  119082. /**
  119083. * Gets or sets a boolean indicating that cache can be kept between frames
  119084. */
  119085. preventCacheWipeBetweenFrames: boolean;
  119086. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119087. validateShaderPrograms: boolean;
  119088. /**
  119089. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119090. * This can provide greater z depth for distant objects.
  119091. */
  119092. useReverseDepthBuffer: boolean;
  119093. /**
  119094. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119095. */
  119096. disableUniformBuffers: boolean;
  119097. /** @hidden */
  119098. _uniformBuffers: UniformBuffer[];
  119099. /**
  119100. * Gets a boolean indicating that the engine supports uniform buffers
  119101. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119102. */
  119103. get supportsUniformBuffers(): boolean;
  119104. /** @hidden */
  119105. _gl: WebGLRenderingContext;
  119106. /** @hidden */
  119107. _webGLVersion: number;
  119108. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119109. protected _windowIsBackground: boolean;
  119110. protected _creationOptions: EngineOptions;
  119111. protected _highPrecisionShadersAllowed: boolean;
  119112. /** @hidden */
  119113. get _shouldUseHighPrecisionShader(): boolean;
  119114. /**
  119115. * Gets a boolean indicating that only power of 2 textures are supported
  119116. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119117. */
  119118. get needPOTTextures(): boolean;
  119119. /** @hidden */
  119120. _badOS: boolean;
  119121. /** @hidden */
  119122. _badDesktopOS: boolean;
  119123. private _hardwareScalingLevel;
  119124. /** @hidden */
  119125. _caps: EngineCapabilities;
  119126. private _isStencilEnable;
  119127. private _glVersion;
  119128. private _glRenderer;
  119129. private _glVendor;
  119130. /** @hidden */
  119131. _videoTextureSupported: boolean;
  119132. protected _renderingQueueLaunched: boolean;
  119133. protected _activeRenderLoops: (() => void)[];
  119134. /**
  119135. * Observable signaled when a context lost event is raised
  119136. */
  119137. onContextLostObservable: Observable<ThinEngine>;
  119138. /**
  119139. * Observable signaled when a context restored event is raised
  119140. */
  119141. onContextRestoredObservable: Observable<ThinEngine>;
  119142. private _onContextLost;
  119143. private _onContextRestored;
  119144. protected _contextWasLost: boolean;
  119145. /** @hidden */
  119146. _doNotHandleContextLost: boolean;
  119147. /**
  119148. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119149. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119150. */
  119151. get doNotHandleContextLost(): boolean;
  119152. set doNotHandleContextLost(value: boolean);
  119153. /**
  119154. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119155. */
  119156. disableVertexArrayObjects: boolean;
  119157. /** @hidden */
  119158. protected _colorWrite: boolean;
  119159. /** @hidden */
  119160. protected _colorWriteChanged: boolean;
  119161. /** @hidden */
  119162. protected _depthCullingState: DepthCullingState;
  119163. /** @hidden */
  119164. protected _stencilState: StencilState;
  119165. /** @hidden */
  119166. _alphaState: AlphaState;
  119167. /** @hidden */
  119168. _alphaMode: number;
  119169. /** @hidden */
  119170. _alphaEquation: number;
  119171. /** @hidden */
  119172. _internalTexturesCache: InternalTexture[];
  119173. /** @hidden */
  119174. protected _activeChannel: number;
  119175. private _currentTextureChannel;
  119176. /** @hidden */
  119177. protected _boundTexturesCache: {
  119178. [key: string]: Nullable<InternalTexture>;
  119179. };
  119180. /** @hidden */
  119181. protected _currentEffect: Nullable<Effect>;
  119182. /** @hidden */
  119183. protected _currentProgram: Nullable<WebGLProgram>;
  119184. private _compiledEffects;
  119185. private _vertexAttribArraysEnabled;
  119186. /** @hidden */
  119187. protected _cachedViewport: Nullable<IViewportLike>;
  119188. private _cachedVertexArrayObject;
  119189. /** @hidden */
  119190. protected _cachedVertexBuffers: any;
  119191. /** @hidden */
  119192. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119193. /** @hidden */
  119194. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119195. /** @hidden */
  119196. _currentRenderTarget: Nullable<InternalTexture>;
  119197. private _uintIndicesCurrentlySet;
  119198. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119199. /** @hidden */
  119200. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119201. /** @hidden */
  119202. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119203. private _currentBufferPointers;
  119204. private _currentInstanceLocations;
  119205. private _currentInstanceBuffers;
  119206. private _textureUnits;
  119207. /** @hidden */
  119208. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119209. /** @hidden */
  119210. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119211. /** @hidden */
  119212. _boundRenderFunction: any;
  119213. private _vaoRecordInProgress;
  119214. private _mustWipeVertexAttributes;
  119215. private _emptyTexture;
  119216. private _emptyCubeTexture;
  119217. private _emptyTexture3D;
  119218. private _emptyTexture2DArray;
  119219. /** @hidden */
  119220. _frameHandler: number;
  119221. private _nextFreeTextureSlots;
  119222. private _maxSimultaneousTextures;
  119223. private _activeRequests;
  119224. /** @hidden */
  119225. _transformTextureUrl: Nullable<(url: string) => string>;
  119226. /**
  119227. * Gets information about the current host
  119228. */
  119229. hostInformation: HostInformation;
  119230. protected get _supportsHardwareTextureRescaling(): boolean;
  119231. private _framebufferDimensionsObject;
  119232. /**
  119233. * sets the object from which width and height will be taken from when getting render width and height
  119234. * Will fallback to the gl object
  119235. * @param dimensions the framebuffer width and height that will be used.
  119236. */
  119237. set framebufferDimensionsObject(dimensions: Nullable<{
  119238. framebufferWidth: number;
  119239. framebufferHeight: number;
  119240. }>);
  119241. /**
  119242. * Gets the current viewport
  119243. */
  119244. get currentViewport(): Nullable<IViewportLike>;
  119245. /**
  119246. * Gets the default empty texture
  119247. */
  119248. get emptyTexture(): InternalTexture;
  119249. /**
  119250. * Gets the default empty 3D texture
  119251. */
  119252. get emptyTexture3D(): InternalTexture;
  119253. /**
  119254. * Gets the default empty 2D array texture
  119255. */
  119256. get emptyTexture2DArray(): InternalTexture;
  119257. /**
  119258. * Gets the default empty cube texture
  119259. */
  119260. get emptyCubeTexture(): InternalTexture;
  119261. /**
  119262. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119263. */
  119264. readonly premultipliedAlpha: boolean;
  119265. /**
  119266. * Observable event triggered before each texture is initialized
  119267. */
  119268. onBeforeTextureInitObservable: Observable<Texture>;
  119269. /**
  119270. * Creates a new engine
  119271. * @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
  119272. * @param antialias defines enable antialiasing (default: false)
  119273. * @param options defines further options to be sent to the getContext() function
  119274. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119275. */
  119276. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119277. private _rebuildInternalTextures;
  119278. private _rebuildEffects;
  119279. /**
  119280. * Gets a boolean indicating if all created effects are ready
  119281. * @returns true if all effects are ready
  119282. */
  119283. areAllEffectsReady(): boolean;
  119284. protected _rebuildBuffers(): void;
  119285. protected _initGLContext(): void;
  119286. /**
  119287. * Gets version of the current webGL context
  119288. */
  119289. get webGLVersion(): number;
  119290. /**
  119291. * Gets a string identifying the name of the class
  119292. * @returns "Engine" string
  119293. */
  119294. getClassName(): string;
  119295. /**
  119296. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119297. */
  119298. get isStencilEnable(): boolean;
  119299. /** @hidden */
  119300. _prepareWorkingCanvas(): void;
  119301. /**
  119302. * Reset the texture cache to empty state
  119303. */
  119304. resetTextureCache(): void;
  119305. /**
  119306. * Gets an object containing information about the current webGL context
  119307. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119308. */
  119309. getGlInfo(): {
  119310. vendor: string;
  119311. renderer: string;
  119312. version: string;
  119313. };
  119314. /**
  119315. * Defines the hardware scaling level.
  119316. * By default the hardware scaling level is computed from the window device ratio.
  119317. * 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.
  119318. * @param level defines the level to use
  119319. */
  119320. setHardwareScalingLevel(level: number): void;
  119321. /**
  119322. * Gets the current hardware scaling level.
  119323. * By default the hardware scaling level is computed from the window device ratio.
  119324. * 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.
  119325. * @returns a number indicating the current hardware scaling level
  119326. */
  119327. getHardwareScalingLevel(): number;
  119328. /**
  119329. * Gets the list of loaded textures
  119330. * @returns an array containing all loaded textures
  119331. */
  119332. getLoadedTexturesCache(): InternalTexture[];
  119333. /**
  119334. * Gets the object containing all engine capabilities
  119335. * @returns the EngineCapabilities object
  119336. */
  119337. getCaps(): EngineCapabilities;
  119338. /**
  119339. * stop executing a render loop function and remove it from the execution array
  119340. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119341. */
  119342. stopRenderLoop(renderFunction?: () => void): void;
  119343. /** @hidden */
  119344. _renderLoop(): void;
  119345. /**
  119346. * Gets the HTML canvas attached with the current webGL context
  119347. * @returns a HTML canvas
  119348. */
  119349. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119350. /**
  119351. * Gets host window
  119352. * @returns the host window object
  119353. */
  119354. getHostWindow(): Nullable<Window>;
  119355. /**
  119356. * Gets the current render width
  119357. * @param useScreen defines if screen size must be used (or the current render target if any)
  119358. * @returns a number defining the current render width
  119359. */
  119360. getRenderWidth(useScreen?: boolean): number;
  119361. /**
  119362. * Gets the current render height
  119363. * @param useScreen defines if screen size must be used (or the current render target if any)
  119364. * @returns a number defining the current render height
  119365. */
  119366. getRenderHeight(useScreen?: boolean): number;
  119367. /**
  119368. * Can be used to override the current requestAnimationFrame requester.
  119369. * @hidden
  119370. */
  119371. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119372. /**
  119373. * Register and execute a render loop. The engine can have more than one render function
  119374. * @param renderFunction defines the function to continuously execute
  119375. */
  119376. runRenderLoop(renderFunction: () => void): void;
  119377. /**
  119378. * Clear the current render buffer or the current render target (if any is set up)
  119379. * @param color defines the color to use
  119380. * @param backBuffer defines if the back buffer must be cleared
  119381. * @param depth defines if the depth buffer must be cleared
  119382. * @param stencil defines if the stencil buffer must be cleared
  119383. */
  119384. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119385. private _viewportCached;
  119386. /** @hidden */
  119387. _viewport(x: number, y: number, width: number, height: number): void;
  119388. /**
  119389. * Set the WebGL's viewport
  119390. * @param viewport defines the viewport element to be used
  119391. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119392. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119393. */
  119394. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119395. /**
  119396. * Begin a new frame
  119397. */
  119398. beginFrame(): void;
  119399. /**
  119400. * Enf the current frame
  119401. */
  119402. endFrame(): void;
  119403. /**
  119404. * Resize the view according to the canvas' size
  119405. */
  119406. resize(): void;
  119407. /**
  119408. * Force a specific size of the canvas
  119409. * @param width defines the new canvas' width
  119410. * @param height defines the new canvas' height
  119411. * @returns true if the size was changed
  119412. */
  119413. setSize(width: number, height: number): boolean;
  119414. /**
  119415. * Binds the frame buffer to the specified texture.
  119416. * @param texture The texture to render to or null for the default canvas
  119417. * @param faceIndex The face of the texture to render to in case of cube texture
  119418. * @param requiredWidth The width of the target to render to
  119419. * @param requiredHeight The height of the target to render to
  119420. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119421. * @param lodLevel defines the lod level to bind to the frame buffer
  119422. * @param layer defines the 2d array index to bind to frame buffer to
  119423. */
  119424. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119425. /** @hidden */
  119426. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119427. /**
  119428. * Unbind the current render target texture from the webGL context
  119429. * @param texture defines the render target texture to unbind
  119430. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119431. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119432. */
  119433. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119434. /**
  119435. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119436. */
  119437. flushFramebuffer(): void;
  119438. /**
  119439. * Unbind the current render target and bind the default framebuffer
  119440. */
  119441. restoreDefaultFramebuffer(): void;
  119442. /** @hidden */
  119443. protected _resetVertexBufferBinding(): void;
  119444. /**
  119445. * Creates a vertex buffer
  119446. * @param data the data for the vertex buffer
  119447. * @returns the new WebGL static buffer
  119448. */
  119449. createVertexBuffer(data: DataArray): DataBuffer;
  119450. private _createVertexBuffer;
  119451. /**
  119452. * Creates a dynamic vertex buffer
  119453. * @param data the data for the dynamic vertex buffer
  119454. * @returns the new WebGL dynamic buffer
  119455. */
  119456. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119457. protected _resetIndexBufferBinding(): void;
  119458. /**
  119459. * Creates a new index buffer
  119460. * @param indices defines the content of the index buffer
  119461. * @param updatable defines if the index buffer must be updatable
  119462. * @returns a new webGL buffer
  119463. */
  119464. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119465. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119466. /**
  119467. * Bind a webGL buffer to the webGL context
  119468. * @param buffer defines the buffer to bind
  119469. */
  119470. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119471. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119472. private bindBuffer;
  119473. /**
  119474. * update the bound buffer with the given data
  119475. * @param data defines the data to update
  119476. */
  119477. updateArrayBuffer(data: Float32Array): void;
  119478. private _vertexAttribPointer;
  119479. /** @hidden */
  119480. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119481. private _bindVertexBuffersAttributes;
  119482. /**
  119483. * Records a vertex array object
  119484. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119485. * @param vertexBuffers defines the list of vertex buffers to store
  119486. * @param indexBuffer defines the index buffer to store
  119487. * @param effect defines the effect to store
  119488. * @returns the new vertex array object
  119489. */
  119490. recordVertexArrayObject(vertexBuffers: {
  119491. [key: string]: VertexBuffer;
  119492. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119493. /**
  119494. * Bind a specific vertex array object
  119495. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119496. * @param vertexArrayObject defines the vertex array object to bind
  119497. * @param indexBuffer defines the index buffer to bind
  119498. */
  119499. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119500. /**
  119501. * Bind webGl buffers directly to the webGL context
  119502. * @param vertexBuffer defines the vertex buffer to bind
  119503. * @param indexBuffer defines the index buffer to bind
  119504. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119505. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119506. * @param effect defines the effect associated with the vertex buffer
  119507. */
  119508. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119509. private _unbindVertexArrayObject;
  119510. /**
  119511. * Bind a list of vertex buffers to the webGL context
  119512. * @param vertexBuffers defines the list of vertex buffers to bind
  119513. * @param indexBuffer defines the index buffer to bind
  119514. * @param effect defines the effect associated with the vertex buffers
  119515. */
  119516. bindBuffers(vertexBuffers: {
  119517. [key: string]: Nullable<VertexBuffer>;
  119518. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119519. /**
  119520. * Unbind all instance attributes
  119521. */
  119522. unbindInstanceAttributes(): void;
  119523. /**
  119524. * Release and free the memory of a vertex array object
  119525. * @param vao defines the vertex array object to delete
  119526. */
  119527. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119528. /** @hidden */
  119529. _releaseBuffer(buffer: DataBuffer): boolean;
  119530. protected _deleteBuffer(buffer: DataBuffer): void;
  119531. /**
  119532. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119533. * @param instancesBuffer defines the webGL buffer to update and bind
  119534. * @param data defines the data to store in the buffer
  119535. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119536. */
  119537. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119538. /**
  119539. * Bind the content of a webGL buffer used with instantiation
  119540. * @param instancesBuffer defines the webGL buffer to bind
  119541. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119542. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119543. */
  119544. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119545. /**
  119546. * Disable the instance attribute corresponding to the name in parameter
  119547. * @param name defines the name of the attribute to disable
  119548. */
  119549. disableInstanceAttributeByName(name: string): void;
  119550. /**
  119551. * Disable the instance attribute corresponding to the location in parameter
  119552. * @param attributeLocation defines the attribute location of the attribute to disable
  119553. */
  119554. disableInstanceAttribute(attributeLocation: number): void;
  119555. /**
  119556. * Disable the attribute corresponding to the location in parameter
  119557. * @param attributeLocation defines the attribute location of the attribute to disable
  119558. */
  119559. disableAttributeByIndex(attributeLocation: number): void;
  119560. /**
  119561. * Send a draw order
  119562. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119563. * @param indexStart defines the starting index
  119564. * @param indexCount defines the number of index to draw
  119565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119566. */
  119567. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119568. /**
  119569. * Draw a list of points
  119570. * @param verticesStart defines the index of first vertex to draw
  119571. * @param verticesCount defines the count of vertices to draw
  119572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119573. */
  119574. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119575. /**
  119576. * Draw a list of unindexed primitives
  119577. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119578. * @param verticesStart defines the index of first vertex to draw
  119579. * @param verticesCount defines the count of vertices to draw
  119580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119581. */
  119582. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119583. /**
  119584. * Draw a list of indexed primitives
  119585. * @param fillMode defines the primitive to use
  119586. * @param indexStart defines the starting index
  119587. * @param indexCount defines the number of index to draw
  119588. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119589. */
  119590. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119591. /**
  119592. * Draw a list of unindexed primitives
  119593. * @param fillMode defines the primitive to use
  119594. * @param verticesStart defines the index of first vertex to draw
  119595. * @param verticesCount defines the count of vertices to draw
  119596. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119597. */
  119598. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119599. private _drawMode;
  119600. /** @hidden */
  119601. protected _reportDrawCall(): void;
  119602. /** @hidden */
  119603. _releaseEffect(effect: Effect): void;
  119604. /** @hidden */
  119605. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119606. /**
  119607. * Create a new effect (used to store vertex/fragment shaders)
  119608. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119609. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119610. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119611. * @param samplers defines an array of string used to represent textures
  119612. * @param defines defines the string containing the defines to use to compile the shaders
  119613. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119614. * @param onCompiled defines a function to call when the effect creation is successful
  119615. * @param onError defines a function to call when the effect creation has failed
  119616. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119617. * @returns the new Effect
  119618. */
  119619. 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;
  119620. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119621. private _compileShader;
  119622. private _compileRawShader;
  119623. /** @hidden */
  119624. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119625. /**
  119626. * Directly creates a webGL program
  119627. * @param pipelineContext defines the pipeline context to attach to
  119628. * @param vertexCode defines the vertex shader code to use
  119629. * @param fragmentCode defines the fragment shader code to use
  119630. * @param context defines the webGL context to use (if not set, the current one will be used)
  119631. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119632. * @returns the new webGL program
  119633. */
  119634. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119635. /**
  119636. * Creates a webGL program
  119637. * @param pipelineContext defines the pipeline context to attach to
  119638. * @param vertexCode defines the vertex shader code to use
  119639. * @param fragmentCode defines the fragment shader code to use
  119640. * @param defines defines the string containing the defines to use to compile the shaders
  119641. * @param context defines the webGL context to use (if not set, the current one will be used)
  119642. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119643. * @returns the new webGL program
  119644. */
  119645. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119646. /**
  119647. * Creates a new pipeline context
  119648. * @returns the new pipeline
  119649. */
  119650. createPipelineContext(): IPipelineContext;
  119651. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119652. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119653. /** @hidden */
  119654. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119655. /** @hidden */
  119656. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119657. /** @hidden */
  119658. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119659. /**
  119660. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119661. * @param pipelineContext defines the pipeline context to use
  119662. * @param uniformsNames defines the list of uniform names
  119663. * @returns an array of webGL uniform locations
  119664. */
  119665. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119666. /**
  119667. * Gets the lsit of active attributes for a given webGL program
  119668. * @param pipelineContext defines the pipeline context to use
  119669. * @param attributesNames defines the list of attribute names to get
  119670. * @returns an array of indices indicating the offset of each attribute
  119671. */
  119672. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119673. /**
  119674. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119675. * @param effect defines the effect to activate
  119676. */
  119677. enableEffect(effect: Nullable<Effect>): void;
  119678. /**
  119679. * Set the value of an uniform to a number (int)
  119680. * @param uniform defines the webGL uniform location where to store the value
  119681. * @param value defines the int number to store
  119682. * @returns true if the value was set
  119683. */
  119684. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119685. /**
  119686. * Set the value of an uniform to an array of int32
  119687. * @param uniform defines the webGL uniform location where to store the value
  119688. * @param array defines the array of int32 to store
  119689. * @returns true if the value was set
  119690. */
  119691. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119692. /**
  119693. * Set the value of an uniform to an array of int32 (stored as vec2)
  119694. * @param uniform defines the webGL uniform location where to store the value
  119695. * @param array defines the array of int32 to store
  119696. * @returns true if the value was set
  119697. */
  119698. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119699. /**
  119700. * Set the value of an uniform to an array of int32 (stored as vec3)
  119701. * @param uniform defines the webGL uniform location where to store the value
  119702. * @param array defines the array of int32 to store
  119703. * @returns true if the value was set
  119704. */
  119705. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119706. /**
  119707. * Set the value of an uniform to an array of int32 (stored as vec4)
  119708. * @param uniform defines the webGL uniform location where to store the value
  119709. * @param array defines the array of int32 to store
  119710. * @returns true if the value was set
  119711. */
  119712. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119713. /**
  119714. * Set the value of an uniform to an array of number
  119715. * @param uniform defines the webGL uniform location where to store the value
  119716. * @param array defines the array of number to store
  119717. * @returns true if the value was set
  119718. */
  119719. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119720. /**
  119721. * Set the value of an uniform to an array of number (stored as vec2)
  119722. * @param uniform defines the webGL uniform location where to store the value
  119723. * @param array defines the array of number to store
  119724. * @returns true if the value was set
  119725. */
  119726. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119727. /**
  119728. * Set the value of an uniform to an array of number (stored as vec3)
  119729. * @param uniform defines the webGL uniform location where to store the value
  119730. * @param array defines the array of number to store
  119731. * @returns true if the value was set
  119732. */
  119733. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119734. /**
  119735. * Set the value of an uniform to an array of number (stored as vec4)
  119736. * @param uniform defines the webGL uniform location where to store the value
  119737. * @param array defines the array of number to store
  119738. * @returns true if the value was set
  119739. */
  119740. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119741. /**
  119742. * Set the value of an uniform to an array of float32 (stored as matrices)
  119743. * @param uniform defines the webGL uniform location where to store the value
  119744. * @param matrices defines the array of float32 to store
  119745. * @returns true if the value was set
  119746. */
  119747. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119748. /**
  119749. * Set the value of an uniform to a matrix (3x3)
  119750. * @param uniform defines the webGL uniform location where to store the value
  119751. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119752. * @returns true if the value was set
  119753. */
  119754. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119755. /**
  119756. * Set the value of an uniform to a matrix (2x2)
  119757. * @param uniform defines the webGL uniform location where to store the value
  119758. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119759. * @returns true if the value was set
  119760. */
  119761. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119762. /**
  119763. * Set the value of an uniform to a number (float)
  119764. * @param uniform defines the webGL uniform location where to store the value
  119765. * @param value defines the float number to store
  119766. * @returns true if the value was transfered
  119767. */
  119768. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119769. /**
  119770. * Set the value of an uniform to a vec2
  119771. * @param uniform defines the webGL uniform location where to store the value
  119772. * @param x defines the 1st component of the value
  119773. * @param y defines the 2nd component of the value
  119774. * @returns true if the value was set
  119775. */
  119776. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119777. /**
  119778. * Set the value of an uniform to a vec3
  119779. * @param uniform defines the webGL uniform location where to store the value
  119780. * @param x defines the 1st component of the value
  119781. * @param y defines the 2nd component of the value
  119782. * @param z defines the 3rd component of the value
  119783. * @returns true if the value was set
  119784. */
  119785. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119786. /**
  119787. * Set the value of an uniform to a vec4
  119788. * @param uniform defines the webGL uniform location where to store the value
  119789. * @param x defines the 1st component of the value
  119790. * @param y defines the 2nd component of the value
  119791. * @param z defines the 3rd component of the value
  119792. * @param w defines the 4th component of the value
  119793. * @returns true if the value was set
  119794. */
  119795. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  119796. /**
  119797. * Apply all cached states (depth, culling, stencil and alpha)
  119798. */
  119799. applyStates(): void;
  119800. /**
  119801. * Enable or disable color writing
  119802. * @param enable defines the state to set
  119803. */
  119804. setColorWrite(enable: boolean): void;
  119805. /**
  119806. * Gets a boolean indicating if color writing is enabled
  119807. * @returns the current color writing state
  119808. */
  119809. getColorWrite(): boolean;
  119810. /**
  119811. * Gets the depth culling state manager
  119812. */
  119813. get depthCullingState(): DepthCullingState;
  119814. /**
  119815. * Gets the alpha state manager
  119816. */
  119817. get alphaState(): AlphaState;
  119818. /**
  119819. * Gets the stencil state manager
  119820. */
  119821. get stencilState(): StencilState;
  119822. /**
  119823. * Clears the list of texture accessible through engine.
  119824. * This can help preventing texture load conflict due to name collision.
  119825. */
  119826. clearInternalTexturesCache(): void;
  119827. /**
  119828. * Force the entire cache to be cleared
  119829. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119830. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119831. */
  119832. wipeCaches(bruteForce?: boolean): void;
  119833. /** @hidden */
  119834. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  119835. min: number;
  119836. mag: number;
  119837. };
  119838. /** @hidden */
  119839. _createTexture(): WebGLTexture;
  119840. /**
  119841. * Usually called from Texture.ts.
  119842. * Passed information to create a WebGLTexture
  119843. * @param url defines a value which contains one of the following:
  119844. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119845. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119846. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119848. * @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)
  119849. * @param scene needed for loading to the correct scene
  119850. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119851. * @param onLoad optional callback to be called upon successful completion
  119852. * @param onError optional callback to be called upon failure
  119853. * @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
  119854. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119855. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119856. * @param forcedExtension defines the extension to use to pick the right loader
  119857. * @param mimeType defines an optional mime type
  119858. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119859. */
  119860. 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;
  119861. /**
  119862. * Loads an image as an HTMLImageElement.
  119863. * @param input url string, ArrayBuffer, or Blob to load
  119864. * @param onLoad callback called when the image successfully loads
  119865. * @param onError callback called when the image fails to load
  119866. * @param offlineProvider offline provider for caching
  119867. * @param mimeType optional mime type
  119868. * @returns the HTMLImageElement of the loaded image
  119869. * @hidden
  119870. */
  119871. 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>;
  119872. /**
  119873. * @hidden
  119874. */
  119875. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  119876. private _unpackFlipYCached;
  119877. /**
  119878. * In case you are sharing the context with other applications, it might
  119879. * be interested to not cache the unpack flip y state to ensure a consistent
  119880. * value would be set.
  119881. */
  119882. enableUnpackFlipYCached: boolean;
  119883. /** @hidden */
  119884. _unpackFlipY(value: boolean): void;
  119885. /** @hidden */
  119886. _getUnpackAlignement(): number;
  119887. private _getTextureTarget;
  119888. /**
  119889. * Update the sampling mode of a given texture
  119890. * @param samplingMode defines the required sampling mode
  119891. * @param texture defines the texture to update
  119892. * @param generateMipMaps defines whether to generate mipmaps for the texture
  119893. */
  119894. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  119895. /**
  119896. * Update the sampling mode of a given texture
  119897. * @param texture defines the texture to update
  119898. * @param wrapU defines the texture wrap mode of the u coordinates
  119899. * @param wrapV defines the texture wrap mode of the v coordinates
  119900. * @param wrapR defines the texture wrap mode of the r coordinates
  119901. */
  119902. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  119903. /** @hidden */
  119904. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  119905. width: number;
  119906. height: number;
  119907. layers?: number;
  119908. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  119909. /** @hidden */
  119910. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119911. /** @hidden */
  119912. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  119913. /**
  119914. * Update a portion of an internal texture
  119915. * @param texture defines the texture to update
  119916. * @param imageData defines the data to store into the texture
  119917. * @param xOffset defines the x coordinates of the update rectangle
  119918. * @param yOffset defines the y coordinates of the update rectangle
  119919. * @param width defines the width of the update rectangle
  119920. * @param height defines the height of the update rectangle
  119921. * @param faceIndex defines the face index if texture is a cube (0 by default)
  119922. * @param lod defines the lod level to update (0 by default)
  119923. */
  119924. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  119925. /** @hidden */
  119926. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119927. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  119928. private _prepareWebGLTexture;
  119929. /** @hidden */
  119930. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  119931. private _getDepthStencilBuffer;
  119932. /** @hidden */
  119933. _releaseFramebufferObjects(texture: InternalTexture): void;
  119934. /** @hidden */
  119935. _releaseTexture(texture: InternalTexture): void;
  119936. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  119937. protected _setProgram(program: WebGLProgram): void;
  119938. protected _boundUniforms: {
  119939. [key: number]: WebGLUniformLocation;
  119940. };
  119941. /**
  119942. * Binds an effect to the webGL context
  119943. * @param effect defines the effect to bind
  119944. */
  119945. bindSamplers(effect: Effect): void;
  119946. private _activateCurrentTexture;
  119947. /** @hidden */
  119948. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  119949. /** @hidden */
  119950. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  119951. /**
  119952. * Unbind all textures from the webGL context
  119953. */
  119954. unbindAllTextures(): void;
  119955. /**
  119956. * Sets a texture to the according uniform.
  119957. * @param channel The texture channel
  119958. * @param uniform The uniform to set
  119959. * @param texture The texture to apply
  119960. */
  119961. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  119962. private _bindSamplerUniformToChannel;
  119963. private _getTextureWrapMode;
  119964. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  119965. /**
  119966. * Sets an array of texture to the webGL context
  119967. * @param channel defines the channel where the texture array must be set
  119968. * @param uniform defines the associated uniform location
  119969. * @param textures defines the array of textures to bind
  119970. */
  119971. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  119972. /** @hidden */
  119973. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  119974. private _setTextureParameterFloat;
  119975. private _setTextureParameterInteger;
  119976. /**
  119977. * Unbind all vertex attributes from the webGL context
  119978. */
  119979. unbindAllAttributes(): void;
  119980. /**
  119981. * 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
  119982. */
  119983. releaseEffects(): void;
  119984. /**
  119985. * Dispose and release all associated resources
  119986. */
  119987. dispose(): void;
  119988. /**
  119989. * Attach a new callback raised when context lost event is fired
  119990. * @param callback defines the callback to call
  119991. */
  119992. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119993. /**
  119994. * Attach a new callback raised when context restored event is fired
  119995. * @param callback defines the callback to call
  119996. */
  119997. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  119998. /**
  119999. * Get the current error code of the webGL context
  120000. * @returns the error code
  120001. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120002. */
  120003. getError(): number;
  120004. private _canRenderToFloatFramebuffer;
  120005. private _canRenderToHalfFloatFramebuffer;
  120006. private _canRenderToFramebuffer;
  120007. /** @hidden */
  120008. _getWebGLTextureType(type: number): number;
  120009. /** @hidden */
  120010. _getInternalFormat(format: number): number;
  120011. /** @hidden */
  120012. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120013. /** @hidden */
  120014. _getRGBAMultiSampleBufferFormat(type: number): number;
  120015. /** @hidden */
  120016. _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;
  120017. /**
  120018. * Loads a file from a url
  120019. * @param url url to load
  120020. * @param onSuccess callback called when the file successfully loads
  120021. * @param onProgress callback called while file is loading (if the server supports this mode)
  120022. * @param offlineProvider defines the offline provider for caching
  120023. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120024. * @param onError callback called when the file fails to load
  120025. * @returns a file request object
  120026. * @hidden
  120027. */
  120028. 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;
  120029. /**
  120030. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120031. * @param x defines the x coordinate of the rectangle where pixels must be read
  120032. * @param y defines the y coordinate of the rectangle where pixels must be read
  120033. * @param width defines the width of the rectangle where pixels must be read
  120034. * @param height defines the height of the rectangle where pixels must be read
  120035. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120036. * @returns a Uint8Array containing RGBA colors
  120037. */
  120038. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120039. private static _IsSupported;
  120040. private static _HasMajorPerformanceCaveat;
  120041. /**
  120042. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120043. */
  120044. static get IsSupported(): boolean;
  120045. /**
  120046. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120047. * @returns true if the engine can be created
  120048. * @ignorenaming
  120049. */
  120050. static isSupported(): boolean;
  120051. /**
  120052. * 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)
  120053. */
  120054. static get HasMajorPerformanceCaveat(): boolean;
  120055. /**
  120056. * Find the next highest power of two.
  120057. * @param x Number to start search from.
  120058. * @return Next highest power of two.
  120059. */
  120060. static CeilingPOT(x: number): number;
  120061. /**
  120062. * Find the next lowest power of two.
  120063. * @param x Number to start search from.
  120064. * @return Next lowest power of two.
  120065. */
  120066. static FloorPOT(x: number): number;
  120067. /**
  120068. * Find the nearest power of two.
  120069. * @param x Number to start search from.
  120070. * @return Next nearest power of two.
  120071. */
  120072. static NearestPOT(x: number): number;
  120073. /**
  120074. * Get the closest exponent of two
  120075. * @param value defines the value to approximate
  120076. * @param max defines the maximum value to return
  120077. * @param mode defines how to define the closest value
  120078. * @returns closest exponent of two of the given value
  120079. */
  120080. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120081. /**
  120082. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120083. * @param func - the function to be called
  120084. * @param requester - the object that will request the next frame. Falls back to window.
  120085. * @returns frame number
  120086. */
  120087. static QueueNewFrame(func: () => void, requester?: any): number;
  120088. /**
  120089. * Gets host document
  120090. * @returns the host document object
  120091. */
  120092. getHostDocument(): Nullable<Document>;
  120093. }
  120094. }
  120095. declare module BABYLON {
  120096. /**
  120097. * Defines the source of the internal texture
  120098. */
  120099. export enum InternalTextureSource {
  120100. /**
  120101. * The source of the texture data is unknown
  120102. */
  120103. Unknown = 0,
  120104. /**
  120105. * Texture data comes from an URL
  120106. */
  120107. Url = 1,
  120108. /**
  120109. * Texture data is only used for temporary storage
  120110. */
  120111. Temp = 2,
  120112. /**
  120113. * Texture data comes from raw data (ArrayBuffer)
  120114. */
  120115. Raw = 3,
  120116. /**
  120117. * Texture content is dynamic (video or dynamic texture)
  120118. */
  120119. Dynamic = 4,
  120120. /**
  120121. * Texture content is generated by rendering to it
  120122. */
  120123. RenderTarget = 5,
  120124. /**
  120125. * Texture content is part of a multi render target process
  120126. */
  120127. MultiRenderTarget = 6,
  120128. /**
  120129. * Texture data comes from a cube data file
  120130. */
  120131. Cube = 7,
  120132. /**
  120133. * Texture data comes from a raw cube data
  120134. */
  120135. CubeRaw = 8,
  120136. /**
  120137. * Texture data come from a prefiltered cube data file
  120138. */
  120139. CubePrefiltered = 9,
  120140. /**
  120141. * Texture content is raw 3D data
  120142. */
  120143. Raw3D = 10,
  120144. /**
  120145. * Texture content is raw 2D array data
  120146. */
  120147. Raw2DArray = 11,
  120148. /**
  120149. * Texture content is a depth texture
  120150. */
  120151. Depth = 12,
  120152. /**
  120153. * Texture data comes from a raw cube data encoded with RGBD
  120154. */
  120155. CubeRawRGBD = 13
  120156. }
  120157. /**
  120158. * Class used to store data associated with WebGL texture data for the engine
  120159. * This class should not be used directly
  120160. */
  120161. export class InternalTexture {
  120162. /** @hidden */
  120163. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120164. /**
  120165. * Defines if the texture is ready
  120166. */
  120167. isReady: boolean;
  120168. /**
  120169. * Defines if the texture is a cube texture
  120170. */
  120171. isCube: boolean;
  120172. /**
  120173. * Defines if the texture contains 3D data
  120174. */
  120175. is3D: boolean;
  120176. /**
  120177. * Defines if the texture contains 2D array data
  120178. */
  120179. is2DArray: boolean;
  120180. /**
  120181. * Defines if the texture contains multiview data
  120182. */
  120183. isMultiview: boolean;
  120184. /**
  120185. * Gets the URL used to load this texture
  120186. */
  120187. url: string;
  120188. /**
  120189. * Gets the sampling mode of the texture
  120190. */
  120191. samplingMode: number;
  120192. /**
  120193. * Gets a boolean indicating if the texture needs mipmaps generation
  120194. */
  120195. generateMipMaps: boolean;
  120196. /**
  120197. * Gets the number of samples used by the texture (WebGL2+ only)
  120198. */
  120199. samples: number;
  120200. /**
  120201. * Gets the type of the texture (int, float...)
  120202. */
  120203. type: number;
  120204. /**
  120205. * Gets the format of the texture (RGB, RGBA...)
  120206. */
  120207. format: number;
  120208. /**
  120209. * Observable called when the texture is loaded
  120210. */
  120211. onLoadedObservable: Observable<InternalTexture>;
  120212. /**
  120213. * Gets the width of the texture
  120214. */
  120215. width: number;
  120216. /**
  120217. * Gets the height of the texture
  120218. */
  120219. height: number;
  120220. /**
  120221. * Gets the depth of the texture
  120222. */
  120223. depth: number;
  120224. /**
  120225. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120226. */
  120227. baseWidth: number;
  120228. /**
  120229. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120230. */
  120231. baseHeight: number;
  120232. /**
  120233. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120234. */
  120235. baseDepth: number;
  120236. /**
  120237. * Gets a boolean indicating if the texture is inverted on Y axis
  120238. */
  120239. invertY: boolean;
  120240. /** @hidden */
  120241. _invertVScale: boolean;
  120242. /** @hidden */
  120243. _associatedChannel: number;
  120244. /** @hidden */
  120245. _source: InternalTextureSource;
  120246. /** @hidden */
  120247. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120248. /** @hidden */
  120249. _bufferView: Nullable<ArrayBufferView>;
  120250. /** @hidden */
  120251. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120252. /** @hidden */
  120253. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120254. /** @hidden */
  120255. _size: number;
  120256. /** @hidden */
  120257. _extension: string;
  120258. /** @hidden */
  120259. _files: Nullable<string[]>;
  120260. /** @hidden */
  120261. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120262. /** @hidden */
  120263. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120264. /** @hidden */
  120265. _framebuffer: Nullable<WebGLFramebuffer>;
  120266. /** @hidden */
  120267. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120268. /** @hidden */
  120269. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120270. /** @hidden */
  120271. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120272. /** @hidden */
  120273. _attachments: Nullable<number[]>;
  120274. /** @hidden */
  120275. _textureArray: Nullable<InternalTexture[]>;
  120276. /** @hidden */
  120277. _cachedCoordinatesMode: Nullable<number>;
  120278. /** @hidden */
  120279. _cachedWrapU: Nullable<number>;
  120280. /** @hidden */
  120281. _cachedWrapV: Nullable<number>;
  120282. /** @hidden */
  120283. _cachedWrapR: Nullable<number>;
  120284. /** @hidden */
  120285. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120286. /** @hidden */
  120287. _isDisabled: boolean;
  120288. /** @hidden */
  120289. _compression: Nullable<string>;
  120290. /** @hidden */
  120291. _generateStencilBuffer: boolean;
  120292. /** @hidden */
  120293. _generateDepthBuffer: boolean;
  120294. /** @hidden */
  120295. _comparisonFunction: number;
  120296. /** @hidden */
  120297. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120298. /** @hidden */
  120299. _lodGenerationScale: number;
  120300. /** @hidden */
  120301. _lodGenerationOffset: number;
  120302. /** @hidden */
  120303. _depthStencilTexture: Nullable<InternalTexture>;
  120304. /** @hidden */
  120305. _colorTextureArray: Nullable<WebGLTexture>;
  120306. /** @hidden */
  120307. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120308. /** @hidden */
  120309. _lodTextureHigh: Nullable<BaseTexture>;
  120310. /** @hidden */
  120311. _lodTextureMid: Nullable<BaseTexture>;
  120312. /** @hidden */
  120313. _lodTextureLow: Nullable<BaseTexture>;
  120314. /** @hidden */
  120315. _isRGBD: boolean;
  120316. /** @hidden */
  120317. _linearSpecularLOD: boolean;
  120318. /** @hidden */
  120319. _irradianceTexture: Nullable<BaseTexture>;
  120320. /** @hidden */
  120321. _webGLTexture: Nullable<WebGLTexture>;
  120322. /** @hidden */
  120323. _references: number;
  120324. /** @hidden */
  120325. _gammaSpace: Nullable<boolean>;
  120326. private _engine;
  120327. /**
  120328. * Gets the Engine the texture belongs to.
  120329. * @returns The babylon engine
  120330. */
  120331. getEngine(): ThinEngine;
  120332. /**
  120333. * Gets the data source type of the texture
  120334. */
  120335. get source(): InternalTextureSource;
  120336. /**
  120337. * Creates a new InternalTexture
  120338. * @param engine defines the engine to use
  120339. * @param source defines the type of data that will be used
  120340. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120341. */
  120342. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120343. /**
  120344. * Increments the number of references (ie. the number of Texture that point to it)
  120345. */
  120346. incrementReferences(): void;
  120347. /**
  120348. * Change the size of the texture (not the size of the content)
  120349. * @param width defines the new width
  120350. * @param height defines the new height
  120351. * @param depth defines the new depth (1 by default)
  120352. */
  120353. updateSize(width: int, height: int, depth?: int): void;
  120354. /** @hidden */
  120355. _rebuild(): void;
  120356. /** @hidden */
  120357. _swapAndDie(target: InternalTexture): void;
  120358. /**
  120359. * Dispose the current allocated resources
  120360. */
  120361. dispose(): void;
  120362. }
  120363. }
  120364. declare module BABYLON {
  120365. /**
  120366. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120368. */
  120369. export class Analyser {
  120370. /**
  120371. * Gets or sets the smoothing
  120372. * @ignorenaming
  120373. */
  120374. SMOOTHING: number;
  120375. /**
  120376. * Gets or sets the FFT table size
  120377. * @ignorenaming
  120378. */
  120379. FFT_SIZE: number;
  120380. /**
  120381. * Gets or sets the bar graph amplitude
  120382. * @ignorenaming
  120383. */
  120384. BARGRAPHAMPLITUDE: number;
  120385. /**
  120386. * Gets or sets the position of the debug canvas
  120387. * @ignorenaming
  120388. */
  120389. DEBUGCANVASPOS: {
  120390. x: number;
  120391. y: number;
  120392. };
  120393. /**
  120394. * Gets or sets the debug canvas size
  120395. * @ignorenaming
  120396. */
  120397. DEBUGCANVASSIZE: {
  120398. width: number;
  120399. height: number;
  120400. };
  120401. private _byteFreqs;
  120402. private _byteTime;
  120403. private _floatFreqs;
  120404. private _webAudioAnalyser;
  120405. private _debugCanvas;
  120406. private _debugCanvasContext;
  120407. private _scene;
  120408. private _registerFunc;
  120409. private _audioEngine;
  120410. /**
  120411. * Creates a new analyser
  120412. * @param scene defines hosting scene
  120413. */
  120414. constructor(scene: Scene);
  120415. /**
  120416. * Get the number of data values you will have to play with for the visualization
  120417. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120418. * @returns a number
  120419. */
  120420. getFrequencyBinCount(): number;
  120421. /**
  120422. * Gets the current frequency data as a byte array
  120423. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120424. * @returns a Uint8Array
  120425. */
  120426. getByteFrequencyData(): Uint8Array;
  120427. /**
  120428. * Gets the current waveform as a byte array
  120429. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120430. * @returns a Uint8Array
  120431. */
  120432. getByteTimeDomainData(): Uint8Array;
  120433. /**
  120434. * Gets the current frequency data as a float array
  120435. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120436. * @returns a Float32Array
  120437. */
  120438. getFloatFrequencyData(): Float32Array;
  120439. /**
  120440. * Renders the debug canvas
  120441. */
  120442. drawDebugCanvas(): void;
  120443. /**
  120444. * Stops rendering the debug canvas and removes it
  120445. */
  120446. stopDebugCanvas(): void;
  120447. /**
  120448. * Connects two audio nodes
  120449. * @param inputAudioNode defines first node to connect
  120450. * @param outputAudioNode defines second node to connect
  120451. */
  120452. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120453. /**
  120454. * Releases all associated resources
  120455. */
  120456. dispose(): void;
  120457. }
  120458. }
  120459. declare module BABYLON {
  120460. /**
  120461. * This represents an audio engine and it is responsible
  120462. * to play, synchronize and analyse sounds throughout the application.
  120463. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120464. */
  120465. export interface IAudioEngine extends IDisposable {
  120466. /**
  120467. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120468. */
  120469. readonly canUseWebAudio: boolean;
  120470. /**
  120471. * Gets the current AudioContext if available.
  120472. */
  120473. readonly audioContext: Nullable<AudioContext>;
  120474. /**
  120475. * The master gain node defines the global audio volume of your audio engine.
  120476. */
  120477. readonly masterGain: GainNode;
  120478. /**
  120479. * Gets whether or not mp3 are supported by your browser.
  120480. */
  120481. readonly isMP3supported: boolean;
  120482. /**
  120483. * Gets whether or not ogg are supported by your browser.
  120484. */
  120485. readonly isOGGsupported: boolean;
  120486. /**
  120487. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120488. * @ignoreNaming
  120489. */
  120490. WarnedWebAudioUnsupported: boolean;
  120491. /**
  120492. * Defines if the audio engine relies on a custom unlocked button.
  120493. * In this case, the embedded button will not be displayed.
  120494. */
  120495. useCustomUnlockedButton: boolean;
  120496. /**
  120497. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120498. */
  120499. readonly unlocked: boolean;
  120500. /**
  120501. * Event raised when audio has been unlocked on the browser.
  120502. */
  120503. onAudioUnlockedObservable: Observable<AudioEngine>;
  120504. /**
  120505. * Event raised when audio has been locked on the browser.
  120506. */
  120507. onAudioLockedObservable: Observable<AudioEngine>;
  120508. /**
  120509. * Flags the audio engine in Locked state.
  120510. * This happens due to new browser policies preventing audio to autoplay.
  120511. */
  120512. lock(): void;
  120513. /**
  120514. * Unlocks the audio engine once a user action has been done on the dom.
  120515. * This is helpful to resume play once browser policies have been satisfied.
  120516. */
  120517. unlock(): void;
  120518. /**
  120519. * Gets the global volume sets on the master gain.
  120520. * @returns the global volume if set or -1 otherwise
  120521. */
  120522. getGlobalVolume(): number;
  120523. /**
  120524. * Sets the global volume of your experience (sets on the master gain).
  120525. * @param newVolume Defines the new global volume of the application
  120526. */
  120527. setGlobalVolume(newVolume: number): void;
  120528. /**
  120529. * Connect the audio engine to an audio analyser allowing some amazing
  120530. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120532. * @param analyser The analyser to connect to the engine
  120533. */
  120534. connectToAnalyser(analyser: Analyser): void;
  120535. }
  120536. /**
  120537. * This represents the default audio engine used in babylon.
  120538. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120540. */
  120541. export class AudioEngine implements IAudioEngine {
  120542. private _audioContext;
  120543. private _audioContextInitialized;
  120544. private _muteButton;
  120545. private _hostElement;
  120546. /**
  120547. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120548. */
  120549. canUseWebAudio: boolean;
  120550. /**
  120551. * The master gain node defines the global audio volume of your audio engine.
  120552. */
  120553. masterGain: GainNode;
  120554. /**
  120555. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120556. * @ignoreNaming
  120557. */
  120558. WarnedWebAudioUnsupported: boolean;
  120559. /**
  120560. * Gets whether or not mp3 are supported by your browser.
  120561. */
  120562. isMP3supported: boolean;
  120563. /**
  120564. * Gets whether or not ogg are supported by your browser.
  120565. */
  120566. isOGGsupported: boolean;
  120567. /**
  120568. * Gets whether audio has been unlocked on the device.
  120569. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120570. * a user interaction has happened.
  120571. */
  120572. unlocked: boolean;
  120573. /**
  120574. * Defines if the audio engine relies on a custom unlocked button.
  120575. * In this case, the embedded button will not be displayed.
  120576. */
  120577. useCustomUnlockedButton: boolean;
  120578. /**
  120579. * Event raised when audio has been unlocked on the browser.
  120580. */
  120581. onAudioUnlockedObservable: Observable<AudioEngine>;
  120582. /**
  120583. * Event raised when audio has been locked on the browser.
  120584. */
  120585. onAudioLockedObservable: Observable<AudioEngine>;
  120586. /**
  120587. * Gets the current AudioContext if available.
  120588. */
  120589. get audioContext(): Nullable<AudioContext>;
  120590. private _connectedAnalyser;
  120591. /**
  120592. * Instantiates a new audio engine.
  120593. *
  120594. * There should be only one per page as some browsers restrict the number
  120595. * of audio contexts you can create.
  120596. * @param hostElement defines the host element where to display the mute icon if necessary
  120597. */
  120598. constructor(hostElement?: Nullable<HTMLElement>);
  120599. /**
  120600. * Flags the audio engine in Locked state.
  120601. * This happens due to new browser policies preventing audio to autoplay.
  120602. */
  120603. lock(): void;
  120604. /**
  120605. * Unlocks the audio engine once a user action has been done on the dom.
  120606. * This is helpful to resume play once browser policies have been satisfied.
  120607. */
  120608. unlock(): void;
  120609. private _resumeAudioContext;
  120610. private _initializeAudioContext;
  120611. private _tryToRun;
  120612. private _triggerRunningState;
  120613. private _triggerSuspendedState;
  120614. private _displayMuteButton;
  120615. private _moveButtonToTopLeft;
  120616. private _onResize;
  120617. private _hideMuteButton;
  120618. /**
  120619. * Destroy and release the resources associated with the audio ccontext.
  120620. */
  120621. dispose(): void;
  120622. /**
  120623. * Gets the global volume sets on the master gain.
  120624. * @returns the global volume if set or -1 otherwise
  120625. */
  120626. getGlobalVolume(): number;
  120627. /**
  120628. * Sets the global volume of your experience (sets on the master gain).
  120629. * @param newVolume Defines the new global volume of the application
  120630. */
  120631. setGlobalVolume(newVolume: number): void;
  120632. /**
  120633. * Connect the audio engine to an audio analyser allowing some amazing
  120634. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120636. * @param analyser The analyser to connect to the engine
  120637. */
  120638. connectToAnalyser(analyser: Analyser): void;
  120639. }
  120640. }
  120641. declare module BABYLON {
  120642. /**
  120643. * Interface used to present a loading screen while loading a scene
  120644. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120645. */
  120646. export interface ILoadingScreen {
  120647. /**
  120648. * Function called to display the loading screen
  120649. */
  120650. displayLoadingUI: () => void;
  120651. /**
  120652. * Function called to hide the loading screen
  120653. */
  120654. hideLoadingUI: () => void;
  120655. /**
  120656. * Gets or sets the color to use for the background
  120657. */
  120658. loadingUIBackgroundColor: string;
  120659. /**
  120660. * Gets or sets the text to display while loading
  120661. */
  120662. loadingUIText: string;
  120663. }
  120664. /**
  120665. * Class used for the default loading screen
  120666. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120667. */
  120668. export class DefaultLoadingScreen implements ILoadingScreen {
  120669. private _renderingCanvas;
  120670. private _loadingText;
  120671. private _loadingDivBackgroundColor;
  120672. private _loadingDiv;
  120673. private _loadingTextDiv;
  120674. /** Gets or sets the logo url to use for the default loading screen */
  120675. static DefaultLogoUrl: string;
  120676. /** Gets or sets the spinner url to use for the default loading screen */
  120677. static DefaultSpinnerUrl: string;
  120678. /**
  120679. * Creates a new default loading screen
  120680. * @param _renderingCanvas defines the canvas used to render the scene
  120681. * @param _loadingText defines the default text to display
  120682. * @param _loadingDivBackgroundColor defines the default background color
  120683. */
  120684. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120685. /**
  120686. * Function called to display the loading screen
  120687. */
  120688. displayLoadingUI(): void;
  120689. /**
  120690. * Function called to hide the loading screen
  120691. */
  120692. hideLoadingUI(): void;
  120693. /**
  120694. * Gets or sets the text to display while loading
  120695. */
  120696. set loadingUIText(text: string);
  120697. get loadingUIText(): string;
  120698. /**
  120699. * Gets or sets the color to use for the background
  120700. */
  120701. get loadingUIBackgroundColor(): string;
  120702. set loadingUIBackgroundColor(color: string);
  120703. private _resizeLoadingUI;
  120704. }
  120705. }
  120706. declare module BABYLON {
  120707. /**
  120708. * Interface for any object that can request an animation frame
  120709. */
  120710. export interface ICustomAnimationFrameRequester {
  120711. /**
  120712. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120713. */
  120714. renderFunction?: Function;
  120715. /**
  120716. * Called to request the next frame to render to
  120717. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120718. */
  120719. requestAnimationFrame: Function;
  120720. /**
  120721. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120722. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120723. */
  120724. requestID?: number;
  120725. }
  120726. }
  120727. declare module BABYLON {
  120728. /**
  120729. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120730. */
  120731. export class PerformanceMonitor {
  120732. private _enabled;
  120733. private _rollingFrameTime;
  120734. private _lastFrameTimeMs;
  120735. /**
  120736. * constructor
  120737. * @param frameSampleSize The number of samples required to saturate the sliding window
  120738. */
  120739. constructor(frameSampleSize?: number);
  120740. /**
  120741. * Samples current frame
  120742. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120743. */
  120744. sampleFrame(timeMs?: number): void;
  120745. /**
  120746. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120747. */
  120748. get averageFrameTime(): number;
  120749. /**
  120750. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120751. */
  120752. get averageFrameTimeVariance(): number;
  120753. /**
  120754. * Returns the frame time of the most recent frame
  120755. */
  120756. get instantaneousFrameTime(): number;
  120757. /**
  120758. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120759. */
  120760. get averageFPS(): number;
  120761. /**
  120762. * Returns the average framerate in frames per second using the most recent frame time
  120763. */
  120764. get instantaneousFPS(): number;
  120765. /**
  120766. * Returns true if enough samples have been taken to completely fill the sliding window
  120767. */
  120768. get isSaturated(): boolean;
  120769. /**
  120770. * Enables contributions to the sliding window sample set
  120771. */
  120772. enable(): void;
  120773. /**
  120774. * Disables contributions to the sliding window sample set
  120775. * Samples will not be interpolated over the disabled period
  120776. */
  120777. disable(): void;
  120778. /**
  120779. * Returns true if sampling is enabled
  120780. */
  120781. get isEnabled(): boolean;
  120782. /**
  120783. * Resets performance monitor
  120784. */
  120785. reset(): void;
  120786. }
  120787. /**
  120788. * RollingAverage
  120789. *
  120790. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120791. */
  120792. export class RollingAverage {
  120793. /**
  120794. * Current average
  120795. */
  120796. average: number;
  120797. /**
  120798. * Current variance
  120799. */
  120800. variance: number;
  120801. protected _samples: Array<number>;
  120802. protected _sampleCount: number;
  120803. protected _pos: number;
  120804. protected _m2: number;
  120805. /**
  120806. * constructor
  120807. * @param length The number of samples required to saturate the sliding window
  120808. */
  120809. constructor(length: number);
  120810. /**
  120811. * Adds a sample to the sample set
  120812. * @param v The sample value
  120813. */
  120814. add(v: number): void;
  120815. /**
  120816. * Returns previously added values or null if outside of history or outside the sliding window domain
  120817. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  120818. * @return Value previously recorded with add() or null if outside of range
  120819. */
  120820. history(i: number): number;
  120821. /**
  120822. * Returns true if enough samples have been taken to completely fill the sliding window
  120823. * @return true if sample-set saturated
  120824. */
  120825. isSaturated(): boolean;
  120826. /**
  120827. * Resets the rolling average (equivalent to 0 samples taken so far)
  120828. */
  120829. reset(): void;
  120830. /**
  120831. * Wraps a value around the sample range boundaries
  120832. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  120833. * @return Wrapped position in sample range
  120834. */
  120835. protected _wrapPosition(i: number): number;
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * This class is used to track a performance counter which is number based.
  120841. * The user has access to many properties which give statistics of different nature.
  120842. *
  120843. * The implementer can track two kinds of Performance Counter: time and count.
  120844. * 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.
  120845. * 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.
  120846. */
  120847. export class PerfCounter {
  120848. /**
  120849. * Gets or sets a global boolean to turn on and off all the counters
  120850. */
  120851. static Enabled: boolean;
  120852. /**
  120853. * Returns the smallest value ever
  120854. */
  120855. get min(): number;
  120856. /**
  120857. * Returns the biggest value ever
  120858. */
  120859. get max(): number;
  120860. /**
  120861. * Returns the average value since the performance counter is running
  120862. */
  120863. get average(): number;
  120864. /**
  120865. * Returns the average value of the last second the counter was monitored
  120866. */
  120867. get lastSecAverage(): number;
  120868. /**
  120869. * Returns the current value
  120870. */
  120871. get current(): number;
  120872. /**
  120873. * Gets the accumulated total
  120874. */
  120875. get total(): number;
  120876. /**
  120877. * Gets the total value count
  120878. */
  120879. get count(): number;
  120880. /**
  120881. * Creates a new counter
  120882. */
  120883. constructor();
  120884. /**
  120885. * Call this method to start monitoring a new frame.
  120886. * 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.
  120887. */
  120888. fetchNewFrame(): void;
  120889. /**
  120890. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  120891. * @param newCount the count value to add to the monitored count
  120892. * @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.
  120893. */
  120894. addCount(newCount: number, fetchResult: boolean): void;
  120895. /**
  120896. * Start monitoring this performance counter
  120897. */
  120898. beginMonitoring(): void;
  120899. /**
  120900. * Compute the time lapsed since the previous beginMonitoring() call.
  120901. * @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
  120902. */
  120903. endMonitoring(newFrame?: boolean): void;
  120904. private _fetchResult;
  120905. private _startMonitoringTime;
  120906. private _min;
  120907. private _max;
  120908. private _average;
  120909. private _current;
  120910. private _totalValueCount;
  120911. private _totalAccumulated;
  120912. private _lastSecAverage;
  120913. private _lastSecAccumulated;
  120914. private _lastSecTime;
  120915. private _lastSecValueCount;
  120916. }
  120917. }
  120918. declare module BABYLON {
  120919. interface ThinEngine {
  120920. /** @hidden */
  120921. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  120922. }
  120923. }
  120924. declare module BABYLON {
  120925. /**
  120926. * Defines the interface used by display changed events
  120927. */
  120928. export interface IDisplayChangedEventArgs {
  120929. /** Gets the vrDisplay object (if any) */
  120930. vrDisplay: Nullable<any>;
  120931. /** Gets a boolean indicating if webVR is supported */
  120932. vrSupported: boolean;
  120933. }
  120934. /**
  120935. * Defines the interface used by objects containing a viewport (like a camera)
  120936. */
  120937. interface IViewportOwnerLike {
  120938. /**
  120939. * Gets or sets the viewport
  120940. */
  120941. viewport: IViewportLike;
  120942. }
  120943. /**
  120944. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  120945. */
  120946. export class Engine extends ThinEngine {
  120947. /** Defines that alpha blending is disabled */
  120948. static readonly ALPHA_DISABLE: number;
  120949. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  120950. static readonly ALPHA_ADD: number;
  120951. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  120952. static readonly ALPHA_COMBINE: number;
  120953. /** Defines that alpha blending to DEST - SRC * DEST */
  120954. static readonly ALPHA_SUBTRACT: number;
  120955. /** Defines that alpha blending to SRC * DEST */
  120956. static readonly ALPHA_MULTIPLY: number;
  120957. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  120958. static readonly ALPHA_MAXIMIZED: number;
  120959. /** Defines that alpha blending to SRC + DEST */
  120960. static readonly ALPHA_ONEONE: number;
  120961. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  120962. static readonly ALPHA_PREMULTIPLIED: number;
  120963. /**
  120964. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  120965. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  120966. */
  120967. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  120968. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  120969. static readonly ALPHA_INTERPOLATE: number;
  120970. /**
  120971. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  120972. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  120973. */
  120974. static readonly ALPHA_SCREENMODE: number;
  120975. /** Defines that the ressource is not delayed*/
  120976. static readonly DELAYLOADSTATE_NONE: number;
  120977. /** Defines that the ressource was successfully delay loaded */
  120978. static readonly DELAYLOADSTATE_LOADED: number;
  120979. /** Defines that the ressource is currently delay loading */
  120980. static readonly DELAYLOADSTATE_LOADING: number;
  120981. /** Defines that the ressource is delayed and has not started loading */
  120982. static readonly DELAYLOADSTATE_NOTLOADED: number;
  120983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  120984. static readonly NEVER: number;
  120985. /** 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 */
  120986. static readonly ALWAYS: number;
  120987. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  120988. static readonly LESS: number;
  120989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  120990. static readonly EQUAL: number;
  120991. /** 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 */
  120992. static readonly LEQUAL: number;
  120993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  120994. static readonly GREATER: number;
  120995. /** 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 */
  120996. static readonly GEQUAL: number;
  120997. /** 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 */
  120998. static readonly NOTEQUAL: number;
  120999. /** Passed to stencilOperation to specify that stencil value must be kept */
  121000. static readonly KEEP: number;
  121001. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121002. static readonly REPLACE: number;
  121003. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121004. static readonly INCR: number;
  121005. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121006. static readonly DECR: number;
  121007. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121008. static readonly INVERT: number;
  121009. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121010. static readonly INCR_WRAP: number;
  121011. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121012. static readonly DECR_WRAP: number;
  121013. /** Texture is not repeating outside of 0..1 UVs */
  121014. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121015. /** Texture is repeating outside of 0..1 UVs */
  121016. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121017. /** Texture is repeating and mirrored */
  121018. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121019. /** ALPHA */
  121020. static readonly TEXTUREFORMAT_ALPHA: number;
  121021. /** LUMINANCE */
  121022. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121023. /** LUMINANCE_ALPHA */
  121024. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121025. /** RGB */
  121026. static readonly TEXTUREFORMAT_RGB: number;
  121027. /** RGBA */
  121028. static readonly TEXTUREFORMAT_RGBA: number;
  121029. /** RED */
  121030. static readonly TEXTUREFORMAT_RED: number;
  121031. /** RED (2nd reference) */
  121032. static readonly TEXTUREFORMAT_R: number;
  121033. /** RG */
  121034. static readonly TEXTUREFORMAT_RG: number;
  121035. /** RED_INTEGER */
  121036. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121037. /** RED_INTEGER (2nd reference) */
  121038. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121039. /** RG_INTEGER */
  121040. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121041. /** RGB_INTEGER */
  121042. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121043. /** RGBA_INTEGER */
  121044. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121045. /** UNSIGNED_BYTE */
  121046. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121047. /** UNSIGNED_BYTE (2nd reference) */
  121048. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121049. /** FLOAT */
  121050. static readonly TEXTURETYPE_FLOAT: number;
  121051. /** HALF_FLOAT */
  121052. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121053. /** BYTE */
  121054. static readonly TEXTURETYPE_BYTE: number;
  121055. /** SHORT */
  121056. static readonly TEXTURETYPE_SHORT: number;
  121057. /** UNSIGNED_SHORT */
  121058. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121059. /** INT */
  121060. static readonly TEXTURETYPE_INT: number;
  121061. /** UNSIGNED_INT */
  121062. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121063. /** UNSIGNED_SHORT_4_4_4_4 */
  121064. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121065. /** UNSIGNED_SHORT_5_5_5_1 */
  121066. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121067. /** UNSIGNED_SHORT_5_6_5 */
  121068. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121069. /** UNSIGNED_INT_2_10_10_10_REV */
  121070. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121071. /** UNSIGNED_INT_24_8 */
  121072. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121073. /** UNSIGNED_INT_10F_11F_11F_REV */
  121074. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121075. /** UNSIGNED_INT_5_9_9_9_REV */
  121076. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121077. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121078. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121079. /** nearest is mag = nearest and min = nearest and mip = linear */
  121080. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121082. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121083. /** Trilinear is mag = linear and min = linear and mip = linear */
  121084. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121085. /** nearest is mag = nearest and min = nearest and mip = linear */
  121086. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121088. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121089. /** Trilinear is mag = linear and min = linear and mip = linear */
  121090. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121091. /** mag = nearest and min = nearest and mip = nearest */
  121092. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121093. /** mag = nearest and min = linear and mip = nearest */
  121094. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121095. /** mag = nearest and min = linear and mip = linear */
  121096. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121097. /** mag = nearest and min = linear and mip = none */
  121098. static readonly TEXTURE_NEAREST_LINEAR: number;
  121099. /** mag = nearest and min = nearest and mip = none */
  121100. static readonly TEXTURE_NEAREST_NEAREST: number;
  121101. /** mag = linear and min = nearest and mip = nearest */
  121102. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121103. /** mag = linear and min = nearest and mip = linear */
  121104. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121105. /** mag = linear and min = linear and mip = none */
  121106. static readonly TEXTURE_LINEAR_LINEAR: number;
  121107. /** mag = linear and min = nearest and mip = none */
  121108. static readonly TEXTURE_LINEAR_NEAREST: number;
  121109. /** Explicit coordinates mode */
  121110. static readonly TEXTURE_EXPLICIT_MODE: number;
  121111. /** Spherical coordinates mode */
  121112. static readonly TEXTURE_SPHERICAL_MODE: number;
  121113. /** Planar coordinates mode */
  121114. static readonly TEXTURE_PLANAR_MODE: number;
  121115. /** Cubic coordinates mode */
  121116. static readonly TEXTURE_CUBIC_MODE: number;
  121117. /** Projection coordinates mode */
  121118. static readonly TEXTURE_PROJECTION_MODE: number;
  121119. /** Skybox coordinates mode */
  121120. static readonly TEXTURE_SKYBOX_MODE: number;
  121121. /** Inverse Cubic coordinates mode */
  121122. static readonly TEXTURE_INVCUBIC_MODE: number;
  121123. /** Equirectangular coordinates mode */
  121124. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121125. /** Equirectangular Fixed coordinates mode */
  121126. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121127. /** Equirectangular Fixed Mirrored coordinates mode */
  121128. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121129. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121130. static readonly SCALEMODE_FLOOR: number;
  121131. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121132. static readonly SCALEMODE_NEAREST: number;
  121133. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121134. static readonly SCALEMODE_CEILING: number;
  121135. /**
  121136. * Returns the current npm package of the sdk
  121137. */
  121138. static get NpmPackage(): string;
  121139. /**
  121140. * Returns the current version of the framework
  121141. */
  121142. static get Version(): string;
  121143. /** Gets the list of created engines */
  121144. static get Instances(): Engine[];
  121145. /**
  121146. * Gets the latest created engine
  121147. */
  121148. static get LastCreatedEngine(): Nullable<Engine>;
  121149. /**
  121150. * Gets the latest created scene
  121151. */
  121152. static get LastCreatedScene(): Nullable<Scene>;
  121153. /**
  121154. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121155. * @param flag defines which part of the materials must be marked as dirty
  121156. * @param predicate defines a predicate used to filter which materials should be affected
  121157. */
  121158. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121159. /**
  121160. * Method called to create the default loading screen.
  121161. * This can be overriden in your own app.
  121162. * @param canvas The rendering canvas element
  121163. * @returns The loading screen
  121164. */
  121165. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121166. /**
  121167. * Method called to create the default rescale post process on each engine.
  121168. */
  121169. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121170. /**
  121171. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121172. **/
  121173. enableOfflineSupport: boolean;
  121174. /**
  121175. * 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)
  121176. **/
  121177. disableManifestCheck: boolean;
  121178. /**
  121179. * Gets the list of created scenes
  121180. */
  121181. scenes: Scene[];
  121182. /**
  121183. * Event raised when a new scene is created
  121184. */
  121185. onNewSceneAddedObservable: Observable<Scene>;
  121186. /**
  121187. * Gets the list of created postprocesses
  121188. */
  121189. postProcesses: PostProcess[];
  121190. /**
  121191. * Gets a boolean indicating if the pointer is currently locked
  121192. */
  121193. isPointerLock: boolean;
  121194. /**
  121195. * Observable event triggered each time the rendering canvas is resized
  121196. */
  121197. onResizeObservable: Observable<Engine>;
  121198. /**
  121199. * Observable event triggered each time the canvas loses focus
  121200. */
  121201. onCanvasBlurObservable: Observable<Engine>;
  121202. /**
  121203. * Observable event triggered each time the canvas gains focus
  121204. */
  121205. onCanvasFocusObservable: Observable<Engine>;
  121206. /**
  121207. * Observable event triggered each time the canvas receives pointerout event
  121208. */
  121209. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121210. /**
  121211. * Observable raised when the engine begins a new frame
  121212. */
  121213. onBeginFrameObservable: Observable<Engine>;
  121214. /**
  121215. * If set, will be used to request the next animation frame for the render loop
  121216. */
  121217. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121218. /**
  121219. * Observable raised when the engine ends the current frame
  121220. */
  121221. onEndFrameObservable: Observable<Engine>;
  121222. /**
  121223. * Observable raised when the engine is about to compile a shader
  121224. */
  121225. onBeforeShaderCompilationObservable: Observable<Engine>;
  121226. /**
  121227. * Observable raised when the engine has jsut compiled a shader
  121228. */
  121229. onAfterShaderCompilationObservable: Observable<Engine>;
  121230. /**
  121231. * Gets the audio engine
  121232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121233. * @ignorenaming
  121234. */
  121235. static audioEngine: IAudioEngine;
  121236. /**
  121237. * Default AudioEngine factory responsible of creating the Audio Engine.
  121238. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121239. */
  121240. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121241. /**
  121242. * Default offline support factory responsible of creating a tool used to store data locally.
  121243. * By default, this will create a Database object if the workload has been embedded.
  121244. */
  121245. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121246. private _loadingScreen;
  121247. private _pointerLockRequested;
  121248. private _rescalePostProcess;
  121249. private _deterministicLockstep;
  121250. private _lockstepMaxSteps;
  121251. private _timeStep;
  121252. protected get _supportsHardwareTextureRescaling(): boolean;
  121253. private _fps;
  121254. private _deltaTime;
  121255. /** @hidden */
  121256. _drawCalls: PerfCounter;
  121257. /** 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 */
  121258. canvasTabIndex: number;
  121259. /**
  121260. * Turn this value on if you want to pause FPS computation when in background
  121261. */
  121262. disablePerformanceMonitorInBackground: boolean;
  121263. private _performanceMonitor;
  121264. /**
  121265. * Gets the performance monitor attached to this engine
  121266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121267. */
  121268. get performanceMonitor(): PerformanceMonitor;
  121269. private _onFocus;
  121270. private _onBlur;
  121271. private _onCanvasPointerOut;
  121272. private _onCanvasBlur;
  121273. private _onCanvasFocus;
  121274. private _onFullscreenChange;
  121275. private _onPointerLockChange;
  121276. /**
  121277. * Gets the HTML element used to attach event listeners
  121278. * @returns a HTML element
  121279. */
  121280. getInputElement(): Nullable<HTMLElement>;
  121281. /**
  121282. * Creates a new engine
  121283. * @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
  121284. * @param antialias defines enable antialiasing (default: false)
  121285. * @param options defines further options to be sent to the getContext() function
  121286. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121287. */
  121288. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121289. /**
  121290. * Gets current aspect ratio
  121291. * @param viewportOwner defines the camera to use to get the aspect ratio
  121292. * @param useScreen defines if screen size must be used (or the current render target if any)
  121293. * @returns a number defining the aspect ratio
  121294. */
  121295. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121296. /**
  121297. * Gets current screen aspect ratio
  121298. * @returns a number defining the aspect ratio
  121299. */
  121300. getScreenAspectRatio(): number;
  121301. /**
  121302. * Gets the client rect of the HTML canvas attached with the current webGL context
  121303. * @returns a client rectanglee
  121304. */
  121305. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121306. /**
  121307. * Gets the client rect of the HTML element used for events
  121308. * @returns a client rectanglee
  121309. */
  121310. getInputElementClientRect(): Nullable<ClientRect>;
  121311. /**
  121312. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121314. * @returns true if engine is in deterministic lock step mode
  121315. */
  121316. isDeterministicLockStep(): boolean;
  121317. /**
  121318. * Gets the max steps when engine is running in deterministic lock step
  121319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121320. * @returns the max steps
  121321. */
  121322. getLockstepMaxSteps(): number;
  121323. /**
  121324. * Returns the time in ms between steps when using deterministic lock step.
  121325. * @returns time step in (ms)
  121326. */
  121327. getTimeStep(): number;
  121328. /**
  121329. * Force the mipmap generation for the given render target texture
  121330. * @param texture defines the render target texture to use
  121331. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121332. */
  121333. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121334. /** States */
  121335. /**
  121336. * Set various states to the webGL context
  121337. * @param culling defines backface culling state
  121338. * @param zOffset defines the value to apply to zOffset (0 by default)
  121339. * @param force defines if states must be applied even if cache is up to date
  121340. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121341. */
  121342. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121343. /**
  121344. * Set the z offset to apply to current rendering
  121345. * @param value defines the offset to apply
  121346. */
  121347. setZOffset(value: number): void;
  121348. /**
  121349. * Gets the current value of the zOffset
  121350. * @returns the current zOffset state
  121351. */
  121352. getZOffset(): number;
  121353. /**
  121354. * Enable or disable depth buffering
  121355. * @param enable defines the state to set
  121356. */
  121357. setDepthBuffer(enable: boolean): void;
  121358. /**
  121359. * Gets a boolean indicating if depth writing is enabled
  121360. * @returns the current depth writing state
  121361. */
  121362. getDepthWrite(): boolean;
  121363. /**
  121364. * Enable or disable depth writing
  121365. * @param enable defines the state to set
  121366. */
  121367. setDepthWrite(enable: boolean): void;
  121368. /**
  121369. * Gets a boolean indicating if stencil buffer is enabled
  121370. * @returns the current stencil buffer state
  121371. */
  121372. getStencilBuffer(): boolean;
  121373. /**
  121374. * Enable or disable the stencil buffer
  121375. * @param enable defines if the stencil buffer must be enabled or disabled
  121376. */
  121377. setStencilBuffer(enable: boolean): void;
  121378. /**
  121379. * Gets the current stencil mask
  121380. * @returns a number defining the new stencil mask to use
  121381. */
  121382. getStencilMask(): number;
  121383. /**
  121384. * Sets the current stencil mask
  121385. * @param mask defines the new stencil mask to use
  121386. */
  121387. setStencilMask(mask: number): void;
  121388. /**
  121389. * Gets the current stencil function
  121390. * @returns a number defining the stencil function to use
  121391. */
  121392. getStencilFunction(): number;
  121393. /**
  121394. * Gets the current stencil reference value
  121395. * @returns a number defining the stencil reference value to use
  121396. */
  121397. getStencilFunctionReference(): number;
  121398. /**
  121399. * Gets the current stencil mask
  121400. * @returns a number defining the stencil mask to use
  121401. */
  121402. getStencilFunctionMask(): number;
  121403. /**
  121404. * Sets the current stencil function
  121405. * @param stencilFunc defines the new stencil function to use
  121406. */
  121407. setStencilFunction(stencilFunc: number): void;
  121408. /**
  121409. * Sets the current stencil reference
  121410. * @param reference defines the new stencil reference to use
  121411. */
  121412. setStencilFunctionReference(reference: number): void;
  121413. /**
  121414. * Sets the current stencil mask
  121415. * @param mask defines the new stencil mask to use
  121416. */
  121417. setStencilFunctionMask(mask: number): void;
  121418. /**
  121419. * Gets the current stencil operation when stencil fails
  121420. * @returns a number defining stencil operation to use when stencil fails
  121421. */
  121422. getStencilOperationFail(): number;
  121423. /**
  121424. * Gets the current stencil operation when depth fails
  121425. * @returns a number defining stencil operation to use when depth fails
  121426. */
  121427. getStencilOperationDepthFail(): number;
  121428. /**
  121429. * Gets the current stencil operation when stencil passes
  121430. * @returns a number defining stencil operation to use when stencil passes
  121431. */
  121432. getStencilOperationPass(): number;
  121433. /**
  121434. * Sets the stencil operation to use when stencil fails
  121435. * @param operation defines the stencil operation to use when stencil fails
  121436. */
  121437. setStencilOperationFail(operation: number): void;
  121438. /**
  121439. * Sets the stencil operation to use when depth fails
  121440. * @param operation defines the stencil operation to use when depth fails
  121441. */
  121442. setStencilOperationDepthFail(operation: number): void;
  121443. /**
  121444. * Sets the stencil operation to use when stencil passes
  121445. * @param operation defines the stencil operation to use when stencil passes
  121446. */
  121447. setStencilOperationPass(operation: number): void;
  121448. /**
  121449. * Sets a boolean indicating if the dithering state is enabled or disabled
  121450. * @param value defines the dithering state
  121451. */
  121452. setDitheringState(value: boolean): void;
  121453. /**
  121454. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121455. * @param value defines the rasterizer state
  121456. */
  121457. setRasterizerState(value: boolean): void;
  121458. /**
  121459. * Gets the current depth function
  121460. * @returns a number defining the depth function
  121461. */
  121462. getDepthFunction(): Nullable<number>;
  121463. /**
  121464. * Sets the current depth function
  121465. * @param depthFunc defines the function to use
  121466. */
  121467. setDepthFunction(depthFunc: number): void;
  121468. /**
  121469. * Sets the current depth function to GREATER
  121470. */
  121471. setDepthFunctionToGreater(): void;
  121472. /**
  121473. * Sets the current depth function to GEQUAL
  121474. */
  121475. setDepthFunctionToGreaterOrEqual(): void;
  121476. /**
  121477. * Sets the current depth function to LESS
  121478. */
  121479. setDepthFunctionToLess(): void;
  121480. /**
  121481. * Sets the current depth function to LEQUAL
  121482. */
  121483. setDepthFunctionToLessOrEqual(): void;
  121484. private _cachedStencilBuffer;
  121485. private _cachedStencilFunction;
  121486. private _cachedStencilMask;
  121487. private _cachedStencilOperationPass;
  121488. private _cachedStencilOperationFail;
  121489. private _cachedStencilOperationDepthFail;
  121490. private _cachedStencilReference;
  121491. /**
  121492. * Caches the the state of the stencil buffer
  121493. */
  121494. cacheStencilState(): void;
  121495. /**
  121496. * Restores the state of the stencil buffer
  121497. */
  121498. restoreStencilState(): void;
  121499. /**
  121500. * Directly set the WebGL Viewport
  121501. * @param x defines the x coordinate of the viewport (in screen space)
  121502. * @param y defines the y coordinate of the viewport (in screen space)
  121503. * @param width defines the width of the viewport (in screen space)
  121504. * @param height defines the height of the viewport (in screen space)
  121505. * @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
  121506. */
  121507. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121508. /**
  121509. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121510. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121511. * @param y defines the y-coordinate of the corner of the clear rectangle
  121512. * @param width defines the width of the clear rectangle
  121513. * @param height defines the height of the clear rectangle
  121514. * @param clearColor defines the clear color
  121515. */
  121516. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121517. /**
  121518. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121519. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121520. * @param y defines the y-coordinate of the corner of the clear rectangle
  121521. * @param width defines the width of the clear rectangle
  121522. * @param height defines the height of the clear rectangle
  121523. */
  121524. enableScissor(x: number, y: number, width: number, height: number): void;
  121525. /**
  121526. * Disable previously set scissor test rectangle
  121527. */
  121528. disableScissor(): void;
  121529. protected _reportDrawCall(): void;
  121530. /**
  121531. * Initializes a webVR display and starts listening to display change events
  121532. * The onVRDisplayChangedObservable will be notified upon these changes
  121533. * @returns The onVRDisplayChangedObservable
  121534. */
  121535. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121536. /** @hidden */
  121537. _prepareVRComponent(): void;
  121538. /** @hidden */
  121539. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121540. /** @hidden */
  121541. _submitVRFrame(): void;
  121542. /**
  121543. * Call this function to leave webVR mode
  121544. * Will do nothing if webVR is not supported or if there is no webVR device
  121545. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121546. */
  121547. disableVR(): void;
  121548. /**
  121549. * Gets a boolean indicating that the system is in VR mode and is presenting
  121550. * @returns true if VR mode is engaged
  121551. */
  121552. isVRPresenting(): boolean;
  121553. /** @hidden */
  121554. _requestVRFrame(): void;
  121555. /** @hidden */
  121556. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121557. /**
  121558. * Gets the source code of the vertex shader associated with a specific webGL program
  121559. * @param program defines the program to use
  121560. * @returns a string containing the source code of the vertex shader associated with the program
  121561. */
  121562. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121563. /**
  121564. * Gets the source code of the fragment shader associated with a specific webGL program
  121565. * @param program defines the program to use
  121566. * @returns a string containing the source code of the fragment shader associated with the program
  121567. */
  121568. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121569. /**
  121570. * Sets a depth stencil texture from a render target to the according uniform.
  121571. * @param channel The texture channel
  121572. * @param uniform The uniform to set
  121573. * @param texture The render target texture containing the depth stencil texture to apply
  121574. */
  121575. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121576. /**
  121577. * Sets a texture to the webGL context from a postprocess
  121578. * @param channel defines the channel to use
  121579. * @param postProcess defines the source postprocess
  121580. */
  121581. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121582. /**
  121583. * Binds the output of the passed in post process to the texture channel specified
  121584. * @param channel The channel the texture should be bound to
  121585. * @param postProcess The post process which's output should be bound
  121586. */
  121587. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121588. protected _rebuildBuffers(): void;
  121589. /** @hidden */
  121590. _renderFrame(): void;
  121591. _renderLoop(): void;
  121592. /** @hidden */
  121593. _renderViews(): boolean;
  121594. /**
  121595. * Toggle full screen mode
  121596. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121597. */
  121598. switchFullscreen(requestPointerLock: boolean): void;
  121599. /**
  121600. * Enters full screen mode
  121601. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121602. */
  121603. enterFullscreen(requestPointerLock: boolean): void;
  121604. /**
  121605. * Exits full screen mode
  121606. */
  121607. exitFullscreen(): void;
  121608. /**
  121609. * Enters Pointerlock mode
  121610. */
  121611. enterPointerlock(): void;
  121612. /**
  121613. * Exits Pointerlock mode
  121614. */
  121615. exitPointerlock(): void;
  121616. /**
  121617. * Begin a new frame
  121618. */
  121619. beginFrame(): void;
  121620. /**
  121621. * Enf the current frame
  121622. */
  121623. endFrame(): void;
  121624. resize(): void;
  121625. /**
  121626. * Force a specific size of the canvas
  121627. * @param width defines the new canvas' width
  121628. * @param height defines the new canvas' height
  121629. * @returns true if the size was changed
  121630. */
  121631. setSize(width: number, height: number): boolean;
  121632. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121633. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121634. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121635. _releaseTexture(texture: InternalTexture): void;
  121636. /**
  121637. * @hidden
  121638. * Rescales a texture
  121639. * @param source input texutre
  121640. * @param destination destination texture
  121641. * @param scene scene to use to render the resize
  121642. * @param internalFormat format to use when resizing
  121643. * @param onComplete callback to be called when resize has completed
  121644. */
  121645. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121646. /**
  121647. * Gets the current framerate
  121648. * @returns a number representing the framerate
  121649. */
  121650. getFps(): number;
  121651. /**
  121652. * Gets the time spent between current and previous frame
  121653. * @returns a number representing the delta time in ms
  121654. */
  121655. getDeltaTime(): number;
  121656. private _measureFps;
  121657. /** @hidden */
  121658. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121659. /**
  121660. * Updates the sample count of a render target texture
  121661. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121662. * @param texture defines the texture to update
  121663. * @param samples defines the sample count to set
  121664. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121665. */
  121666. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121667. /**
  121668. * Updates a depth texture Comparison Mode and Function.
  121669. * If the comparison Function is equal to 0, the mode will be set to none.
  121670. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121671. * @param texture The texture to set the comparison function for
  121672. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121673. */
  121674. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121675. /**
  121676. * Creates a webGL buffer to use with instanciation
  121677. * @param capacity defines the size of the buffer
  121678. * @returns the webGL buffer
  121679. */
  121680. createInstancesBuffer(capacity: number): DataBuffer;
  121681. /**
  121682. * Delete a webGL buffer used with instanciation
  121683. * @param buffer defines the webGL buffer to delete
  121684. */
  121685. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121686. private _clientWaitAsync;
  121687. /** @hidden */
  121688. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121689. dispose(): void;
  121690. private _disableTouchAction;
  121691. /**
  121692. * Display the loading screen
  121693. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121694. */
  121695. displayLoadingUI(): void;
  121696. /**
  121697. * Hide the loading screen
  121698. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121699. */
  121700. hideLoadingUI(): void;
  121701. /**
  121702. * Gets the current loading screen object
  121703. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121704. */
  121705. get loadingScreen(): ILoadingScreen;
  121706. /**
  121707. * Sets the current loading screen object
  121708. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121709. */
  121710. set loadingScreen(loadingScreen: ILoadingScreen);
  121711. /**
  121712. * Sets the current loading screen text
  121713. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121714. */
  121715. set loadingUIText(text: string);
  121716. /**
  121717. * Sets the current loading screen background color
  121718. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121719. */
  121720. set loadingUIBackgroundColor(color: string);
  121721. /** Pointerlock and fullscreen */
  121722. /**
  121723. * Ask the browser to promote the current element to pointerlock mode
  121724. * @param element defines the DOM element to promote
  121725. */
  121726. static _RequestPointerlock(element: HTMLElement): void;
  121727. /**
  121728. * Asks the browser to exit pointerlock mode
  121729. */
  121730. static _ExitPointerlock(): void;
  121731. /**
  121732. * Ask the browser to promote the current element to fullscreen rendering mode
  121733. * @param element defines the DOM element to promote
  121734. */
  121735. static _RequestFullscreen(element: HTMLElement): void;
  121736. /**
  121737. * Asks the browser to exit fullscreen mode
  121738. */
  121739. static _ExitFullscreen(): void;
  121740. }
  121741. }
  121742. declare module BABYLON {
  121743. /**
  121744. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121745. * during the life time of the application.
  121746. */
  121747. export class EngineStore {
  121748. /** Gets the list of created engines */
  121749. static Instances: Engine[];
  121750. /** @hidden */
  121751. static _LastCreatedScene: Nullable<Scene>;
  121752. /**
  121753. * Gets the latest created engine
  121754. */
  121755. static get LastCreatedEngine(): Nullable<Engine>;
  121756. /**
  121757. * Gets the latest created scene
  121758. */
  121759. static get LastCreatedScene(): Nullable<Scene>;
  121760. /**
  121761. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121762. * @ignorenaming
  121763. */
  121764. static UseFallbackTexture: boolean;
  121765. /**
  121766. * Texture content used if a texture cannot loaded
  121767. * @ignorenaming
  121768. */
  121769. static FallbackTexture: string;
  121770. }
  121771. }
  121772. declare module BABYLON {
  121773. /**
  121774. * Helper class that provides a small promise polyfill
  121775. */
  121776. export class PromisePolyfill {
  121777. /**
  121778. * Static function used to check if the polyfill is required
  121779. * If this is the case then the function will inject the polyfill to window.Promise
  121780. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121781. */
  121782. static Apply(force?: boolean): void;
  121783. }
  121784. }
  121785. declare module BABYLON {
  121786. /**
  121787. * Interface for screenshot methods with describe argument called `size` as object with options
  121788. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121789. */
  121790. export interface IScreenshotSize {
  121791. /**
  121792. * number in pixels for canvas height
  121793. */
  121794. height?: number;
  121795. /**
  121796. * multiplier allowing render at a higher or lower resolution
  121797. * If value is defined then height and width will be ignored and taken from camera
  121798. */
  121799. precision?: number;
  121800. /**
  121801. * number in pixels for canvas width
  121802. */
  121803. width?: number;
  121804. }
  121805. }
  121806. declare module BABYLON {
  121807. interface IColor4Like {
  121808. r: float;
  121809. g: float;
  121810. b: float;
  121811. a: float;
  121812. }
  121813. /**
  121814. * Class containing a set of static utilities functions
  121815. */
  121816. export class Tools {
  121817. /**
  121818. * Gets or sets the base URL to use to load assets
  121819. */
  121820. static get BaseUrl(): string;
  121821. static set BaseUrl(value: string);
  121822. /**
  121823. * Enable/Disable Custom HTTP Request Headers globally.
  121824. * default = false
  121825. * @see CustomRequestHeaders
  121826. */
  121827. static UseCustomRequestHeaders: boolean;
  121828. /**
  121829. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  121830. * i.e. when loading files, where the server/service expects an Authorization header
  121831. */
  121832. static CustomRequestHeaders: {
  121833. [key: string]: string;
  121834. };
  121835. /**
  121836. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  121837. */
  121838. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  121839. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  121840. /**
  121841. * Default behaviour for cors in the application.
  121842. * It can be a string if the expected behavior is identical in the entire app.
  121843. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  121844. */
  121845. static get CorsBehavior(): string | ((url: string | string[]) => string);
  121846. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  121847. /**
  121848. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121849. * @ignorenaming
  121850. */
  121851. static get UseFallbackTexture(): boolean;
  121852. static set UseFallbackTexture(value: boolean);
  121853. /**
  121854. * Use this object to register external classes like custom textures or material
  121855. * to allow the laoders to instantiate them
  121856. */
  121857. static get RegisteredExternalClasses(): {
  121858. [key: string]: Object;
  121859. };
  121860. static set RegisteredExternalClasses(classes: {
  121861. [key: string]: Object;
  121862. });
  121863. /**
  121864. * Texture content used if a texture cannot loaded
  121865. * @ignorenaming
  121866. */
  121867. static get fallbackTexture(): string;
  121868. static set fallbackTexture(value: string);
  121869. /**
  121870. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  121871. * @param u defines the coordinate on X axis
  121872. * @param v defines the coordinate on Y axis
  121873. * @param width defines the width of the source data
  121874. * @param height defines the height of the source data
  121875. * @param pixels defines the source byte array
  121876. * @param color defines the output color
  121877. */
  121878. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  121879. /**
  121880. * Interpolates between a and b via alpha
  121881. * @param a The lower value (returned when alpha = 0)
  121882. * @param b The upper value (returned when alpha = 1)
  121883. * @param alpha The interpolation-factor
  121884. * @return The mixed value
  121885. */
  121886. static Mix(a: number, b: number, alpha: number): number;
  121887. /**
  121888. * Tries to instantiate a new object from a given class name
  121889. * @param className defines the class name to instantiate
  121890. * @returns the new object or null if the system was not able to do the instantiation
  121891. */
  121892. static Instantiate(className: string): any;
  121893. /**
  121894. * Provides a slice function that will work even on IE
  121895. * @param data defines the array to slice
  121896. * @param start defines the start of the data (optional)
  121897. * @param end defines the end of the data (optional)
  121898. * @returns the new sliced array
  121899. */
  121900. static Slice<T>(data: T, start?: number, end?: number): T;
  121901. /**
  121902. * Polyfill for setImmediate
  121903. * @param action defines the action to execute after the current execution block
  121904. */
  121905. static SetImmediate(action: () => void): void;
  121906. /**
  121907. * Function indicating if a number is an exponent of 2
  121908. * @param value defines the value to test
  121909. * @returns true if the value is an exponent of 2
  121910. */
  121911. static IsExponentOfTwo(value: number): boolean;
  121912. private static _tmpFloatArray;
  121913. /**
  121914. * Returns the nearest 32-bit single precision float representation of a Number
  121915. * @param value A Number. If the parameter is of a different type, it will get converted
  121916. * to a number or to NaN if it cannot be converted
  121917. * @returns number
  121918. */
  121919. static FloatRound(value: number): number;
  121920. /**
  121921. * Extracts the filename from a path
  121922. * @param path defines the path to use
  121923. * @returns the filename
  121924. */
  121925. static GetFilename(path: string): string;
  121926. /**
  121927. * Extracts the "folder" part of a path (everything before the filename).
  121928. * @param uri The URI to extract the info from
  121929. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  121930. * @returns The "folder" part of the path
  121931. */
  121932. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  121933. /**
  121934. * Extracts text content from a DOM element hierarchy
  121935. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  121936. */
  121937. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  121938. /**
  121939. * Convert an angle in radians to degrees
  121940. * @param angle defines the angle to convert
  121941. * @returns the angle in degrees
  121942. */
  121943. static ToDegrees(angle: number): number;
  121944. /**
  121945. * Convert an angle in degrees to radians
  121946. * @param angle defines the angle to convert
  121947. * @returns the angle in radians
  121948. */
  121949. static ToRadians(angle: number): number;
  121950. /**
  121951. * Returns an array if obj is not an array
  121952. * @param obj defines the object to evaluate as an array
  121953. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  121954. * @returns either obj directly if obj is an array or a new array containing obj
  121955. */
  121956. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  121957. /**
  121958. * Gets the pointer prefix to use
  121959. * @param engine defines the engine we are finding the prefix for
  121960. * @returns "pointer" if touch is enabled. Else returns "mouse"
  121961. */
  121962. static GetPointerPrefix(engine: Engine): string;
  121963. /**
  121964. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  121965. * @param url define the url we are trying
  121966. * @param element define the dom element where to configure the cors policy
  121967. */
  121968. static SetCorsBehavior(url: string | string[], element: {
  121969. crossOrigin: string | null;
  121970. }): void;
  121971. /**
  121972. * Removes unwanted characters from an url
  121973. * @param url defines the url to clean
  121974. * @returns the cleaned url
  121975. */
  121976. static CleanUrl(url: string): string;
  121977. /**
  121978. * Gets or sets a function used to pre-process url before using them to load assets
  121979. */
  121980. static get PreprocessUrl(): (url: string) => string;
  121981. static set PreprocessUrl(processor: (url: string) => string);
  121982. /**
  121983. * Loads an image as an HTMLImageElement.
  121984. * @param input url string, ArrayBuffer, or Blob to load
  121985. * @param onLoad callback called when the image successfully loads
  121986. * @param onError callback called when the image fails to load
  121987. * @param offlineProvider offline provider for caching
  121988. * @param mimeType optional mime type
  121989. * @returns the HTMLImageElement of the loaded image
  121990. */
  121991. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  121992. /**
  121993. * Loads a file from a url
  121994. * @param url url string, ArrayBuffer, or Blob to load
  121995. * @param onSuccess callback called when the file successfully loads
  121996. * @param onProgress callback called while file is loading (if the server supports this mode)
  121997. * @param offlineProvider defines the offline provider for caching
  121998. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121999. * @param onError callback called when the file fails to load
  122000. * @returns a file request object
  122001. */
  122002. 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;
  122003. /**
  122004. * Loads a file from a url
  122005. * @param url the file url to load
  122006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122007. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122008. */
  122009. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122010. /**
  122011. * Load a script (identified by an url). When the url returns, the
  122012. * content of this file is added into a new script element, attached to the DOM (body element)
  122013. * @param scriptUrl defines the url of the script to laod
  122014. * @param onSuccess defines the callback called when the script is loaded
  122015. * @param onError defines the callback to call if an error occurs
  122016. * @param scriptId defines the id of the script element
  122017. */
  122018. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122019. /**
  122020. * Load an asynchronous script (identified by an url). When the url returns, the
  122021. * content of this file is added into a new script element, attached to the DOM (body element)
  122022. * @param scriptUrl defines the url of the script to laod
  122023. * @param scriptId defines the id of the script element
  122024. * @returns a promise request object
  122025. */
  122026. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122027. /**
  122028. * Loads a file from a blob
  122029. * @param fileToLoad defines the blob to use
  122030. * @param callback defines the callback to call when data is loaded
  122031. * @param progressCallback defines the callback to call during loading process
  122032. * @returns a file request object
  122033. */
  122034. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122035. /**
  122036. * Reads a file from a File object
  122037. * @param file defines the file to load
  122038. * @param onSuccess defines the callback to call when data is loaded
  122039. * @param onProgress defines the callback to call during loading process
  122040. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122041. * @param onError defines the callback to call when an error occurs
  122042. * @returns a file request object
  122043. */
  122044. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122045. /**
  122046. * Creates a data url from a given string content
  122047. * @param content defines the content to convert
  122048. * @returns the new data url link
  122049. */
  122050. static FileAsURL(content: string): string;
  122051. /**
  122052. * Format the given number to a specific decimal format
  122053. * @param value defines the number to format
  122054. * @param decimals defines the number of decimals to use
  122055. * @returns the formatted string
  122056. */
  122057. static Format(value: number, decimals?: number): string;
  122058. /**
  122059. * Tries to copy an object by duplicating every property
  122060. * @param source defines the source object
  122061. * @param destination defines the target object
  122062. * @param doNotCopyList defines a list of properties to avoid
  122063. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122064. */
  122065. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122066. /**
  122067. * Gets a boolean indicating if the given object has no own property
  122068. * @param obj defines the object to test
  122069. * @returns true if object has no own property
  122070. */
  122071. static IsEmpty(obj: any): boolean;
  122072. /**
  122073. * Function used to register events at window level
  122074. * @param windowElement defines the Window object to use
  122075. * @param events defines the events to register
  122076. */
  122077. static RegisterTopRootEvents(windowElement: Window, events: {
  122078. name: string;
  122079. handler: Nullable<(e: FocusEvent) => any>;
  122080. }[]): void;
  122081. /**
  122082. * Function used to unregister events from window level
  122083. * @param windowElement defines the Window object to use
  122084. * @param events defines the events to unregister
  122085. */
  122086. static UnregisterTopRootEvents(windowElement: Window, events: {
  122087. name: string;
  122088. handler: Nullable<(e: FocusEvent) => any>;
  122089. }[]): void;
  122090. /**
  122091. * @ignore
  122092. */
  122093. static _ScreenshotCanvas: HTMLCanvasElement;
  122094. /**
  122095. * Dumps the current bound framebuffer
  122096. * @param width defines the rendering width
  122097. * @param height defines the rendering height
  122098. * @param engine defines the hosting engine
  122099. * @param successCallback defines the callback triggered once the data are available
  122100. * @param mimeType defines the mime type of the result
  122101. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122102. */
  122103. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122104. /**
  122105. * Converts the canvas data to blob.
  122106. * This acts as a polyfill for browsers not supporting the to blob function.
  122107. * @param canvas Defines the canvas to extract the data from
  122108. * @param successCallback Defines the callback triggered once the data are available
  122109. * @param mimeType Defines the mime type of the result
  122110. */
  122111. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122112. /**
  122113. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122114. * @param successCallback defines the callback triggered once the data are available
  122115. * @param mimeType defines the mime type of the result
  122116. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122117. */
  122118. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122119. /**
  122120. * Downloads a blob in the browser
  122121. * @param blob defines the blob to download
  122122. * @param fileName defines the name of the downloaded file
  122123. */
  122124. static Download(blob: Blob, fileName: string): void;
  122125. /**
  122126. * Captures a screenshot of the current rendering
  122127. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122128. * @param engine defines the rendering engine
  122129. * @param camera defines the source camera
  122130. * @param size This parameter can be set to a single number or to an object with the
  122131. * following (optional) properties: precision, width, height. If a single number is passed,
  122132. * it will be used for both width and height. If an object is passed, the screenshot size
  122133. * will be derived from the parameters. The precision property is a multiplier allowing
  122134. * rendering at a higher or lower resolution
  122135. * @param successCallback defines the callback receives a single parameter which contains the
  122136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122137. * src parameter of an <img> to display it
  122138. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122139. * Check your browser for supported MIME types
  122140. */
  122141. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122142. /**
  122143. * Captures a screenshot of the current rendering
  122144. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122145. * @param engine defines the rendering engine
  122146. * @param camera defines the source camera
  122147. * @param size This parameter can be set to a single number or to an object with the
  122148. * following (optional) properties: precision, width, height. If a single number is passed,
  122149. * it will be used for both width and height. If an object is passed, the screenshot size
  122150. * will be derived from the parameters. The precision property is a multiplier allowing
  122151. * rendering at a higher or lower resolution
  122152. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122153. * Check your browser for supported MIME types
  122154. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122155. * to the src parameter of an <img> to display it
  122156. */
  122157. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122158. /**
  122159. * Generates an image screenshot from the specified camera.
  122160. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122161. * @param engine The engine to use for rendering
  122162. * @param camera The camera to use for rendering
  122163. * @param size This parameter can be set to a single number or to an object with the
  122164. * following (optional) properties: precision, width, height. If a single number is passed,
  122165. * it will be used for both width and height. If an object is passed, the screenshot size
  122166. * will be derived from the parameters. The precision property is a multiplier allowing
  122167. * rendering at a higher or lower resolution
  122168. * @param successCallback The callback receives a single parameter which contains the
  122169. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122170. * src parameter of an <img> to display it
  122171. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122172. * Check your browser for supported MIME types
  122173. * @param samples Texture samples (default: 1)
  122174. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122175. * @param fileName A name for for the downloaded file.
  122176. */
  122177. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122178. /**
  122179. * Generates an image screenshot from the specified camera.
  122180. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122181. * @param engine The engine to use for rendering
  122182. * @param camera The camera to use for rendering
  122183. * @param size This parameter can be set to a single number or to an object with the
  122184. * following (optional) properties: precision, width, height. If a single number is passed,
  122185. * it will be used for both width and height. If an object is passed, the screenshot size
  122186. * will be derived from the parameters. The precision property is a multiplier allowing
  122187. * rendering at a higher or lower resolution
  122188. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122189. * Check your browser for supported MIME types
  122190. * @param samples Texture samples (default: 1)
  122191. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122192. * @param fileName A name for for the downloaded file.
  122193. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122194. * to the src parameter of an <img> to display it
  122195. */
  122196. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122197. /**
  122198. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122199. * Be aware Math.random() could cause collisions, but:
  122200. * "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"
  122201. * @returns a pseudo random id
  122202. */
  122203. static RandomId(): string;
  122204. /**
  122205. * Test if the given uri is a base64 string
  122206. * @param uri The uri to test
  122207. * @return True if the uri is a base64 string or false otherwise
  122208. */
  122209. static IsBase64(uri: string): boolean;
  122210. /**
  122211. * Decode the given base64 uri.
  122212. * @param uri The uri to decode
  122213. * @return The decoded base64 data.
  122214. */
  122215. static DecodeBase64(uri: string): ArrayBuffer;
  122216. /**
  122217. * Gets the absolute url.
  122218. * @param url the input url
  122219. * @return the absolute url
  122220. */
  122221. static GetAbsoluteUrl(url: string): string;
  122222. /**
  122223. * No log
  122224. */
  122225. static readonly NoneLogLevel: number;
  122226. /**
  122227. * Only message logs
  122228. */
  122229. static readonly MessageLogLevel: number;
  122230. /**
  122231. * Only warning logs
  122232. */
  122233. static readonly WarningLogLevel: number;
  122234. /**
  122235. * Only error logs
  122236. */
  122237. static readonly ErrorLogLevel: number;
  122238. /**
  122239. * All logs
  122240. */
  122241. static readonly AllLogLevel: number;
  122242. /**
  122243. * Gets a value indicating the number of loading errors
  122244. * @ignorenaming
  122245. */
  122246. static get errorsCount(): number;
  122247. /**
  122248. * Callback called when a new log is added
  122249. */
  122250. static OnNewCacheEntry: (entry: string) => void;
  122251. /**
  122252. * Log a message to the console
  122253. * @param message defines the message to log
  122254. */
  122255. static Log(message: string): void;
  122256. /**
  122257. * Write a warning message to the console
  122258. * @param message defines the message to log
  122259. */
  122260. static Warn(message: string): void;
  122261. /**
  122262. * Write an error message to the console
  122263. * @param message defines the message to log
  122264. */
  122265. static Error(message: string): void;
  122266. /**
  122267. * Gets current log cache (list of logs)
  122268. */
  122269. static get LogCache(): string;
  122270. /**
  122271. * Clears the log cache
  122272. */
  122273. static ClearLogCache(): void;
  122274. /**
  122275. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122276. */
  122277. static set LogLevels(level: number);
  122278. /**
  122279. * Checks if the window object exists
  122280. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122281. */
  122282. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122283. /**
  122284. * No performance log
  122285. */
  122286. static readonly PerformanceNoneLogLevel: number;
  122287. /**
  122288. * Use user marks to log performance
  122289. */
  122290. static readonly PerformanceUserMarkLogLevel: number;
  122291. /**
  122292. * Log performance to the console
  122293. */
  122294. static readonly PerformanceConsoleLogLevel: number;
  122295. private static _performance;
  122296. /**
  122297. * Sets the current performance log level
  122298. */
  122299. static set PerformanceLogLevel(level: number);
  122300. private static _StartPerformanceCounterDisabled;
  122301. private static _EndPerformanceCounterDisabled;
  122302. private static _StartUserMark;
  122303. private static _EndUserMark;
  122304. private static _StartPerformanceConsole;
  122305. private static _EndPerformanceConsole;
  122306. /**
  122307. * Starts a performance counter
  122308. */
  122309. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122310. /**
  122311. * Ends a specific performance coutner
  122312. */
  122313. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122314. /**
  122315. * Gets either window.performance.now() if supported or Date.now() else
  122316. */
  122317. static get Now(): number;
  122318. /**
  122319. * This method will return the name of the class used to create the instance of the given object.
  122320. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122321. * @param object the object to get the class name from
  122322. * @param isType defines if the object is actually a type
  122323. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122324. */
  122325. static GetClassName(object: any, isType?: boolean): string;
  122326. /**
  122327. * Gets the first element of an array satisfying a given predicate
  122328. * @param array defines the array to browse
  122329. * @param predicate defines the predicate to use
  122330. * @returns null if not found or the element
  122331. */
  122332. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122333. /**
  122334. * This method will return the name of the full name of the class, including its owning module (if any).
  122335. * 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).
  122336. * @param object the object to get the class name from
  122337. * @param isType defines if the object is actually a type
  122338. * @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.
  122339. * @ignorenaming
  122340. */
  122341. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122342. /**
  122343. * Returns a promise that resolves after the given amount of time.
  122344. * @param delay Number of milliseconds to delay
  122345. * @returns Promise that resolves after the given amount of time
  122346. */
  122347. static DelayAsync(delay: number): Promise<void>;
  122348. /**
  122349. * Utility function to detect if the current user agent is Safari
  122350. * @returns whether or not the current user agent is safari
  122351. */
  122352. static IsSafari(): boolean;
  122353. }
  122354. /**
  122355. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122356. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122357. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122358. * @param name The name of the class, case should be preserved
  122359. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122360. */
  122361. export function className(name: string, module?: string): (target: Object) => void;
  122362. /**
  122363. * An implementation of a loop for asynchronous functions.
  122364. */
  122365. export class AsyncLoop {
  122366. /**
  122367. * Defines the number of iterations for the loop
  122368. */
  122369. iterations: number;
  122370. /**
  122371. * Defines the current index of the loop.
  122372. */
  122373. index: number;
  122374. private _done;
  122375. private _fn;
  122376. private _successCallback;
  122377. /**
  122378. * Constructor.
  122379. * @param iterations the number of iterations.
  122380. * @param func the function to run each iteration
  122381. * @param successCallback the callback that will be called upon succesful execution
  122382. * @param offset starting offset.
  122383. */
  122384. constructor(
  122385. /**
  122386. * Defines the number of iterations for the loop
  122387. */
  122388. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122389. /**
  122390. * Execute the next iteration. Must be called after the last iteration was finished.
  122391. */
  122392. executeNext(): void;
  122393. /**
  122394. * Break the loop and run the success callback.
  122395. */
  122396. breakLoop(): void;
  122397. /**
  122398. * Create and run an async loop.
  122399. * @param iterations the number of iterations.
  122400. * @param fn the function to run each iteration
  122401. * @param successCallback the callback that will be called upon succesful execution
  122402. * @param offset starting offset.
  122403. * @returns the created async loop object
  122404. */
  122405. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122406. /**
  122407. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122408. * @param iterations total number of iterations
  122409. * @param syncedIterations number of synchronous iterations in each async iteration.
  122410. * @param fn the function to call each iteration.
  122411. * @param callback a success call back that will be called when iterating stops.
  122412. * @param breakFunction a break condition (optional)
  122413. * @param timeout timeout settings for the setTimeout function. default - 0.
  122414. * @returns the created async loop object
  122415. */
  122416. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122417. }
  122418. }
  122419. declare module BABYLON {
  122420. /**
  122421. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122422. * The underlying implementation relies on an associative array to ensure the best performances.
  122423. * The value can be anything including 'null' but except 'undefined'
  122424. */
  122425. export class StringDictionary<T> {
  122426. /**
  122427. * This will clear this dictionary and copy the content from the 'source' one.
  122428. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122429. * @param source the dictionary to take the content from and copy to this dictionary
  122430. */
  122431. copyFrom(source: StringDictionary<T>): void;
  122432. /**
  122433. * Get a value based from its key
  122434. * @param key the given key to get the matching value from
  122435. * @return the value if found, otherwise undefined is returned
  122436. */
  122437. get(key: string): T | undefined;
  122438. /**
  122439. * Get a value from its key or add it if it doesn't exist.
  122440. * This method will ensure you that a given key/data will be present in the dictionary.
  122441. * @param key the given key to get the matching value from
  122442. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122443. * The factory will only be invoked if there's no data for the given key.
  122444. * @return the value corresponding to the key.
  122445. */
  122446. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122447. /**
  122448. * Get a value from its key if present in the dictionary otherwise add it
  122449. * @param key the key to get the value from
  122450. * @param val if there's no such key/value pair in the dictionary add it with this value
  122451. * @return the value corresponding to the key
  122452. */
  122453. getOrAdd(key: string, val: T): T;
  122454. /**
  122455. * Check if there's a given key in the dictionary
  122456. * @param key the key to check for
  122457. * @return true if the key is present, false otherwise
  122458. */
  122459. contains(key: string): boolean;
  122460. /**
  122461. * Add a new key and its corresponding value
  122462. * @param key the key to add
  122463. * @param value the value corresponding to the key
  122464. * @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
  122465. */
  122466. add(key: string, value: T): boolean;
  122467. /**
  122468. * Update a specific value associated to a key
  122469. * @param key defines the key to use
  122470. * @param value defines the value to store
  122471. * @returns true if the value was updated (or false if the key was not found)
  122472. */
  122473. set(key: string, value: T): boolean;
  122474. /**
  122475. * Get the element of the given key and remove it from the dictionary
  122476. * @param key defines the key to search
  122477. * @returns the value associated with the key or null if not found
  122478. */
  122479. getAndRemove(key: string): Nullable<T>;
  122480. /**
  122481. * Remove a key/value from the dictionary.
  122482. * @param key the key to remove
  122483. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122484. */
  122485. remove(key: string): boolean;
  122486. /**
  122487. * Clear the whole content of the dictionary
  122488. */
  122489. clear(): void;
  122490. /**
  122491. * Gets the current count
  122492. */
  122493. get count(): number;
  122494. /**
  122495. * Execute a callback on each key/val of the dictionary.
  122496. * Note that you can remove any element in this dictionary in the callback implementation
  122497. * @param callback the callback to execute on a given key/value pair
  122498. */
  122499. forEach(callback: (key: string, val: T) => void): void;
  122500. /**
  122501. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122502. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122503. * Note that you can remove any element in this dictionary in the callback implementation
  122504. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122505. * @returns the first item
  122506. */
  122507. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122508. private _count;
  122509. private _data;
  122510. }
  122511. }
  122512. declare module BABYLON {
  122513. /** @hidden */
  122514. export interface ICollisionCoordinator {
  122515. createCollider(): Collider;
  122516. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122517. init(scene: Scene): void;
  122518. }
  122519. /** @hidden */
  122520. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122521. private _scene;
  122522. private _scaledPosition;
  122523. private _scaledVelocity;
  122524. private _finalPosition;
  122525. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122526. createCollider(): Collider;
  122527. init(scene: Scene): void;
  122528. private _collideWithWorld;
  122529. }
  122530. }
  122531. declare module BABYLON {
  122532. /**
  122533. * Class used to manage all inputs for the scene.
  122534. */
  122535. export class InputManager {
  122536. /** The distance in pixel that you have to move to prevent some events */
  122537. static DragMovementThreshold: number;
  122538. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122539. static LongPressDelay: number;
  122540. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122541. static DoubleClickDelay: number;
  122542. /** If you need to check double click without raising a single click at first click, enable this flag */
  122543. static ExclusiveDoubleClickMode: boolean;
  122544. /** 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. */
  122545. private _alreadyAttached;
  122546. private _wheelEventName;
  122547. private _onPointerMove;
  122548. private _onPointerDown;
  122549. private _onPointerUp;
  122550. private _initClickEvent;
  122551. private _initActionManager;
  122552. private _delayedSimpleClick;
  122553. private _delayedSimpleClickTimeout;
  122554. private _previousDelayedSimpleClickTimeout;
  122555. private _meshPickProceed;
  122556. private _previousButtonPressed;
  122557. private _currentPickResult;
  122558. private _previousPickResult;
  122559. private _totalPointersPressed;
  122560. private _doubleClickOccured;
  122561. private _pointerOverMesh;
  122562. private _pickedDownMesh;
  122563. private _pickedUpMesh;
  122564. private _pointerX;
  122565. private _pointerY;
  122566. private _unTranslatedPointerX;
  122567. private _unTranslatedPointerY;
  122568. private _startingPointerPosition;
  122569. private _previousStartingPointerPosition;
  122570. private _startingPointerTime;
  122571. private _previousStartingPointerTime;
  122572. private _pointerCaptures;
  122573. private _meshUnderPointerId;
  122574. private _onKeyDown;
  122575. private _onKeyUp;
  122576. private _onCanvasFocusObserver;
  122577. private _onCanvasBlurObserver;
  122578. private _scene;
  122579. /**
  122580. * Creates a new InputManager
  122581. * @param scene defines the hosting scene
  122582. */
  122583. constructor(scene: Scene);
  122584. /**
  122585. * Gets the mesh that is currently under the pointer
  122586. */
  122587. get meshUnderPointer(): Nullable<AbstractMesh>;
  122588. /**
  122589. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122590. * @param pointerId the pointer id to use
  122591. * @returns The mesh under this pointer id or null if not found
  122592. */
  122593. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122594. /**
  122595. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122596. */
  122597. get unTranslatedPointer(): Vector2;
  122598. /**
  122599. * Gets or sets the current on-screen X position of the pointer
  122600. */
  122601. get pointerX(): number;
  122602. set pointerX(value: number);
  122603. /**
  122604. * Gets or sets the current on-screen Y position of the pointer
  122605. */
  122606. get pointerY(): number;
  122607. set pointerY(value: number);
  122608. private _updatePointerPosition;
  122609. private _processPointerMove;
  122610. private _setRayOnPointerInfo;
  122611. private _checkPrePointerObservable;
  122612. /**
  122613. * Use this method to simulate a pointer move on a mesh
  122614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122617. */
  122618. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122619. /**
  122620. * Use this method to simulate a pointer down on a mesh
  122621. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122622. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122623. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122624. */
  122625. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122626. private _processPointerDown;
  122627. /** @hidden */
  122628. _isPointerSwiping(): boolean;
  122629. /**
  122630. * Use this method to simulate a pointer up on a mesh
  122631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122634. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122635. */
  122636. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122637. private _processPointerUp;
  122638. /**
  122639. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122640. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122641. * @returns true if the pointer was captured
  122642. */
  122643. isPointerCaptured(pointerId?: number): boolean;
  122644. /**
  122645. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122646. * @param attachUp defines if you want to attach events to pointerup
  122647. * @param attachDown defines if you want to attach events to pointerdown
  122648. * @param attachMove defines if you want to attach events to pointermove
  122649. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122650. */
  122651. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122652. /**
  122653. * Detaches all event handlers
  122654. */
  122655. detachControl(): void;
  122656. /**
  122657. * Force the value of meshUnderPointer
  122658. * @param mesh defines the mesh to use
  122659. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122660. */
  122661. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122662. /**
  122663. * Gets the mesh under the pointer
  122664. * @returns a Mesh or null if no mesh is under the pointer
  122665. */
  122666. getPointerOverMesh(): Nullable<AbstractMesh>;
  122667. }
  122668. }
  122669. declare module BABYLON {
  122670. /**
  122671. * This class defines the direct association between an animation and a target
  122672. */
  122673. export class TargetedAnimation {
  122674. /**
  122675. * Animation to perform
  122676. */
  122677. animation: Animation;
  122678. /**
  122679. * Target to animate
  122680. */
  122681. target: any;
  122682. /**
  122683. * Returns the string "TargetedAnimation"
  122684. * @returns "TargetedAnimation"
  122685. */
  122686. getClassName(): string;
  122687. /**
  122688. * Serialize the object
  122689. * @returns the JSON object representing the current entity
  122690. */
  122691. serialize(): any;
  122692. }
  122693. /**
  122694. * Use this class to create coordinated animations on multiple targets
  122695. */
  122696. export class AnimationGroup implements IDisposable {
  122697. /** The name of the animation group */
  122698. name: string;
  122699. private _scene;
  122700. private _targetedAnimations;
  122701. private _animatables;
  122702. private _from;
  122703. private _to;
  122704. private _isStarted;
  122705. private _isPaused;
  122706. private _speedRatio;
  122707. private _loopAnimation;
  122708. private _isAdditive;
  122709. /**
  122710. * Gets or sets the unique id of the node
  122711. */
  122712. uniqueId: number;
  122713. /**
  122714. * This observable will notify when one animation have ended
  122715. */
  122716. onAnimationEndObservable: Observable<TargetedAnimation>;
  122717. /**
  122718. * Observer raised when one animation loops
  122719. */
  122720. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122721. /**
  122722. * Observer raised when all animations have looped
  122723. */
  122724. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122725. /**
  122726. * This observable will notify when all animations have ended.
  122727. */
  122728. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122729. /**
  122730. * This observable will notify when all animations have paused.
  122731. */
  122732. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122733. /**
  122734. * This observable will notify when all animations are playing.
  122735. */
  122736. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122737. /**
  122738. * Gets the first frame
  122739. */
  122740. get from(): number;
  122741. /**
  122742. * Gets the last frame
  122743. */
  122744. get to(): number;
  122745. /**
  122746. * Define if the animations are started
  122747. */
  122748. get isStarted(): boolean;
  122749. /**
  122750. * Gets a value indicating that the current group is playing
  122751. */
  122752. get isPlaying(): boolean;
  122753. /**
  122754. * Gets or sets the speed ratio to use for all animations
  122755. */
  122756. get speedRatio(): number;
  122757. /**
  122758. * Gets or sets the speed ratio to use for all animations
  122759. */
  122760. set speedRatio(value: number);
  122761. /**
  122762. * Gets or sets if all animations should loop or not
  122763. */
  122764. get loopAnimation(): boolean;
  122765. set loopAnimation(value: boolean);
  122766. /**
  122767. * Gets or sets if all animations should be evaluated additively
  122768. */
  122769. get isAdditive(): boolean;
  122770. set isAdditive(value: boolean);
  122771. /**
  122772. * Gets the targeted animations for this animation group
  122773. */
  122774. get targetedAnimations(): Array<TargetedAnimation>;
  122775. /**
  122776. * returning the list of animatables controlled by this animation group.
  122777. */
  122778. get animatables(): Array<Animatable>;
  122779. /**
  122780. * Gets the list of target animations
  122781. */
  122782. get children(): TargetedAnimation[];
  122783. /**
  122784. * Instantiates a new Animation Group.
  122785. * This helps managing several animations at once.
  122786. * @see https://doc.babylonjs.com/how_to/group
  122787. * @param name Defines the name of the group
  122788. * @param scene Defines the scene the group belongs to
  122789. */
  122790. constructor(
  122791. /** The name of the animation group */
  122792. name: string, scene?: Nullable<Scene>);
  122793. /**
  122794. * Add an animation (with its target) in the group
  122795. * @param animation defines the animation we want to add
  122796. * @param target defines the target of the animation
  122797. * @returns the TargetedAnimation object
  122798. */
  122799. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  122800. /**
  122801. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  122802. * It can add constant keys at begin or end
  122803. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  122804. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  122805. * @returns the animation group
  122806. */
  122807. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  122808. private _animationLoopCount;
  122809. private _animationLoopFlags;
  122810. private _processLoop;
  122811. /**
  122812. * Start all animations on given targets
  122813. * @param loop defines if animations must loop
  122814. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  122815. * @param from defines the from key (optional)
  122816. * @param to defines the to key (optional)
  122817. * @param isAdditive defines the additive state for the resulting animatables (optional)
  122818. * @returns the current animation group
  122819. */
  122820. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  122821. /**
  122822. * Pause all animations
  122823. * @returns the animation group
  122824. */
  122825. pause(): AnimationGroup;
  122826. /**
  122827. * Play all animations to initial state
  122828. * This function will start() the animations if they were not started or will restart() them if they were paused
  122829. * @param loop defines if animations must loop
  122830. * @returns the animation group
  122831. */
  122832. play(loop?: boolean): AnimationGroup;
  122833. /**
  122834. * Reset all animations to initial state
  122835. * @returns the animation group
  122836. */
  122837. reset(): AnimationGroup;
  122838. /**
  122839. * Restart animations from key 0
  122840. * @returns the animation group
  122841. */
  122842. restart(): AnimationGroup;
  122843. /**
  122844. * Stop all animations
  122845. * @returns the animation group
  122846. */
  122847. stop(): AnimationGroup;
  122848. /**
  122849. * Set animation weight for all animatables
  122850. * @param weight defines the weight to use
  122851. * @return the animationGroup
  122852. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122853. */
  122854. setWeightForAllAnimatables(weight: number): AnimationGroup;
  122855. /**
  122856. * Synchronize and normalize all animatables with a source animatable
  122857. * @param root defines the root animatable to synchronize with
  122858. * @return the animationGroup
  122859. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122860. */
  122861. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  122862. /**
  122863. * Goes to a specific frame in this animation group
  122864. * @param frame the frame number to go to
  122865. * @return the animationGroup
  122866. */
  122867. goToFrame(frame: number): AnimationGroup;
  122868. /**
  122869. * Dispose all associated resources
  122870. */
  122871. dispose(): void;
  122872. private _checkAnimationGroupEnded;
  122873. /**
  122874. * Clone the current animation group and returns a copy
  122875. * @param newName defines the name of the new group
  122876. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  122877. * @returns the new aniamtion group
  122878. */
  122879. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  122880. /**
  122881. * Serializes the animationGroup to an object
  122882. * @returns Serialized object
  122883. */
  122884. serialize(): any;
  122885. /**
  122886. * Returns a new AnimationGroup object parsed from the source provided.
  122887. * @param parsedAnimationGroup defines the source
  122888. * @param scene defines the scene that will receive the animationGroup
  122889. * @returns a new AnimationGroup
  122890. */
  122891. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  122892. /**
  122893. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  122894. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  122895. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  122896. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  122897. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  122898. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  122899. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  122900. */
  122901. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  122902. /**
  122903. * Returns the string "AnimationGroup"
  122904. * @returns "AnimationGroup"
  122905. */
  122906. getClassName(): string;
  122907. /**
  122908. * Creates a detailled string about the object
  122909. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  122910. * @returns a string representing the object
  122911. */
  122912. toString(fullDetails?: boolean): string;
  122913. }
  122914. }
  122915. declare module BABYLON {
  122916. /**
  122917. * Define an interface for all classes that will hold resources
  122918. */
  122919. export interface IDisposable {
  122920. /**
  122921. * Releases all held resources
  122922. */
  122923. dispose(): void;
  122924. }
  122925. /** Interface defining initialization parameters for Scene class */
  122926. export interface SceneOptions {
  122927. /**
  122928. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  122929. * It will improve performance when the number of geometries becomes important.
  122930. */
  122931. useGeometryUniqueIdsMap?: boolean;
  122932. /**
  122933. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  122934. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122935. */
  122936. useMaterialMeshMap?: boolean;
  122937. /**
  122938. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  122939. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  122940. */
  122941. useClonedMeshMap?: boolean;
  122942. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  122943. virtual?: boolean;
  122944. }
  122945. /**
  122946. * Represents a scene to be rendered by the engine.
  122947. * @see https://doc.babylonjs.com/features/scene
  122948. */
  122949. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  122950. /** The fog is deactivated */
  122951. static readonly FOGMODE_NONE: number;
  122952. /** The fog density is following an exponential function */
  122953. static readonly FOGMODE_EXP: number;
  122954. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  122955. static readonly FOGMODE_EXP2: number;
  122956. /** The fog density is following a linear function. */
  122957. static readonly FOGMODE_LINEAR: number;
  122958. /**
  122959. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  122960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122961. */
  122962. static MinDeltaTime: number;
  122963. /**
  122964. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  122965. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122966. */
  122967. static MaxDeltaTime: number;
  122968. /**
  122969. * Factory used to create the default material.
  122970. * @param name The name of the material to create
  122971. * @param scene The scene to create the material for
  122972. * @returns The default material
  122973. */
  122974. static DefaultMaterialFactory(scene: Scene): Material;
  122975. /**
  122976. * Factory used to create the a collision coordinator.
  122977. * @returns The collision coordinator
  122978. */
  122979. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  122980. /** @hidden */
  122981. _inputManager: InputManager;
  122982. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  122983. cameraToUseForPointers: Nullable<Camera>;
  122984. /** @hidden */
  122985. readonly _isScene: boolean;
  122986. /** @hidden */
  122987. _blockEntityCollection: boolean;
  122988. /**
  122989. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  122990. */
  122991. autoClear: boolean;
  122992. /**
  122993. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  122994. */
  122995. autoClearDepthAndStencil: boolean;
  122996. /**
  122997. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  122998. */
  122999. clearColor: Color4;
  123000. /**
  123001. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123002. */
  123003. ambientColor: Color3;
  123004. /**
  123005. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123006. * It should only be one of the following (if not the default embedded one):
  123007. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123008. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123009. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123010. * The material properties need to be setup according to the type of texture in use.
  123011. */
  123012. environmentBRDFTexture: BaseTexture;
  123013. /**
  123014. * Texture used in all pbr material as the reflection texture.
  123015. * As in the majority of the scene they are the same (exception for multi room and so on),
  123016. * this is easier to reference from here than from all the materials.
  123017. */
  123018. get environmentTexture(): Nullable<BaseTexture>;
  123019. /**
  123020. * Texture used in all pbr material as the reflection texture.
  123021. * As in the majority of the scene they are the same (exception for multi room and so on),
  123022. * this is easier to set here than in all the materials.
  123023. */
  123024. set environmentTexture(value: Nullable<BaseTexture>);
  123025. /** @hidden */
  123026. protected _environmentIntensity: number;
  123027. /**
  123028. * Intensity of the environment in all pbr material.
  123029. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123030. * As in the majority of the scene they are the same (exception for multi room and so on),
  123031. * this is easier to reference from here than from all the materials.
  123032. */
  123033. get environmentIntensity(): number;
  123034. /**
  123035. * Intensity of the environment in all pbr material.
  123036. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123037. * As in the majority of the scene they are the same (exception for multi room and so on),
  123038. * this is easier to set here than in all the materials.
  123039. */
  123040. set environmentIntensity(value: number);
  123041. /** @hidden */
  123042. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123043. /**
  123044. * Default image processing configuration used either in the rendering
  123045. * Forward main pass or through the imageProcessingPostProcess if present.
  123046. * As in the majority of the scene they are the same (exception for multi camera),
  123047. * this is easier to reference from here than from all the materials and post process.
  123048. *
  123049. * No setter as we it is a shared configuration, you can set the values instead.
  123050. */
  123051. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123052. private _forceWireframe;
  123053. /**
  123054. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123055. */
  123056. set forceWireframe(value: boolean);
  123057. get forceWireframe(): boolean;
  123058. private _skipFrustumClipping;
  123059. /**
  123060. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123061. */
  123062. set skipFrustumClipping(value: boolean);
  123063. get skipFrustumClipping(): boolean;
  123064. private _forcePointsCloud;
  123065. /**
  123066. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123067. */
  123068. set forcePointsCloud(value: boolean);
  123069. get forcePointsCloud(): boolean;
  123070. /**
  123071. * Gets or sets the active clipplane 1
  123072. */
  123073. clipPlane: Nullable<Plane>;
  123074. /**
  123075. * Gets or sets the active clipplane 2
  123076. */
  123077. clipPlane2: Nullable<Plane>;
  123078. /**
  123079. * Gets or sets the active clipplane 3
  123080. */
  123081. clipPlane3: Nullable<Plane>;
  123082. /**
  123083. * Gets or sets the active clipplane 4
  123084. */
  123085. clipPlane4: Nullable<Plane>;
  123086. /**
  123087. * Gets or sets the active clipplane 5
  123088. */
  123089. clipPlane5: Nullable<Plane>;
  123090. /**
  123091. * Gets or sets the active clipplane 6
  123092. */
  123093. clipPlane6: Nullable<Plane>;
  123094. /**
  123095. * Gets or sets a boolean indicating if animations are enabled
  123096. */
  123097. animationsEnabled: boolean;
  123098. private _animationPropertiesOverride;
  123099. /**
  123100. * Gets or sets the animation properties override
  123101. */
  123102. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123103. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123104. /**
  123105. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123106. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123107. */
  123108. useConstantAnimationDeltaTime: boolean;
  123109. /**
  123110. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123111. * Please note that it requires to run a ray cast through the scene on every frame
  123112. */
  123113. constantlyUpdateMeshUnderPointer: boolean;
  123114. /**
  123115. * Defines the HTML cursor to use when hovering over interactive elements
  123116. */
  123117. hoverCursor: string;
  123118. /**
  123119. * Defines the HTML default cursor to use (empty by default)
  123120. */
  123121. defaultCursor: string;
  123122. /**
  123123. * Defines whether cursors are handled by the scene.
  123124. */
  123125. doNotHandleCursors: boolean;
  123126. /**
  123127. * This is used to call preventDefault() on pointer down
  123128. * in order to block unwanted artifacts like system double clicks
  123129. */
  123130. preventDefaultOnPointerDown: boolean;
  123131. /**
  123132. * This is used to call preventDefault() on pointer up
  123133. * in order to block unwanted artifacts like system double clicks
  123134. */
  123135. preventDefaultOnPointerUp: boolean;
  123136. /**
  123137. * Gets or sets user defined metadata
  123138. */
  123139. metadata: any;
  123140. /**
  123141. * For internal use only. Please do not use.
  123142. */
  123143. reservedDataStore: any;
  123144. /**
  123145. * Gets the name of the plugin used to load this scene (null by default)
  123146. */
  123147. loadingPluginName: string;
  123148. /**
  123149. * Use this array to add regular expressions used to disable offline support for specific urls
  123150. */
  123151. disableOfflineSupportExceptionRules: RegExp[];
  123152. /**
  123153. * An event triggered when the scene is disposed.
  123154. */
  123155. onDisposeObservable: Observable<Scene>;
  123156. private _onDisposeObserver;
  123157. /** Sets a function to be executed when this scene is disposed. */
  123158. set onDispose(callback: () => void);
  123159. /**
  123160. * An event triggered before rendering the scene (right after animations and physics)
  123161. */
  123162. onBeforeRenderObservable: Observable<Scene>;
  123163. private _onBeforeRenderObserver;
  123164. /** Sets a function to be executed before rendering this scene */
  123165. set beforeRender(callback: Nullable<() => void>);
  123166. /**
  123167. * An event triggered after rendering the scene
  123168. */
  123169. onAfterRenderObservable: Observable<Scene>;
  123170. /**
  123171. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123172. */
  123173. onAfterRenderCameraObservable: Observable<Camera>;
  123174. private _onAfterRenderObserver;
  123175. /** Sets a function to be executed after rendering this scene */
  123176. set afterRender(callback: Nullable<() => void>);
  123177. /**
  123178. * An event triggered before animating the scene
  123179. */
  123180. onBeforeAnimationsObservable: Observable<Scene>;
  123181. /**
  123182. * An event triggered after animations processing
  123183. */
  123184. onAfterAnimationsObservable: Observable<Scene>;
  123185. /**
  123186. * An event triggered before draw calls are ready to be sent
  123187. */
  123188. onBeforeDrawPhaseObservable: Observable<Scene>;
  123189. /**
  123190. * An event triggered after draw calls have been sent
  123191. */
  123192. onAfterDrawPhaseObservable: Observable<Scene>;
  123193. /**
  123194. * An event triggered when the scene is ready
  123195. */
  123196. onReadyObservable: Observable<Scene>;
  123197. /**
  123198. * An event triggered before rendering a camera
  123199. */
  123200. onBeforeCameraRenderObservable: Observable<Camera>;
  123201. private _onBeforeCameraRenderObserver;
  123202. /** Sets a function to be executed before rendering a camera*/
  123203. set beforeCameraRender(callback: () => void);
  123204. /**
  123205. * An event triggered after rendering a camera
  123206. */
  123207. onAfterCameraRenderObservable: Observable<Camera>;
  123208. private _onAfterCameraRenderObserver;
  123209. /** Sets a function to be executed after rendering a camera*/
  123210. set afterCameraRender(callback: () => void);
  123211. /**
  123212. * An event triggered when active meshes evaluation is about to start
  123213. */
  123214. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123215. /**
  123216. * An event triggered when active meshes evaluation is done
  123217. */
  123218. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123219. /**
  123220. * An event triggered when particles rendering is about to start
  123221. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123222. */
  123223. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123224. /**
  123225. * An event triggered when particles rendering is done
  123226. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123227. */
  123228. onAfterParticlesRenderingObservable: Observable<Scene>;
  123229. /**
  123230. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123231. */
  123232. onDataLoadedObservable: Observable<Scene>;
  123233. /**
  123234. * An event triggered when a camera is created
  123235. */
  123236. onNewCameraAddedObservable: Observable<Camera>;
  123237. /**
  123238. * An event triggered when a camera is removed
  123239. */
  123240. onCameraRemovedObservable: Observable<Camera>;
  123241. /**
  123242. * An event triggered when a light is created
  123243. */
  123244. onNewLightAddedObservable: Observable<Light>;
  123245. /**
  123246. * An event triggered when a light is removed
  123247. */
  123248. onLightRemovedObservable: Observable<Light>;
  123249. /**
  123250. * An event triggered when a geometry is created
  123251. */
  123252. onNewGeometryAddedObservable: Observable<Geometry>;
  123253. /**
  123254. * An event triggered when a geometry is removed
  123255. */
  123256. onGeometryRemovedObservable: Observable<Geometry>;
  123257. /**
  123258. * An event triggered when a transform node is created
  123259. */
  123260. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123261. /**
  123262. * An event triggered when a transform node is removed
  123263. */
  123264. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123265. /**
  123266. * An event triggered when a mesh is created
  123267. */
  123268. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123269. /**
  123270. * An event triggered when a mesh is removed
  123271. */
  123272. onMeshRemovedObservable: Observable<AbstractMesh>;
  123273. /**
  123274. * An event triggered when a skeleton is created
  123275. */
  123276. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123277. /**
  123278. * An event triggered when a skeleton is removed
  123279. */
  123280. onSkeletonRemovedObservable: Observable<Skeleton>;
  123281. /**
  123282. * An event triggered when a material is created
  123283. */
  123284. onNewMaterialAddedObservable: Observable<Material>;
  123285. /**
  123286. * An event triggered when a material is removed
  123287. */
  123288. onMaterialRemovedObservable: Observable<Material>;
  123289. /**
  123290. * An event triggered when a texture is created
  123291. */
  123292. onNewTextureAddedObservable: Observable<BaseTexture>;
  123293. /**
  123294. * An event triggered when a texture is removed
  123295. */
  123296. onTextureRemovedObservable: Observable<BaseTexture>;
  123297. /**
  123298. * An event triggered when render targets are about to be rendered
  123299. * Can happen multiple times per frame.
  123300. */
  123301. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123302. /**
  123303. * An event triggered when render targets were rendered.
  123304. * Can happen multiple times per frame.
  123305. */
  123306. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123307. /**
  123308. * An event triggered before calculating deterministic simulation step
  123309. */
  123310. onBeforeStepObservable: Observable<Scene>;
  123311. /**
  123312. * An event triggered after calculating deterministic simulation step
  123313. */
  123314. onAfterStepObservable: Observable<Scene>;
  123315. /**
  123316. * An event triggered when the activeCamera property is updated
  123317. */
  123318. onActiveCameraChanged: Observable<Scene>;
  123319. /**
  123320. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123321. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123322. * 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)
  123323. */
  123324. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123325. /**
  123326. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123327. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123328. * 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)
  123329. */
  123330. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123331. /**
  123332. * This Observable will when a mesh has been imported into the scene.
  123333. */
  123334. onMeshImportedObservable: Observable<AbstractMesh>;
  123335. /**
  123336. * This Observable will when an animation file has been imported into the scene.
  123337. */
  123338. onAnimationFileImportedObservable: Observable<Scene>;
  123339. /**
  123340. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123341. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123342. */
  123343. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123344. /** @hidden */
  123345. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123346. /**
  123347. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123348. */
  123349. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123350. /**
  123351. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123352. */
  123353. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123354. /**
  123355. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123356. */
  123357. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123358. /** Callback called when a pointer move is detected */
  123359. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123360. /** Callback called when a pointer down is detected */
  123361. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123362. /** Callback called when a pointer up is detected */
  123363. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123364. /** Callback called when a pointer pick is detected */
  123365. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123366. /**
  123367. * 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).
  123368. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123369. */
  123370. onPrePointerObservable: Observable<PointerInfoPre>;
  123371. /**
  123372. * Observable event triggered each time an input event is received from the rendering canvas
  123373. */
  123374. onPointerObservable: Observable<PointerInfo>;
  123375. /**
  123376. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123377. */
  123378. get unTranslatedPointer(): Vector2;
  123379. /**
  123380. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123381. */
  123382. static get DragMovementThreshold(): number;
  123383. static set DragMovementThreshold(value: number);
  123384. /**
  123385. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123386. */
  123387. static get LongPressDelay(): number;
  123388. static set LongPressDelay(value: number);
  123389. /**
  123390. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123391. */
  123392. static get DoubleClickDelay(): number;
  123393. static set DoubleClickDelay(value: number);
  123394. /** If you need to check double click without raising a single click at first click, enable this flag */
  123395. static get ExclusiveDoubleClickMode(): boolean;
  123396. static set ExclusiveDoubleClickMode(value: boolean);
  123397. /** @hidden */
  123398. _mirroredCameraPosition: Nullable<Vector3>;
  123399. /**
  123400. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123401. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123402. */
  123403. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123404. /**
  123405. * Observable event triggered each time an keyboard event is received from the hosting window
  123406. */
  123407. onKeyboardObservable: Observable<KeyboardInfo>;
  123408. private _useRightHandedSystem;
  123409. /**
  123410. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123411. */
  123412. set useRightHandedSystem(value: boolean);
  123413. get useRightHandedSystem(): boolean;
  123414. private _timeAccumulator;
  123415. private _currentStepId;
  123416. private _currentInternalStep;
  123417. /**
  123418. * Sets the step Id used by deterministic lock step
  123419. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123420. * @param newStepId defines the step Id
  123421. */
  123422. setStepId(newStepId: number): void;
  123423. /**
  123424. * Gets the step Id used by deterministic lock step
  123425. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123426. * @returns the step Id
  123427. */
  123428. getStepId(): number;
  123429. /**
  123430. * Gets the internal step used by deterministic lock step
  123431. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123432. * @returns the internal step
  123433. */
  123434. getInternalStep(): number;
  123435. private _fogEnabled;
  123436. /**
  123437. * Gets or sets a boolean indicating if fog is enabled on this scene
  123438. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123439. * (Default is true)
  123440. */
  123441. set fogEnabled(value: boolean);
  123442. get fogEnabled(): boolean;
  123443. private _fogMode;
  123444. /**
  123445. * Gets or sets the fog mode to use
  123446. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123447. * | mode | value |
  123448. * | --- | --- |
  123449. * | FOGMODE_NONE | 0 |
  123450. * | FOGMODE_EXP | 1 |
  123451. * | FOGMODE_EXP2 | 2 |
  123452. * | FOGMODE_LINEAR | 3 |
  123453. */
  123454. set fogMode(value: number);
  123455. get fogMode(): number;
  123456. /**
  123457. * Gets or sets the fog color to use
  123458. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123459. * (Default is Color3(0.2, 0.2, 0.3))
  123460. */
  123461. fogColor: Color3;
  123462. /**
  123463. * Gets or sets the fog density to use
  123464. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123465. * (Default is 0.1)
  123466. */
  123467. fogDensity: number;
  123468. /**
  123469. * Gets or sets the fog start distance to use
  123470. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123471. * (Default is 0)
  123472. */
  123473. fogStart: number;
  123474. /**
  123475. * Gets or sets the fog end distance to use
  123476. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123477. * (Default is 1000)
  123478. */
  123479. fogEnd: number;
  123480. /**
  123481. * Flag indicating that the frame buffer binding is handled by another component
  123482. */
  123483. prePass: boolean;
  123484. private _shadowsEnabled;
  123485. /**
  123486. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123487. */
  123488. set shadowsEnabled(value: boolean);
  123489. get shadowsEnabled(): boolean;
  123490. private _lightsEnabled;
  123491. /**
  123492. * Gets or sets a boolean indicating if lights are enabled on this scene
  123493. */
  123494. set lightsEnabled(value: boolean);
  123495. get lightsEnabled(): boolean;
  123496. /** All of the active cameras added to this scene. */
  123497. activeCameras: Camera[];
  123498. /** @hidden */
  123499. _activeCamera: Nullable<Camera>;
  123500. /** Gets or sets the current active camera */
  123501. get activeCamera(): Nullable<Camera>;
  123502. set activeCamera(value: Nullable<Camera>);
  123503. private _defaultMaterial;
  123504. /** The default material used on meshes when no material is affected */
  123505. get defaultMaterial(): Material;
  123506. /** The default material used on meshes when no material is affected */
  123507. set defaultMaterial(value: Material);
  123508. private _texturesEnabled;
  123509. /**
  123510. * Gets or sets a boolean indicating if textures are enabled on this scene
  123511. */
  123512. set texturesEnabled(value: boolean);
  123513. get texturesEnabled(): boolean;
  123514. /**
  123515. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123516. */
  123517. physicsEnabled: boolean;
  123518. /**
  123519. * Gets or sets a boolean indicating if particles are enabled on this scene
  123520. */
  123521. particlesEnabled: boolean;
  123522. /**
  123523. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123524. */
  123525. spritesEnabled: boolean;
  123526. private _skeletonsEnabled;
  123527. /**
  123528. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123529. */
  123530. set skeletonsEnabled(value: boolean);
  123531. get skeletonsEnabled(): boolean;
  123532. /**
  123533. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123534. */
  123535. lensFlaresEnabled: boolean;
  123536. /**
  123537. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123538. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123539. */
  123540. collisionsEnabled: boolean;
  123541. private _collisionCoordinator;
  123542. /** @hidden */
  123543. get collisionCoordinator(): ICollisionCoordinator;
  123544. /**
  123545. * Defines the gravity applied to this scene (used only for collisions)
  123546. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123547. */
  123548. gravity: Vector3;
  123549. /**
  123550. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123551. */
  123552. postProcessesEnabled: boolean;
  123553. /**
  123554. * Gets the current postprocess manager
  123555. */
  123556. postProcessManager: PostProcessManager;
  123557. /**
  123558. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123559. */
  123560. renderTargetsEnabled: boolean;
  123561. /**
  123562. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123563. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123564. */
  123565. dumpNextRenderTargets: boolean;
  123566. /**
  123567. * The list of user defined render targets added to the scene
  123568. */
  123569. customRenderTargets: RenderTargetTexture[];
  123570. /**
  123571. * Defines if texture loading must be delayed
  123572. * If true, textures will only be loaded when they need to be rendered
  123573. */
  123574. useDelayedTextureLoading: boolean;
  123575. /**
  123576. * Gets the list of meshes imported to the scene through SceneLoader
  123577. */
  123578. importedMeshesFiles: String[];
  123579. /**
  123580. * Gets or sets a boolean indicating if probes are enabled on this scene
  123581. */
  123582. probesEnabled: boolean;
  123583. /**
  123584. * Gets or sets the current offline provider to use to store scene data
  123585. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123586. */
  123587. offlineProvider: IOfflineProvider;
  123588. /**
  123589. * Gets or sets the action manager associated with the scene
  123590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123591. */
  123592. actionManager: AbstractActionManager;
  123593. private _meshesForIntersections;
  123594. /**
  123595. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123596. */
  123597. proceduralTexturesEnabled: boolean;
  123598. private _engine;
  123599. private _totalVertices;
  123600. /** @hidden */
  123601. _activeIndices: PerfCounter;
  123602. /** @hidden */
  123603. _activeParticles: PerfCounter;
  123604. /** @hidden */
  123605. _activeBones: PerfCounter;
  123606. private _animationRatio;
  123607. /** @hidden */
  123608. _animationTimeLast: number;
  123609. /** @hidden */
  123610. _animationTime: number;
  123611. /**
  123612. * Gets or sets a general scale for animation speed
  123613. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123614. */
  123615. animationTimeScale: number;
  123616. /** @hidden */
  123617. _cachedMaterial: Nullable<Material>;
  123618. /** @hidden */
  123619. _cachedEffect: Nullable<Effect>;
  123620. /** @hidden */
  123621. _cachedVisibility: Nullable<number>;
  123622. private _renderId;
  123623. private _frameId;
  123624. private _executeWhenReadyTimeoutId;
  123625. private _intermediateRendering;
  123626. private _viewUpdateFlag;
  123627. private _projectionUpdateFlag;
  123628. /** @hidden */
  123629. _toBeDisposed: Nullable<IDisposable>[];
  123630. private _activeRequests;
  123631. /** @hidden */
  123632. _pendingData: any[];
  123633. private _isDisposed;
  123634. /**
  123635. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123636. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123637. */
  123638. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123639. private _activeMeshes;
  123640. private _processedMaterials;
  123641. private _renderTargets;
  123642. /** @hidden */
  123643. _activeParticleSystems: SmartArray<IParticleSystem>;
  123644. private _activeSkeletons;
  123645. private _softwareSkinnedMeshes;
  123646. private _renderingManager;
  123647. /** @hidden */
  123648. _activeAnimatables: Animatable[];
  123649. private _transformMatrix;
  123650. private _sceneUbo;
  123651. /** @hidden */
  123652. _viewMatrix: Matrix;
  123653. private _projectionMatrix;
  123654. /** @hidden */
  123655. _forcedViewPosition: Nullable<Vector3>;
  123656. /** @hidden */
  123657. _frustumPlanes: Plane[];
  123658. /**
  123659. * Gets the list of frustum planes (built from the active camera)
  123660. */
  123661. get frustumPlanes(): Plane[];
  123662. /**
  123663. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123664. * This is useful if there are more lights that the maximum simulteanous authorized
  123665. */
  123666. requireLightSorting: boolean;
  123667. /** @hidden */
  123668. readonly useMaterialMeshMap: boolean;
  123669. /** @hidden */
  123670. readonly useClonedMeshMap: boolean;
  123671. private _externalData;
  123672. private _uid;
  123673. /**
  123674. * @hidden
  123675. * Backing store of defined scene components.
  123676. */
  123677. _components: ISceneComponent[];
  123678. /**
  123679. * @hidden
  123680. * Backing store of defined scene components.
  123681. */
  123682. _serializableComponents: ISceneSerializableComponent[];
  123683. /**
  123684. * List of components to register on the next registration step.
  123685. */
  123686. private _transientComponents;
  123687. /**
  123688. * Registers the transient components if needed.
  123689. */
  123690. private _registerTransientComponents;
  123691. /**
  123692. * @hidden
  123693. * Add a component to the scene.
  123694. * Note that the ccomponent could be registered on th next frame if this is called after
  123695. * the register component stage.
  123696. * @param component Defines the component to add to the scene
  123697. */
  123698. _addComponent(component: ISceneComponent): void;
  123699. /**
  123700. * @hidden
  123701. * Gets a component from the scene.
  123702. * @param name defines the name of the component to retrieve
  123703. * @returns the component or null if not present
  123704. */
  123705. _getComponent(name: string): Nullable<ISceneComponent>;
  123706. /**
  123707. * @hidden
  123708. * Defines the actions happening before camera updates.
  123709. */
  123710. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123711. /**
  123712. * @hidden
  123713. * Defines the actions happening before clear the canvas.
  123714. */
  123715. _beforeClearStage: Stage<SimpleStageAction>;
  123716. /**
  123717. * @hidden
  123718. * Defines the actions when collecting render targets for the frame.
  123719. */
  123720. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123721. /**
  123722. * @hidden
  123723. * Defines the actions happening for one camera in the frame.
  123724. */
  123725. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123726. /**
  123727. * @hidden
  123728. * Defines the actions happening during the per mesh ready checks.
  123729. */
  123730. _isReadyForMeshStage: Stage<MeshStageAction>;
  123731. /**
  123732. * @hidden
  123733. * Defines the actions happening before evaluate active mesh checks.
  123734. */
  123735. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123736. /**
  123737. * @hidden
  123738. * Defines the actions happening during the evaluate sub mesh checks.
  123739. */
  123740. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123741. /**
  123742. * @hidden
  123743. * Defines the actions happening during the active mesh stage.
  123744. */
  123745. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123746. /**
  123747. * @hidden
  123748. * Defines the actions happening during the per camera render target step.
  123749. */
  123750. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123751. /**
  123752. * @hidden
  123753. * Defines the actions happening just before the active camera is drawing.
  123754. */
  123755. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123756. /**
  123757. * @hidden
  123758. * Defines the actions happening just before a render target is drawing.
  123759. */
  123760. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123761. /**
  123762. * @hidden
  123763. * Defines the actions happening just before a rendering group is drawing.
  123764. */
  123765. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123766. /**
  123767. * @hidden
  123768. * Defines the actions happening just before a mesh is drawing.
  123769. */
  123770. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123771. /**
  123772. * @hidden
  123773. * Defines the actions happening just after a mesh has been drawn.
  123774. */
  123775. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123776. /**
  123777. * @hidden
  123778. * Defines the actions happening just after a rendering group has been drawn.
  123779. */
  123780. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123781. /**
  123782. * @hidden
  123783. * Defines the actions happening just after the active camera has been drawn.
  123784. */
  123785. _afterCameraDrawStage: Stage<CameraStageAction>;
  123786. /**
  123787. * @hidden
  123788. * Defines the actions happening just after a render target has been drawn.
  123789. */
  123790. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123791. /**
  123792. * @hidden
  123793. * Defines the actions happening just after rendering all cameras and computing intersections.
  123794. */
  123795. _afterRenderStage: Stage<SimpleStageAction>;
  123796. /**
  123797. * @hidden
  123798. * Defines the actions happening when a pointer move event happens.
  123799. */
  123800. _pointerMoveStage: Stage<PointerMoveStageAction>;
  123801. /**
  123802. * @hidden
  123803. * Defines the actions happening when a pointer down event happens.
  123804. */
  123805. _pointerDownStage: Stage<PointerUpDownStageAction>;
  123806. /**
  123807. * @hidden
  123808. * Defines the actions happening when a pointer up event happens.
  123809. */
  123810. _pointerUpStage: Stage<PointerUpDownStageAction>;
  123811. /**
  123812. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  123813. */
  123814. private geometriesByUniqueId;
  123815. /**
  123816. * Creates a new Scene
  123817. * @param engine defines the engine to use to render this scene
  123818. * @param options defines the scene options
  123819. */
  123820. constructor(engine: Engine, options?: SceneOptions);
  123821. /**
  123822. * Gets a string identifying the name of the class
  123823. * @returns "Scene" string
  123824. */
  123825. getClassName(): string;
  123826. private _defaultMeshCandidates;
  123827. /**
  123828. * @hidden
  123829. */
  123830. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  123831. private _defaultSubMeshCandidates;
  123832. /**
  123833. * @hidden
  123834. */
  123835. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  123836. /**
  123837. * Sets the default candidate providers for the scene.
  123838. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  123839. * and getCollidingSubMeshCandidates to their default function
  123840. */
  123841. setDefaultCandidateProviders(): void;
  123842. /**
  123843. * Gets the mesh that is currently under the pointer
  123844. */
  123845. get meshUnderPointer(): Nullable<AbstractMesh>;
  123846. /**
  123847. * Gets or sets the current on-screen X position of the pointer
  123848. */
  123849. get pointerX(): number;
  123850. set pointerX(value: number);
  123851. /**
  123852. * Gets or sets the current on-screen Y position of the pointer
  123853. */
  123854. get pointerY(): number;
  123855. set pointerY(value: number);
  123856. /**
  123857. * Gets the cached material (ie. the latest rendered one)
  123858. * @returns the cached material
  123859. */
  123860. getCachedMaterial(): Nullable<Material>;
  123861. /**
  123862. * Gets the cached effect (ie. the latest rendered one)
  123863. * @returns the cached effect
  123864. */
  123865. getCachedEffect(): Nullable<Effect>;
  123866. /**
  123867. * Gets the cached visibility state (ie. the latest rendered one)
  123868. * @returns the cached visibility state
  123869. */
  123870. getCachedVisibility(): Nullable<number>;
  123871. /**
  123872. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  123873. * @param material defines the current material
  123874. * @param effect defines the current effect
  123875. * @param visibility defines the current visibility state
  123876. * @returns true if one parameter is not cached
  123877. */
  123878. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  123879. /**
  123880. * Gets the engine associated with the scene
  123881. * @returns an Engine
  123882. */
  123883. getEngine(): Engine;
  123884. /**
  123885. * Gets the total number of vertices rendered per frame
  123886. * @returns the total number of vertices rendered per frame
  123887. */
  123888. getTotalVertices(): number;
  123889. /**
  123890. * Gets the performance counter for total vertices
  123891. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123892. */
  123893. get totalVerticesPerfCounter(): PerfCounter;
  123894. /**
  123895. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  123896. * @returns the total number of active indices rendered per frame
  123897. */
  123898. getActiveIndices(): number;
  123899. /**
  123900. * Gets the performance counter for active indices
  123901. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123902. */
  123903. get totalActiveIndicesPerfCounter(): PerfCounter;
  123904. /**
  123905. * Gets the total number of active particles rendered per frame
  123906. * @returns the total number of active particles rendered per frame
  123907. */
  123908. getActiveParticles(): number;
  123909. /**
  123910. * Gets the performance counter for active particles
  123911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123912. */
  123913. get activeParticlesPerfCounter(): PerfCounter;
  123914. /**
  123915. * Gets the total number of active bones rendered per frame
  123916. * @returns the total number of active bones rendered per frame
  123917. */
  123918. getActiveBones(): number;
  123919. /**
  123920. * Gets the performance counter for active bones
  123921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  123922. */
  123923. get activeBonesPerfCounter(): PerfCounter;
  123924. /**
  123925. * Gets the array of active meshes
  123926. * @returns an array of AbstractMesh
  123927. */
  123928. getActiveMeshes(): SmartArray<AbstractMesh>;
  123929. /**
  123930. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  123931. * @returns a number
  123932. */
  123933. getAnimationRatio(): number;
  123934. /**
  123935. * Gets an unique Id for the current render phase
  123936. * @returns a number
  123937. */
  123938. getRenderId(): number;
  123939. /**
  123940. * Gets an unique Id for the current frame
  123941. * @returns a number
  123942. */
  123943. getFrameId(): number;
  123944. /** Call this function if you want to manually increment the render Id*/
  123945. incrementRenderId(): void;
  123946. private _createUbo;
  123947. /**
  123948. * Use this method to simulate a pointer move on a mesh
  123949. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123950. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123951. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123952. * @returns the current scene
  123953. */
  123954. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123955. /**
  123956. * Use this method to simulate a pointer down on a mesh
  123957. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123958. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123959. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123960. * @returns the current scene
  123961. */
  123962. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  123963. /**
  123964. * Use this method to simulate a pointer up on a mesh
  123965. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123966. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123967. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123968. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123969. * @returns the current scene
  123970. */
  123971. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  123972. /**
  123973. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123974. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123975. * @returns true if the pointer was captured
  123976. */
  123977. isPointerCaptured(pointerId?: number): boolean;
  123978. /**
  123979. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123980. * @param attachUp defines if you want to attach events to pointerup
  123981. * @param attachDown defines if you want to attach events to pointerdown
  123982. * @param attachMove defines if you want to attach events to pointermove
  123983. */
  123984. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  123985. /** Detaches all event handlers*/
  123986. detachControl(): void;
  123987. /**
  123988. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  123989. * Delay loaded resources are not taking in account
  123990. * @return true if all required resources are ready
  123991. */
  123992. isReady(): boolean;
  123993. /** Resets all cached information relative to material (including effect and visibility) */
  123994. resetCachedMaterial(): void;
  123995. /**
  123996. * Registers a function to be called before every frame render
  123997. * @param func defines the function to register
  123998. */
  123999. registerBeforeRender(func: () => void): void;
  124000. /**
  124001. * Unregisters a function called before every frame render
  124002. * @param func defines the function to unregister
  124003. */
  124004. unregisterBeforeRender(func: () => void): void;
  124005. /**
  124006. * Registers a function to be called after every frame render
  124007. * @param func defines the function to register
  124008. */
  124009. registerAfterRender(func: () => void): void;
  124010. /**
  124011. * Unregisters a function called after every frame render
  124012. * @param func defines the function to unregister
  124013. */
  124014. unregisterAfterRender(func: () => void): void;
  124015. private _executeOnceBeforeRender;
  124016. /**
  124017. * The provided function will run before render once and will be disposed afterwards.
  124018. * A timeout delay can be provided so that the function will be executed in N ms.
  124019. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124020. * @param func The function to be executed.
  124021. * @param timeout optional delay in ms
  124022. */
  124023. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124024. /** @hidden */
  124025. _addPendingData(data: any): void;
  124026. /** @hidden */
  124027. _removePendingData(data: any): void;
  124028. /**
  124029. * Returns the number of items waiting to be loaded
  124030. * @returns the number of items waiting to be loaded
  124031. */
  124032. getWaitingItemsCount(): number;
  124033. /**
  124034. * Returns a boolean indicating if the scene is still loading data
  124035. */
  124036. get isLoading(): boolean;
  124037. /**
  124038. * Registers a function to be executed when the scene is ready
  124039. * @param {Function} func - the function to be executed
  124040. */
  124041. executeWhenReady(func: () => void): void;
  124042. /**
  124043. * Returns a promise that resolves when the scene is ready
  124044. * @returns A promise that resolves when the scene is ready
  124045. */
  124046. whenReadyAsync(): Promise<void>;
  124047. /** @hidden */
  124048. _checkIsReady(): void;
  124049. /**
  124050. * Gets all animatable attached to the scene
  124051. */
  124052. get animatables(): Animatable[];
  124053. /**
  124054. * Resets the last animation time frame.
  124055. * Useful to override when animations start running when loading a scene for the first time.
  124056. */
  124057. resetLastAnimationTimeFrame(): void;
  124058. /**
  124059. * Gets the current view matrix
  124060. * @returns a Matrix
  124061. */
  124062. getViewMatrix(): Matrix;
  124063. /**
  124064. * Gets the current projection matrix
  124065. * @returns a Matrix
  124066. */
  124067. getProjectionMatrix(): Matrix;
  124068. /**
  124069. * Gets the current transform matrix
  124070. * @returns a Matrix made of View * Projection
  124071. */
  124072. getTransformMatrix(): Matrix;
  124073. /**
  124074. * Sets the current transform matrix
  124075. * @param viewL defines the View matrix to use
  124076. * @param projectionL defines the Projection matrix to use
  124077. * @param viewR defines the right View matrix to use (if provided)
  124078. * @param projectionR defines the right Projection matrix to use (if provided)
  124079. */
  124080. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124081. /**
  124082. * Gets the uniform buffer used to store scene data
  124083. * @returns a UniformBuffer
  124084. */
  124085. getSceneUniformBuffer(): UniformBuffer;
  124086. /**
  124087. * Gets an unique (relatively to the current scene) Id
  124088. * @returns an unique number for the scene
  124089. */
  124090. getUniqueId(): number;
  124091. /**
  124092. * Add a mesh to the list of scene's meshes
  124093. * @param newMesh defines the mesh to add
  124094. * @param recursive if all child meshes should also be added to the scene
  124095. */
  124096. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124097. /**
  124098. * Remove a mesh for the list of scene's meshes
  124099. * @param toRemove defines the mesh to remove
  124100. * @param recursive if all child meshes should also be removed from the scene
  124101. * @returns the index where the mesh was in the mesh list
  124102. */
  124103. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124104. /**
  124105. * Add a transform node to the list of scene's transform nodes
  124106. * @param newTransformNode defines the transform node to add
  124107. */
  124108. addTransformNode(newTransformNode: TransformNode): void;
  124109. /**
  124110. * Remove a transform node for the list of scene's transform nodes
  124111. * @param toRemove defines the transform node to remove
  124112. * @returns the index where the transform node was in the transform node list
  124113. */
  124114. removeTransformNode(toRemove: TransformNode): number;
  124115. /**
  124116. * Remove a skeleton for the list of scene's skeletons
  124117. * @param toRemove defines the skeleton to remove
  124118. * @returns the index where the skeleton was in the skeleton list
  124119. */
  124120. removeSkeleton(toRemove: Skeleton): number;
  124121. /**
  124122. * Remove a morph target for the list of scene's morph targets
  124123. * @param toRemove defines the morph target to remove
  124124. * @returns the index where the morph target was in the morph target list
  124125. */
  124126. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124127. /**
  124128. * Remove a light for the list of scene's lights
  124129. * @param toRemove defines the light to remove
  124130. * @returns the index where the light was in the light list
  124131. */
  124132. removeLight(toRemove: Light): number;
  124133. /**
  124134. * Remove a camera for the list of scene's cameras
  124135. * @param toRemove defines the camera to remove
  124136. * @returns the index where the camera was in the camera list
  124137. */
  124138. removeCamera(toRemove: Camera): number;
  124139. /**
  124140. * Remove a particle system for the list of scene's particle systems
  124141. * @param toRemove defines the particle system to remove
  124142. * @returns the index where the particle system was in the particle system list
  124143. */
  124144. removeParticleSystem(toRemove: IParticleSystem): number;
  124145. /**
  124146. * Remove a animation for the list of scene's animations
  124147. * @param toRemove defines the animation to remove
  124148. * @returns the index where the animation was in the animation list
  124149. */
  124150. removeAnimation(toRemove: Animation): number;
  124151. /**
  124152. * Will stop the animation of the given target
  124153. * @param target - the target
  124154. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124155. * @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)
  124156. */
  124157. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124158. /**
  124159. * Removes the given animation group from this scene.
  124160. * @param toRemove The animation group to remove
  124161. * @returns The index of the removed animation group
  124162. */
  124163. removeAnimationGroup(toRemove: AnimationGroup): number;
  124164. /**
  124165. * Removes the given multi-material from this scene.
  124166. * @param toRemove The multi-material to remove
  124167. * @returns The index of the removed multi-material
  124168. */
  124169. removeMultiMaterial(toRemove: MultiMaterial): number;
  124170. /**
  124171. * Removes the given material from this scene.
  124172. * @param toRemove The material to remove
  124173. * @returns The index of the removed material
  124174. */
  124175. removeMaterial(toRemove: Material): number;
  124176. /**
  124177. * Removes the given action manager from this scene.
  124178. * @param toRemove The action manager to remove
  124179. * @returns The index of the removed action manager
  124180. */
  124181. removeActionManager(toRemove: AbstractActionManager): number;
  124182. /**
  124183. * Removes the given texture from this scene.
  124184. * @param toRemove The texture to remove
  124185. * @returns The index of the removed texture
  124186. */
  124187. removeTexture(toRemove: BaseTexture): number;
  124188. /**
  124189. * Adds the given light to this scene
  124190. * @param newLight The light to add
  124191. */
  124192. addLight(newLight: Light): void;
  124193. /**
  124194. * Sorts the list list based on light priorities
  124195. */
  124196. sortLightsByPriority(): void;
  124197. /**
  124198. * Adds the given camera to this scene
  124199. * @param newCamera The camera to add
  124200. */
  124201. addCamera(newCamera: Camera): void;
  124202. /**
  124203. * Adds the given skeleton to this scene
  124204. * @param newSkeleton The skeleton to add
  124205. */
  124206. addSkeleton(newSkeleton: Skeleton): void;
  124207. /**
  124208. * Adds the given particle system to this scene
  124209. * @param newParticleSystem The particle system to add
  124210. */
  124211. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124212. /**
  124213. * Adds the given animation to this scene
  124214. * @param newAnimation The animation to add
  124215. */
  124216. addAnimation(newAnimation: Animation): void;
  124217. /**
  124218. * Adds the given animation group to this scene.
  124219. * @param newAnimationGroup The animation group to add
  124220. */
  124221. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124222. /**
  124223. * Adds the given multi-material to this scene
  124224. * @param newMultiMaterial The multi-material to add
  124225. */
  124226. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124227. /**
  124228. * Adds the given material to this scene
  124229. * @param newMaterial The material to add
  124230. */
  124231. addMaterial(newMaterial: Material): void;
  124232. /**
  124233. * Adds the given morph target to this scene
  124234. * @param newMorphTargetManager The morph target to add
  124235. */
  124236. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124237. /**
  124238. * Adds the given geometry to this scene
  124239. * @param newGeometry The geometry to add
  124240. */
  124241. addGeometry(newGeometry: Geometry): void;
  124242. /**
  124243. * Adds the given action manager to this scene
  124244. * @param newActionManager The action manager to add
  124245. */
  124246. addActionManager(newActionManager: AbstractActionManager): void;
  124247. /**
  124248. * Adds the given texture to this scene.
  124249. * @param newTexture The texture to add
  124250. */
  124251. addTexture(newTexture: BaseTexture): void;
  124252. /**
  124253. * Switch active camera
  124254. * @param newCamera defines the new active camera
  124255. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124256. */
  124257. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124258. /**
  124259. * sets the active camera of the scene using its ID
  124260. * @param id defines the camera's ID
  124261. * @return the new active camera or null if none found.
  124262. */
  124263. setActiveCameraByID(id: string): Nullable<Camera>;
  124264. /**
  124265. * sets the active camera of the scene using its name
  124266. * @param name defines the camera's name
  124267. * @returns the new active camera or null if none found.
  124268. */
  124269. setActiveCameraByName(name: string): Nullable<Camera>;
  124270. /**
  124271. * get an animation group using its name
  124272. * @param name defines the material's name
  124273. * @return the animation group or null if none found.
  124274. */
  124275. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124276. /**
  124277. * Get a material using its unique id
  124278. * @param uniqueId defines the material's unique id
  124279. * @return the material or null if none found.
  124280. */
  124281. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124282. /**
  124283. * get a material using its id
  124284. * @param id defines the material's ID
  124285. * @return the material or null if none found.
  124286. */
  124287. getMaterialByID(id: string): Nullable<Material>;
  124288. /**
  124289. * Gets a the last added material using a given id
  124290. * @param id defines the material's ID
  124291. * @return the last material with the given id or null if none found.
  124292. */
  124293. getLastMaterialByID(id: string): Nullable<Material>;
  124294. /**
  124295. * Gets a material using its name
  124296. * @param name defines the material's name
  124297. * @return the material or null if none found.
  124298. */
  124299. getMaterialByName(name: string): Nullable<Material>;
  124300. /**
  124301. * Get a texture using its unique id
  124302. * @param uniqueId defines the texture's unique id
  124303. * @return the texture or null if none found.
  124304. */
  124305. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124306. /**
  124307. * Gets a camera using its id
  124308. * @param id defines the id to look for
  124309. * @returns the camera or null if not found
  124310. */
  124311. getCameraByID(id: string): Nullable<Camera>;
  124312. /**
  124313. * Gets a camera using its unique id
  124314. * @param uniqueId defines the unique id to look for
  124315. * @returns the camera or null if not found
  124316. */
  124317. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124318. /**
  124319. * Gets a camera using its name
  124320. * @param name defines the camera's name
  124321. * @return the camera or null if none found.
  124322. */
  124323. getCameraByName(name: string): Nullable<Camera>;
  124324. /**
  124325. * Gets a bone using its id
  124326. * @param id defines the bone's id
  124327. * @return the bone or null if not found
  124328. */
  124329. getBoneByID(id: string): Nullable<Bone>;
  124330. /**
  124331. * Gets a bone using its id
  124332. * @param name defines the bone's name
  124333. * @return the bone or null if not found
  124334. */
  124335. getBoneByName(name: string): Nullable<Bone>;
  124336. /**
  124337. * Gets a light node using its name
  124338. * @param name defines the the light's name
  124339. * @return the light or null if none found.
  124340. */
  124341. getLightByName(name: string): Nullable<Light>;
  124342. /**
  124343. * Gets a light node using its id
  124344. * @param id defines the light's id
  124345. * @return the light or null if none found.
  124346. */
  124347. getLightByID(id: string): Nullable<Light>;
  124348. /**
  124349. * Gets a light node using its scene-generated unique ID
  124350. * @param uniqueId defines the light's unique id
  124351. * @return the light or null if none found.
  124352. */
  124353. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124354. /**
  124355. * Gets a particle system by id
  124356. * @param id defines the particle system id
  124357. * @return the corresponding system or null if none found
  124358. */
  124359. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124360. /**
  124361. * Gets a geometry using its ID
  124362. * @param id defines the geometry's id
  124363. * @return the geometry or null if none found.
  124364. */
  124365. getGeometryByID(id: string): Nullable<Geometry>;
  124366. private _getGeometryByUniqueID;
  124367. /**
  124368. * Add a new geometry to this scene
  124369. * @param geometry defines the geometry to be added to the scene.
  124370. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124371. * @return a boolean defining if the geometry was added or not
  124372. */
  124373. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124374. /**
  124375. * Removes an existing geometry
  124376. * @param geometry defines the geometry to be removed from the scene
  124377. * @return a boolean defining if the geometry was removed or not
  124378. */
  124379. removeGeometry(geometry: Geometry): boolean;
  124380. /**
  124381. * Gets the list of geometries attached to the scene
  124382. * @returns an array of Geometry
  124383. */
  124384. getGeometries(): Geometry[];
  124385. /**
  124386. * Gets the first added mesh found of a given ID
  124387. * @param id defines the id to search for
  124388. * @return the mesh found or null if not found at all
  124389. */
  124390. getMeshByID(id: string): Nullable<AbstractMesh>;
  124391. /**
  124392. * Gets a list of meshes using their id
  124393. * @param id defines the id to search for
  124394. * @returns a list of meshes
  124395. */
  124396. getMeshesByID(id: string): Array<AbstractMesh>;
  124397. /**
  124398. * Gets the first added transform node found of a given ID
  124399. * @param id defines the id to search for
  124400. * @return the found transform node or null if not found at all.
  124401. */
  124402. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124403. /**
  124404. * Gets a transform node with its auto-generated unique id
  124405. * @param uniqueId efines the unique id to search for
  124406. * @return the found transform node or null if not found at all.
  124407. */
  124408. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124409. /**
  124410. * Gets a list of transform nodes using their id
  124411. * @param id defines the id to search for
  124412. * @returns a list of transform nodes
  124413. */
  124414. getTransformNodesByID(id: string): Array<TransformNode>;
  124415. /**
  124416. * Gets a mesh with its auto-generated unique id
  124417. * @param uniqueId defines the unique id to search for
  124418. * @return the found mesh or null if not found at all.
  124419. */
  124420. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124421. /**
  124422. * Gets a the last added mesh using a given id
  124423. * @param id defines the id to search for
  124424. * @return the found mesh or null if not found at all.
  124425. */
  124426. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124427. /**
  124428. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124429. * @param id defines the id to search for
  124430. * @return the found node or null if not found at all
  124431. */
  124432. getLastEntryByID(id: string): Nullable<Node>;
  124433. /**
  124434. * Gets a node (Mesh, Camera, Light) using a given id
  124435. * @param id defines the id to search for
  124436. * @return the found node or null if not found at all
  124437. */
  124438. getNodeByID(id: string): Nullable<Node>;
  124439. /**
  124440. * Gets a node (Mesh, Camera, Light) using a given name
  124441. * @param name defines the name to search for
  124442. * @return the found node or null if not found at all.
  124443. */
  124444. getNodeByName(name: string): Nullable<Node>;
  124445. /**
  124446. * Gets a mesh using a given name
  124447. * @param name defines the name to search for
  124448. * @return the found mesh or null if not found at all.
  124449. */
  124450. getMeshByName(name: string): Nullable<AbstractMesh>;
  124451. /**
  124452. * Gets a transform node using a given name
  124453. * @param name defines the name to search for
  124454. * @return the found transform node or null if not found at all.
  124455. */
  124456. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124457. /**
  124458. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124459. * @param id defines the id to search for
  124460. * @return the found skeleton or null if not found at all.
  124461. */
  124462. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124463. /**
  124464. * Gets a skeleton using a given auto generated unique id
  124465. * @param uniqueId defines the unique id to search for
  124466. * @return the found skeleton or null if not found at all.
  124467. */
  124468. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124469. /**
  124470. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124471. * @param id defines the id to search for
  124472. * @return the found skeleton or null if not found at all.
  124473. */
  124474. getSkeletonById(id: string): Nullable<Skeleton>;
  124475. /**
  124476. * Gets a skeleton using a given name
  124477. * @param name defines the name to search for
  124478. * @return the found skeleton or null if not found at all.
  124479. */
  124480. getSkeletonByName(name: string): Nullable<Skeleton>;
  124481. /**
  124482. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124483. * @param id defines the id to search for
  124484. * @return the found morph target manager or null if not found at all.
  124485. */
  124486. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124487. /**
  124488. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124489. * @param id defines the id to search for
  124490. * @return the found morph target or null if not found at all.
  124491. */
  124492. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124493. /**
  124494. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124495. * @param name defines the name to search for
  124496. * @return the found morph target or null if not found at all.
  124497. */
  124498. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124499. /**
  124500. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124501. * @param name defines the name to search for
  124502. * @return the found post process or null if not found at all.
  124503. */
  124504. getPostProcessByName(name: string): Nullable<PostProcess>;
  124505. /**
  124506. * Gets a boolean indicating if the given mesh is active
  124507. * @param mesh defines the mesh to look for
  124508. * @returns true if the mesh is in the active list
  124509. */
  124510. isActiveMesh(mesh: AbstractMesh): boolean;
  124511. /**
  124512. * Return a unique id as a string which can serve as an identifier for the scene
  124513. */
  124514. get uid(): string;
  124515. /**
  124516. * Add an externaly attached data from its key.
  124517. * This method call will fail and return false, if such key already exists.
  124518. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124519. * @param key the unique key that identifies the data
  124520. * @param data the data object to associate to the key for this Engine instance
  124521. * @return true if no such key were already present and the data was added successfully, false otherwise
  124522. */
  124523. addExternalData<T>(key: string, data: T): boolean;
  124524. /**
  124525. * Get an externaly attached data from its key
  124526. * @param key the unique key that identifies the data
  124527. * @return the associated data, if present (can be null), or undefined if not present
  124528. */
  124529. getExternalData<T>(key: string): Nullable<T>;
  124530. /**
  124531. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124532. * @param key the unique key that identifies the data
  124533. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124534. * @return the associated data, can be null if the factory returned null.
  124535. */
  124536. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124537. /**
  124538. * Remove an externaly attached data from the Engine instance
  124539. * @param key the unique key that identifies the data
  124540. * @return true if the data was successfully removed, false if it doesn't exist
  124541. */
  124542. removeExternalData(key: string): boolean;
  124543. private _evaluateSubMesh;
  124544. /**
  124545. * Clear the processed materials smart array preventing retention point in material dispose.
  124546. */
  124547. freeProcessedMaterials(): void;
  124548. private _preventFreeActiveMeshesAndRenderingGroups;
  124549. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124550. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124551. * when disposing several meshes in a row or a hierarchy of meshes.
  124552. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124553. */
  124554. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124555. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124556. /**
  124557. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124558. */
  124559. freeActiveMeshes(): void;
  124560. /**
  124561. * Clear the info related to rendering groups preventing retention points during dispose.
  124562. */
  124563. freeRenderingGroups(): void;
  124564. /** @hidden */
  124565. _isInIntermediateRendering(): boolean;
  124566. /**
  124567. * Lambda returning the list of potentially active meshes.
  124568. */
  124569. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124570. /**
  124571. * Lambda returning the list of potentially active sub meshes.
  124572. */
  124573. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124574. /**
  124575. * Lambda returning the list of potentially intersecting sub meshes.
  124576. */
  124577. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124578. /**
  124579. * Lambda returning the list of potentially colliding sub meshes.
  124580. */
  124581. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124582. private _activeMeshesFrozen;
  124583. private _skipEvaluateActiveMeshesCompletely;
  124584. /**
  124585. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124586. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124587. * @param onSuccess optional success callback
  124588. * @param onError optional error callback
  124589. * @returns the current scene
  124590. */
  124591. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124592. /**
  124593. * Use this function to restart evaluating active meshes on every frame
  124594. * @returns the current scene
  124595. */
  124596. unfreezeActiveMeshes(): Scene;
  124597. private _evaluateActiveMeshes;
  124598. private _activeMesh;
  124599. /**
  124600. * Update the transform matrix to update from the current active camera
  124601. * @param force defines a boolean used to force the update even if cache is up to date
  124602. */
  124603. updateTransformMatrix(force?: boolean): void;
  124604. private _bindFrameBuffer;
  124605. /** @hidden */
  124606. _allowPostProcessClearColor: boolean;
  124607. /** @hidden */
  124608. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124609. private _processSubCameras;
  124610. private _checkIntersections;
  124611. /** @hidden */
  124612. _advancePhysicsEngineStep(step: number): void;
  124613. /**
  124614. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124615. */
  124616. getDeterministicFrameTime: () => number;
  124617. /** @hidden */
  124618. _animate(): void;
  124619. /** Execute all animations (for a frame) */
  124620. animate(): void;
  124621. /**
  124622. * Render the scene
  124623. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124624. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124625. */
  124626. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124627. /**
  124628. * Freeze all materials
  124629. * A frozen material will not be updatable but should be faster to render
  124630. */
  124631. freezeMaterials(): void;
  124632. /**
  124633. * Unfreeze all materials
  124634. * A frozen material will not be updatable but should be faster to render
  124635. */
  124636. unfreezeMaterials(): void;
  124637. /**
  124638. * Releases all held ressources
  124639. */
  124640. dispose(): void;
  124641. /**
  124642. * Gets if the scene is already disposed
  124643. */
  124644. get isDisposed(): boolean;
  124645. /**
  124646. * Call this function to reduce memory footprint of the scene.
  124647. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124648. */
  124649. clearCachedVertexData(): void;
  124650. /**
  124651. * This function will remove the local cached buffer data from texture.
  124652. * It will save memory but will prevent the texture from being rebuilt
  124653. */
  124654. cleanCachedTextureBuffer(): void;
  124655. /**
  124656. * Get the world extend vectors with an optional filter
  124657. *
  124658. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124659. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124660. */
  124661. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124662. min: Vector3;
  124663. max: Vector3;
  124664. };
  124665. /**
  124666. * Creates a ray that can be used to pick in the scene
  124667. * @param x defines the x coordinate of the origin (on-screen)
  124668. * @param y defines the y coordinate of the origin (on-screen)
  124669. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124670. * @param camera defines the camera to use for the picking
  124671. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124672. * @returns a Ray
  124673. */
  124674. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124675. /**
  124676. * Creates a ray that can be used to pick in the scene
  124677. * @param x defines the x coordinate of the origin (on-screen)
  124678. * @param y defines the y coordinate of the origin (on-screen)
  124679. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124680. * @param result defines the ray where to store the picking ray
  124681. * @param camera defines the camera to use for the picking
  124682. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124683. * @returns the current scene
  124684. */
  124685. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124686. /**
  124687. * Creates a ray that can be used to pick in the scene
  124688. * @param x defines the x coordinate of the origin (on-screen)
  124689. * @param y defines the y coordinate of the origin (on-screen)
  124690. * @param camera defines the camera to use for the picking
  124691. * @returns a Ray
  124692. */
  124693. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124694. /**
  124695. * Creates a ray that can be used to pick in the scene
  124696. * @param x defines the x coordinate of the origin (on-screen)
  124697. * @param y defines the y coordinate of the origin (on-screen)
  124698. * @param result defines the ray where to store the picking ray
  124699. * @param camera defines the camera to use for the picking
  124700. * @returns the current scene
  124701. */
  124702. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124703. /** Launch a ray to try to pick a mesh in the scene
  124704. * @param x position on screen
  124705. * @param y position on screen
  124706. * @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
  124707. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124708. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124710. * @returns a PickingInfo
  124711. */
  124712. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124713. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124714. * @param x position on screen
  124715. * @param y position on screen
  124716. * @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
  124717. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124718. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124719. * @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)
  124720. */
  124721. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124722. /** Use the given ray to pick a mesh in the scene
  124723. * @param ray The ray to use to pick meshes
  124724. * @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
  124725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124726. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124727. * @returns a PickingInfo
  124728. */
  124729. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124730. /**
  124731. * Launch a ray to try to pick a mesh in the scene
  124732. * @param x X position on screen
  124733. * @param y Y position on screen
  124734. * @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
  124735. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124736. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124737. * @returns an array of PickingInfo
  124738. */
  124739. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124740. /**
  124741. * Launch a ray to try to pick a mesh in the scene
  124742. * @param ray Ray to use
  124743. * @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
  124744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124745. * @returns an array of PickingInfo
  124746. */
  124747. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124748. /**
  124749. * Force the value of meshUnderPointer
  124750. * @param mesh defines the mesh to use
  124751. * @param pointerId optional pointer id when using more than one pointer
  124752. */
  124753. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124754. /**
  124755. * Gets the mesh under the pointer
  124756. * @returns a Mesh or null if no mesh is under the pointer
  124757. */
  124758. getPointerOverMesh(): Nullable<AbstractMesh>;
  124759. /** @hidden */
  124760. _rebuildGeometries(): void;
  124761. /** @hidden */
  124762. _rebuildTextures(): void;
  124763. private _getByTags;
  124764. /**
  124765. * Get a list of meshes by tags
  124766. * @param tagsQuery defines the tags query to use
  124767. * @param forEach defines a predicate used to filter results
  124768. * @returns an array of Mesh
  124769. */
  124770. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124771. /**
  124772. * Get a list of cameras by tags
  124773. * @param tagsQuery defines the tags query to use
  124774. * @param forEach defines a predicate used to filter results
  124775. * @returns an array of Camera
  124776. */
  124777. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124778. /**
  124779. * Get a list of lights by tags
  124780. * @param tagsQuery defines the tags query to use
  124781. * @param forEach defines a predicate used to filter results
  124782. * @returns an array of Light
  124783. */
  124784. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124785. /**
  124786. * Get a list of materials by tags
  124787. * @param tagsQuery defines the tags query to use
  124788. * @param forEach defines a predicate used to filter results
  124789. * @returns an array of Material
  124790. */
  124791. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124792. /**
  124793. * Get a list of transform nodes by tags
  124794. * @param tagsQuery defines the tags query to use
  124795. * @param forEach defines a predicate used to filter results
  124796. * @returns an array of TransformNode
  124797. */
  124798. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  124799. /**
  124800. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124801. * This allowed control for front to back rendering or reversly depending of the special needs.
  124802. *
  124803. * @param renderingGroupId The rendering group id corresponding to its index
  124804. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124805. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124806. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124807. */
  124808. 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;
  124809. /**
  124810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124811. *
  124812. * @param renderingGroupId The rendering group id corresponding to its index
  124813. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124814. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124815. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124816. */
  124817. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  124818. /**
  124819. * Gets the current auto clear configuration for one rendering group of the rendering
  124820. * manager.
  124821. * @param index the rendering group index to get the information for
  124822. * @returns The auto clear setup for the requested rendering group
  124823. */
  124824. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  124825. private _blockMaterialDirtyMechanism;
  124826. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  124827. get blockMaterialDirtyMechanism(): boolean;
  124828. set blockMaterialDirtyMechanism(value: boolean);
  124829. /**
  124830. * Will flag all materials as dirty to trigger new shader compilation
  124831. * @param flag defines the flag used to specify which material part must be marked as dirty
  124832. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  124833. */
  124834. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  124835. /** @hidden */
  124836. _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;
  124837. /** @hidden */
  124838. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124839. /** @hidden */
  124840. _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;
  124841. /** @hidden */
  124842. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  124843. /** @hidden */
  124844. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  124845. /** @hidden */
  124846. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124847. }
  124848. }
  124849. declare module BABYLON {
  124850. /**
  124851. * Set of assets to keep when moving a scene into an asset container.
  124852. */
  124853. export class KeepAssets extends AbstractScene {
  124854. }
  124855. /**
  124856. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  124857. */
  124858. export class InstantiatedEntries {
  124859. /**
  124860. * List of new root nodes (eg. nodes with no parent)
  124861. */
  124862. rootNodes: TransformNode[];
  124863. /**
  124864. * List of new skeletons
  124865. */
  124866. skeletons: Skeleton[];
  124867. /**
  124868. * List of new animation groups
  124869. */
  124870. animationGroups: AnimationGroup[];
  124871. }
  124872. /**
  124873. * Container with a set of assets that can be added or removed from a scene.
  124874. */
  124875. export class AssetContainer extends AbstractScene {
  124876. private _wasAddedToScene;
  124877. /**
  124878. * The scene the AssetContainer belongs to.
  124879. */
  124880. scene: Scene;
  124881. /**
  124882. * Instantiates an AssetContainer.
  124883. * @param scene The scene the AssetContainer belongs to.
  124884. */
  124885. constructor(scene: Scene);
  124886. /**
  124887. * Instantiate or clone all meshes and add the new ones to the scene.
  124888. * Skeletons and animation groups will all be cloned
  124889. * @param nameFunction defines an optional function used to get new names for clones
  124890. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  124891. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  124892. */
  124893. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  124894. /**
  124895. * Adds all the assets from the container to the scene.
  124896. */
  124897. addAllToScene(): void;
  124898. /**
  124899. * Removes all the assets in the container from the scene
  124900. */
  124901. removeAllFromScene(): void;
  124902. /**
  124903. * Disposes all the assets in the container
  124904. */
  124905. dispose(): void;
  124906. private _moveAssets;
  124907. /**
  124908. * Removes all the assets contained in the scene and adds them to the container.
  124909. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  124910. */
  124911. moveAllFromScene(keepAssets?: KeepAssets): void;
  124912. /**
  124913. * 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.
  124914. * @returns the root mesh
  124915. */
  124916. createRootMesh(): Mesh;
  124917. /**
  124918. * Merge animations (direct and animation groups) from this asset container into a scene
  124919. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124920. * @param animatables set of animatables to retarget to a node from the scene
  124921. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  124922. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  124923. */
  124924. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  124925. }
  124926. }
  124927. declare module BABYLON {
  124928. /**
  124929. * Defines how the parser contract is defined.
  124930. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  124931. */
  124932. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  124933. /**
  124934. * Defines how the individual parser contract is defined.
  124935. * These parser can parse an individual asset
  124936. */
  124937. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  124938. /**
  124939. * Base class of the scene acting as a container for the different elements composing a scene.
  124940. * This class is dynamically extended by the different components of the scene increasing
  124941. * flexibility and reducing coupling
  124942. */
  124943. export abstract class AbstractScene {
  124944. /**
  124945. * Stores the list of available parsers in the application.
  124946. */
  124947. private static _BabylonFileParsers;
  124948. /**
  124949. * Stores the list of available individual parsers in the application.
  124950. */
  124951. private static _IndividualBabylonFileParsers;
  124952. /**
  124953. * Adds a parser in the list of available ones
  124954. * @param name Defines the name of the parser
  124955. * @param parser Defines the parser to add
  124956. */
  124957. static AddParser(name: string, parser: BabylonFileParser): void;
  124958. /**
  124959. * Gets a general parser from the list of avaialble ones
  124960. * @param name Defines the name of the parser
  124961. * @returns the requested parser or null
  124962. */
  124963. static GetParser(name: string): Nullable<BabylonFileParser>;
  124964. /**
  124965. * Adds n individual parser in the list of available ones
  124966. * @param name Defines the name of the parser
  124967. * @param parser Defines the parser to add
  124968. */
  124969. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  124970. /**
  124971. * Gets an individual parser from the list of avaialble ones
  124972. * @param name Defines the name of the parser
  124973. * @returns the requested parser or null
  124974. */
  124975. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  124976. /**
  124977. * Parser json data and populate both a scene and its associated container object
  124978. * @param jsonData Defines the data to parse
  124979. * @param scene Defines the scene to parse the data for
  124980. * @param container Defines the container attached to the parsing sequence
  124981. * @param rootUrl Defines the root url of the data
  124982. */
  124983. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  124984. /**
  124985. * Gets the list of root nodes (ie. nodes with no parent)
  124986. */
  124987. rootNodes: Node[];
  124988. /** All of the cameras added to this scene
  124989. * @see https://doc.babylonjs.com/babylon101/cameras
  124990. */
  124991. cameras: Camera[];
  124992. /**
  124993. * All of the lights added to this scene
  124994. * @see https://doc.babylonjs.com/babylon101/lights
  124995. */
  124996. lights: Light[];
  124997. /**
  124998. * All of the (abstract) meshes added to this scene
  124999. */
  125000. meshes: AbstractMesh[];
  125001. /**
  125002. * The list of skeletons added to the scene
  125003. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125004. */
  125005. skeletons: Skeleton[];
  125006. /**
  125007. * All of the particle systems added to this scene
  125008. * @see https://doc.babylonjs.com/babylon101/particles
  125009. */
  125010. particleSystems: IParticleSystem[];
  125011. /**
  125012. * Gets a list of Animations associated with the scene
  125013. */
  125014. animations: Animation[];
  125015. /**
  125016. * All of the animation groups added to this scene
  125017. * @see https://doc.babylonjs.com/how_to/group
  125018. */
  125019. animationGroups: AnimationGroup[];
  125020. /**
  125021. * All of the multi-materials added to this scene
  125022. * @see https://doc.babylonjs.com/how_to/multi_materials
  125023. */
  125024. multiMaterials: MultiMaterial[];
  125025. /**
  125026. * All of the materials added to this scene
  125027. * In the context of a Scene, it is not supposed to be modified manually.
  125028. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125029. * Note also that the order of the Material within the array is not significant and might change.
  125030. * @see https://doc.babylonjs.com/babylon101/materials
  125031. */
  125032. materials: Material[];
  125033. /**
  125034. * The list of morph target managers added to the scene
  125035. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125036. */
  125037. morphTargetManagers: MorphTargetManager[];
  125038. /**
  125039. * The list of geometries used in the scene.
  125040. */
  125041. geometries: Geometry[];
  125042. /**
  125043. * All of the tranform nodes added to this scene
  125044. * In the context of a Scene, it is not supposed to be modified manually.
  125045. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125046. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125047. * @see https://doc.babylonjs.com/how_to/transformnode
  125048. */
  125049. transformNodes: TransformNode[];
  125050. /**
  125051. * ActionManagers available on the scene.
  125052. */
  125053. actionManagers: AbstractActionManager[];
  125054. /**
  125055. * Textures to keep.
  125056. */
  125057. textures: BaseTexture[];
  125058. /** @hidden */
  125059. protected _environmentTexture: Nullable<BaseTexture>;
  125060. /**
  125061. * Texture used in all pbr material as the reflection texture.
  125062. * As in the majority of the scene they are the same (exception for multi room and so on),
  125063. * this is easier to reference from here than from all the materials.
  125064. */
  125065. get environmentTexture(): Nullable<BaseTexture>;
  125066. set environmentTexture(value: Nullable<BaseTexture>);
  125067. /**
  125068. * The list of postprocesses added to the scene
  125069. */
  125070. postProcesses: PostProcess[];
  125071. /**
  125072. * @returns all meshes, lights, cameras, transformNodes and bones
  125073. */
  125074. getNodes(): Array<Node>;
  125075. }
  125076. }
  125077. declare module BABYLON {
  125078. /**
  125079. * Interface used to define options for Sound class
  125080. */
  125081. export interface ISoundOptions {
  125082. /**
  125083. * Does the sound autoplay once loaded.
  125084. */
  125085. autoplay?: boolean;
  125086. /**
  125087. * Does the sound loop after it finishes playing once.
  125088. */
  125089. loop?: boolean;
  125090. /**
  125091. * Sound's volume
  125092. */
  125093. volume?: number;
  125094. /**
  125095. * Is it a spatial sound?
  125096. */
  125097. spatialSound?: boolean;
  125098. /**
  125099. * Maximum distance to hear that sound
  125100. */
  125101. maxDistance?: number;
  125102. /**
  125103. * Uses user defined attenuation function
  125104. */
  125105. useCustomAttenuation?: boolean;
  125106. /**
  125107. * Define the roll off factor of spatial sounds.
  125108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125109. */
  125110. rolloffFactor?: number;
  125111. /**
  125112. * Define the reference distance the sound should be heard perfectly.
  125113. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125114. */
  125115. refDistance?: number;
  125116. /**
  125117. * Define the distance attenuation model the sound will follow.
  125118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125119. */
  125120. distanceModel?: string;
  125121. /**
  125122. * Defines the playback speed (1 by default)
  125123. */
  125124. playbackRate?: number;
  125125. /**
  125126. * Defines if the sound is from a streaming source
  125127. */
  125128. streaming?: boolean;
  125129. /**
  125130. * Defines an optional length (in seconds) inside the sound file
  125131. */
  125132. length?: number;
  125133. /**
  125134. * Defines an optional offset (in seconds) inside the sound file
  125135. */
  125136. offset?: number;
  125137. /**
  125138. * If true, URLs will not be required to state the audio file codec to use.
  125139. */
  125140. skipCodecCheck?: boolean;
  125141. }
  125142. /**
  125143. * Defines a sound that can be played in the application.
  125144. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125145. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125146. */
  125147. export class Sound {
  125148. /**
  125149. * The name of the sound in the scene.
  125150. */
  125151. name: string;
  125152. /**
  125153. * Does the sound autoplay once loaded.
  125154. */
  125155. autoplay: boolean;
  125156. /**
  125157. * Does the sound loop after it finishes playing once.
  125158. */
  125159. loop: boolean;
  125160. /**
  125161. * Does the sound use a custom attenuation curve to simulate the falloff
  125162. * happening when the source gets further away from the camera.
  125163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125164. */
  125165. useCustomAttenuation: boolean;
  125166. /**
  125167. * The sound track id this sound belongs to.
  125168. */
  125169. soundTrackId: number;
  125170. /**
  125171. * Is this sound currently played.
  125172. */
  125173. isPlaying: boolean;
  125174. /**
  125175. * Is this sound currently paused.
  125176. */
  125177. isPaused: boolean;
  125178. /**
  125179. * Does this sound enables spatial sound.
  125180. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125181. */
  125182. spatialSound: boolean;
  125183. /**
  125184. * Define the reference distance the sound should be heard perfectly.
  125185. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125186. */
  125187. refDistance: number;
  125188. /**
  125189. * Define the roll off factor of spatial sounds.
  125190. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125191. */
  125192. rolloffFactor: number;
  125193. /**
  125194. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125196. */
  125197. maxDistance: number;
  125198. /**
  125199. * Define the distance attenuation model the sound will follow.
  125200. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125201. */
  125202. distanceModel: string;
  125203. /**
  125204. * @hidden
  125205. * Back Compat
  125206. **/
  125207. onended: () => any;
  125208. /**
  125209. * Gets or sets an object used to store user defined information for the sound.
  125210. */
  125211. metadata: any;
  125212. /**
  125213. * Observable event when the current playing sound finishes.
  125214. */
  125215. onEndedObservable: Observable<Sound>;
  125216. private _panningModel;
  125217. private _playbackRate;
  125218. private _streaming;
  125219. private _startTime;
  125220. private _startOffset;
  125221. private _position;
  125222. /** @hidden */
  125223. _positionInEmitterSpace: boolean;
  125224. private _localDirection;
  125225. private _volume;
  125226. private _isReadyToPlay;
  125227. private _isDirectional;
  125228. private _readyToPlayCallback;
  125229. private _audioBuffer;
  125230. private _soundSource;
  125231. private _streamingSource;
  125232. private _soundPanner;
  125233. private _soundGain;
  125234. private _inputAudioNode;
  125235. private _outputAudioNode;
  125236. private _coneInnerAngle;
  125237. private _coneOuterAngle;
  125238. private _coneOuterGain;
  125239. private _scene;
  125240. private _connectedTransformNode;
  125241. private _customAttenuationFunction;
  125242. private _registerFunc;
  125243. private _isOutputConnected;
  125244. private _htmlAudioElement;
  125245. private _urlType;
  125246. private _length?;
  125247. private _offset?;
  125248. /** @hidden */
  125249. static _SceneComponentInitialization: (scene: Scene) => void;
  125250. /**
  125251. * Create a sound and attach it to a scene
  125252. * @param name Name of your sound
  125253. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125254. * @param scene defines the scene the sound belongs to
  125255. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125256. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125257. */
  125258. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125259. /**
  125260. * Release the sound and its associated resources
  125261. */
  125262. dispose(): void;
  125263. /**
  125264. * Gets if the sounds is ready to be played or not.
  125265. * @returns true if ready, otherwise false
  125266. */
  125267. isReady(): boolean;
  125268. private _soundLoaded;
  125269. /**
  125270. * Sets the data of the sound from an audiobuffer
  125271. * @param audioBuffer The audioBuffer containing the data
  125272. */
  125273. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125274. /**
  125275. * Updates the current sounds options such as maxdistance, loop...
  125276. * @param options A JSON object containing values named as the object properties
  125277. */
  125278. updateOptions(options: ISoundOptions): void;
  125279. private _createSpatialParameters;
  125280. private _updateSpatialParameters;
  125281. /**
  125282. * Switch the panning model to HRTF:
  125283. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125285. */
  125286. switchPanningModelToHRTF(): void;
  125287. /**
  125288. * Switch the panning model to Equal Power:
  125289. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125291. */
  125292. switchPanningModelToEqualPower(): void;
  125293. private _switchPanningModel;
  125294. /**
  125295. * Connect this sound to a sound track audio node like gain...
  125296. * @param soundTrackAudioNode the sound track audio node to connect to
  125297. */
  125298. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125299. /**
  125300. * Transform this sound into a directional source
  125301. * @param coneInnerAngle Size of the inner cone in degree
  125302. * @param coneOuterAngle Size of the outer cone in degree
  125303. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125304. */
  125305. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125306. /**
  125307. * Gets or sets the inner angle for the directional cone.
  125308. */
  125309. get directionalConeInnerAngle(): number;
  125310. /**
  125311. * Gets or sets the inner angle for the directional cone.
  125312. */
  125313. set directionalConeInnerAngle(value: number);
  125314. /**
  125315. * Gets or sets the outer angle for the directional cone.
  125316. */
  125317. get directionalConeOuterAngle(): number;
  125318. /**
  125319. * Gets or sets the outer angle for the directional cone.
  125320. */
  125321. set directionalConeOuterAngle(value: number);
  125322. /**
  125323. * Sets the position of the emitter if spatial sound is enabled
  125324. * @param newPosition Defines the new posisiton
  125325. */
  125326. setPosition(newPosition: Vector3): void;
  125327. /**
  125328. * Sets the local direction of the emitter if spatial sound is enabled
  125329. * @param newLocalDirection Defines the new local direction
  125330. */
  125331. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125332. private _updateDirection;
  125333. /** @hidden */
  125334. updateDistanceFromListener(): void;
  125335. /**
  125336. * Sets a new custom attenuation function for the sound.
  125337. * @param callback Defines the function used for the attenuation
  125338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125339. */
  125340. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125341. /**
  125342. * Play the sound
  125343. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125344. * @param offset (optional) Start the sound at a specific time in seconds
  125345. * @param length (optional) Sound duration (in seconds)
  125346. */
  125347. play(time?: number, offset?: number, length?: number): void;
  125348. private _onended;
  125349. /**
  125350. * Stop the sound
  125351. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125352. */
  125353. stop(time?: number): void;
  125354. /**
  125355. * Put the sound in pause
  125356. */
  125357. pause(): void;
  125358. /**
  125359. * Sets a dedicated volume for this sounds
  125360. * @param newVolume Define the new volume of the sound
  125361. * @param time Define time for gradual change to new volume
  125362. */
  125363. setVolume(newVolume: number, time?: number): void;
  125364. /**
  125365. * Set the sound play back rate
  125366. * @param newPlaybackRate Define the playback rate the sound should be played at
  125367. */
  125368. setPlaybackRate(newPlaybackRate: number): void;
  125369. /**
  125370. * Gets the volume of the sound.
  125371. * @returns the volume of the sound
  125372. */
  125373. getVolume(): number;
  125374. /**
  125375. * Attach the sound to a dedicated mesh
  125376. * @param transformNode The transform node to connect the sound with
  125377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125378. */
  125379. attachToMesh(transformNode: TransformNode): void;
  125380. /**
  125381. * Detach the sound from the previously attached mesh
  125382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125383. */
  125384. detachFromMesh(): void;
  125385. private _onRegisterAfterWorldMatrixUpdate;
  125386. /**
  125387. * Clone the current sound in the scene.
  125388. * @returns the new sound clone
  125389. */
  125390. clone(): Nullable<Sound>;
  125391. /**
  125392. * Gets the current underlying audio buffer containing the data
  125393. * @returns the audio buffer
  125394. */
  125395. getAudioBuffer(): Nullable<AudioBuffer>;
  125396. /**
  125397. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125398. * @returns the source node
  125399. */
  125400. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125401. /**
  125402. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125403. * @returns the gain node
  125404. */
  125405. getSoundGain(): Nullable<GainNode>;
  125406. /**
  125407. * Serializes the Sound in a JSON representation
  125408. * @returns the JSON representation of the sound
  125409. */
  125410. serialize(): any;
  125411. /**
  125412. * Parse a JSON representation of a sound to innstantiate in a given scene
  125413. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125414. * @param scene Define the scene the new parsed sound should be created in
  125415. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125416. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125417. * @returns the newly parsed sound
  125418. */
  125419. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /**
  125424. * This defines an action helpful to play a defined sound on a triggered action.
  125425. */
  125426. export class PlaySoundAction extends Action {
  125427. private _sound;
  125428. /**
  125429. * Instantiate the action
  125430. * @param triggerOptions defines the trigger options
  125431. * @param sound defines the sound to play
  125432. * @param condition defines the trigger related conditions
  125433. */
  125434. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125435. /** @hidden */
  125436. _prepare(): void;
  125437. /**
  125438. * Execute the action and play the sound.
  125439. */
  125440. execute(): void;
  125441. /**
  125442. * Serializes the actions and its related information.
  125443. * @param parent defines the object to serialize in
  125444. * @returns the serialized object
  125445. */
  125446. serialize(parent: any): any;
  125447. }
  125448. /**
  125449. * This defines an action helpful to stop a defined sound on a triggered action.
  125450. */
  125451. export class StopSoundAction extends Action {
  125452. private _sound;
  125453. /**
  125454. * Instantiate the action
  125455. * @param triggerOptions defines the trigger options
  125456. * @param sound defines the sound to stop
  125457. * @param condition defines the trigger related conditions
  125458. */
  125459. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125460. /** @hidden */
  125461. _prepare(): void;
  125462. /**
  125463. * Execute the action and stop the sound.
  125464. */
  125465. execute(): void;
  125466. /**
  125467. * Serializes the actions and its related information.
  125468. * @param parent defines the object to serialize in
  125469. * @returns the serialized object
  125470. */
  125471. serialize(parent: any): any;
  125472. }
  125473. }
  125474. declare module BABYLON {
  125475. /**
  125476. * This defines an action responsible to change the value of a property
  125477. * by interpolating between its current value and the newly set one once triggered.
  125478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125479. */
  125480. export class InterpolateValueAction extends Action {
  125481. /**
  125482. * Defines the path of the property where the value should be interpolated
  125483. */
  125484. propertyPath: string;
  125485. /**
  125486. * Defines the target value at the end of the interpolation.
  125487. */
  125488. value: any;
  125489. /**
  125490. * Defines the time it will take for the property to interpolate to the value.
  125491. */
  125492. duration: number;
  125493. /**
  125494. * Defines if the other scene animations should be stopped when the action has been triggered
  125495. */
  125496. stopOtherAnimations?: boolean;
  125497. /**
  125498. * Defines a callback raised once the interpolation animation has been done.
  125499. */
  125500. onInterpolationDone?: () => void;
  125501. /**
  125502. * Observable triggered once the interpolation animation has been done.
  125503. */
  125504. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125505. private _target;
  125506. private _effectiveTarget;
  125507. private _property;
  125508. /**
  125509. * Instantiate the action
  125510. * @param triggerOptions defines the trigger options
  125511. * @param target defines the object containing the value to interpolate
  125512. * @param propertyPath defines the path to the property in the target object
  125513. * @param value defines the target value at the end of the interpolation
  125514. * @param duration deines the time it will take for the property to interpolate to the value.
  125515. * @param condition defines the trigger related conditions
  125516. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125517. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125518. */
  125519. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125520. /** @hidden */
  125521. _prepare(): void;
  125522. /**
  125523. * Execute the action starts the value interpolation.
  125524. */
  125525. execute(): void;
  125526. /**
  125527. * Serializes the actions and its related information.
  125528. * @param parent defines the object to serialize in
  125529. * @returns the serialized object
  125530. */
  125531. serialize(parent: any): any;
  125532. }
  125533. }
  125534. declare module BABYLON {
  125535. /**
  125536. * Options allowed during the creation of a sound track.
  125537. */
  125538. export interface ISoundTrackOptions {
  125539. /**
  125540. * The volume the sound track should take during creation
  125541. */
  125542. volume?: number;
  125543. /**
  125544. * Define if the sound track is the main sound track of the scene
  125545. */
  125546. mainTrack?: boolean;
  125547. }
  125548. /**
  125549. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125550. * It will be also used in a future release to apply effects on a specific track.
  125551. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125552. */
  125553. export class SoundTrack {
  125554. /**
  125555. * The unique identifier of the sound track in the scene.
  125556. */
  125557. id: number;
  125558. /**
  125559. * The list of sounds included in the sound track.
  125560. */
  125561. soundCollection: Array<Sound>;
  125562. private _outputAudioNode;
  125563. private _scene;
  125564. private _connectedAnalyser;
  125565. private _options;
  125566. private _isInitialized;
  125567. /**
  125568. * Creates a new sound track.
  125569. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125570. * @param scene Define the scene the sound track belongs to
  125571. * @param options
  125572. */
  125573. constructor(scene: Scene, options?: ISoundTrackOptions);
  125574. private _initializeSoundTrackAudioGraph;
  125575. /**
  125576. * Release the sound track and its associated resources
  125577. */
  125578. dispose(): void;
  125579. /**
  125580. * Adds a sound to this sound track
  125581. * @param sound define the cound to add
  125582. * @ignoreNaming
  125583. */
  125584. AddSound(sound: Sound): void;
  125585. /**
  125586. * Removes a sound to this sound track
  125587. * @param sound define the cound to remove
  125588. * @ignoreNaming
  125589. */
  125590. RemoveSound(sound: Sound): void;
  125591. /**
  125592. * Set a global volume for the full sound track.
  125593. * @param newVolume Define the new volume of the sound track
  125594. */
  125595. setVolume(newVolume: number): void;
  125596. /**
  125597. * Switch the panning model to HRTF:
  125598. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125600. */
  125601. switchPanningModelToHRTF(): void;
  125602. /**
  125603. * Switch the panning model to Equal Power:
  125604. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125606. */
  125607. switchPanningModelToEqualPower(): void;
  125608. /**
  125609. * Connect the sound track to an audio analyser allowing some amazing
  125610. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125611. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125612. * @param analyser The analyser to connect to the engine
  125613. */
  125614. connectToAnalyser(analyser: Analyser): void;
  125615. }
  125616. }
  125617. declare module BABYLON {
  125618. interface AbstractScene {
  125619. /**
  125620. * The list of sounds used in the scene.
  125621. */
  125622. sounds: Nullable<Array<Sound>>;
  125623. }
  125624. interface Scene {
  125625. /**
  125626. * @hidden
  125627. * Backing field
  125628. */
  125629. _mainSoundTrack: SoundTrack;
  125630. /**
  125631. * The main sound track played by the scene.
  125632. * It cotains your primary collection of sounds.
  125633. */
  125634. mainSoundTrack: SoundTrack;
  125635. /**
  125636. * The list of sound tracks added to the scene
  125637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125638. */
  125639. soundTracks: Nullable<Array<SoundTrack>>;
  125640. /**
  125641. * Gets a sound using a given name
  125642. * @param name defines the name to search for
  125643. * @return the found sound or null if not found at all.
  125644. */
  125645. getSoundByName(name: string): Nullable<Sound>;
  125646. /**
  125647. * Gets or sets if audio support is enabled
  125648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125649. */
  125650. audioEnabled: boolean;
  125651. /**
  125652. * Gets or sets if audio will be output to headphones
  125653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125654. */
  125655. headphone: boolean;
  125656. /**
  125657. * Gets or sets custom audio listener position provider
  125658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125659. */
  125660. audioListenerPositionProvider: Nullable<() => Vector3>;
  125661. /**
  125662. * Gets or sets a refresh rate when using 3D audio positioning
  125663. */
  125664. audioPositioningRefreshRate: number;
  125665. }
  125666. /**
  125667. * Defines the sound scene component responsible to manage any sounds
  125668. * in a given scene.
  125669. */
  125670. export class AudioSceneComponent implements ISceneSerializableComponent {
  125671. private static _CameraDirectionLH;
  125672. private static _CameraDirectionRH;
  125673. /**
  125674. * The component name helpfull to identify the component in the list of scene components.
  125675. */
  125676. readonly name: string;
  125677. /**
  125678. * The scene the component belongs to.
  125679. */
  125680. scene: Scene;
  125681. private _audioEnabled;
  125682. /**
  125683. * Gets whether audio is enabled or not.
  125684. * Please use related enable/disable method to switch state.
  125685. */
  125686. get audioEnabled(): boolean;
  125687. private _headphone;
  125688. /**
  125689. * Gets whether audio is outputing to headphone or not.
  125690. * Please use the according Switch methods to change output.
  125691. */
  125692. get headphone(): boolean;
  125693. /**
  125694. * Gets or sets a refresh rate when using 3D audio positioning
  125695. */
  125696. audioPositioningRefreshRate: number;
  125697. private _audioListenerPositionProvider;
  125698. /**
  125699. * Gets the current audio listener position provider
  125700. */
  125701. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125702. /**
  125703. * Sets a custom listener position for all sounds in the scene
  125704. * By default, this is the position of the first active camera
  125705. */
  125706. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125707. /**
  125708. * Creates a new instance of the component for the given scene
  125709. * @param scene Defines the scene to register the component in
  125710. */
  125711. constructor(scene: Scene);
  125712. /**
  125713. * Registers the component in a given scene
  125714. */
  125715. register(): void;
  125716. /**
  125717. * Rebuilds the elements related to this component in case of
  125718. * context lost for instance.
  125719. */
  125720. rebuild(): void;
  125721. /**
  125722. * Serializes the component data to the specified json object
  125723. * @param serializationObject The object to serialize to
  125724. */
  125725. serialize(serializationObject: any): void;
  125726. /**
  125727. * Adds all the elements from the container to the scene
  125728. * @param container the container holding the elements
  125729. */
  125730. addFromContainer(container: AbstractScene): void;
  125731. /**
  125732. * Removes all the elements in the container from the scene
  125733. * @param container contains the elements to remove
  125734. * @param dispose if the removed element should be disposed (default: false)
  125735. */
  125736. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125737. /**
  125738. * Disposes the component and the associated ressources.
  125739. */
  125740. dispose(): void;
  125741. /**
  125742. * Disables audio in the associated scene.
  125743. */
  125744. disableAudio(): void;
  125745. /**
  125746. * Enables audio in the associated scene.
  125747. */
  125748. enableAudio(): void;
  125749. /**
  125750. * Switch audio to headphone output.
  125751. */
  125752. switchAudioModeForHeadphones(): void;
  125753. /**
  125754. * Switch audio to normal speakers.
  125755. */
  125756. switchAudioModeForNormalSpeakers(): void;
  125757. private _cachedCameraDirection;
  125758. private _cachedCameraPosition;
  125759. private _lastCheck;
  125760. private _afterRender;
  125761. }
  125762. }
  125763. declare module BABYLON {
  125764. /**
  125765. * Wraps one or more Sound objects and selects one with random weight for playback.
  125766. */
  125767. export class WeightedSound {
  125768. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125769. loop: boolean;
  125770. private _coneInnerAngle;
  125771. private _coneOuterAngle;
  125772. private _volume;
  125773. /** A Sound is currently playing. */
  125774. isPlaying: boolean;
  125775. /** A Sound is currently paused. */
  125776. isPaused: boolean;
  125777. private _sounds;
  125778. private _weights;
  125779. private _currentIndex?;
  125780. /**
  125781. * Creates a new WeightedSound from the list of sounds given.
  125782. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125783. * @param sounds Array of Sounds that will be selected from.
  125784. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125785. */
  125786. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125787. /**
  125788. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125789. */
  125790. get directionalConeInnerAngle(): number;
  125791. /**
  125792. * The size of cone in degress for a directional sound in which there will be no attenuation.
  125793. */
  125794. set directionalConeInnerAngle(value: number);
  125795. /**
  125796. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125797. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125798. */
  125799. get directionalConeOuterAngle(): number;
  125800. /**
  125801. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125802. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125803. */
  125804. set directionalConeOuterAngle(value: number);
  125805. /**
  125806. * Playback volume.
  125807. */
  125808. get volume(): number;
  125809. /**
  125810. * Playback volume.
  125811. */
  125812. set volume(value: number);
  125813. private _onended;
  125814. /**
  125815. * Suspend playback
  125816. */
  125817. pause(): void;
  125818. /**
  125819. * Stop playback
  125820. */
  125821. stop(): void;
  125822. /**
  125823. * Start playback.
  125824. * @param startOffset Position the clip head at a specific time in seconds.
  125825. */
  125826. play(startOffset?: number): void;
  125827. }
  125828. }
  125829. declare module BABYLON {
  125830. /**
  125831. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  125832. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  125833. */
  125834. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  125835. /**
  125836. * Gets the name of the behavior.
  125837. */
  125838. get name(): string;
  125839. /**
  125840. * The easing function used by animations
  125841. */
  125842. static EasingFunction: BackEase;
  125843. /**
  125844. * The easing mode used by animations
  125845. */
  125846. static EasingMode: number;
  125847. /**
  125848. * The duration of the animation, in milliseconds
  125849. */
  125850. transitionDuration: number;
  125851. /**
  125852. * Length of the distance animated by the transition when lower radius is reached
  125853. */
  125854. lowerRadiusTransitionRange: number;
  125855. /**
  125856. * Length of the distance animated by the transition when upper radius is reached
  125857. */
  125858. upperRadiusTransitionRange: number;
  125859. private _autoTransitionRange;
  125860. /**
  125861. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125862. */
  125863. get autoTransitionRange(): boolean;
  125864. /**
  125865. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125866. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  125867. */
  125868. set autoTransitionRange(value: boolean);
  125869. private _attachedCamera;
  125870. private _onAfterCheckInputsObserver;
  125871. private _onMeshTargetChangedObserver;
  125872. /**
  125873. * Initializes the behavior.
  125874. */
  125875. init(): void;
  125876. /**
  125877. * Attaches the behavior to its arc rotate camera.
  125878. * @param camera Defines the camera to attach the behavior to
  125879. */
  125880. attach(camera: ArcRotateCamera): void;
  125881. /**
  125882. * Detaches the behavior from its current arc rotate camera.
  125883. */
  125884. detach(): void;
  125885. private _radiusIsAnimating;
  125886. private _radiusBounceTransition;
  125887. private _animatables;
  125888. private _cachedWheelPrecision;
  125889. /**
  125890. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  125891. * @param radiusLimit The limit to check against.
  125892. * @return Bool to indicate if at limit.
  125893. */
  125894. private _isRadiusAtLimit;
  125895. /**
  125896. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  125897. * @param radiusDelta The delta by which to animate to. Can be negative.
  125898. */
  125899. private _applyBoundRadiusAnimation;
  125900. /**
  125901. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  125902. */
  125903. protected _clearAnimationLocks(): void;
  125904. /**
  125905. * Stops and removes all animations that have been applied to the camera
  125906. */
  125907. stopAllAnimations(): void;
  125908. }
  125909. }
  125910. declare module BABYLON {
  125911. /**
  125912. * 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.
  125913. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  125914. */
  125915. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  125916. /**
  125917. * Gets the name of the behavior.
  125918. */
  125919. get name(): string;
  125920. private _mode;
  125921. private _radiusScale;
  125922. private _positionScale;
  125923. private _defaultElevation;
  125924. private _elevationReturnTime;
  125925. private _elevationReturnWaitTime;
  125926. private _zoomStopsAnimation;
  125927. private _framingTime;
  125928. /**
  125929. * The easing function used by animations
  125930. */
  125931. static EasingFunction: ExponentialEase;
  125932. /**
  125933. * The easing mode used by animations
  125934. */
  125935. static EasingMode: number;
  125936. /**
  125937. * Sets the current mode used by the behavior
  125938. */
  125939. set mode(mode: number);
  125940. /**
  125941. * Gets current mode used by the behavior.
  125942. */
  125943. get mode(): number;
  125944. /**
  125945. * Sets the scale applied to the radius (1 by default)
  125946. */
  125947. set radiusScale(radius: number);
  125948. /**
  125949. * Gets the scale applied to the radius
  125950. */
  125951. get radiusScale(): number;
  125952. /**
  125953. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125954. */
  125955. set positionScale(scale: number);
  125956. /**
  125957. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  125958. */
  125959. get positionScale(): number;
  125960. /**
  125961. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125962. * behaviour is triggered, in radians.
  125963. */
  125964. set defaultElevation(elevation: number);
  125965. /**
  125966. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  125967. * behaviour is triggered, in radians.
  125968. */
  125969. get defaultElevation(): number;
  125970. /**
  125971. * Sets the time (in milliseconds) taken to return to the default beta position.
  125972. * Negative value indicates camera should not return to default.
  125973. */
  125974. set elevationReturnTime(speed: number);
  125975. /**
  125976. * Gets the time (in milliseconds) taken to return to the default beta position.
  125977. * Negative value indicates camera should not return to default.
  125978. */
  125979. get elevationReturnTime(): number;
  125980. /**
  125981. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125982. */
  125983. set elevationReturnWaitTime(time: number);
  125984. /**
  125985. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  125986. */
  125987. get elevationReturnWaitTime(): number;
  125988. /**
  125989. * Sets the flag that indicates if user zooming should stop animation.
  125990. */
  125991. set zoomStopsAnimation(flag: boolean);
  125992. /**
  125993. * Gets the flag that indicates if user zooming should stop animation.
  125994. */
  125995. get zoomStopsAnimation(): boolean;
  125996. /**
  125997. * Sets the transition time when framing the mesh, in milliseconds
  125998. */
  125999. set framingTime(time: number);
  126000. /**
  126001. * Gets the transition time when framing the mesh, in milliseconds
  126002. */
  126003. get framingTime(): number;
  126004. /**
  126005. * Define if the behavior should automatically change the configured
  126006. * camera limits and sensibilities.
  126007. */
  126008. autoCorrectCameraLimitsAndSensibility: boolean;
  126009. private _onPrePointerObservableObserver;
  126010. private _onAfterCheckInputsObserver;
  126011. private _onMeshTargetChangedObserver;
  126012. private _attachedCamera;
  126013. private _isPointerDown;
  126014. private _lastInteractionTime;
  126015. /**
  126016. * Initializes the behavior.
  126017. */
  126018. init(): void;
  126019. /**
  126020. * Attaches the behavior to its arc rotate camera.
  126021. * @param camera Defines the camera to attach the behavior to
  126022. */
  126023. attach(camera: ArcRotateCamera): void;
  126024. /**
  126025. * Detaches the behavior from its current arc rotate camera.
  126026. */
  126027. detach(): void;
  126028. private _animatables;
  126029. private _betaIsAnimating;
  126030. private _betaTransition;
  126031. private _radiusTransition;
  126032. private _vectorTransition;
  126033. /**
  126034. * Targets the given mesh and updates zoom level accordingly.
  126035. * @param mesh The mesh to target.
  126036. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126037. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126038. */
  126039. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126040. /**
  126041. * Targets the given mesh with its children and updates zoom level accordingly.
  126042. * @param mesh The mesh to target.
  126043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126045. */
  126046. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126047. /**
  126048. * Targets the given meshes with their children and updates zoom level accordingly.
  126049. * @param meshes The mesh to target.
  126050. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126051. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126052. */
  126053. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126054. /**
  126055. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126056. * @param minimumWorld Determines the smaller position of the bounding box extend
  126057. * @param maximumWorld Determines the bigger position of the bounding box extend
  126058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126060. */
  126061. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126062. /**
  126063. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126064. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126065. * frustum width.
  126066. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126067. * to fully enclose the mesh in the viewing frustum.
  126068. */
  126069. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126070. /**
  126071. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126072. * is automatically returned to its default position (expected to be above ground plane).
  126073. */
  126074. private _maintainCameraAboveGround;
  126075. /**
  126076. * Returns the frustum slope based on the canvas ratio and camera FOV
  126077. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126078. */
  126079. private _getFrustumSlope;
  126080. /**
  126081. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126082. */
  126083. private _clearAnimationLocks;
  126084. /**
  126085. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126086. */
  126087. private _applyUserInteraction;
  126088. /**
  126089. * Stops and removes all animations that have been applied to the camera
  126090. */
  126091. stopAllAnimations(): void;
  126092. /**
  126093. * Gets a value indicating if the user is moving the camera
  126094. */
  126095. get isUserIsMoving(): boolean;
  126096. /**
  126097. * The camera can move all the way towards the mesh.
  126098. */
  126099. static IgnoreBoundsSizeMode: number;
  126100. /**
  126101. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126102. */
  126103. static FitFrustumSidesMode: number;
  126104. }
  126105. }
  126106. declare module BABYLON {
  126107. /**
  126108. * Base class for Camera Pointer Inputs.
  126109. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126110. * for example usage.
  126111. */
  126112. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126113. /**
  126114. * Defines the camera the input is attached to.
  126115. */
  126116. abstract camera: Camera;
  126117. /**
  126118. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126119. */
  126120. protected _altKey: boolean;
  126121. protected _ctrlKey: boolean;
  126122. protected _metaKey: boolean;
  126123. protected _shiftKey: boolean;
  126124. /**
  126125. * Which mouse buttons were pressed at time of last mouse event.
  126126. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126127. */
  126128. protected _buttonsPressed: number;
  126129. /**
  126130. * Defines the buttons associated with the input to handle camera move.
  126131. */
  126132. buttons: number[];
  126133. /**
  126134. * Attach the input controls to a specific dom element to get the input from.
  126135. * @param element Defines the element the controls should be listened from
  126136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126137. */
  126138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126139. /**
  126140. * Detach the current controls from the specified dom element.
  126141. * @param element Defines the element to stop listening the inputs from
  126142. */
  126143. detachControl(element: Nullable<HTMLElement>): void;
  126144. /**
  126145. * Gets the class name of the current input.
  126146. * @returns the class name
  126147. */
  126148. getClassName(): string;
  126149. /**
  126150. * Get the friendly name associated with the input class.
  126151. * @returns the input friendly name
  126152. */
  126153. getSimpleName(): string;
  126154. /**
  126155. * Called on pointer POINTERDOUBLETAP event.
  126156. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126157. */
  126158. protected onDoubleTap(type: string): void;
  126159. /**
  126160. * Called on pointer POINTERMOVE event if only a single touch is active.
  126161. * Override this method to provide functionality.
  126162. */
  126163. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126164. /**
  126165. * Called on pointer POINTERMOVE event if multiple touches are active.
  126166. * Override this method to provide functionality.
  126167. */
  126168. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126169. /**
  126170. * Called on JS contextmenu event.
  126171. * Override this method to provide functionality.
  126172. */
  126173. protected onContextMenu(evt: PointerEvent): void;
  126174. /**
  126175. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126176. * press.
  126177. * Override this method to provide functionality.
  126178. */
  126179. protected onButtonDown(evt: PointerEvent): void;
  126180. /**
  126181. * Called each time a new POINTERUP event occurs. Ie, for each button
  126182. * release.
  126183. * Override this method to provide functionality.
  126184. */
  126185. protected onButtonUp(evt: PointerEvent): void;
  126186. /**
  126187. * Called when window becomes inactive.
  126188. * Override this method to provide functionality.
  126189. */
  126190. protected onLostFocus(): void;
  126191. private _pointerInput;
  126192. private _observer;
  126193. private _onLostFocus;
  126194. private pointA;
  126195. private pointB;
  126196. }
  126197. }
  126198. declare module BABYLON {
  126199. /**
  126200. * Manage the pointers inputs to control an arc rotate camera.
  126201. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126202. */
  126203. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126204. /**
  126205. * Defines the camera the input is attached to.
  126206. */
  126207. camera: ArcRotateCamera;
  126208. /**
  126209. * Gets the class name of the current input.
  126210. * @returns the class name
  126211. */
  126212. getClassName(): string;
  126213. /**
  126214. * Defines the buttons associated with the input to handle camera move.
  126215. */
  126216. buttons: number[];
  126217. /**
  126218. * Defines the pointer angular sensibility along the X axis or how fast is
  126219. * the camera rotating.
  126220. */
  126221. angularSensibilityX: number;
  126222. /**
  126223. * Defines the pointer angular sensibility along the Y axis or how fast is
  126224. * the camera rotating.
  126225. */
  126226. angularSensibilityY: number;
  126227. /**
  126228. * Defines the pointer pinch precision or how fast is the camera zooming.
  126229. */
  126230. pinchPrecision: number;
  126231. /**
  126232. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126233. * from 0.
  126234. * It defines the percentage of current camera.radius to use as delta when
  126235. * pinch zoom is used.
  126236. */
  126237. pinchDeltaPercentage: number;
  126238. /**
  126239. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126240. * that any object in the plane at the camera's target point will scale
  126241. * perfectly with finger motion.
  126242. * Overrides pinchDeltaPercentage and pinchPrecision.
  126243. */
  126244. useNaturalPinchZoom: boolean;
  126245. /**
  126246. * Defines the pointer panning sensibility or how fast is the camera moving.
  126247. */
  126248. panningSensibility: number;
  126249. /**
  126250. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126251. */
  126252. multiTouchPanning: boolean;
  126253. /**
  126254. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126255. * zoom (pinch) through multitouch.
  126256. */
  126257. multiTouchPanAndZoom: boolean;
  126258. /**
  126259. * Revers pinch action direction.
  126260. */
  126261. pinchInwards: boolean;
  126262. private _isPanClick;
  126263. private _twoFingerActivityCount;
  126264. private _isPinching;
  126265. /**
  126266. * Called on pointer POINTERMOVE event if only a single touch is active.
  126267. */
  126268. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126269. /**
  126270. * Called on pointer POINTERDOUBLETAP event.
  126271. */
  126272. protected onDoubleTap(type: string): void;
  126273. /**
  126274. * Called on pointer POINTERMOVE event if multiple touches are active.
  126275. */
  126276. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126277. /**
  126278. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126279. * press.
  126280. */
  126281. protected onButtonDown(evt: PointerEvent): void;
  126282. /**
  126283. * Called each time a new POINTERUP event occurs. Ie, for each button
  126284. * release.
  126285. */
  126286. protected onButtonUp(evt: PointerEvent): void;
  126287. /**
  126288. * Called when window becomes inactive.
  126289. */
  126290. protected onLostFocus(): void;
  126291. }
  126292. }
  126293. declare module BABYLON {
  126294. /**
  126295. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126296. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126297. */
  126298. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126299. /**
  126300. * Defines the camera the input is attached to.
  126301. */
  126302. camera: ArcRotateCamera;
  126303. /**
  126304. * Defines the list of key codes associated with the up action (increase alpha)
  126305. */
  126306. keysUp: number[];
  126307. /**
  126308. * Defines the list of key codes associated with the down action (decrease alpha)
  126309. */
  126310. keysDown: number[];
  126311. /**
  126312. * Defines the list of key codes associated with the left action (increase beta)
  126313. */
  126314. keysLeft: number[];
  126315. /**
  126316. * Defines the list of key codes associated with the right action (decrease beta)
  126317. */
  126318. keysRight: number[];
  126319. /**
  126320. * Defines the list of key codes associated with the reset action.
  126321. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126322. */
  126323. keysReset: number[];
  126324. /**
  126325. * Defines the panning sensibility of the inputs.
  126326. * (How fast is the camera panning)
  126327. */
  126328. panningSensibility: number;
  126329. /**
  126330. * Defines the zooming sensibility of the inputs.
  126331. * (How fast is the camera zooming)
  126332. */
  126333. zoomingSensibility: number;
  126334. /**
  126335. * Defines whether maintaining the alt key down switch the movement mode from
  126336. * orientation to zoom.
  126337. */
  126338. useAltToZoom: boolean;
  126339. /**
  126340. * Rotation speed of the camera
  126341. */
  126342. angularSpeed: number;
  126343. private _keys;
  126344. private _ctrlPressed;
  126345. private _altPressed;
  126346. private _onCanvasBlurObserver;
  126347. private _onKeyboardObserver;
  126348. private _engine;
  126349. private _scene;
  126350. /**
  126351. * Attach the input controls to a specific dom element to get the input from.
  126352. * @param element Defines the element the controls should be listened from
  126353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126354. */
  126355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126356. /**
  126357. * Detach the current controls from the specified dom element.
  126358. * @param element Defines the element to stop listening the inputs from
  126359. */
  126360. detachControl(element: Nullable<HTMLElement>): void;
  126361. /**
  126362. * Update the current camera state depending on the inputs that have been used this frame.
  126363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126364. */
  126365. checkInputs(): void;
  126366. /**
  126367. * Gets the class name of the current intput.
  126368. * @returns the class name
  126369. */
  126370. getClassName(): string;
  126371. /**
  126372. * Get the friendly name associated with the input class.
  126373. * @returns the input friendly name
  126374. */
  126375. getSimpleName(): string;
  126376. }
  126377. }
  126378. declare module BABYLON {
  126379. /**
  126380. * Manage the mouse wheel inputs to control an arc rotate camera.
  126381. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126382. */
  126383. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126384. /**
  126385. * Defines the camera the input is attached to.
  126386. */
  126387. camera: ArcRotateCamera;
  126388. /**
  126389. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126390. */
  126391. wheelPrecision: number;
  126392. /**
  126393. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126394. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126395. */
  126396. wheelDeltaPercentage: number;
  126397. private _wheel;
  126398. private _observer;
  126399. private computeDeltaFromMouseWheelLegacyEvent;
  126400. /**
  126401. * Attach the input controls to a specific dom element to get the input from.
  126402. * @param element Defines the element the controls should be listened from
  126403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126404. */
  126405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126406. /**
  126407. * Detach the current controls from the specified dom element.
  126408. * @param element Defines the element to stop listening the inputs from
  126409. */
  126410. detachControl(element: Nullable<HTMLElement>): void;
  126411. /**
  126412. * Gets the class name of the current intput.
  126413. * @returns the class name
  126414. */
  126415. getClassName(): string;
  126416. /**
  126417. * Get the friendly name associated with the input class.
  126418. * @returns the input friendly name
  126419. */
  126420. getSimpleName(): string;
  126421. }
  126422. }
  126423. declare module BABYLON {
  126424. /**
  126425. * Default Inputs manager for the ArcRotateCamera.
  126426. * It groups all the default supported inputs for ease of use.
  126427. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126428. */
  126429. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126430. /**
  126431. * Instantiates a new ArcRotateCameraInputsManager.
  126432. * @param camera Defines the camera the inputs belong to
  126433. */
  126434. constructor(camera: ArcRotateCamera);
  126435. /**
  126436. * Add mouse wheel input support to the input manager.
  126437. * @returns the current input manager
  126438. */
  126439. addMouseWheel(): ArcRotateCameraInputsManager;
  126440. /**
  126441. * Add pointers input support to the input manager.
  126442. * @returns the current input manager
  126443. */
  126444. addPointers(): ArcRotateCameraInputsManager;
  126445. /**
  126446. * Add keyboard input support to the input manager.
  126447. * @returns the current input manager
  126448. */
  126449. addKeyboard(): ArcRotateCameraInputsManager;
  126450. }
  126451. }
  126452. declare module BABYLON {
  126453. /**
  126454. * This represents an orbital type of camera.
  126455. *
  126456. * 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.
  126457. * 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.
  126458. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126459. */
  126460. export class ArcRotateCamera extends TargetCamera {
  126461. /**
  126462. * Defines the rotation angle of the camera along the longitudinal axis.
  126463. */
  126464. alpha: number;
  126465. /**
  126466. * Defines the rotation angle of the camera along the latitudinal axis.
  126467. */
  126468. beta: number;
  126469. /**
  126470. * Defines the radius of the camera from it s target point.
  126471. */
  126472. radius: number;
  126473. protected _target: Vector3;
  126474. protected _targetHost: Nullable<AbstractMesh>;
  126475. /**
  126476. * Defines the target point of the camera.
  126477. * The camera looks towards it form the radius distance.
  126478. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126479. */
  126480. get target(): Vector3;
  126481. set target(value: Vector3);
  126482. /**
  126483. * Define the current local position of the camera in the scene
  126484. */
  126485. get position(): Vector3;
  126486. set position(newPosition: Vector3);
  126487. protected _upToYMatrix: Matrix;
  126488. protected _YToUpMatrix: Matrix;
  126489. /**
  126490. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126491. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126492. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126493. */
  126494. set upVector(vec: Vector3);
  126495. get upVector(): Vector3;
  126496. /**
  126497. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126498. */
  126499. setMatUp(): void;
  126500. /**
  126501. * Current inertia value on the longitudinal axis.
  126502. * The bigger this number the longer it will take for the camera to stop.
  126503. */
  126504. inertialAlphaOffset: number;
  126505. /**
  126506. * Current inertia value on the latitudinal axis.
  126507. * The bigger this number the longer it will take for the camera to stop.
  126508. */
  126509. inertialBetaOffset: number;
  126510. /**
  126511. * Current inertia value on the radius axis.
  126512. * The bigger this number the longer it will take for the camera to stop.
  126513. */
  126514. inertialRadiusOffset: number;
  126515. /**
  126516. * Minimum allowed angle on the longitudinal axis.
  126517. * This can help limiting how the Camera is able to move in the scene.
  126518. */
  126519. lowerAlphaLimit: Nullable<number>;
  126520. /**
  126521. * Maximum allowed angle on the longitudinal axis.
  126522. * This can help limiting how the Camera is able to move in the scene.
  126523. */
  126524. upperAlphaLimit: Nullable<number>;
  126525. /**
  126526. * Minimum allowed angle on the latitudinal axis.
  126527. * This can help limiting how the Camera is able to move in the scene.
  126528. */
  126529. lowerBetaLimit: number;
  126530. /**
  126531. * Maximum allowed angle on the latitudinal axis.
  126532. * This can help limiting how the Camera is able to move in the scene.
  126533. */
  126534. upperBetaLimit: number;
  126535. /**
  126536. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126537. * This can help limiting how the Camera is able to move in the scene.
  126538. */
  126539. lowerRadiusLimit: Nullable<number>;
  126540. /**
  126541. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126542. * This can help limiting how the Camera is able to move in the scene.
  126543. */
  126544. upperRadiusLimit: Nullable<number>;
  126545. /**
  126546. * Defines the current inertia value used during panning of the camera along the X axis.
  126547. */
  126548. inertialPanningX: number;
  126549. /**
  126550. * Defines the current inertia value used during panning of the camera along the Y axis.
  126551. */
  126552. inertialPanningY: number;
  126553. /**
  126554. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126555. * Basically if your fingers moves away from more than this distance you will be considered
  126556. * in pinch mode.
  126557. */
  126558. pinchToPanMaxDistance: number;
  126559. /**
  126560. * Defines the maximum distance the camera can pan.
  126561. * This could help keeping the cammera always in your scene.
  126562. */
  126563. panningDistanceLimit: Nullable<number>;
  126564. /**
  126565. * Defines the target of the camera before paning.
  126566. */
  126567. panningOriginTarget: Vector3;
  126568. /**
  126569. * Defines the value of the inertia used during panning.
  126570. * 0 would mean stop inertia and one would mean no decelleration at all.
  126571. */
  126572. panningInertia: number;
  126573. /**
  126574. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126575. */
  126576. get angularSensibilityX(): number;
  126577. set angularSensibilityX(value: number);
  126578. /**
  126579. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126580. */
  126581. get angularSensibilityY(): number;
  126582. set angularSensibilityY(value: number);
  126583. /**
  126584. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126585. */
  126586. get pinchPrecision(): number;
  126587. set pinchPrecision(value: number);
  126588. /**
  126589. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126590. * It will be used instead of pinchDeltaPrecision if different from 0.
  126591. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126592. */
  126593. get pinchDeltaPercentage(): number;
  126594. set pinchDeltaPercentage(value: number);
  126595. /**
  126596. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126597. * and pinch delta percentage.
  126598. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126599. * that any object in the plane at the camera's target point will scale
  126600. * perfectly with finger motion.
  126601. */
  126602. get useNaturalPinchZoom(): boolean;
  126603. set useNaturalPinchZoom(value: boolean);
  126604. /**
  126605. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126606. */
  126607. get panningSensibility(): number;
  126608. set panningSensibility(value: number);
  126609. /**
  126610. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126611. */
  126612. get keysUp(): number[];
  126613. set keysUp(value: number[]);
  126614. /**
  126615. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126616. */
  126617. get keysDown(): number[];
  126618. set keysDown(value: number[]);
  126619. /**
  126620. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126621. */
  126622. get keysLeft(): number[];
  126623. set keysLeft(value: number[]);
  126624. /**
  126625. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126626. */
  126627. get keysRight(): number[];
  126628. set keysRight(value: number[]);
  126629. /**
  126630. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126631. */
  126632. get wheelPrecision(): number;
  126633. set wheelPrecision(value: number);
  126634. /**
  126635. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126636. * It will be used instead of pinchDeltaPrecision if different from 0.
  126637. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126638. */
  126639. get wheelDeltaPercentage(): number;
  126640. set wheelDeltaPercentage(value: number);
  126641. /**
  126642. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126643. */
  126644. zoomOnFactor: number;
  126645. /**
  126646. * Defines a screen offset for the camera position.
  126647. */
  126648. targetScreenOffset: Vector2;
  126649. /**
  126650. * Allows the camera to be completely reversed.
  126651. * If false the camera can not arrive upside down.
  126652. */
  126653. allowUpsideDown: boolean;
  126654. /**
  126655. * Define if double tap/click is used to restore the previously saved state of the camera.
  126656. */
  126657. useInputToRestoreState: boolean;
  126658. /** @hidden */
  126659. _viewMatrix: Matrix;
  126660. /** @hidden */
  126661. _useCtrlForPanning: boolean;
  126662. /** @hidden */
  126663. _panningMouseButton: number;
  126664. /**
  126665. * Defines the input associated to the camera.
  126666. */
  126667. inputs: ArcRotateCameraInputsManager;
  126668. /** @hidden */
  126669. _reset: () => void;
  126670. /**
  126671. * Defines the allowed panning axis.
  126672. */
  126673. panningAxis: Vector3;
  126674. protected _localDirection: Vector3;
  126675. protected _transformedDirection: Vector3;
  126676. private _bouncingBehavior;
  126677. /**
  126678. * Gets the bouncing behavior of the camera if it has been enabled.
  126679. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126680. */
  126681. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126682. /**
  126683. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126684. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126685. */
  126686. get useBouncingBehavior(): boolean;
  126687. set useBouncingBehavior(value: boolean);
  126688. private _framingBehavior;
  126689. /**
  126690. * Gets the framing behavior of the camera if it has been enabled.
  126691. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126692. */
  126693. get framingBehavior(): Nullable<FramingBehavior>;
  126694. /**
  126695. * Defines if the framing behavior of the camera is enabled on the camera.
  126696. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126697. */
  126698. get useFramingBehavior(): boolean;
  126699. set useFramingBehavior(value: boolean);
  126700. private _autoRotationBehavior;
  126701. /**
  126702. * Gets the auto rotation behavior of the camera if it has been enabled.
  126703. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126704. */
  126705. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126706. /**
  126707. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126708. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126709. */
  126710. get useAutoRotationBehavior(): boolean;
  126711. set useAutoRotationBehavior(value: boolean);
  126712. /**
  126713. * Observable triggered when the mesh target has been changed on the camera.
  126714. */
  126715. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126716. /**
  126717. * Event raised when the camera is colliding with a mesh.
  126718. */
  126719. onCollide: (collidedMesh: AbstractMesh) => void;
  126720. /**
  126721. * Defines whether the camera should check collision with the objects oh the scene.
  126722. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126723. */
  126724. checkCollisions: boolean;
  126725. /**
  126726. * Defines the collision radius of the camera.
  126727. * This simulates a sphere around the camera.
  126728. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126729. */
  126730. collisionRadius: Vector3;
  126731. protected _collider: Collider;
  126732. protected _previousPosition: Vector3;
  126733. protected _collisionVelocity: Vector3;
  126734. protected _newPosition: Vector3;
  126735. protected _previousAlpha: number;
  126736. protected _previousBeta: number;
  126737. protected _previousRadius: number;
  126738. protected _collisionTriggered: boolean;
  126739. protected _targetBoundingCenter: Nullable<Vector3>;
  126740. private _computationVector;
  126741. /**
  126742. * Instantiates a new ArcRotateCamera in a given scene
  126743. * @param name Defines the name of the camera
  126744. * @param alpha Defines the camera rotation along the logitudinal axis
  126745. * @param beta Defines the camera rotation along the latitudinal axis
  126746. * @param radius Defines the camera distance from its target
  126747. * @param target Defines the camera target
  126748. * @param scene Defines the scene the camera belongs to
  126749. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126750. */
  126751. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126752. /** @hidden */
  126753. _initCache(): void;
  126754. /** @hidden */
  126755. _updateCache(ignoreParentClass?: boolean): void;
  126756. protected _getTargetPosition(): Vector3;
  126757. private _storedAlpha;
  126758. private _storedBeta;
  126759. private _storedRadius;
  126760. private _storedTarget;
  126761. private _storedTargetScreenOffset;
  126762. /**
  126763. * Stores the current state of the camera (alpha, beta, radius and target)
  126764. * @returns the camera itself
  126765. */
  126766. storeState(): Camera;
  126767. /**
  126768. * @hidden
  126769. * Restored camera state. You must call storeState() first
  126770. */
  126771. _restoreStateValues(): boolean;
  126772. /** @hidden */
  126773. _isSynchronizedViewMatrix(): boolean;
  126774. /**
  126775. * Attached controls to the current camera.
  126776. * @param element Defines the element the controls should be listened from
  126777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126778. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126779. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126780. */
  126781. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126782. /**
  126783. * Detach the current controls from the camera.
  126784. * The camera will stop reacting to inputs.
  126785. * @param element Defines the element to stop listening the inputs from
  126786. */
  126787. detachControl(element: HTMLElement): void;
  126788. /** @hidden */
  126789. _checkInputs(): void;
  126790. protected _checkLimits(): void;
  126791. /**
  126792. * Rebuilds angles (alpha, beta) and radius from the give position and target
  126793. */
  126794. rebuildAnglesAndRadius(): void;
  126795. /**
  126796. * Use a position to define the current camera related information like alpha, beta and radius
  126797. * @param position Defines the position to set the camera at
  126798. */
  126799. setPosition(position: Vector3): void;
  126800. /**
  126801. * Defines the target the camera should look at.
  126802. * This will automatically adapt alpha beta and radius to fit within the new target.
  126803. * @param target Defines the new target as a Vector or a mesh
  126804. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  126805. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  126806. */
  126807. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  126808. /** @hidden */
  126809. _getViewMatrix(): Matrix;
  126810. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  126811. /**
  126812. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  126813. * @param meshes Defines the mesh to zoom on
  126814. * @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)
  126815. */
  126816. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  126817. /**
  126818. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  126819. * The target will be changed but the radius
  126820. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  126821. * @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)
  126822. */
  126823. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  126824. min: Vector3;
  126825. max: Vector3;
  126826. distance: number;
  126827. }, doNotUpdateMaxZ?: boolean): void;
  126828. /**
  126829. * @override
  126830. * Override Camera.createRigCamera
  126831. */
  126832. createRigCamera(name: string, cameraIndex: number): Camera;
  126833. /**
  126834. * @hidden
  126835. * @override
  126836. * Override Camera._updateRigCameras
  126837. */
  126838. _updateRigCameras(): void;
  126839. /**
  126840. * Destroy the camera and release the current resources hold by it.
  126841. */
  126842. dispose(): void;
  126843. /**
  126844. * Gets the current object class name.
  126845. * @return the class name
  126846. */
  126847. getClassName(): string;
  126848. }
  126849. }
  126850. declare module BABYLON {
  126851. /**
  126852. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  126853. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126854. */
  126855. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  126856. /**
  126857. * Gets the name of the behavior.
  126858. */
  126859. get name(): string;
  126860. private _zoomStopsAnimation;
  126861. private _idleRotationSpeed;
  126862. private _idleRotationWaitTime;
  126863. private _idleRotationSpinupTime;
  126864. /**
  126865. * Sets the flag that indicates if user zooming should stop animation.
  126866. */
  126867. set zoomStopsAnimation(flag: boolean);
  126868. /**
  126869. * Gets the flag that indicates if user zooming should stop animation.
  126870. */
  126871. get zoomStopsAnimation(): boolean;
  126872. /**
  126873. * Sets the default speed at which the camera rotates around the model.
  126874. */
  126875. set idleRotationSpeed(speed: number);
  126876. /**
  126877. * Gets the default speed at which the camera rotates around the model.
  126878. */
  126879. get idleRotationSpeed(): number;
  126880. /**
  126881. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  126882. */
  126883. set idleRotationWaitTime(time: number);
  126884. /**
  126885. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  126886. */
  126887. get idleRotationWaitTime(): number;
  126888. /**
  126889. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126890. */
  126891. set idleRotationSpinupTime(time: number);
  126892. /**
  126893. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  126894. */
  126895. get idleRotationSpinupTime(): number;
  126896. /**
  126897. * Gets a value indicating if the camera is currently rotating because of this behavior
  126898. */
  126899. get rotationInProgress(): boolean;
  126900. private _onPrePointerObservableObserver;
  126901. private _onAfterCheckInputsObserver;
  126902. private _attachedCamera;
  126903. private _isPointerDown;
  126904. private _lastFrameTime;
  126905. private _lastInteractionTime;
  126906. private _cameraRotationSpeed;
  126907. /**
  126908. * Initializes the behavior.
  126909. */
  126910. init(): void;
  126911. /**
  126912. * Attaches the behavior to its arc rotate camera.
  126913. * @param camera Defines the camera to attach the behavior to
  126914. */
  126915. attach(camera: ArcRotateCamera): void;
  126916. /**
  126917. * Detaches the behavior from its current arc rotate camera.
  126918. */
  126919. detach(): void;
  126920. /**
  126921. * Returns true if user is scrolling.
  126922. * @return true if user is scrolling.
  126923. */
  126924. private _userIsZooming;
  126925. private _lastFrameRadius;
  126926. private _shouldAnimationStopForInteraction;
  126927. /**
  126928. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126929. */
  126930. private _applyUserInteraction;
  126931. private _userIsMoving;
  126932. }
  126933. }
  126934. declare module BABYLON {
  126935. /**
  126936. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  126937. */
  126938. export class AttachToBoxBehavior implements Behavior<Mesh> {
  126939. private ui;
  126940. /**
  126941. * The name of the behavior
  126942. */
  126943. name: string;
  126944. /**
  126945. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  126946. */
  126947. distanceAwayFromFace: number;
  126948. /**
  126949. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  126950. */
  126951. distanceAwayFromBottomOfFace: number;
  126952. private _faceVectors;
  126953. private _target;
  126954. private _scene;
  126955. private _onRenderObserver;
  126956. private _tmpMatrix;
  126957. private _tmpVector;
  126958. /**
  126959. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  126960. * @param ui The transform node that should be attched to the mesh
  126961. */
  126962. constructor(ui: TransformNode);
  126963. /**
  126964. * Initializes the behavior
  126965. */
  126966. init(): void;
  126967. private _closestFace;
  126968. private _zeroVector;
  126969. private _lookAtTmpMatrix;
  126970. private _lookAtToRef;
  126971. /**
  126972. * Attaches the AttachToBoxBehavior to the passed in mesh
  126973. * @param target The mesh that the specified node will be attached to
  126974. */
  126975. attach(target: Mesh): void;
  126976. /**
  126977. * Detaches the behavior from the mesh
  126978. */
  126979. detach(): void;
  126980. }
  126981. }
  126982. declare module BABYLON {
  126983. /**
  126984. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  126985. */
  126986. export class FadeInOutBehavior implements Behavior<Mesh> {
  126987. /**
  126988. * Time in milliseconds to delay before fading in (Default: 0)
  126989. */
  126990. delay: number;
  126991. /**
  126992. * Time in milliseconds for the mesh to fade in (Default: 300)
  126993. */
  126994. fadeInTime: number;
  126995. private _millisecondsPerFrame;
  126996. private _hovered;
  126997. private _hoverValue;
  126998. private _ownerNode;
  126999. /**
  127000. * Instatiates the FadeInOutBehavior
  127001. */
  127002. constructor();
  127003. /**
  127004. * The name of the behavior
  127005. */
  127006. get name(): string;
  127007. /**
  127008. * Initializes the behavior
  127009. */
  127010. init(): void;
  127011. /**
  127012. * Attaches the fade behavior on the passed in mesh
  127013. * @param ownerNode The mesh that will be faded in/out once attached
  127014. */
  127015. attach(ownerNode: Mesh): void;
  127016. /**
  127017. * Detaches the behavior from the mesh
  127018. */
  127019. detach(): void;
  127020. /**
  127021. * Triggers the mesh to begin fading in or out
  127022. * @param value if the object should fade in or out (true to fade in)
  127023. */
  127024. fadeIn(value: boolean): void;
  127025. private _update;
  127026. private _setAllVisibility;
  127027. }
  127028. }
  127029. declare module BABYLON {
  127030. /**
  127031. * Class containing a set of static utilities functions for managing Pivots
  127032. * @hidden
  127033. */
  127034. export class PivotTools {
  127035. private static _PivotCached;
  127036. private static _OldPivotPoint;
  127037. private static _PivotTranslation;
  127038. private static _PivotTmpVector;
  127039. private static _PivotPostMultiplyPivotMatrix;
  127040. /** @hidden */
  127041. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127042. /** @hidden */
  127043. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127044. }
  127045. }
  127046. declare module BABYLON {
  127047. /**
  127048. * Class containing static functions to help procedurally build meshes
  127049. */
  127050. export class PlaneBuilder {
  127051. /**
  127052. * Creates a plane mesh
  127053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127059. * @param name defines the name of the mesh
  127060. * @param options defines the options used to create the mesh
  127061. * @param scene defines the hosting scene
  127062. * @returns the plane mesh
  127063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127064. */
  127065. static CreatePlane(name: string, options: {
  127066. size?: number;
  127067. width?: number;
  127068. height?: number;
  127069. sideOrientation?: number;
  127070. frontUVs?: Vector4;
  127071. backUVs?: Vector4;
  127072. updatable?: boolean;
  127073. sourcePlane?: Plane;
  127074. }, scene?: Nullable<Scene>): Mesh;
  127075. }
  127076. }
  127077. declare module BABYLON {
  127078. /**
  127079. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127080. */
  127081. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127082. private static _AnyMouseID;
  127083. /**
  127084. * Abstract mesh the behavior is set on
  127085. */
  127086. attachedNode: AbstractMesh;
  127087. private _dragPlane;
  127088. private _scene;
  127089. private _pointerObserver;
  127090. private _beforeRenderObserver;
  127091. private static _planeScene;
  127092. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127093. /**
  127094. * 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)
  127095. */
  127096. maxDragAngle: number;
  127097. /**
  127098. * @hidden
  127099. */
  127100. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127101. /**
  127102. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127103. */
  127104. currentDraggingPointerID: number;
  127105. /**
  127106. * The last position where the pointer hit the drag plane in world space
  127107. */
  127108. lastDragPosition: Vector3;
  127109. /**
  127110. * If the behavior is currently in a dragging state
  127111. */
  127112. dragging: boolean;
  127113. /**
  127114. * 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)
  127115. */
  127116. dragDeltaRatio: number;
  127117. /**
  127118. * If the drag plane orientation should be updated during the dragging (Default: true)
  127119. */
  127120. updateDragPlane: boolean;
  127121. private _debugMode;
  127122. private _moving;
  127123. /**
  127124. * Fires each time the attached mesh is dragged with the pointer
  127125. * * delta between last drag position and current drag position in world space
  127126. * * dragDistance along the drag axis
  127127. * * dragPlaneNormal normal of the current drag plane used during the drag
  127128. * * dragPlanePoint in world space where the drag intersects the drag plane
  127129. */
  127130. onDragObservable: Observable<{
  127131. delta: Vector3;
  127132. dragPlanePoint: Vector3;
  127133. dragPlaneNormal: Vector3;
  127134. dragDistance: number;
  127135. pointerId: number;
  127136. }>;
  127137. /**
  127138. * Fires each time a drag begins (eg. mouse down on mesh)
  127139. */
  127140. onDragStartObservable: Observable<{
  127141. dragPlanePoint: Vector3;
  127142. pointerId: number;
  127143. }>;
  127144. /**
  127145. * Fires each time a drag ends (eg. mouse release after drag)
  127146. */
  127147. onDragEndObservable: Observable<{
  127148. dragPlanePoint: Vector3;
  127149. pointerId: number;
  127150. }>;
  127151. /**
  127152. * If the attached mesh should be moved when dragged
  127153. */
  127154. moveAttached: boolean;
  127155. /**
  127156. * If the drag behavior will react to drag events (Default: true)
  127157. */
  127158. enabled: boolean;
  127159. /**
  127160. * If pointer events should start and release the drag (Default: true)
  127161. */
  127162. startAndReleaseDragOnPointerEvents: boolean;
  127163. /**
  127164. * If camera controls should be detached during the drag
  127165. */
  127166. detachCameraControls: boolean;
  127167. /**
  127168. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127169. */
  127170. useObjectOrientationForDragging: boolean;
  127171. private _options;
  127172. /**
  127173. * Gets the options used by the behavior
  127174. */
  127175. get options(): {
  127176. dragAxis?: Vector3;
  127177. dragPlaneNormal?: Vector3;
  127178. };
  127179. /**
  127180. * Sets the options used by the behavior
  127181. */
  127182. set options(options: {
  127183. dragAxis?: Vector3;
  127184. dragPlaneNormal?: Vector3;
  127185. });
  127186. /**
  127187. * Creates a pointer drag behavior that can be attached to a mesh
  127188. * @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)
  127189. */
  127190. constructor(options?: {
  127191. dragAxis?: Vector3;
  127192. dragPlaneNormal?: Vector3;
  127193. });
  127194. /**
  127195. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127196. */
  127197. validateDrag: (targetPosition: Vector3) => boolean;
  127198. /**
  127199. * The name of the behavior
  127200. */
  127201. get name(): string;
  127202. /**
  127203. * Initializes the behavior
  127204. */
  127205. init(): void;
  127206. private _tmpVector;
  127207. private _alternatePickedPoint;
  127208. private _worldDragAxis;
  127209. private _targetPosition;
  127210. private _attachedElement;
  127211. /**
  127212. * Attaches the drag behavior the passed in mesh
  127213. * @param ownerNode The mesh that will be dragged around once attached
  127214. * @param predicate Predicate to use for pick filtering
  127215. */
  127216. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127217. /**
  127218. * Force relase the drag action by code.
  127219. */
  127220. releaseDrag(): void;
  127221. private _startDragRay;
  127222. private _lastPointerRay;
  127223. /**
  127224. * Simulates the start of a pointer drag event on the behavior
  127225. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127226. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127227. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127228. */
  127229. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127230. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127231. private _dragDelta;
  127232. protected _moveDrag(ray: Ray): void;
  127233. private _pickWithRayOnDragPlane;
  127234. private _pointA;
  127235. private _pointC;
  127236. private _localAxis;
  127237. private _lookAt;
  127238. private _updateDragPlanePosition;
  127239. /**
  127240. * Detaches the behavior from the mesh
  127241. */
  127242. detach(): void;
  127243. }
  127244. }
  127245. declare module BABYLON {
  127246. /**
  127247. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127248. */
  127249. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127250. private _dragBehaviorA;
  127251. private _dragBehaviorB;
  127252. private _startDistance;
  127253. private _initialScale;
  127254. private _targetScale;
  127255. private _ownerNode;
  127256. private _sceneRenderObserver;
  127257. /**
  127258. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127259. */
  127260. constructor();
  127261. /**
  127262. * The name of the behavior
  127263. */
  127264. get name(): string;
  127265. /**
  127266. * Initializes the behavior
  127267. */
  127268. init(): void;
  127269. private _getCurrentDistance;
  127270. /**
  127271. * Attaches the scale behavior the passed in mesh
  127272. * @param ownerNode The mesh that will be scaled around once attached
  127273. */
  127274. attach(ownerNode: Mesh): void;
  127275. /**
  127276. * Detaches the behavior from the mesh
  127277. */
  127278. detach(): void;
  127279. }
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * 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
  127284. */
  127285. export class SixDofDragBehavior implements Behavior<Mesh> {
  127286. private static _virtualScene;
  127287. private _ownerNode;
  127288. private _sceneRenderObserver;
  127289. private _scene;
  127290. private _targetPosition;
  127291. private _virtualOriginMesh;
  127292. private _virtualDragMesh;
  127293. private _pointerObserver;
  127294. private _moving;
  127295. private _startingOrientation;
  127296. private _attachedElement;
  127297. /**
  127298. * 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)
  127299. */
  127300. private zDragFactor;
  127301. /**
  127302. * If the object should rotate to face the drag origin
  127303. */
  127304. rotateDraggedObject: boolean;
  127305. /**
  127306. * If the behavior is currently in a dragging state
  127307. */
  127308. dragging: boolean;
  127309. /**
  127310. * 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)
  127311. */
  127312. dragDeltaRatio: number;
  127313. /**
  127314. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127315. */
  127316. currentDraggingPointerID: number;
  127317. /**
  127318. * If camera controls should be detached during the drag
  127319. */
  127320. detachCameraControls: boolean;
  127321. /**
  127322. * Fires each time a drag starts
  127323. */
  127324. onDragStartObservable: Observable<{}>;
  127325. /**
  127326. * Fires each time a drag ends (eg. mouse release after drag)
  127327. */
  127328. onDragEndObservable: Observable<{}>;
  127329. /**
  127330. * 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
  127331. */
  127332. constructor();
  127333. /**
  127334. * The name of the behavior
  127335. */
  127336. get name(): string;
  127337. /**
  127338. * Initializes the behavior
  127339. */
  127340. init(): void;
  127341. /**
  127342. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127343. */
  127344. private get _pointerCamera();
  127345. /**
  127346. * Attaches the scale behavior the passed in mesh
  127347. * @param ownerNode The mesh that will be scaled around once attached
  127348. */
  127349. attach(ownerNode: Mesh): void;
  127350. /**
  127351. * Detaches the behavior from the mesh
  127352. */
  127353. detach(): void;
  127354. }
  127355. }
  127356. declare module BABYLON {
  127357. /**
  127358. * Class used to apply inverse kinematics to bones
  127359. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127360. */
  127361. export class BoneIKController {
  127362. private static _tmpVecs;
  127363. private static _tmpQuat;
  127364. private static _tmpMats;
  127365. /**
  127366. * Gets or sets the target mesh
  127367. */
  127368. targetMesh: AbstractMesh;
  127369. /** Gets or sets the mesh used as pole */
  127370. poleTargetMesh: AbstractMesh;
  127371. /**
  127372. * Gets or sets the bone used as pole
  127373. */
  127374. poleTargetBone: Nullable<Bone>;
  127375. /**
  127376. * Gets or sets the target position
  127377. */
  127378. targetPosition: Vector3;
  127379. /**
  127380. * Gets or sets the pole target position
  127381. */
  127382. poleTargetPosition: Vector3;
  127383. /**
  127384. * Gets or sets the pole target local offset
  127385. */
  127386. poleTargetLocalOffset: Vector3;
  127387. /**
  127388. * Gets or sets the pole angle
  127389. */
  127390. poleAngle: number;
  127391. /**
  127392. * Gets or sets the mesh associated with the controller
  127393. */
  127394. mesh: AbstractMesh;
  127395. /**
  127396. * 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)
  127397. */
  127398. slerpAmount: number;
  127399. private _bone1Quat;
  127400. private _bone1Mat;
  127401. private _bone2Ang;
  127402. private _bone1;
  127403. private _bone2;
  127404. private _bone1Length;
  127405. private _bone2Length;
  127406. private _maxAngle;
  127407. private _maxReach;
  127408. private _rightHandedSystem;
  127409. private _bendAxis;
  127410. private _slerping;
  127411. private _adjustRoll;
  127412. /**
  127413. * Gets or sets maximum allowed angle
  127414. */
  127415. get maxAngle(): number;
  127416. set maxAngle(value: number);
  127417. /**
  127418. * Creates a new BoneIKController
  127419. * @param mesh defines the mesh to control
  127420. * @param bone defines the bone to control
  127421. * @param options defines options to set up the controller
  127422. */
  127423. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127424. targetMesh?: AbstractMesh;
  127425. poleTargetMesh?: AbstractMesh;
  127426. poleTargetBone?: Bone;
  127427. poleTargetLocalOffset?: Vector3;
  127428. poleAngle?: number;
  127429. bendAxis?: Vector3;
  127430. maxAngle?: number;
  127431. slerpAmount?: number;
  127432. });
  127433. private _setMaxAngle;
  127434. /**
  127435. * Force the controller to update the bones
  127436. */
  127437. update(): void;
  127438. }
  127439. }
  127440. declare module BABYLON {
  127441. /**
  127442. * Class used to make a bone look toward a point in space
  127443. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127444. */
  127445. export class BoneLookController {
  127446. private static _tmpVecs;
  127447. private static _tmpQuat;
  127448. private static _tmpMats;
  127449. /**
  127450. * The target Vector3 that the bone will look at
  127451. */
  127452. target: Vector3;
  127453. /**
  127454. * The mesh that the bone is attached to
  127455. */
  127456. mesh: AbstractMesh;
  127457. /**
  127458. * The bone that will be looking to the target
  127459. */
  127460. bone: Bone;
  127461. /**
  127462. * The up axis of the coordinate system that is used when the bone is rotated
  127463. */
  127464. upAxis: Vector3;
  127465. /**
  127466. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127467. */
  127468. upAxisSpace: Space;
  127469. /**
  127470. * Used to make an adjustment to the yaw of the bone
  127471. */
  127472. adjustYaw: number;
  127473. /**
  127474. * Used to make an adjustment to the pitch of the bone
  127475. */
  127476. adjustPitch: number;
  127477. /**
  127478. * Used to make an adjustment to the roll of the bone
  127479. */
  127480. adjustRoll: number;
  127481. /**
  127482. * 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)
  127483. */
  127484. slerpAmount: number;
  127485. private _minYaw;
  127486. private _maxYaw;
  127487. private _minPitch;
  127488. private _maxPitch;
  127489. private _minYawSin;
  127490. private _minYawCos;
  127491. private _maxYawSin;
  127492. private _maxYawCos;
  127493. private _midYawConstraint;
  127494. private _minPitchTan;
  127495. private _maxPitchTan;
  127496. private _boneQuat;
  127497. private _slerping;
  127498. private _transformYawPitch;
  127499. private _transformYawPitchInv;
  127500. private _firstFrameSkipped;
  127501. private _yawRange;
  127502. private _fowardAxis;
  127503. /**
  127504. * Gets or sets the minimum yaw angle that the bone can look to
  127505. */
  127506. get minYaw(): number;
  127507. set minYaw(value: number);
  127508. /**
  127509. * Gets or sets the maximum yaw angle that the bone can look to
  127510. */
  127511. get maxYaw(): number;
  127512. set maxYaw(value: number);
  127513. /**
  127514. * Gets or sets the minimum pitch angle that the bone can look to
  127515. */
  127516. get minPitch(): number;
  127517. set minPitch(value: number);
  127518. /**
  127519. * Gets or sets the maximum pitch angle that the bone can look to
  127520. */
  127521. get maxPitch(): number;
  127522. set maxPitch(value: number);
  127523. /**
  127524. * Create a BoneLookController
  127525. * @param mesh the mesh that the bone belongs to
  127526. * @param bone the bone that will be looking to the target
  127527. * @param target the target Vector3 to look at
  127528. * @param options optional settings:
  127529. * * maxYaw: the maximum angle the bone will yaw to
  127530. * * minYaw: the minimum angle the bone will yaw to
  127531. * * maxPitch: the maximum angle the bone will pitch to
  127532. * * minPitch: the minimum angle the bone will yaw to
  127533. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127534. * * upAxis: the up axis of the coordinate system
  127535. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127536. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127537. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127538. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127539. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127540. * * adjustRoll: used to make an adjustment to the roll of the bone
  127541. **/
  127542. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127543. maxYaw?: number;
  127544. minYaw?: number;
  127545. maxPitch?: number;
  127546. minPitch?: number;
  127547. slerpAmount?: number;
  127548. upAxis?: Vector3;
  127549. upAxisSpace?: Space;
  127550. yawAxis?: Vector3;
  127551. pitchAxis?: Vector3;
  127552. adjustYaw?: number;
  127553. adjustPitch?: number;
  127554. adjustRoll?: number;
  127555. });
  127556. /**
  127557. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127558. */
  127559. update(): void;
  127560. private _getAngleDiff;
  127561. private _getAngleBetween;
  127562. private _isAngleBetween;
  127563. }
  127564. }
  127565. declare module BABYLON {
  127566. /**
  127567. * Manage the gamepad inputs to control an arc rotate camera.
  127568. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127569. */
  127570. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127571. /**
  127572. * Defines the camera the input is attached to.
  127573. */
  127574. camera: ArcRotateCamera;
  127575. /**
  127576. * Defines the gamepad the input is gathering event from.
  127577. */
  127578. gamepad: Nullable<Gamepad>;
  127579. /**
  127580. * Defines the gamepad rotation sensiblity.
  127581. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127582. */
  127583. gamepadRotationSensibility: number;
  127584. /**
  127585. * Defines the gamepad move sensiblity.
  127586. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127587. */
  127588. gamepadMoveSensibility: number;
  127589. private _yAxisScale;
  127590. /**
  127591. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127592. */
  127593. get invertYAxis(): boolean;
  127594. set invertYAxis(value: boolean);
  127595. private _onGamepadConnectedObserver;
  127596. private _onGamepadDisconnectedObserver;
  127597. /**
  127598. * Attach the input controls to a specific dom element to get the input from.
  127599. * @param element Defines the element the controls should be listened from
  127600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127601. */
  127602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127603. /**
  127604. * Detach the current controls from the specified dom element.
  127605. * @param element Defines the element to stop listening the inputs from
  127606. */
  127607. detachControl(element: Nullable<HTMLElement>): void;
  127608. /**
  127609. * Update the current camera state depending on the inputs that have been used this frame.
  127610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127611. */
  127612. checkInputs(): void;
  127613. /**
  127614. * Gets the class name of the current intput.
  127615. * @returns the class name
  127616. */
  127617. getClassName(): string;
  127618. /**
  127619. * Get the friendly name associated with the input class.
  127620. * @returns the input friendly name
  127621. */
  127622. getSimpleName(): string;
  127623. }
  127624. }
  127625. declare module BABYLON {
  127626. interface ArcRotateCameraInputsManager {
  127627. /**
  127628. * Add orientation input support to the input manager.
  127629. * @returns the current input manager
  127630. */
  127631. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127632. }
  127633. /**
  127634. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127636. */
  127637. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127638. /**
  127639. * Defines the camera the input is attached to.
  127640. */
  127641. camera: ArcRotateCamera;
  127642. /**
  127643. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127644. */
  127645. alphaCorrection: number;
  127646. /**
  127647. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127648. */
  127649. gammaCorrection: number;
  127650. private _alpha;
  127651. private _gamma;
  127652. private _dirty;
  127653. private _deviceOrientationHandler;
  127654. /**
  127655. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127656. */
  127657. constructor();
  127658. /**
  127659. * Attach the input controls to a specific dom element to get the input from.
  127660. * @param element Defines the element the controls should be listened from
  127661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127662. */
  127663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127664. /** @hidden */
  127665. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127666. /**
  127667. * Update the current camera state depending on the inputs that have been used this frame.
  127668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127669. */
  127670. checkInputs(): void;
  127671. /**
  127672. * Detach the current controls from the specified dom element.
  127673. * @param element Defines the element to stop listening the inputs from
  127674. */
  127675. detachControl(element: Nullable<HTMLElement>): void;
  127676. /**
  127677. * Gets the class name of the current intput.
  127678. * @returns the class name
  127679. */
  127680. getClassName(): string;
  127681. /**
  127682. * Get the friendly name associated with the input class.
  127683. * @returns the input friendly name
  127684. */
  127685. getSimpleName(): string;
  127686. }
  127687. }
  127688. declare module BABYLON {
  127689. /**
  127690. * Listen to mouse events to control the camera.
  127691. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127692. */
  127693. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127694. /**
  127695. * Defines the camera the input is attached to.
  127696. */
  127697. camera: FlyCamera;
  127698. /**
  127699. * Defines if touch is enabled. (Default is true.)
  127700. */
  127701. touchEnabled: boolean;
  127702. /**
  127703. * Defines the buttons associated with the input to handle camera rotation.
  127704. */
  127705. buttons: number[];
  127706. /**
  127707. * Assign buttons for Yaw control.
  127708. */
  127709. buttonsYaw: number[];
  127710. /**
  127711. * Assign buttons for Pitch control.
  127712. */
  127713. buttonsPitch: number[];
  127714. /**
  127715. * Assign buttons for Roll control.
  127716. */
  127717. buttonsRoll: number[];
  127718. /**
  127719. * Detect if any button is being pressed while mouse is moved.
  127720. * -1 = Mouse locked.
  127721. * 0 = Left button.
  127722. * 1 = Middle Button.
  127723. * 2 = Right Button.
  127724. */
  127725. activeButton: number;
  127726. /**
  127727. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127728. * Higher values reduce its sensitivity.
  127729. */
  127730. angularSensibility: number;
  127731. private _observer;
  127732. private _rollObserver;
  127733. private previousPosition;
  127734. private noPreventDefault;
  127735. private element;
  127736. /**
  127737. * Listen to mouse events to control the camera.
  127738. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127739. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127740. */
  127741. constructor(touchEnabled?: boolean);
  127742. /**
  127743. * Attach the mouse control to the HTML DOM element.
  127744. * @param element Defines the element that listens to the input events.
  127745. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127746. */
  127747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127748. /**
  127749. * Detach the current controls from the specified dom element.
  127750. * @param element Defines the element to stop listening the inputs from
  127751. */
  127752. detachControl(element: Nullable<HTMLElement>): void;
  127753. /**
  127754. * Gets the class name of the current input.
  127755. * @returns the class name.
  127756. */
  127757. getClassName(): string;
  127758. /**
  127759. * Get the friendly name associated with the input class.
  127760. * @returns the input's friendly name.
  127761. */
  127762. getSimpleName(): string;
  127763. private _pointerInput;
  127764. private _onMouseMove;
  127765. /**
  127766. * Rotate camera by mouse offset.
  127767. */
  127768. private rotateCamera;
  127769. }
  127770. }
  127771. declare module BABYLON {
  127772. /**
  127773. * Default Inputs manager for the FlyCamera.
  127774. * It groups all the default supported inputs for ease of use.
  127775. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127776. */
  127777. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127778. /**
  127779. * Instantiates a new FlyCameraInputsManager.
  127780. * @param camera Defines the camera the inputs belong to.
  127781. */
  127782. constructor(camera: FlyCamera);
  127783. /**
  127784. * Add keyboard input support to the input manager.
  127785. * @returns the new FlyCameraKeyboardMoveInput().
  127786. */
  127787. addKeyboard(): FlyCameraInputsManager;
  127788. /**
  127789. * Add mouse input support to the input manager.
  127790. * @param touchEnabled Enable touch screen support.
  127791. * @returns the new FlyCameraMouseInput().
  127792. */
  127793. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  127794. }
  127795. }
  127796. declare module BABYLON {
  127797. /**
  127798. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127799. * such as in a 3D Space Shooter or a Flight Simulator.
  127800. */
  127801. export class FlyCamera extends TargetCamera {
  127802. /**
  127803. * Define the collision ellipsoid of the camera.
  127804. * This is helpful for simulating a camera body, like a player's body.
  127805. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127806. */
  127807. ellipsoid: Vector3;
  127808. /**
  127809. * Define an offset for the position of the ellipsoid around the camera.
  127810. * This can be helpful if the camera is attached away from the player's body center,
  127811. * such as at its head.
  127812. */
  127813. ellipsoidOffset: Vector3;
  127814. /**
  127815. * Enable or disable collisions of the camera with the rest of the scene objects.
  127816. */
  127817. checkCollisions: boolean;
  127818. /**
  127819. * Enable or disable gravity on the camera.
  127820. */
  127821. applyGravity: boolean;
  127822. /**
  127823. * Define the current direction the camera is moving to.
  127824. */
  127825. cameraDirection: Vector3;
  127826. /**
  127827. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  127828. * This overrides and empties cameraRotation.
  127829. */
  127830. rotationQuaternion: Quaternion;
  127831. /**
  127832. * Track Roll to maintain the wanted Rolling when looking around.
  127833. */
  127834. _trackRoll: number;
  127835. /**
  127836. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  127837. */
  127838. rollCorrect: number;
  127839. /**
  127840. * Mimic a banked turn, Rolling the camera when Yawing.
  127841. * It's recommended to use rollCorrect = 10 for faster banking correction.
  127842. */
  127843. bankedTurn: boolean;
  127844. /**
  127845. * Limit in radians for how much Roll banking will add. (Default: 90°)
  127846. */
  127847. bankedTurnLimit: number;
  127848. /**
  127849. * Value of 0 disables the banked Roll.
  127850. * Value of 1 is equal to the Yaw angle in radians.
  127851. */
  127852. bankedTurnMultiplier: number;
  127853. /**
  127854. * The inputs manager loads all the input sources, such as keyboard and mouse.
  127855. */
  127856. inputs: FlyCameraInputsManager;
  127857. /**
  127858. * Gets the input sensibility for mouse input.
  127859. * Higher values reduce sensitivity.
  127860. */
  127861. get angularSensibility(): number;
  127862. /**
  127863. * Sets the input sensibility for a mouse input.
  127864. * Higher values reduce sensitivity.
  127865. */
  127866. set angularSensibility(value: number);
  127867. /**
  127868. * Get the keys for camera movement forward.
  127869. */
  127870. get keysForward(): number[];
  127871. /**
  127872. * Set the keys for camera movement forward.
  127873. */
  127874. set keysForward(value: number[]);
  127875. /**
  127876. * Get the keys for camera movement backward.
  127877. */
  127878. get keysBackward(): number[];
  127879. set keysBackward(value: number[]);
  127880. /**
  127881. * Get the keys for camera movement up.
  127882. */
  127883. get keysUp(): number[];
  127884. /**
  127885. * Set the keys for camera movement up.
  127886. */
  127887. set keysUp(value: number[]);
  127888. /**
  127889. * Get the keys for camera movement down.
  127890. */
  127891. get keysDown(): number[];
  127892. /**
  127893. * Set the keys for camera movement down.
  127894. */
  127895. set keysDown(value: number[]);
  127896. /**
  127897. * Get the keys for camera movement left.
  127898. */
  127899. get keysLeft(): number[];
  127900. /**
  127901. * Set the keys for camera movement left.
  127902. */
  127903. set keysLeft(value: number[]);
  127904. /**
  127905. * Set the keys for camera movement right.
  127906. */
  127907. get keysRight(): number[];
  127908. /**
  127909. * Set the keys for camera movement right.
  127910. */
  127911. set keysRight(value: number[]);
  127912. /**
  127913. * Event raised when the camera collides with a mesh in the scene.
  127914. */
  127915. onCollide: (collidedMesh: AbstractMesh) => void;
  127916. private _collider;
  127917. private _needMoveForGravity;
  127918. private _oldPosition;
  127919. private _diffPosition;
  127920. private _newPosition;
  127921. /** @hidden */
  127922. _localDirection: Vector3;
  127923. /** @hidden */
  127924. _transformedDirection: Vector3;
  127925. /**
  127926. * Instantiates a FlyCamera.
  127927. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127928. * such as in a 3D Space Shooter or a Flight Simulator.
  127929. * @param name Define the name of the camera in the scene.
  127930. * @param position Define the starting position of the camera in the scene.
  127931. * @param scene Define the scene the camera belongs to.
  127932. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  127933. */
  127934. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127935. /**
  127936. * Attach a control to the HTML DOM element.
  127937. * @param element Defines the element that listens to the input events.
  127938. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  127939. */
  127940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127941. /**
  127942. * Detach a control from the HTML DOM element.
  127943. * The camera will stop reacting to that input.
  127944. * @param element Defines the element that listens to the input events.
  127945. */
  127946. detachControl(element: HTMLElement): void;
  127947. private _collisionMask;
  127948. /**
  127949. * Get the mask that the camera ignores in collision events.
  127950. */
  127951. get collisionMask(): number;
  127952. /**
  127953. * Set the mask that the camera ignores in collision events.
  127954. */
  127955. set collisionMask(mask: number);
  127956. /** @hidden */
  127957. _collideWithWorld(displacement: Vector3): void;
  127958. /** @hidden */
  127959. private _onCollisionPositionChange;
  127960. /** @hidden */
  127961. _checkInputs(): void;
  127962. /** @hidden */
  127963. _decideIfNeedsToMove(): boolean;
  127964. /** @hidden */
  127965. _updatePosition(): void;
  127966. /**
  127967. * Restore the Roll to its target value at the rate specified.
  127968. * @param rate - Higher means slower restoring.
  127969. * @hidden
  127970. */
  127971. restoreRoll(rate: number): void;
  127972. /**
  127973. * Destroy the camera and release the current resources held by it.
  127974. */
  127975. dispose(): void;
  127976. /**
  127977. * Get the current object class name.
  127978. * @returns the class name.
  127979. */
  127980. getClassName(): string;
  127981. }
  127982. }
  127983. declare module BABYLON {
  127984. /**
  127985. * Listen to keyboard events to control the camera.
  127986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127987. */
  127988. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  127989. /**
  127990. * Defines the camera the input is attached to.
  127991. */
  127992. camera: FlyCamera;
  127993. /**
  127994. * The list of keyboard keys used to control the forward move of the camera.
  127995. */
  127996. keysForward: number[];
  127997. /**
  127998. * The list of keyboard keys used to control the backward move of the camera.
  127999. */
  128000. keysBackward: number[];
  128001. /**
  128002. * The list of keyboard keys used to control the forward move of the camera.
  128003. */
  128004. keysUp: number[];
  128005. /**
  128006. * The list of keyboard keys used to control the backward move of the camera.
  128007. */
  128008. keysDown: number[];
  128009. /**
  128010. * The list of keyboard keys used to control the right strafe move of the camera.
  128011. */
  128012. keysRight: number[];
  128013. /**
  128014. * The list of keyboard keys used to control the left strafe move of the camera.
  128015. */
  128016. keysLeft: number[];
  128017. private _keys;
  128018. private _onCanvasBlurObserver;
  128019. private _onKeyboardObserver;
  128020. private _engine;
  128021. private _scene;
  128022. /**
  128023. * Attach the input controls to a specific dom element to get the input from.
  128024. * @param element Defines the element the controls should be listened from
  128025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128026. */
  128027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128028. /**
  128029. * Detach the current controls from the specified dom element.
  128030. * @param element Defines the element to stop listening the inputs from
  128031. */
  128032. detachControl(element: Nullable<HTMLElement>): void;
  128033. /**
  128034. * Gets the class name of the current intput.
  128035. * @returns the class name
  128036. */
  128037. getClassName(): string;
  128038. /** @hidden */
  128039. _onLostFocus(e: FocusEvent): void;
  128040. /**
  128041. * Get the friendly name associated with the input class.
  128042. * @returns the input friendly name
  128043. */
  128044. getSimpleName(): string;
  128045. /**
  128046. * Update the current camera state depending on the inputs that have been used this frame.
  128047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128048. */
  128049. checkInputs(): void;
  128050. }
  128051. }
  128052. declare module BABYLON {
  128053. /**
  128054. * Manage the mouse wheel inputs to control a follow camera.
  128055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128056. */
  128057. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128058. /**
  128059. * Defines the camera the input is attached to.
  128060. */
  128061. camera: FollowCamera;
  128062. /**
  128063. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128064. */
  128065. axisControlRadius: boolean;
  128066. /**
  128067. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128068. */
  128069. axisControlHeight: boolean;
  128070. /**
  128071. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128072. */
  128073. axisControlRotation: boolean;
  128074. /**
  128075. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128076. * relation to mouseWheel events.
  128077. */
  128078. wheelPrecision: number;
  128079. /**
  128080. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128081. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128082. */
  128083. wheelDeltaPercentage: number;
  128084. private _wheel;
  128085. private _observer;
  128086. /**
  128087. * Attach the input controls to a specific dom element to get the input from.
  128088. * @param element Defines the element the controls should be listened from
  128089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128090. */
  128091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128092. /**
  128093. * Detach the current controls from the specified dom element.
  128094. * @param element Defines the element to stop listening the inputs from
  128095. */
  128096. detachControl(element: Nullable<HTMLElement>): void;
  128097. /**
  128098. * Gets the class name of the current intput.
  128099. * @returns the class name
  128100. */
  128101. getClassName(): string;
  128102. /**
  128103. * Get the friendly name associated with the input class.
  128104. * @returns the input friendly name
  128105. */
  128106. getSimpleName(): string;
  128107. }
  128108. }
  128109. declare module BABYLON {
  128110. /**
  128111. * Manage the pointers inputs to control an follow camera.
  128112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128113. */
  128114. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128115. /**
  128116. * Defines the camera the input is attached to.
  128117. */
  128118. camera: FollowCamera;
  128119. /**
  128120. * Gets the class name of the current input.
  128121. * @returns the class name
  128122. */
  128123. getClassName(): string;
  128124. /**
  128125. * Defines the pointer angular sensibility along the X axis or how fast is
  128126. * the camera rotating.
  128127. * A negative number will reverse the axis direction.
  128128. */
  128129. angularSensibilityX: number;
  128130. /**
  128131. * Defines the pointer angular sensibility along the Y axis or how fast is
  128132. * the camera rotating.
  128133. * A negative number will reverse the axis direction.
  128134. */
  128135. angularSensibilityY: number;
  128136. /**
  128137. * Defines the pointer pinch precision or how fast is the camera zooming.
  128138. * A negative number will reverse the axis direction.
  128139. */
  128140. pinchPrecision: number;
  128141. /**
  128142. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128143. * from 0.
  128144. * It defines the percentage of current camera.radius to use as delta when
  128145. * pinch zoom is used.
  128146. */
  128147. pinchDeltaPercentage: number;
  128148. /**
  128149. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128150. */
  128151. axisXControlRadius: boolean;
  128152. /**
  128153. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128154. */
  128155. axisXControlHeight: boolean;
  128156. /**
  128157. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128158. */
  128159. axisXControlRotation: boolean;
  128160. /**
  128161. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128162. */
  128163. axisYControlRadius: boolean;
  128164. /**
  128165. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128166. */
  128167. axisYControlHeight: boolean;
  128168. /**
  128169. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128170. */
  128171. axisYControlRotation: boolean;
  128172. /**
  128173. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128174. */
  128175. axisPinchControlRadius: boolean;
  128176. /**
  128177. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128178. */
  128179. axisPinchControlHeight: boolean;
  128180. /**
  128181. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128182. */
  128183. axisPinchControlRotation: boolean;
  128184. /**
  128185. * Log error messages if basic misconfiguration has occurred.
  128186. */
  128187. warningEnable: boolean;
  128188. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128189. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128190. private _warningCounter;
  128191. private _warning;
  128192. }
  128193. }
  128194. declare module BABYLON {
  128195. /**
  128196. * Default Inputs manager for the FollowCamera.
  128197. * It groups all the default supported inputs for ease of use.
  128198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128199. */
  128200. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128201. /**
  128202. * Instantiates a new FollowCameraInputsManager.
  128203. * @param camera Defines the camera the inputs belong to
  128204. */
  128205. constructor(camera: FollowCamera);
  128206. /**
  128207. * Add keyboard input support to the input manager.
  128208. * @returns the current input manager
  128209. */
  128210. addKeyboard(): FollowCameraInputsManager;
  128211. /**
  128212. * Add mouse wheel input support to the input manager.
  128213. * @returns the current input manager
  128214. */
  128215. addMouseWheel(): FollowCameraInputsManager;
  128216. /**
  128217. * Add pointers input support to the input manager.
  128218. * @returns the current input manager
  128219. */
  128220. addPointers(): FollowCameraInputsManager;
  128221. /**
  128222. * Add orientation input support to the input manager.
  128223. * @returns the current input manager
  128224. */
  128225. addVRDeviceOrientation(): FollowCameraInputsManager;
  128226. }
  128227. }
  128228. declare module BABYLON {
  128229. /**
  128230. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128231. * an arc rotate version arcFollowCamera are available.
  128232. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128233. */
  128234. export class FollowCamera extends TargetCamera {
  128235. /**
  128236. * Distance the follow camera should follow an object at
  128237. */
  128238. radius: number;
  128239. /**
  128240. * Minimum allowed distance of the camera to the axis of rotation
  128241. * (The camera can not get closer).
  128242. * This can help limiting how the Camera is able to move in the scene.
  128243. */
  128244. lowerRadiusLimit: Nullable<number>;
  128245. /**
  128246. * Maximum allowed distance of the camera to the axis of rotation
  128247. * (The camera can not get further).
  128248. * This can help limiting how the Camera is able to move in the scene.
  128249. */
  128250. upperRadiusLimit: Nullable<number>;
  128251. /**
  128252. * Define a rotation offset between the camera and the object it follows
  128253. */
  128254. rotationOffset: number;
  128255. /**
  128256. * Minimum allowed angle to camera position relative to target object.
  128257. * This can help limiting how the Camera is able to move in the scene.
  128258. */
  128259. lowerRotationOffsetLimit: Nullable<number>;
  128260. /**
  128261. * Maximum allowed angle to camera position relative to target object.
  128262. * This can help limiting how the Camera is able to move in the scene.
  128263. */
  128264. upperRotationOffsetLimit: Nullable<number>;
  128265. /**
  128266. * Define a height offset between the camera and the object it follows.
  128267. * It can help following an object from the top (like a car chaing a plane)
  128268. */
  128269. heightOffset: number;
  128270. /**
  128271. * Minimum allowed height of camera position relative to target object.
  128272. * This can help limiting how the Camera is able to move in the scene.
  128273. */
  128274. lowerHeightOffsetLimit: Nullable<number>;
  128275. /**
  128276. * Maximum allowed height of camera position relative to target object.
  128277. * This can help limiting how the Camera is able to move in the scene.
  128278. */
  128279. upperHeightOffsetLimit: Nullable<number>;
  128280. /**
  128281. * Define how fast the camera can accelerate to follow it s target.
  128282. */
  128283. cameraAcceleration: number;
  128284. /**
  128285. * Define the speed limit of the camera following an object.
  128286. */
  128287. maxCameraSpeed: number;
  128288. /**
  128289. * Define the target of the camera.
  128290. */
  128291. lockedTarget: Nullable<AbstractMesh>;
  128292. /**
  128293. * Defines the input associated with the camera.
  128294. */
  128295. inputs: FollowCameraInputsManager;
  128296. /**
  128297. * Instantiates the follow camera.
  128298. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128299. * @param name Define the name of the camera in the scene
  128300. * @param position Define the position of the camera
  128301. * @param scene Define the scene the camera belong to
  128302. * @param lockedTarget Define the target of the camera
  128303. */
  128304. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128305. private _follow;
  128306. /**
  128307. * Attached controls to the current camera.
  128308. * @param element Defines the element the controls should be listened from
  128309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128310. */
  128311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128312. /**
  128313. * Detach the current controls from the camera.
  128314. * The camera will stop reacting to inputs.
  128315. * @param element Defines the element to stop listening the inputs from
  128316. */
  128317. detachControl(element: HTMLElement): void;
  128318. /** @hidden */
  128319. _checkInputs(): void;
  128320. private _checkLimits;
  128321. /**
  128322. * Gets the camera class name.
  128323. * @returns the class name
  128324. */
  128325. getClassName(): string;
  128326. }
  128327. /**
  128328. * Arc Rotate version of the follow camera.
  128329. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128330. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128331. */
  128332. export class ArcFollowCamera extends TargetCamera {
  128333. /** The longitudinal angle of the camera */
  128334. alpha: number;
  128335. /** The latitudinal angle of the camera */
  128336. beta: number;
  128337. /** The radius of the camera from its target */
  128338. radius: number;
  128339. private _cartesianCoordinates;
  128340. /** Define the camera target (the mesh it should follow) */
  128341. private _meshTarget;
  128342. /**
  128343. * Instantiates a new ArcFollowCamera
  128344. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128345. * @param name Define the name of the camera
  128346. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128347. * @param beta Define the rotation angle of the camera around the elevation axis
  128348. * @param radius Define the radius of the camera from its target point
  128349. * @param target Define the target of the camera
  128350. * @param scene Define the scene the camera belongs to
  128351. */
  128352. constructor(name: string,
  128353. /** The longitudinal angle of the camera */
  128354. alpha: number,
  128355. /** The latitudinal angle of the camera */
  128356. beta: number,
  128357. /** The radius of the camera from its target */
  128358. radius: number,
  128359. /** Define the camera target (the mesh it should follow) */
  128360. target: Nullable<AbstractMesh>, scene: Scene);
  128361. private _follow;
  128362. /** @hidden */
  128363. _checkInputs(): void;
  128364. /**
  128365. * Returns the class name of the object.
  128366. * It is mostly used internally for serialization purposes.
  128367. */
  128368. getClassName(): string;
  128369. }
  128370. }
  128371. declare module BABYLON {
  128372. /**
  128373. * Manage the keyboard inputs to control the movement of a follow camera.
  128374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128375. */
  128376. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128377. /**
  128378. * Defines the camera the input is attached to.
  128379. */
  128380. camera: FollowCamera;
  128381. /**
  128382. * Defines the list of key codes associated with the up action (increase heightOffset)
  128383. */
  128384. keysHeightOffsetIncr: number[];
  128385. /**
  128386. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128387. */
  128388. keysHeightOffsetDecr: number[];
  128389. /**
  128390. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128391. */
  128392. keysHeightOffsetModifierAlt: boolean;
  128393. /**
  128394. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128395. */
  128396. keysHeightOffsetModifierCtrl: boolean;
  128397. /**
  128398. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128399. */
  128400. keysHeightOffsetModifierShift: boolean;
  128401. /**
  128402. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128403. */
  128404. keysRotationOffsetIncr: number[];
  128405. /**
  128406. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128407. */
  128408. keysRotationOffsetDecr: number[];
  128409. /**
  128410. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128411. */
  128412. keysRotationOffsetModifierAlt: boolean;
  128413. /**
  128414. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128415. */
  128416. keysRotationOffsetModifierCtrl: boolean;
  128417. /**
  128418. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128419. */
  128420. keysRotationOffsetModifierShift: boolean;
  128421. /**
  128422. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128423. */
  128424. keysRadiusIncr: number[];
  128425. /**
  128426. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128427. */
  128428. keysRadiusDecr: number[];
  128429. /**
  128430. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128431. */
  128432. keysRadiusModifierAlt: boolean;
  128433. /**
  128434. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128435. */
  128436. keysRadiusModifierCtrl: boolean;
  128437. /**
  128438. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128439. */
  128440. keysRadiusModifierShift: boolean;
  128441. /**
  128442. * Defines the rate of change of heightOffset.
  128443. */
  128444. heightSensibility: number;
  128445. /**
  128446. * Defines the rate of change of rotationOffset.
  128447. */
  128448. rotationSensibility: number;
  128449. /**
  128450. * Defines the rate of change of radius.
  128451. */
  128452. radiusSensibility: number;
  128453. private _keys;
  128454. private _ctrlPressed;
  128455. private _altPressed;
  128456. private _shiftPressed;
  128457. private _onCanvasBlurObserver;
  128458. private _onKeyboardObserver;
  128459. private _engine;
  128460. private _scene;
  128461. /**
  128462. * Attach the input controls to a specific dom element to get the input from.
  128463. * @param element Defines the element the controls should be listened from
  128464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128465. */
  128466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128467. /**
  128468. * Detach the current controls from the specified dom element.
  128469. * @param element Defines the element to stop listening the inputs from
  128470. */
  128471. detachControl(element: Nullable<HTMLElement>): void;
  128472. /**
  128473. * Update the current camera state depending on the inputs that have been used this frame.
  128474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128475. */
  128476. checkInputs(): void;
  128477. /**
  128478. * Gets the class name of the current input.
  128479. * @returns the class name
  128480. */
  128481. getClassName(): string;
  128482. /**
  128483. * Get the friendly name associated with the input class.
  128484. * @returns the input friendly name
  128485. */
  128486. getSimpleName(): string;
  128487. /**
  128488. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128489. * allow modification of the heightOffset value.
  128490. */
  128491. private _modifierHeightOffset;
  128492. /**
  128493. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128494. * allow modification of the rotationOffset value.
  128495. */
  128496. private _modifierRotationOffset;
  128497. /**
  128498. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128499. * allow modification of the radius value.
  128500. */
  128501. private _modifierRadius;
  128502. }
  128503. }
  128504. declare module BABYLON {
  128505. interface FreeCameraInputsManager {
  128506. /**
  128507. * @hidden
  128508. */
  128509. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128510. /**
  128511. * Add orientation input support to the input manager.
  128512. * @returns the current input manager
  128513. */
  128514. addDeviceOrientation(): FreeCameraInputsManager;
  128515. }
  128516. /**
  128517. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128518. * Screen rotation is taken into account.
  128519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128520. */
  128521. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128522. private _camera;
  128523. private _screenOrientationAngle;
  128524. private _constantTranform;
  128525. private _screenQuaternion;
  128526. private _alpha;
  128527. private _beta;
  128528. private _gamma;
  128529. /**
  128530. * Can be used to detect if a device orientation sensor is available on a device
  128531. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128532. * @returns a promise that will resolve on orientation change
  128533. */
  128534. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128535. /**
  128536. * @hidden
  128537. */
  128538. _onDeviceOrientationChangedObservable: Observable<void>;
  128539. /**
  128540. * Instantiates a new input
  128541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128542. */
  128543. constructor();
  128544. /**
  128545. * Define the camera controlled by the input.
  128546. */
  128547. get camera(): FreeCamera;
  128548. set camera(camera: FreeCamera);
  128549. /**
  128550. * Attach the input controls to a specific dom element to get the input from.
  128551. * @param element Defines the element the controls should be listened from
  128552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128553. */
  128554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128555. private _orientationChanged;
  128556. private _deviceOrientation;
  128557. /**
  128558. * Detach the current controls from the specified dom element.
  128559. * @param element Defines the element to stop listening the inputs from
  128560. */
  128561. detachControl(element: Nullable<HTMLElement>): void;
  128562. /**
  128563. * Update the current camera state depending on the inputs that have been used this frame.
  128564. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128565. */
  128566. checkInputs(): void;
  128567. /**
  128568. * Gets the class name of the current intput.
  128569. * @returns the class name
  128570. */
  128571. getClassName(): string;
  128572. /**
  128573. * Get the friendly name associated with the input class.
  128574. * @returns the input friendly name
  128575. */
  128576. getSimpleName(): string;
  128577. }
  128578. }
  128579. declare module BABYLON {
  128580. /**
  128581. * Manage the gamepad inputs to control a free camera.
  128582. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128583. */
  128584. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128585. /**
  128586. * Define the camera the input is attached to.
  128587. */
  128588. camera: FreeCamera;
  128589. /**
  128590. * Define the Gamepad controlling the input
  128591. */
  128592. gamepad: Nullable<Gamepad>;
  128593. /**
  128594. * Defines the gamepad rotation sensiblity.
  128595. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128596. */
  128597. gamepadAngularSensibility: number;
  128598. /**
  128599. * Defines the gamepad move sensiblity.
  128600. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128601. */
  128602. gamepadMoveSensibility: number;
  128603. private _yAxisScale;
  128604. /**
  128605. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128606. */
  128607. get invertYAxis(): boolean;
  128608. set invertYAxis(value: boolean);
  128609. private _onGamepadConnectedObserver;
  128610. private _onGamepadDisconnectedObserver;
  128611. private _cameraTransform;
  128612. private _deltaTransform;
  128613. private _vector3;
  128614. private _vector2;
  128615. /**
  128616. * Attach the input controls to a specific dom element to get the input from.
  128617. * @param element Defines the element the controls should be listened from
  128618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128619. */
  128620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128621. /**
  128622. * Detach the current controls from the specified dom element.
  128623. * @param element Defines the element to stop listening the inputs from
  128624. */
  128625. detachControl(element: Nullable<HTMLElement>): void;
  128626. /**
  128627. * Update the current camera state depending on the inputs that have been used this frame.
  128628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128629. */
  128630. checkInputs(): void;
  128631. /**
  128632. * Gets the class name of the current intput.
  128633. * @returns the class name
  128634. */
  128635. getClassName(): string;
  128636. /**
  128637. * Get the friendly name associated with the input class.
  128638. * @returns the input friendly name
  128639. */
  128640. getSimpleName(): string;
  128641. }
  128642. }
  128643. declare module BABYLON {
  128644. /**
  128645. * Defines the potential axis of a Joystick
  128646. */
  128647. export enum JoystickAxis {
  128648. /** X axis */
  128649. X = 0,
  128650. /** Y axis */
  128651. Y = 1,
  128652. /** Z axis */
  128653. Z = 2
  128654. }
  128655. /**
  128656. * Represents the different customization options available
  128657. * for VirtualJoystick
  128658. */
  128659. interface VirtualJoystickCustomizations {
  128660. /**
  128661. * Size of the joystick's puck
  128662. */
  128663. puckSize: number;
  128664. /**
  128665. * Size of the joystick's container
  128666. */
  128667. containerSize: number;
  128668. /**
  128669. * Color of the joystick && puck
  128670. */
  128671. color: string;
  128672. /**
  128673. * Image URL for the joystick's puck
  128674. */
  128675. puckImage?: string;
  128676. /**
  128677. * Image URL for the joystick's container
  128678. */
  128679. containerImage?: string;
  128680. /**
  128681. * Defines the unmoving position of the joystick container
  128682. */
  128683. position?: {
  128684. x: number;
  128685. y: number;
  128686. };
  128687. /**
  128688. * Defines whether or not the joystick container is always visible
  128689. */
  128690. alwaysVisible: boolean;
  128691. /**
  128692. * Defines whether or not to limit the movement of the puck to the joystick's container
  128693. */
  128694. limitToContainer: boolean;
  128695. }
  128696. /**
  128697. * Class used to define virtual joystick (used in touch mode)
  128698. */
  128699. export class VirtualJoystick {
  128700. /**
  128701. * Gets or sets a boolean indicating that left and right values must be inverted
  128702. */
  128703. reverseLeftRight: boolean;
  128704. /**
  128705. * Gets or sets a boolean indicating that up and down values must be inverted
  128706. */
  128707. reverseUpDown: boolean;
  128708. /**
  128709. * Gets the offset value for the position (ie. the change of the position value)
  128710. */
  128711. deltaPosition: Vector3;
  128712. /**
  128713. * Gets a boolean indicating if the virtual joystick was pressed
  128714. */
  128715. pressed: boolean;
  128716. /**
  128717. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128718. */
  128719. static Canvas: Nullable<HTMLCanvasElement>;
  128720. /**
  128721. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128722. */
  128723. limitToContainer: boolean;
  128724. private static _globalJoystickIndex;
  128725. private static _alwaysVisibleSticks;
  128726. private static vjCanvasContext;
  128727. private static vjCanvasWidth;
  128728. private static vjCanvasHeight;
  128729. private static halfWidth;
  128730. private static _GetDefaultOptions;
  128731. private _action;
  128732. private _axisTargetedByLeftAndRight;
  128733. private _axisTargetedByUpAndDown;
  128734. private _joystickSensibility;
  128735. private _inversedSensibility;
  128736. private _joystickPointerID;
  128737. private _joystickColor;
  128738. private _joystickPointerPos;
  128739. private _joystickPreviousPointerPos;
  128740. private _joystickPointerStartPos;
  128741. private _deltaJoystickVector;
  128742. private _leftJoystick;
  128743. private _touches;
  128744. private _joystickPosition;
  128745. private _alwaysVisible;
  128746. private _puckImage;
  128747. private _containerImage;
  128748. private _joystickPuckSize;
  128749. private _joystickContainerSize;
  128750. private _clearPuckSize;
  128751. private _clearContainerSize;
  128752. private _clearPuckSizeOffset;
  128753. private _clearContainerSizeOffset;
  128754. private _onPointerDownHandlerRef;
  128755. private _onPointerMoveHandlerRef;
  128756. private _onPointerUpHandlerRef;
  128757. private _onResize;
  128758. /**
  128759. * Creates a new virtual joystick
  128760. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128761. * @param customizations Defines the options we want to customize the VirtualJoystick
  128762. */
  128763. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128764. /**
  128765. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128766. * @param newJoystickSensibility defines the new sensibility
  128767. */
  128768. setJoystickSensibility(newJoystickSensibility: number): void;
  128769. private _onPointerDown;
  128770. private _onPointerMove;
  128771. private _onPointerUp;
  128772. /**
  128773. * Change the color of the virtual joystick
  128774. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128775. */
  128776. setJoystickColor(newColor: string): void;
  128777. /**
  128778. * Size of the joystick's container
  128779. */
  128780. set containerSize(newSize: number);
  128781. get containerSize(): number;
  128782. /**
  128783. * Size of the joystick's puck
  128784. */
  128785. set puckSize(newSize: number);
  128786. get puckSize(): number;
  128787. /**
  128788. * Clears the set position of the joystick
  128789. */
  128790. clearPosition(): void;
  128791. /**
  128792. * Defines whether or not the joystick container is always visible
  128793. */
  128794. set alwaysVisible(value: boolean);
  128795. get alwaysVisible(): boolean;
  128796. /**
  128797. * Sets the constant position of the Joystick container
  128798. * @param x X axis coordinate
  128799. * @param y Y axis coordinate
  128800. */
  128801. setPosition(x: number, y: number): void;
  128802. /**
  128803. * Defines a callback to call when the joystick is touched
  128804. * @param action defines the callback
  128805. */
  128806. setActionOnTouch(action: () => any): void;
  128807. /**
  128808. * Defines which axis you'd like to control for left & right
  128809. * @param axis defines the axis to use
  128810. */
  128811. setAxisForLeftRight(axis: JoystickAxis): void;
  128812. /**
  128813. * Defines which axis you'd like to control for up & down
  128814. * @param axis defines the axis to use
  128815. */
  128816. setAxisForUpDown(axis: JoystickAxis): void;
  128817. /**
  128818. * Clears the canvas from the previous puck / container draw
  128819. */
  128820. private _clearPreviousDraw;
  128821. /**
  128822. * Loads `urlPath` to be used for the container's image
  128823. * @param urlPath defines the urlPath of an image to use
  128824. */
  128825. setContainerImage(urlPath: string): void;
  128826. /**
  128827. * Loads `urlPath` to be used for the puck's image
  128828. * @param urlPath defines the urlPath of an image to use
  128829. */
  128830. setPuckImage(urlPath: string): void;
  128831. /**
  128832. * Draws the Virtual Joystick's container
  128833. */
  128834. private _drawContainer;
  128835. /**
  128836. * Draws the Virtual Joystick's puck
  128837. */
  128838. private _drawPuck;
  128839. private _drawVirtualJoystick;
  128840. /**
  128841. * Release internal HTML canvas
  128842. */
  128843. releaseCanvas(): void;
  128844. }
  128845. }
  128846. declare module BABYLON {
  128847. interface FreeCameraInputsManager {
  128848. /**
  128849. * Add virtual joystick input support to the input manager.
  128850. * @returns the current input manager
  128851. */
  128852. addVirtualJoystick(): FreeCameraInputsManager;
  128853. }
  128854. /**
  128855. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  128856. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128857. */
  128858. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  128859. /**
  128860. * Defines the camera the input is attached to.
  128861. */
  128862. camera: FreeCamera;
  128863. private _leftjoystick;
  128864. private _rightjoystick;
  128865. /**
  128866. * Gets the left stick of the virtual joystick.
  128867. * @returns The virtual Joystick
  128868. */
  128869. getLeftJoystick(): VirtualJoystick;
  128870. /**
  128871. * Gets the right stick of the virtual joystick.
  128872. * @returns The virtual Joystick
  128873. */
  128874. getRightJoystick(): VirtualJoystick;
  128875. /**
  128876. * Update the current camera state depending on the inputs that have been used this frame.
  128877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128878. */
  128879. checkInputs(): void;
  128880. /**
  128881. * Attach the input controls to a specific dom element to get the input from.
  128882. * @param element Defines the element the controls should be listened from
  128883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128884. */
  128885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128886. /**
  128887. * Detach the current controls from the specified dom element.
  128888. * @param element Defines the element to stop listening the inputs from
  128889. */
  128890. detachControl(element: Nullable<HTMLElement>): void;
  128891. /**
  128892. * Gets the class name of the current intput.
  128893. * @returns the class name
  128894. */
  128895. getClassName(): string;
  128896. /**
  128897. * Get the friendly name associated with the input class.
  128898. * @returns the input friendly name
  128899. */
  128900. getSimpleName(): string;
  128901. }
  128902. }
  128903. declare module BABYLON {
  128904. /**
  128905. * This represents a FPS type of camera controlled by touch.
  128906. * This is like a universal camera minus the Gamepad controls.
  128907. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128908. */
  128909. export class TouchCamera extends FreeCamera {
  128910. /**
  128911. * Defines the touch sensibility for rotation.
  128912. * The higher the faster.
  128913. */
  128914. get touchAngularSensibility(): number;
  128915. set touchAngularSensibility(value: number);
  128916. /**
  128917. * Defines the touch sensibility for move.
  128918. * The higher the faster.
  128919. */
  128920. get touchMoveSensibility(): number;
  128921. set touchMoveSensibility(value: number);
  128922. /**
  128923. * Instantiates a new touch camera.
  128924. * This represents a FPS type of camera controlled by touch.
  128925. * This is like a universal camera minus the Gamepad controls.
  128926. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  128927. * @param name Define the name of the camera in the scene
  128928. * @param position Define the start position of the camera in the scene
  128929. * @param scene Define the scene the camera belongs to
  128930. */
  128931. constructor(name: string, position: Vector3, scene: Scene);
  128932. /**
  128933. * Gets the current object class name.
  128934. * @return the class name
  128935. */
  128936. getClassName(): string;
  128937. /** @hidden */
  128938. _setupInputs(): void;
  128939. }
  128940. }
  128941. declare module BABYLON {
  128942. /**
  128943. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  128944. * being tilted forward or back and left or right.
  128945. */
  128946. export class DeviceOrientationCamera extends FreeCamera {
  128947. private _initialQuaternion;
  128948. private _quaternionCache;
  128949. private _tmpDragQuaternion;
  128950. private _disablePointerInputWhenUsingDeviceOrientation;
  128951. /**
  128952. * Creates a new device orientation camera
  128953. * @param name The name of the camera
  128954. * @param position The start position camera
  128955. * @param scene The scene the camera belongs to
  128956. */
  128957. constructor(name: string, position: Vector3, scene: Scene);
  128958. /**
  128959. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  128960. */
  128961. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  128962. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  128963. private _dragFactor;
  128964. /**
  128965. * Enabled turning on the y axis when the orientation sensor is active
  128966. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  128967. */
  128968. enableHorizontalDragging(dragFactor?: number): void;
  128969. /**
  128970. * Gets the current instance class name ("DeviceOrientationCamera").
  128971. * This helps avoiding instanceof at run time.
  128972. * @returns the class name
  128973. */
  128974. getClassName(): string;
  128975. /**
  128976. * @hidden
  128977. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  128978. */
  128979. _checkInputs(): void;
  128980. /**
  128981. * Reset the camera to its default orientation on the specified axis only.
  128982. * @param axis The axis to reset
  128983. */
  128984. resetToCurrentRotation(axis?: Axis): void;
  128985. }
  128986. }
  128987. declare module BABYLON {
  128988. /**
  128989. * Defines supported buttons for XBox360 compatible gamepads
  128990. */
  128991. export enum Xbox360Button {
  128992. /** A */
  128993. A = 0,
  128994. /** B */
  128995. B = 1,
  128996. /** X */
  128997. X = 2,
  128998. /** Y */
  128999. Y = 3,
  129000. /** Left button */
  129001. LB = 4,
  129002. /** Right button */
  129003. RB = 5,
  129004. /** Back */
  129005. Back = 8,
  129006. /** Start */
  129007. Start = 9,
  129008. /** Left stick */
  129009. LeftStick = 10,
  129010. /** Right stick */
  129011. RightStick = 11
  129012. }
  129013. /** Defines values for XBox360 DPad */
  129014. export enum Xbox360Dpad {
  129015. /** Up */
  129016. Up = 12,
  129017. /** Down */
  129018. Down = 13,
  129019. /** Left */
  129020. Left = 14,
  129021. /** Right */
  129022. Right = 15
  129023. }
  129024. /**
  129025. * Defines a XBox360 gamepad
  129026. */
  129027. export class Xbox360Pad extends Gamepad {
  129028. private _leftTrigger;
  129029. private _rightTrigger;
  129030. private _onlefttriggerchanged;
  129031. private _onrighttriggerchanged;
  129032. private _onbuttondown;
  129033. private _onbuttonup;
  129034. private _ondpaddown;
  129035. private _ondpadup;
  129036. /** Observable raised when a button is pressed */
  129037. onButtonDownObservable: Observable<Xbox360Button>;
  129038. /** Observable raised when a button is released */
  129039. onButtonUpObservable: Observable<Xbox360Button>;
  129040. /** Observable raised when a pad is pressed */
  129041. onPadDownObservable: Observable<Xbox360Dpad>;
  129042. /** Observable raised when a pad is released */
  129043. onPadUpObservable: Observable<Xbox360Dpad>;
  129044. private _buttonA;
  129045. private _buttonB;
  129046. private _buttonX;
  129047. private _buttonY;
  129048. private _buttonBack;
  129049. private _buttonStart;
  129050. private _buttonLB;
  129051. private _buttonRB;
  129052. private _buttonLeftStick;
  129053. private _buttonRightStick;
  129054. private _dPadUp;
  129055. private _dPadDown;
  129056. private _dPadLeft;
  129057. private _dPadRight;
  129058. private _isXboxOnePad;
  129059. /**
  129060. * Creates a new XBox360 gamepad object
  129061. * @param id defines the id of this gamepad
  129062. * @param index defines its index
  129063. * @param gamepad defines the internal HTML gamepad object
  129064. * @param xboxOne defines if it is a XBox One gamepad
  129065. */
  129066. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129067. /**
  129068. * Defines the callback to call when left trigger is pressed
  129069. * @param callback defines the callback to use
  129070. */
  129071. onlefttriggerchanged(callback: (value: number) => void): void;
  129072. /**
  129073. * Defines the callback to call when right trigger is pressed
  129074. * @param callback defines the callback to use
  129075. */
  129076. onrighttriggerchanged(callback: (value: number) => void): void;
  129077. /**
  129078. * Gets the left trigger value
  129079. */
  129080. get leftTrigger(): number;
  129081. /**
  129082. * Sets the left trigger value
  129083. */
  129084. set leftTrigger(newValue: number);
  129085. /**
  129086. * Gets the right trigger value
  129087. */
  129088. get rightTrigger(): number;
  129089. /**
  129090. * Sets the right trigger value
  129091. */
  129092. set rightTrigger(newValue: number);
  129093. /**
  129094. * Defines the callback to call when a button is pressed
  129095. * @param callback defines the callback to use
  129096. */
  129097. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129098. /**
  129099. * Defines the callback to call when a button is released
  129100. * @param callback defines the callback to use
  129101. */
  129102. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129103. /**
  129104. * Defines the callback to call when a pad is pressed
  129105. * @param callback defines the callback to use
  129106. */
  129107. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129108. /**
  129109. * Defines the callback to call when a pad is released
  129110. * @param callback defines the callback to use
  129111. */
  129112. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129113. private _setButtonValue;
  129114. private _setDPadValue;
  129115. /**
  129116. * Gets the value of the `A` button
  129117. */
  129118. get buttonA(): number;
  129119. /**
  129120. * Sets the value of the `A` button
  129121. */
  129122. set buttonA(value: number);
  129123. /**
  129124. * Gets the value of the `B` button
  129125. */
  129126. get buttonB(): number;
  129127. /**
  129128. * Sets the value of the `B` button
  129129. */
  129130. set buttonB(value: number);
  129131. /**
  129132. * Gets the value of the `X` button
  129133. */
  129134. get buttonX(): number;
  129135. /**
  129136. * Sets the value of the `X` button
  129137. */
  129138. set buttonX(value: number);
  129139. /**
  129140. * Gets the value of the `Y` button
  129141. */
  129142. get buttonY(): number;
  129143. /**
  129144. * Sets the value of the `Y` button
  129145. */
  129146. set buttonY(value: number);
  129147. /**
  129148. * Gets the value of the `Start` button
  129149. */
  129150. get buttonStart(): number;
  129151. /**
  129152. * Sets the value of the `Start` button
  129153. */
  129154. set buttonStart(value: number);
  129155. /**
  129156. * Gets the value of the `Back` button
  129157. */
  129158. get buttonBack(): number;
  129159. /**
  129160. * Sets the value of the `Back` button
  129161. */
  129162. set buttonBack(value: number);
  129163. /**
  129164. * Gets the value of the `Left` button
  129165. */
  129166. get buttonLB(): number;
  129167. /**
  129168. * Sets the value of the `Left` button
  129169. */
  129170. set buttonLB(value: number);
  129171. /**
  129172. * Gets the value of the `Right` button
  129173. */
  129174. get buttonRB(): number;
  129175. /**
  129176. * Sets the value of the `Right` button
  129177. */
  129178. set buttonRB(value: number);
  129179. /**
  129180. * Gets the value of the Left joystick
  129181. */
  129182. get buttonLeftStick(): number;
  129183. /**
  129184. * Sets the value of the Left joystick
  129185. */
  129186. set buttonLeftStick(value: number);
  129187. /**
  129188. * Gets the value of the Right joystick
  129189. */
  129190. get buttonRightStick(): number;
  129191. /**
  129192. * Sets the value of the Right joystick
  129193. */
  129194. set buttonRightStick(value: number);
  129195. /**
  129196. * Gets the value of D-pad up
  129197. */
  129198. get dPadUp(): number;
  129199. /**
  129200. * Sets the value of D-pad up
  129201. */
  129202. set dPadUp(value: number);
  129203. /**
  129204. * Gets the value of D-pad down
  129205. */
  129206. get dPadDown(): number;
  129207. /**
  129208. * Sets the value of D-pad down
  129209. */
  129210. set dPadDown(value: number);
  129211. /**
  129212. * Gets the value of D-pad left
  129213. */
  129214. get dPadLeft(): number;
  129215. /**
  129216. * Sets the value of D-pad left
  129217. */
  129218. set dPadLeft(value: number);
  129219. /**
  129220. * Gets the value of D-pad right
  129221. */
  129222. get dPadRight(): number;
  129223. /**
  129224. * Sets the value of D-pad right
  129225. */
  129226. set dPadRight(value: number);
  129227. /**
  129228. * Force the gamepad to synchronize with device values
  129229. */
  129230. update(): void;
  129231. /**
  129232. * Disposes the gamepad
  129233. */
  129234. dispose(): void;
  129235. }
  129236. }
  129237. declare module BABYLON {
  129238. /**
  129239. * Defines supported buttons for DualShock compatible gamepads
  129240. */
  129241. export enum DualShockButton {
  129242. /** Cross */
  129243. Cross = 0,
  129244. /** Circle */
  129245. Circle = 1,
  129246. /** Square */
  129247. Square = 2,
  129248. /** Triangle */
  129249. Triangle = 3,
  129250. /** L1 */
  129251. L1 = 4,
  129252. /** R1 */
  129253. R1 = 5,
  129254. /** Share */
  129255. Share = 8,
  129256. /** Options */
  129257. Options = 9,
  129258. /** Left stick */
  129259. LeftStick = 10,
  129260. /** Right stick */
  129261. RightStick = 11
  129262. }
  129263. /** Defines values for DualShock DPad */
  129264. export enum DualShockDpad {
  129265. /** Up */
  129266. Up = 12,
  129267. /** Down */
  129268. Down = 13,
  129269. /** Left */
  129270. Left = 14,
  129271. /** Right */
  129272. Right = 15
  129273. }
  129274. /**
  129275. * Defines a DualShock gamepad
  129276. */
  129277. export class DualShockPad extends Gamepad {
  129278. private _leftTrigger;
  129279. private _rightTrigger;
  129280. private _onlefttriggerchanged;
  129281. private _onrighttriggerchanged;
  129282. private _onbuttondown;
  129283. private _onbuttonup;
  129284. private _ondpaddown;
  129285. private _ondpadup;
  129286. /** Observable raised when a button is pressed */
  129287. onButtonDownObservable: Observable<DualShockButton>;
  129288. /** Observable raised when a button is released */
  129289. onButtonUpObservable: Observable<DualShockButton>;
  129290. /** Observable raised when a pad is pressed */
  129291. onPadDownObservable: Observable<DualShockDpad>;
  129292. /** Observable raised when a pad is released */
  129293. onPadUpObservable: Observable<DualShockDpad>;
  129294. private _buttonCross;
  129295. private _buttonCircle;
  129296. private _buttonSquare;
  129297. private _buttonTriangle;
  129298. private _buttonShare;
  129299. private _buttonOptions;
  129300. private _buttonL1;
  129301. private _buttonR1;
  129302. private _buttonLeftStick;
  129303. private _buttonRightStick;
  129304. private _dPadUp;
  129305. private _dPadDown;
  129306. private _dPadLeft;
  129307. private _dPadRight;
  129308. /**
  129309. * Creates a new DualShock gamepad object
  129310. * @param id defines the id of this gamepad
  129311. * @param index defines its index
  129312. * @param gamepad defines the internal HTML gamepad object
  129313. */
  129314. constructor(id: string, index: number, gamepad: any);
  129315. /**
  129316. * Defines the callback to call when left trigger is pressed
  129317. * @param callback defines the callback to use
  129318. */
  129319. onlefttriggerchanged(callback: (value: number) => void): void;
  129320. /**
  129321. * Defines the callback to call when right trigger is pressed
  129322. * @param callback defines the callback to use
  129323. */
  129324. onrighttriggerchanged(callback: (value: number) => void): void;
  129325. /**
  129326. * Gets the left trigger value
  129327. */
  129328. get leftTrigger(): number;
  129329. /**
  129330. * Sets the left trigger value
  129331. */
  129332. set leftTrigger(newValue: number);
  129333. /**
  129334. * Gets the right trigger value
  129335. */
  129336. get rightTrigger(): number;
  129337. /**
  129338. * Sets the right trigger value
  129339. */
  129340. set rightTrigger(newValue: number);
  129341. /**
  129342. * Defines the callback to call when a button is pressed
  129343. * @param callback defines the callback to use
  129344. */
  129345. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129346. /**
  129347. * Defines the callback to call when a button is released
  129348. * @param callback defines the callback to use
  129349. */
  129350. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129351. /**
  129352. * Defines the callback to call when a pad is pressed
  129353. * @param callback defines the callback to use
  129354. */
  129355. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129356. /**
  129357. * Defines the callback to call when a pad is released
  129358. * @param callback defines the callback to use
  129359. */
  129360. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129361. private _setButtonValue;
  129362. private _setDPadValue;
  129363. /**
  129364. * Gets the value of the `Cross` button
  129365. */
  129366. get buttonCross(): number;
  129367. /**
  129368. * Sets the value of the `Cross` button
  129369. */
  129370. set buttonCross(value: number);
  129371. /**
  129372. * Gets the value of the `Circle` button
  129373. */
  129374. get buttonCircle(): number;
  129375. /**
  129376. * Sets the value of the `Circle` button
  129377. */
  129378. set buttonCircle(value: number);
  129379. /**
  129380. * Gets the value of the `Square` button
  129381. */
  129382. get buttonSquare(): number;
  129383. /**
  129384. * Sets the value of the `Square` button
  129385. */
  129386. set buttonSquare(value: number);
  129387. /**
  129388. * Gets the value of the `Triangle` button
  129389. */
  129390. get buttonTriangle(): number;
  129391. /**
  129392. * Sets the value of the `Triangle` button
  129393. */
  129394. set buttonTriangle(value: number);
  129395. /**
  129396. * Gets the value of the `Options` button
  129397. */
  129398. get buttonOptions(): number;
  129399. /**
  129400. * Sets the value of the `Options` button
  129401. */
  129402. set buttonOptions(value: number);
  129403. /**
  129404. * Gets the value of the `Share` button
  129405. */
  129406. get buttonShare(): number;
  129407. /**
  129408. * Sets the value of the `Share` button
  129409. */
  129410. set buttonShare(value: number);
  129411. /**
  129412. * Gets the value of the `L1` button
  129413. */
  129414. get buttonL1(): number;
  129415. /**
  129416. * Sets the value of the `L1` button
  129417. */
  129418. set buttonL1(value: number);
  129419. /**
  129420. * Gets the value of the `R1` button
  129421. */
  129422. get buttonR1(): number;
  129423. /**
  129424. * Sets the value of the `R1` button
  129425. */
  129426. set buttonR1(value: number);
  129427. /**
  129428. * Gets the value of the Left joystick
  129429. */
  129430. get buttonLeftStick(): number;
  129431. /**
  129432. * Sets the value of the Left joystick
  129433. */
  129434. set buttonLeftStick(value: number);
  129435. /**
  129436. * Gets the value of the Right joystick
  129437. */
  129438. get buttonRightStick(): number;
  129439. /**
  129440. * Sets the value of the Right joystick
  129441. */
  129442. set buttonRightStick(value: number);
  129443. /**
  129444. * Gets the value of D-pad up
  129445. */
  129446. get dPadUp(): number;
  129447. /**
  129448. * Sets the value of D-pad up
  129449. */
  129450. set dPadUp(value: number);
  129451. /**
  129452. * Gets the value of D-pad down
  129453. */
  129454. get dPadDown(): number;
  129455. /**
  129456. * Sets the value of D-pad down
  129457. */
  129458. set dPadDown(value: number);
  129459. /**
  129460. * Gets the value of D-pad left
  129461. */
  129462. get dPadLeft(): number;
  129463. /**
  129464. * Sets the value of D-pad left
  129465. */
  129466. set dPadLeft(value: number);
  129467. /**
  129468. * Gets the value of D-pad right
  129469. */
  129470. get dPadRight(): number;
  129471. /**
  129472. * Sets the value of D-pad right
  129473. */
  129474. set dPadRight(value: number);
  129475. /**
  129476. * Force the gamepad to synchronize with device values
  129477. */
  129478. update(): void;
  129479. /**
  129480. * Disposes the gamepad
  129481. */
  129482. dispose(): void;
  129483. }
  129484. }
  129485. declare module BABYLON {
  129486. /**
  129487. * Manager for handling gamepads
  129488. */
  129489. export class GamepadManager {
  129490. private _scene?;
  129491. private _babylonGamepads;
  129492. private _oneGamepadConnected;
  129493. /** @hidden */
  129494. _isMonitoring: boolean;
  129495. private _gamepadEventSupported;
  129496. private _gamepadSupport?;
  129497. /**
  129498. * observable to be triggered when the gamepad controller has been connected
  129499. */
  129500. onGamepadConnectedObservable: Observable<Gamepad>;
  129501. /**
  129502. * observable to be triggered when the gamepad controller has been disconnected
  129503. */
  129504. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129505. private _onGamepadConnectedEvent;
  129506. private _onGamepadDisconnectedEvent;
  129507. /**
  129508. * Initializes the gamepad manager
  129509. * @param _scene BabylonJS scene
  129510. */
  129511. constructor(_scene?: Scene | undefined);
  129512. /**
  129513. * The gamepads in the game pad manager
  129514. */
  129515. get gamepads(): Gamepad[];
  129516. /**
  129517. * Get the gamepad controllers based on type
  129518. * @param type The type of gamepad controller
  129519. * @returns Nullable gamepad
  129520. */
  129521. getGamepadByType(type?: number): Nullable<Gamepad>;
  129522. /**
  129523. * Disposes the gamepad manager
  129524. */
  129525. dispose(): void;
  129526. private _addNewGamepad;
  129527. private _startMonitoringGamepads;
  129528. private _stopMonitoringGamepads;
  129529. /** @hidden */
  129530. _checkGamepadsStatus(): void;
  129531. private _updateGamepadObjects;
  129532. }
  129533. }
  129534. declare module BABYLON {
  129535. interface Scene {
  129536. /** @hidden */
  129537. _gamepadManager: Nullable<GamepadManager>;
  129538. /**
  129539. * Gets the gamepad manager associated with the scene
  129540. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129541. */
  129542. gamepadManager: GamepadManager;
  129543. }
  129544. /**
  129545. * Interface representing a free camera inputs manager
  129546. */
  129547. interface FreeCameraInputsManager {
  129548. /**
  129549. * Adds gamepad input support to the FreeCameraInputsManager.
  129550. * @returns the FreeCameraInputsManager
  129551. */
  129552. addGamepad(): FreeCameraInputsManager;
  129553. }
  129554. /**
  129555. * Interface representing an arc rotate camera inputs manager
  129556. */
  129557. interface ArcRotateCameraInputsManager {
  129558. /**
  129559. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129560. * @returns the camera inputs manager
  129561. */
  129562. addGamepad(): ArcRotateCameraInputsManager;
  129563. }
  129564. /**
  129565. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129566. */
  129567. export class GamepadSystemSceneComponent implements ISceneComponent {
  129568. /**
  129569. * The component name helpfull to identify the component in the list of scene components.
  129570. */
  129571. readonly name: string;
  129572. /**
  129573. * The scene the component belongs to.
  129574. */
  129575. scene: Scene;
  129576. /**
  129577. * Creates a new instance of the component for the given scene
  129578. * @param scene Defines the scene to register the component in
  129579. */
  129580. constructor(scene: Scene);
  129581. /**
  129582. * Registers the component in a given scene
  129583. */
  129584. register(): void;
  129585. /**
  129586. * Rebuilds the elements related to this component in case of
  129587. * context lost for instance.
  129588. */
  129589. rebuild(): void;
  129590. /**
  129591. * Disposes the component and the associated ressources
  129592. */
  129593. dispose(): void;
  129594. private _beforeCameraUpdate;
  129595. }
  129596. }
  129597. declare module BABYLON {
  129598. /**
  129599. * 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,
  129600. * which still works and will still be found in many Playgrounds.
  129601. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129602. */
  129603. export class UniversalCamera extends TouchCamera {
  129604. /**
  129605. * Defines the gamepad rotation sensiblity.
  129606. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129607. */
  129608. get gamepadAngularSensibility(): number;
  129609. set gamepadAngularSensibility(value: number);
  129610. /**
  129611. * Defines the gamepad move sensiblity.
  129612. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129613. */
  129614. get gamepadMoveSensibility(): number;
  129615. set gamepadMoveSensibility(value: number);
  129616. /**
  129617. * 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,
  129618. * which still works and will still be found in many Playgrounds.
  129619. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129620. * @param name Define the name of the camera in the scene
  129621. * @param position Define the start position of the camera in the scene
  129622. * @param scene Define the scene the camera belongs to
  129623. */
  129624. constructor(name: string, position: Vector3, scene: Scene);
  129625. /**
  129626. * Gets the current object class name.
  129627. * @return the class name
  129628. */
  129629. getClassName(): string;
  129630. }
  129631. }
  129632. declare module BABYLON {
  129633. /**
  129634. * This represents a FPS type of camera. This is only here for back compat purpose.
  129635. * Please use the UniversalCamera instead as both are identical.
  129636. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129637. */
  129638. export class GamepadCamera extends UniversalCamera {
  129639. /**
  129640. * Instantiates a new Gamepad Camera
  129641. * This represents a FPS type of camera. This is only here for back compat purpose.
  129642. * Please use the UniversalCamera instead as both are identical.
  129643. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129644. * @param name Define the name of the camera in the scene
  129645. * @param position Define the start position of the camera in the scene
  129646. * @param scene Define the scene the camera belongs to
  129647. */
  129648. constructor(name: string, position: Vector3, scene: Scene);
  129649. /**
  129650. * Gets the current object class name.
  129651. * @return the class name
  129652. */
  129653. getClassName(): string;
  129654. }
  129655. }
  129656. declare module BABYLON {
  129657. /** @hidden */
  129658. export var passPixelShader: {
  129659. name: string;
  129660. shader: string;
  129661. };
  129662. }
  129663. declare module BABYLON {
  129664. /** @hidden */
  129665. export var passCubePixelShader: {
  129666. name: string;
  129667. shader: string;
  129668. };
  129669. }
  129670. declare module BABYLON {
  129671. /**
  129672. * PassPostProcess which produces an output the same as it's input
  129673. */
  129674. export class PassPostProcess extends PostProcess {
  129675. /**
  129676. * Gets a string identifying the name of the class
  129677. * @returns "PassPostProcess" string
  129678. */
  129679. getClassName(): string;
  129680. /**
  129681. * Creates the PassPostProcess
  129682. * @param name The name of the effect.
  129683. * @param options The required width/height ratio to downsize to before computing the render pass.
  129684. * @param camera The camera to apply the render pass to.
  129685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129686. * @param engine The engine which the post process will be applied. (default: current engine)
  129687. * @param reusable If the post process can be reused on the same frame. (default: false)
  129688. * @param textureType The type of texture to be used when performing the post processing.
  129689. * @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)
  129690. */
  129691. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129692. /** @hidden */
  129693. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129694. }
  129695. /**
  129696. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129697. */
  129698. export class PassCubePostProcess extends PostProcess {
  129699. private _face;
  129700. /**
  129701. * Gets or sets the cube face to display.
  129702. * * 0 is +X
  129703. * * 1 is -X
  129704. * * 2 is +Y
  129705. * * 3 is -Y
  129706. * * 4 is +Z
  129707. * * 5 is -Z
  129708. */
  129709. get face(): number;
  129710. set face(value: number);
  129711. /**
  129712. * Gets a string identifying the name of the class
  129713. * @returns "PassCubePostProcess" string
  129714. */
  129715. getClassName(): string;
  129716. /**
  129717. * Creates the PassCubePostProcess
  129718. * @param name The name of the effect.
  129719. * @param options The required width/height ratio to downsize to before computing the render pass.
  129720. * @param camera The camera to apply the render pass to.
  129721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129722. * @param engine The engine which the post process will be applied. (default: current engine)
  129723. * @param reusable If the post process can be reused on the same frame. (default: false)
  129724. * @param textureType The type of texture to be used when performing the post processing.
  129725. * @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)
  129726. */
  129727. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129728. /** @hidden */
  129729. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129730. }
  129731. }
  129732. declare module BABYLON {
  129733. /** @hidden */
  129734. export var anaglyphPixelShader: {
  129735. name: string;
  129736. shader: string;
  129737. };
  129738. }
  129739. declare module BABYLON {
  129740. /**
  129741. * Postprocess used to generate anaglyphic rendering
  129742. */
  129743. export class AnaglyphPostProcess extends PostProcess {
  129744. private _passedProcess;
  129745. /**
  129746. * Gets a string identifying the name of the class
  129747. * @returns "AnaglyphPostProcess" string
  129748. */
  129749. getClassName(): string;
  129750. /**
  129751. * Creates a new AnaglyphPostProcess
  129752. * @param name defines postprocess name
  129753. * @param options defines creation options or target ratio scale
  129754. * @param rigCameras defines cameras using this postprocess
  129755. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129756. * @param engine defines hosting engine
  129757. * @param reusable defines if the postprocess will be reused multiple times per frame
  129758. */
  129759. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129760. }
  129761. }
  129762. declare module BABYLON {
  129763. /**
  129764. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129765. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129766. */
  129767. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129768. /**
  129769. * Creates a new AnaglyphArcRotateCamera
  129770. * @param name defines camera name
  129771. * @param alpha defines alpha angle (in radians)
  129772. * @param beta defines beta angle (in radians)
  129773. * @param radius defines radius
  129774. * @param target defines camera target
  129775. * @param interaxialDistance defines distance between each color axis
  129776. * @param scene defines the hosting scene
  129777. */
  129778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129779. /**
  129780. * Gets camera class name
  129781. * @returns AnaglyphArcRotateCamera
  129782. */
  129783. getClassName(): string;
  129784. }
  129785. }
  129786. declare module BABYLON {
  129787. /**
  129788. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129789. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129790. */
  129791. export class AnaglyphFreeCamera extends FreeCamera {
  129792. /**
  129793. * Creates a new AnaglyphFreeCamera
  129794. * @param name defines camera name
  129795. * @param position defines initial position
  129796. * @param interaxialDistance defines distance between each color axis
  129797. * @param scene defines the hosting scene
  129798. */
  129799. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129800. /**
  129801. * Gets camera class name
  129802. * @returns AnaglyphFreeCamera
  129803. */
  129804. getClassName(): string;
  129805. }
  129806. }
  129807. declare module BABYLON {
  129808. /**
  129809. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  129810. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129811. */
  129812. export class AnaglyphGamepadCamera extends GamepadCamera {
  129813. /**
  129814. * Creates a new AnaglyphGamepadCamera
  129815. * @param name defines camera name
  129816. * @param position defines initial position
  129817. * @param interaxialDistance defines distance between each color axis
  129818. * @param scene defines the hosting scene
  129819. */
  129820. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129821. /**
  129822. * Gets camera class name
  129823. * @returns AnaglyphGamepadCamera
  129824. */
  129825. getClassName(): string;
  129826. }
  129827. }
  129828. declare module BABYLON {
  129829. /**
  129830. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  129831. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129832. */
  129833. export class AnaglyphUniversalCamera extends UniversalCamera {
  129834. /**
  129835. * Creates a new AnaglyphUniversalCamera
  129836. * @param name defines camera name
  129837. * @param position defines initial position
  129838. * @param interaxialDistance defines distance between each color axis
  129839. * @param scene defines the hosting scene
  129840. */
  129841. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129842. /**
  129843. * Gets camera class name
  129844. * @returns AnaglyphUniversalCamera
  129845. */
  129846. getClassName(): string;
  129847. }
  129848. }
  129849. declare module BABYLON {
  129850. /**
  129851. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  129852. * @see https://doc.babylonjs.com/features/cameras
  129853. */
  129854. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  129855. /**
  129856. * Creates a new StereoscopicArcRotateCamera
  129857. * @param name defines camera name
  129858. * @param alpha defines alpha angle (in radians)
  129859. * @param beta defines beta angle (in radians)
  129860. * @param radius defines radius
  129861. * @param target defines camera target
  129862. * @param interaxialDistance defines distance between each color axis
  129863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129864. * @param scene defines the hosting scene
  129865. */
  129866. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129867. /**
  129868. * Gets camera class name
  129869. * @returns StereoscopicArcRotateCamera
  129870. */
  129871. getClassName(): string;
  129872. }
  129873. }
  129874. declare module BABYLON {
  129875. /**
  129876. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  129877. * @see https://doc.babylonjs.com/features/cameras
  129878. */
  129879. export class StereoscopicFreeCamera extends FreeCamera {
  129880. /**
  129881. * Creates a new StereoscopicFreeCamera
  129882. * @param name defines camera name
  129883. * @param position defines initial position
  129884. * @param interaxialDistance defines distance between each color axis
  129885. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129886. * @param scene defines the hosting scene
  129887. */
  129888. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129889. /**
  129890. * Gets camera class name
  129891. * @returns StereoscopicFreeCamera
  129892. */
  129893. getClassName(): string;
  129894. }
  129895. }
  129896. declare module BABYLON {
  129897. /**
  129898. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  129899. * @see https://doc.babylonjs.com/features/cameras
  129900. */
  129901. export class StereoscopicGamepadCamera extends GamepadCamera {
  129902. /**
  129903. * Creates a new StereoscopicGamepadCamera
  129904. * @param name defines camera name
  129905. * @param position defines initial position
  129906. * @param interaxialDistance defines distance between each color axis
  129907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129908. * @param scene defines the hosting scene
  129909. */
  129910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129911. /**
  129912. * Gets camera class name
  129913. * @returns StereoscopicGamepadCamera
  129914. */
  129915. getClassName(): string;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. /**
  129920. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  129921. * @see https://doc.babylonjs.com/features/cameras
  129922. */
  129923. export class StereoscopicUniversalCamera extends UniversalCamera {
  129924. /**
  129925. * Creates a new StereoscopicUniversalCamera
  129926. * @param name defines camera name
  129927. * @param position defines initial position
  129928. * @param interaxialDistance defines distance between each color axis
  129929. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129930. * @param scene defines the hosting scene
  129931. */
  129932. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129933. /**
  129934. * Gets camera class name
  129935. * @returns StereoscopicUniversalCamera
  129936. */
  129937. getClassName(): string;
  129938. }
  129939. }
  129940. declare module BABYLON {
  129941. /**
  129942. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  129943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129945. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129946. */
  129947. export class VirtualJoysticksCamera extends FreeCamera {
  129948. /**
  129949. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  129950. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  129951. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  129952. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  129953. * @param name Define the name of the camera in the scene
  129954. * @param position Define the start position of the camera in the scene
  129955. * @param scene Define the scene the camera belongs to
  129956. */
  129957. constructor(name: string, position: Vector3, scene: Scene);
  129958. /**
  129959. * Gets the current object class name.
  129960. * @return the class name
  129961. */
  129962. getClassName(): string;
  129963. }
  129964. }
  129965. declare module BABYLON {
  129966. /**
  129967. * This represents all the required metrics to create a VR camera.
  129968. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  129969. */
  129970. export class VRCameraMetrics {
  129971. /**
  129972. * Define the horizontal resolution off the screen.
  129973. */
  129974. hResolution: number;
  129975. /**
  129976. * Define the vertical resolution off the screen.
  129977. */
  129978. vResolution: number;
  129979. /**
  129980. * Define the horizontal screen size.
  129981. */
  129982. hScreenSize: number;
  129983. /**
  129984. * Define the vertical screen size.
  129985. */
  129986. vScreenSize: number;
  129987. /**
  129988. * Define the vertical screen center position.
  129989. */
  129990. vScreenCenter: number;
  129991. /**
  129992. * Define the distance of the eyes to the screen.
  129993. */
  129994. eyeToScreenDistance: number;
  129995. /**
  129996. * Define the distance between both lenses
  129997. */
  129998. lensSeparationDistance: number;
  129999. /**
  130000. * Define the distance between both viewer's eyes.
  130001. */
  130002. interpupillaryDistance: number;
  130003. /**
  130004. * Define the distortion factor of the VR postprocess.
  130005. * Please, touch with care.
  130006. */
  130007. distortionK: number[];
  130008. /**
  130009. * Define the chromatic aberration correction factors for the VR post process.
  130010. */
  130011. chromaAbCorrection: number[];
  130012. /**
  130013. * Define the scale factor of the post process.
  130014. * The smaller the better but the slower.
  130015. */
  130016. postProcessScaleFactor: number;
  130017. /**
  130018. * Define an offset for the lens center.
  130019. */
  130020. lensCenterOffset: number;
  130021. /**
  130022. * Define if the current vr camera should compensate the distortion of the lense or not.
  130023. */
  130024. compensateDistortion: boolean;
  130025. /**
  130026. * Defines if multiview should be enabled when rendering (Default: false)
  130027. */
  130028. multiviewEnabled: boolean;
  130029. /**
  130030. * Gets the rendering aspect ratio based on the provided resolutions.
  130031. */
  130032. get aspectRatio(): number;
  130033. /**
  130034. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130035. */
  130036. get aspectRatioFov(): number;
  130037. /**
  130038. * @hidden
  130039. */
  130040. get leftHMatrix(): Matrix;
  130041. /**
  130042. * @hidden
  130043. */
  130044. get rightHMatrix(): Matrix;
  130045. /**
  130046. * @hidden
  130047. */
  130048. get leftPreViewMatrix(): Matrix;
  130049. /**
  130050. * @hidden
  130051. */
  130052. get rightPreViewMatrix(): Matrix;
  130053. /**
  130054. * Get the default VRMetrics based on the most generic setup.
  130055. * @returns the default vr metrics
  130056. */
  130057. static GetDefault(): VRCameraMetrics;
  130058. }
  130059. }
  130060. declare module BABYLON {
  130061. /** @hidden */
  130062. export var vrDistortionCorrectionPixelShader: {
  130063. name: string;
  130064. shader: string;
  130065. };
  130066. }
  130067. declare module BABYLON {
  130068. /**
  130069. * VRDistortionCorrectionPostProcess used for mobile VR
  130070. */
  130071. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130072. private _isRightEye;
  130073. private _distortionFactors;
  130074. private _postProcessScaleFactor;
  130075. private _lensCenterOffset;
  130076. private _scaleIn;
  130077. private _scaleFactor;
  130078. private _lensCenter;
  130079. /**
  130080. * Gets a string identifying the name of the class
  130081. * @returns "VRDistortionCorrectionPostProcess" string
  130082. */
  130083. getClassName(): string;
  130084. /**
  130085. * Initializes the VRDistortionCorrectionPostProcess
  130086. * @param name The name of the effect.
  130087. * @param camera The camera to apply the render pass to.
  130088. * @param isRightEye If this is for the right eye distortion
  130089. * @param vrMetrics All the required metrics for the VR camera
  130090. */
  130091. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130092. }
  130093. }
  130094. declare module BABYLON {
  130095. /**
  130096. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130097. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130098. */
  130099. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130100. /**
  130101. * Creates a new VRDeviceOrientationArcRotateCamera
  130102. * @param name defines camera name
  130103. * @param alpha defines the camera rotation along the logitudinal axis
  130104. * @param beta defines the camera rotation along the latitudinal axis
  130105. * @param radius defines the camera distance from its target
  130106. * @param target defines the camera target
  130107. * @param scene defines the scene the camera belongs to
  130108. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130109. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130110. */
  130111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130112. /**
  130113. * Gets camera class name
  130114. * @returns VRDeviceOrientationArcRotateCamera
  130115. */
  130116. getClassName(): string;
  130117. }
  130118. }
  130119. declare module BABYLON {
  130120. /**
  130121. * Camera used to simulate VR rendering (based on FreeCamera)
  130122. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130123. */
  130124. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130125. /**
  130126. * Creates a new VRDeviceOrientationFreeCamera
  130127. * @param name defines camera name
  130128. * @param position defines the start position of the camera
  130129. * @param scene defines the scene the camera belongs to
  130130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130132. */
  130133. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130134. /**
  130135. * Gets camera class name
  130136. * @returns VRDeviceOrientationFreeCamera
  130137. */
  130138. getClassName(): string;
  130139. }
  130140. }
  130141. declare module BABYLON {
  130142. /**
  130143. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130144. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130145. */
  130146. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130147. /**
  130148. * Creates a new VRDeviceOrientationGamepadCamera
  130149. * @param name defines camera name
  130150. * @param position defines the start position of the camera
  130151. * @param scene defines the scene the camera belongs to
  130152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130154. */
  130155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130156. /**
  130157. * Gets camera class name
  130158. * @returns VRDeviceOrientationGamepadCamera
  130159. */
  130160. getClassName(): string;
  130161. }
  130162. }
  130163. declare module BABYLON {
  130164. /**
  130165. * A class extending Texture allowing drawing on a texture
  130166. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130167. */
  130168. export class DynamicTexture extends Texture {
  130169. private _generateMipMaps;
  130170. private _canvas;
  130171. private _context;
  130172. /**
  130173. * Creates a DynamicTexture
  130174. * @param name defines the name of the texture
  130175. * @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
  130176. * @param scene defines the scene where you want the texture
  130177. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130178. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130179. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130180. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130181. */
  130182. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130183. /**
  130184. * Get the current class name of the texture useful for serialization or dynamic coding.
  130185. * @returns "DynamicTexture"
  130186. */
  130187. getClassName(): string;
  130188. /**
  130189. * Gets the current state of canRescale
  130190. */
  130191. get canRescale(): boolean;
  130192. private _recreate;
  130193. /**
  130194. * Scales the texture
  130195. * @param ratio the scale factor to apply to both width and height
  130196. */
  130197. scale(ratio: number): void;
  130198. /**
  130199. * Resizes the texture
  130200. * @param width the new width
  130201. * @param height the new height
  130202. */
  130203. scaleTo(width: number, height: number): void;
  130204. /**
  130205. * Gets the context of the canvas used by the texture
  130206. * @returns the canvas context of the dynamic texture
  130207. */
  130208. getContext(): CanvasRenderingContext2D;
  130209. /**
  130210. * Clears the texture
  130211. */
  130212. clear(): void;
  130213. /**
  130214. * Updates the texture
  130215. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130216. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130217. */
  130218. update(invertY?: boolean, premulAlpha?: boolean): void;
  130219. /**
  130220. * Draws text onto the texture
  130221. * @param text defines the text to be drawn
  130222. * @param x defines the placement of the text from the left
  130223. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130224. * @param font defines the font to be used with font-style, font-size, font-name
  130225. * @param color defines the color used for the text
  130226. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130227. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130228. * @param update defines whether texture is immediately update (default is true)
  130229. */
  130230. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130231. /**
  130232. * Clones the texture
  130233. * @returns the clone of the texture.
  130234. */
  130235. clone(): DynamicTexture;
  130236. /**
  130237. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130238. * @returns a serialized dynamic texture object
  130239. */
  130240. serialize(): any;
  130241. private _IsCanvasElement;
  130242. /** @hidden */
  130243. _rebuild(): void;
  130244. }
  130245. }
  130246. declare module BABYLON {
  130247. /**
  130248. * Class containing static functions to help procedurally build meshes
  130249. */
  130250. export class GroundBuilder {
  130251. /**
  130252. * Creates a ground mesh
  130253. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130254. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130256. * @param name defines the name of the mesh
  130257. * @param options defines the options used to create the mesh
  130258. * @param scene defines the hosting scene
  130259. * @returns the ground mesh
  130260. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130261. */
  130262. static CreateGround(name: string, options: {
  130263. width?: number;
  130264. height?: number;
  130265. subdivisions?: number;
  130266. subdivisionsX?: number;
  130267. subdivisionsY?: number;
  130268. updatable?: boolean;
  130269. }, scene: any): Mesh;
  130270. /**
  130271. * Creates a tiled ground mesh
  130272. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130273. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130274. * * 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
  130275. * * 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
  130276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130277. * @param name defines the name of the mesh
  130278. * @param options defines the options used to create the mesh
  130279. * @param scene defines the hosting scene
  130280. * @returns the tiled ground mesh
  130281. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130282. */
  130283. static CreateTiledGround(name: string, options: {
  130284. xmin: number;
  130285. zmin: number;
  130286. xmax: number;
  130287. zmax: number;
  130288. subdivisions?: {
  130289. w: number;
  130290. h: number;
  130291. };
  130292. precision?: {
  130293. w: number;
  130294. h: number;
  130295. };
  130296. updatable?: boolean;
  130297. }, scene?: Nullable<Scene>): Mesh;
  130298. /**
  130299. * Creates a ground mesh from a height map
  130300. * * The parameter `url` sets the URL of the height map image resource.
  130301. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130302. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130303. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130304. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130305. * * 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.
  130306. * * 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).
  130307. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130309. * @param name defines the name of the mesh
  130310. * @param url defines the url to the height map
  130311. * @param options defines the options used to create the mesh
  130312. * @param scene defines the hosting scene
  130313. * @returns the ground mesh
  130314. * @see https://doc.babylonjs.com/babylon101/height_map
  130315. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130316. */
  130317. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130318. width?: number;
  130319. height?: number;
  130320. subdivisions?: number;
  130321. minHeight?: number;
  130322. maxHeight?: number;
  130323. colorFilter?: Color3;
  130324. alphaFilter?: number;
  130325. updatable?: boolean;
  130326. onReady?: (mesh: GroundMesh) => void;
  130327. }, scene?: Nullable<Scene>): GroundMesh;
  130328. }
  130329. }
  130330. declare module BABYLON {
  130331. /**
  130332. * Class containing static functions to help procedurally build meshes
  130333. */
  130334. export class TorusBuilder {
  130335. /**
  130336. * Creates a torus mesh
  130337. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130338. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130339. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130343. * @param name defines the name of the mesh
  130344. * @param options defines the options used to create the mesh
  130345. * @param scene defines the hosting scene
  130346. * @returns the torus mesh
  130347. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130348. */
  130349. static CreateTorus(name: string, options: {
  130350. diameter?: number;
  130351. thickness?: number;
  130352. tessellation?: number;
  130353. updatable?: boolean;
  130354. sideOrientation?: number;
  130355. frontUVs?: Vector4;
  130356. backUVs?: Vector4;
  130357. }, scene: any): Mesh;
  130358. }
  130359. }
  130360. declare module BABYLON {
  130361. /**
  130362. * Class containing static functions to help procedurally build meshes
  130363. */
  130364. export class CylinderBuilder {
  130365. /**
  130366. * Creates a cylinder or a cone mesh
  130367. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130368. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130369. * * 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.
  130370. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130371. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130372. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130373. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130374. * * 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).
  130375. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130376. * * 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).
  130377. * * 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
  130378. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130379. * * 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
  130380. * * 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.
  130381. * * If `enclose` is false, a ring surface is one element.
  130382. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130383. * * 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
  130384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130387. * @param name defines the name of the mesh
  130388. * @param options defines the options used to create the mesh
  130389. * @param scene defines the hosting scene
  130390. * @returns the cylinder mesh
  130391. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130392. */
  130393. static CreateCylinder(name: string, options: {
  130394. height?: number;
  130395. diameterTop?: number;
  130396. diameterBottom?: number;
  130397. diameter?: number;
  130398. tessellation?: number;
  130399. subdivisions?: number;
  130400. arc?: number;
  130401. faceColors?: Color4[];
  130402. faceUV?: Vector4[];
  130403. updatable?: boolean;
  130404. hasRings?: boolean;
  130405. enclose?: boolean;
  130406. cap?: number;
  130407. sideOrientation?: number;
  130408. frontUVs?: Vector4;
  130409. backUVs?: Vector4;
  130410. }, scene: any): Mesh;
  130411. }
  130412. }
  130413. declare module BABYLON {
  130414. /**
  130415. * States of the webXR experience
  130416. */
  130417. export enum WebXRState {
  130418. /**
  130419. * Transitioning to being in XR mode
  130420. */
  130421. ENTERING_XR = 0,
  130422. /**
  130423. * Transitioning to non XR mode
  130424. */
  130425. EXITING_XR = 1,
  130426. /**
  130427. * In XR mode and presenting
  130428. */
  130429. IN_XR = 2,
  130430. /**
  130431. * Not entered XR mode
  130432. */
  130433. NOT_IN_XR = 3
  130434. }
  130435. /**
  130436. * Abstraction of the XR render target
  130437. */
  130438. export interface WebXRRenderTarget extends IDisposable {
  130439. /**
  130440. * xrpresent context of the canvas which can be used to display/mirror xr content
  130441. */
  130442. canvasContext: WebGLRenderingContext;
  130443. /**
  130444. * xr layer for the canvas
  130445. */
  130446. xrLayer: Nullable<XRWebGLLayer>;
  130447. /**
  130448. * Initializes the xr layer for the session
  130449. * @param xrSession xr session
  130450. * @returns a promise that will resolve once the XR Layer has been created
  130451. */
  130452. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130453. }
  130454. }
  130455. declare module BABYLON {
  130456. /**
  130457. * COnfiguration object for WebXR output canvas
  130458. */
  130459. export class WebXRManagedOutputCanvasOptions {
  130460. /**
  130461. * An optional canvas in case you wish to create it yourself and provide it here.
  130462. * If not provided, a new canvas will be created
  130463. */
  130464. canvasElement?: HTMLCanvasElement;
  130465. /**
  130466. * Options for this XR Layer output
  130467. */
  130468. canvasOptions?: XRWebGLLayerOptions;
  130469. /**
  130470. * CSS styling for a newly created canvas (if not provided)
  130471. */
  130472. newCanvasCssStyle?: string;
  130473. /**
  130474. * Get the default values of the configuration object
  130475. * @param engine defines the engine to use (can be null)
  130476. * @returns default values of this configuration object
  130477. */
  130478. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130479. }
  130480. /**
  130481. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130482. */
  130483. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130484. private _options;
  130485. private _canvas;
  130486. private _engine;
  130487. private _originalCanvasSize;
  130488. /**
  130489. * Rendering context of the canvas which can be used to display/mirror xr content
  130490. */
  130491. canvasContext: WebGLRenderingContext;
  130492. /**
  130493. * xr layer for the canvas
  130494. */
  130495. xrLayer: Nullable<XRWebGLLayer>;
  130496. /**
  130497. * Obseervers registered here will be triggered when the xr layer was initialized
  130498. */
  130499. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130500. /**
  130501. * Initializes the canvas to be added/removed upon entering/exiting xr
  130502. * @param _xrSessionManager The XR Session manager
  130503. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130504. */
  130505. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130506. /**
  130507. * Disposes of the object
  130508. */
  130509. dispose(): void;
  130510. /**
  130511. * Initializes the xr layer for the session
  130512. * @param xrSession xr session
  130513. * @returns a promise that will resolve once the XR Layer has been created
  130514. */
  130515. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130516. private _addCanvas;
  130517. private _removeCanvas;
  130518. private _setCanvasSize;
  130519. private _setManagedOutputCanvas;
  130520. }
  130521. }
  130522. declare module BABYLON {
  130523. /**
  130524. * Manages an XRSession to work with Babylon's engine
  130525. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130526. */
  130527. export class WebXRSessionManager implements IDisposable {
  130528. /** The scene which the session should be created for */
  130529. scene: Scene;
  130530. private _referenceSpace;
  130531. private _rttProvider;
  130532. private _sessionEnded;
  130533. private _xrNavigator;
  130534. private baseLayer;
  130535. /**
  130536. * The base reference space from which the session started. good if you want to reset your
  130537. * reference space
  130538. */
  130539. baseReferenceSpace: XRReferenceSpace;
  130540. /**
  130541. * Current XR frame
  130542. */
  130543. currentFrame: Nullable<XRFrame>;
  130544. /** WebXR timestamp updated every frame */
  130545. currentTimestamp: number;
  130546. /**
  130547. * Used just in case of a failure to initialize an immersive session.
  130548. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130549. */
  130550. defaultHeightCompensation: number;
  130551. /**
  130552. * Fires every time a new xrFrame arrives which can be used to update the camera
  130553. */
  130554. onXRFrameObservable: Observable<XRFrame>;
  130555. /**
  130556. * Fires when the reference space changed
  130557. */
  130558. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130559. /**
  130560. * Fires when the xr session is ended either by the device or manually done
  130561. */
  130562. onXRSessionEnded: Observable<any>;
  130563. /**
  130564. * Fires when the xr session is ended either by the device or manually done
  130565. */
  130566. onXRSessionInit: Observable<XRSession>;
  130567. /**
  130568. * Underlying xr session
  130569. */
  130570. session: XRSession;
  130571. /**
  130572. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130573. * or get the offset the player is currently at.
  130574. */
  130575. viewerReferenceSpace: XRReferenceSpace;
  130576. /**
  130577. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130578. * @param scene The scene which the session should be created for
  130579. */
  130580. constructor(
  130581. /** The scene which the session should be created for */
  130582. scene: Scene);
  130583. /**
  130584. * The current reference space used in this session. This reference space can constantly change!
  130585. * It is mainly used to offset the camera's position.
  130586. */
  130587. get referenceSpace(): XRReferenceSpace;
  130588. /**
  130589. * Set a new reference space and triggers the observable
  130590. */
  130591. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130592. /**
  130593. * Disposes of the session manager
  130594. */
  130595. dispose(): void;
  130596. /**
  130597. * Stops the xrSession and restores the render loop
  130598. * @returns Promise which resolves after it exits XR
  130599. */
  130600. exitXRAsync(): Promise<void>;
  130601. /**
  130602. * Gets the correct render target texture to be rendered this frame for this eye
  130603. * @param eye the eye for which to get the render target
  130604. * @returns the render target for the specified eye
  130605. */
  130606. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130607. /**
  130608. * Creates a WebXRRenderTarget object for the XR session
  130609. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130610. * @param options optional options to provide when creating a new render target
  130611. * @returns a WebXR render target to which the session can render
  130612. */
  130613. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130614. /**
  130615. * Initializes the manager
  130616. * After initialization enterXR can be called to start an XR session
  130617. * @returns Promise which resolves after it is initialized
  130618. */
  130619. initializeAsync(): Promise<void>;
  130620. /**
  130621. * Initializes an xr session
  130622. * @param xrSessionMode mode to initialize
  130623. * @param xrSessionInit defines optional and required values to pass to the session builder
  130624. * @returns a promise which will resolve once the session has been initialized
  130625. */
  130626. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130627. /**
  130628. * Checks if a session would be supported for the creation options specified
  130629. * @param sessionMode session mode to check if supported eg. immersive-vr
  130630. * @returns A Promise that resolves to true if supported and false if not
  130631. */
  130632. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130633. /**
  130634. * Resets the reference space to the one started the session
  130635. */
  130636. resetReferenceSpace(): void;
  130637. /**
  130638. * Starts rendering to the xr layer
  130639. */
  130640. runXRRenderLoop(): void;
  130641. /**
  130642. * Sets the reference space on the xr session
  130643. * @param referenceSpaceType space to set
  130644. * @returns a promise that will resolve once the reference space has been set
  130645. */
  130646. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130647. /**
  130648. * Updates the render state of the session
  130649. * @param state state to set
  130650. * @returns a promise that resolves once the render state has been updated
  130651. */
  130652. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130653. /**
  130654. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130655. * @param sessionMode defines the session to test
  130656. * @returns a promise with boolean as final value
  130657. */
  130658. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130659. private _createRenderTargetTexture;
  130660. }
  130661. }
  130662. declare module BABYLON {
  130663. /**
  130664. * WebXR Camera which holds the views for the xrSession
  130665. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130666. */
  130667. export class WebXRCamera extends FreeCamera {
  130668. private _xrSessionManager;
  130669. private _firstFrame;
  130670. private _referenceQuaternion;
  130671. private _referencedPosition;
  130672. private _xrInvPositionCache;
  130673. private _xrInvQuaternionCache;
  130674. /**
  130675. * Observable raised before camera teleportation
  130676. */
  130677. onBeforeCameraTeleport: Observable<Vector3>;
  130678. /**
  130679. * Observable raised after camera teleportation
  130680. */
  130681. onAfterCameraTeleport: Observable<Vector3>;
  130682. /**
  130683. * Should position compensation execute on first frame.
  130684. * This is used when copying the position from a native (non XR) camera
  130685. */
  130686. compensateOnFirstFrame: boolean;
  130687. /**
  130688. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130689. * @param name the name of the camera
  130690. * @param scene the scene to add the camera to
  130691. * @param _xrSessionManager a constructed xr session manager
  130692. */
  130693. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130694. /**
  130695. * Return the user's height, unrelated to the current ground.
  130696. * This will be the y position of this camera, when ground level is 0.
  130697. */
  130698. get realWorldHeight(): number;
  130699. /** @hidden */
  130700. _updateForDualEyeDebugging(): void;
  130701. /**
  130702. * Sets this camera's transformation based on a non-vr camera
  130703. * @param otherCamera the non-vr camera to copy the transformation from
  130704. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130705. */
  130706. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130707. /**
  130708. * Gets the current instance class name ("WebXRCamera").
  130709. * @returns the class name
  130710. */
  130711. getClassName(): string;
  130712. private _rotate180;
  130713. private _updateFromXRSession;
  130714. private _updateNumberOfRigCameras;
  130715. private _updateReferenceSpace;
  130716. private _updateReferenceSpaceOffset;
  130717. }
  130718. }
  130719. declare module BABYLON {
  130720. /**
  130721. * Defining the interface required for a (webxr) feature
  130722. */
  130723. export interface IWebXRFeature extends IDisposable {
  130724. /**
  130725. * Is this feature attached
  130726. */
  130727. attached: boolean;
  130728. /**
  130729. * Should auto-attach be disabled?
  130730. */
  130731. disableAutoAttach: boolean;
  130732. /**
  130733. * Attach the feature to the session
  130734. * Will usually be called by the features manager
  130735. *
  130736. * @param force should attachment be forced (even when already attached)
  130737. * @returns true if successful.
  130738. */
  130739. attach(force?: boolean): boolean;
  130740. /**
  130741. * Detach the feature from the session
  130742. * Will usually be called by the features manager
  130743. *
  130744. * @returns true if successful.
  130745. */
  130746. detach(): boolean;
  130747. /**
  130748. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130749. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130750. *
  130751. * @returns whether or not the feature is compatible in this environment
  130752. */
  130753. isCompatible(): boolean;
  130754. /**
  130755. * Was this feature disposed;
  130756. */
  130757. isDisposed: boolean;
  130758. /**
  130759. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130760. */
  130761. xrNativeFeatureName?: string;
  130762. /**
  130763. * A list of (Babylon WebXR) features this feature depends on
  130764. */
  130765. dependsOn?: string[];
  130766. }
  130767. /**
  130768. * A list of the currently available features without referencing them
  130769. */
  130770. export class WebXRFeatureName {
  130771. /**
  130772. * The name of the anchor system feature
  130773. */
  130774. static readonly ANCHOR_SYSTEM: string;
  130775. /**
  130776. * The name of the background remover feature
  130777. */
  130778. static readonly BACKGROUND_REMOVER: string;
  130779. /**
  130780. * The name of the hit test feature
  130781. */
  130782. static readonly HIT_TEST: string;
  130783. /**
  130784. * physics impostors for xr controllers feature
  130785. */
  130786. static readonly PHYSICS_CONTROLLERS: string;
  130787. /**
  130788. * The name of the plane detection feature
  130789. */
  130790. static readonly PLANE_DETECTION: string;
  130791. /**
  130792. * The name of the pointer selection feature
  130793. */
  130794. static readonly POINTER_SELECTION: string;
  130795. /**
  130796. * The name of the teleportation feature
  130797. */
  130798. static readonly TELEPORTATION: string;
  130799. /**
  130800. * The name of the feature points feature.
  130801. */
  130802. static readonly FEATURE_POINTS: string;
  130803. /**
  130804. * The name of the hand tracking feature.
  130805. */
  130806. static readonly HAND_TRACKING: string;
  130807. }
  130808. /**
  130809. * Defining the constructor of a feature. Used to register the modules.
  130810. */
  130811. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  130812. /**
  130813. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  130814. * It is mainly used in AR sessions.
  130815. *
  130816. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  130817. */
  130818. export class WebXRFeaturesManager implements IDisposable {
  130819. private _xrSessionManager;
  130820. private static readonly _AvailableFeatures;
  130821. private _features;
  130822. /**
  130823. * constructs a new features manages.
  130824. *
  130825. * @param _xrSessionManager an instance of WebXRSessionManager
  130826. */
  130827. constructor(_xrSessionManager: WebXRSessionManager);
  130828. /**
  130829. * Used to register a module. After calling this function a developer can use this feature in the scene.
  130830. * Mainly used internally.
  130831. *
  130832. * @param featureName the name of the feature to register
  130833. * @param constructorFunction the function used to construct the module
  130834. * @param version the (babylon) version of the module
  130835. * @param stable is that a stable version of this module
  130836. */
  130837. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  130838. /**
  130839. * Returns a constructor of a specific feature.
  130840. *
  130841. * @param featureName the name of the feature to construct
  130842. * @param version the version of the feature to load
  130843. * @param xrSessionManager the xrSessionManager. Used to construct the module
  130844. * @param options optional options provided to the module.
  130845. * @returns a function that, when called, will return a new instance of this feature
  130846. */
  130847. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  130848. /**
  130849. * Can be used to return the list of features currently registered
  130850. *
  130851. * @returns an Array of available features
  130852. */
  130853. static GetAvailableFeatures(): string[];
  130854. /**
  130855. * Gets the versions available for a specific feature
  130856. * @param featureName the name of the feature
  130857. * @returns an array with the available versions
  130858. */
  130859. static GetAvailableVersions(featureName: string): string[];
  130860. /**
  130861. * Return the latest unstable version of this feature
  130862. * @param featureName the name of the feature to search
  130863. * @returns the version number. if not found will return -1
  130864. */
  130865. static GetLatestVersionOfFeature(featureName: string): number;
  130866. /**
  130867. * Return the latest stable version of this feature
  130868. * @param featureName the name of the feature to search
  130869. * @returns the version number. if not found will return -1
  130870. */
  130871. static GetStableVersionOfFeature(featureName: string): number;
  130872. /**
  130873. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  130874. * Can be used during a session to start a feature
  130875. * @param featureName the name of feature to attach
  130876. */
  130877. attachFeature(featureName: string): void;
  130878. /**
  130879. * Can be used inside a session or when the session ends to detach a specific feature
  130880. * @param featureName the name of the feature to detach
  130881. */
  130882. detachFeature(featureName: string): void;
  130883. /**
  130884. * Used to disable an already-enabled feature
  130885. * The feature will be disposed and will be recreated once enabled.
  130886. * @param featureName the feature to disable
  130887. * @returns true if disable was successful
  130888. */
  130889. disableFeature(featureName: string | {
  130890. Name: string;
  130891. }): boolean;
  130892. /**
  130893. * dispose this features manager
  130894. */
  130895. dispose(): void;
  130896. /**
  130897. * 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.
  130898. * 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.
  130899. *
  130900. * @param featureName the name of the feature to load or the class of the feature
  130901. * @param version optional version to load. if not provided the latest version will be enabled
  130902. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  130903. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  130904. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  130905. * @returns a new constructed feature or throws an error if feature not found.
  130906. */
  130907. enableFeature(featureName: string | {
  130908. Name: string;
  130909. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  130910. /**
  130911. * get the implementation of an enabled feature.
  130912. * @param featureName the name of the feature to load
  130913. * @returns the feature class, if found
  130914. */
  130915. getEnabledFeature(featureName: string): IWebXRFeature;
  130916. /**
  130917. * Get the list of enabled features
  130918. * @returns an array of enabled features
  130919. */
  130920. getEnabledFeatures(): string[];
  130921. /**
  130922. * This function will exten the session creation configuration object with enabled features.
  130923. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  130924. * according to the defined "required" variable, provided during enableFeature call
  130925. * @param xrSessionInit the xr Session init object to extend
  130926. *
  130927. * @returns an extended XRSessionInit object
  130928. */
  130929. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  130930. }
  130931. }
  130932. declare module BABYLON {
  130933. /**
  130934. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  130935. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  130936. */
  130937. export class WebXRExperienceHelper implements IDisposable {
  130938. private scene;
  130939. private _nonVRCamera;
  130940. private _originalSceneAutoClear;
  130941. private _supported;
  130942. /**
  130943. * Camera used to render xr content
  130944. */
  130945. camera: WebXRCamera;
  130946. /** A features manager for this xr session */
  130947. featuresManager: WebXRFeaturesManager;
  130948. /**
  130949. * Observers registered here will be triggered after the camera's initial transformation is set
  130950. * This can be used to set a different ground level or an extra rotation.
  130951. *
  130952. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  130953. * to the position set after this observable is done executing.
  130954. */
  130955. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  130956. /**
  130957. * Fires when the state of the experience helper has changed
  130958. */
  130959. onStateChangedObservable: Observable<WebXRState>;
  130960. /** Session manager used to keep track of xr session */
  130961. sessionManager: WebXRSessionManager;
  130962. /**
  130963. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  130964. */
  130965. state: WebXRState;
  130966. /**
  130967. * Creates a WebXRExperienceHelper
  130968. * @param scene The scene the helper should be created in
  130969. */
  130970. private constructor();
  130971. /**
  130972. * Creates the experience helper
  130973. * @param scene the scene to attach the experience helper to
  130974. * @returns a promise for the experience helper
  130975. */
  130976. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  130977. /**
  130978. * Disposes of the experience helper
  130979. */
  130980. dispose(): void;
  130981. /**
  130982. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  130983. * @param sessionMode options for the XR session
  130984. * @param referenceSpaceType frame of reference of the XR session
  130985. * @param renderTarget the output canvas that will be used to enter XR mode
  130986. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  130987. * @returns promise that resolves after xr mode has entered
  130988. */
  130989. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  130990. /**
  130991. * Exits XR mode and returns the scene to its original state
  130992. * @returns promise that resolves after xr mode has exited
  130993. */
  130994. exitXRAsync(): Promise<void>;
  130995. private _nonXRToXRCamera;
  130996. private _setState;
  130997. }
  130998. }
  130999. declare module BABYLON {
  131000. /**
  131001. * X-Y values for axes in WebXR
  131002. */
  131003. export interface IWebXRMotionControllerAxesValue {
  131004. /**
  131005. * The value of the x axis
  131006. */
  131007. x: number;
  131008. /**
  131009. * The value of the y-axis
  131010. */
  131011. y: number;
  131012. }
  131013. /**
  131014. * changed / previous values for the values of this component
  131015. */
  131016. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131017. /**
  131018. * current (this frame) value
  131019. */
  131020. current: T;
  131021. /**
  131022. * previous (last change) value
  131023. */
  131024. previous: T;
  131025. }
  131026. /**
  131027. * Represents changes in the component between current frame and last values recorded
  131028. */
  131029. export interface IWebXRMotionControllerComponentChanges {
  131030. /**
  131031. * will be populated with previous and current values if axes changed
  131032. */
  131033. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131034. /**
  131035. * will be populated with previous and current values if pressed changed
  131036. */
  131037. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131038. /**
  131039. * will be populated with previous and current values if touched changed
  131040. */
  131041. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131042. /**
  131043. * will be populated with previous and current values if value changed
  131044. */
  131045. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131046. }
  131047. /**
  131048. * This class represents a single component (for example button or thumbstick) of a motion controller
  131049. */
  131050. export class WebXRControllerComponent implements IDisposable {
  131051. /**
  131052. * the id of this component
  131053. */
  131054. id: string;
  131055. /**
  131056. * the type of the component
  131057. */
  131058. type: MotionControllerComponentType;
  131059. private _buttonIndex;
  131060. private _axesIndices;
  131061. private _axes;
  131062. private _changes;
  131063. private _currentValue;
  131064. private _hasChanges;
  131065. private _pressed;
  131066. private _touched;
  131067. /**
  131068. * button component type
  131069. */
  131070. static BUTTON_TYPE: MotionControllerComponentType;
  131071. /**
  131072. * squeeze component type
  131073. */
  131074. static SQUEEZE_TYPE: MotionControllerComponentType;
  131075. /**
  131076. * Thumbstick component type
  131077. */
  131078. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131079. /**
  131080. * Touchpad component type
  131081. */
  131082. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131083. /**
  131084. * trigger component type
  131085. */
  131086. static TRIGGER_TYPE: MotionControllerComponentType;
  131087. /**
  131088. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131089. * the axes data changes
  131090. */
  131091. onAxisValueChangedObservable: Observable<{
  131092. x: number;
  131093. y: number;
  131094. }>;
  131095. /**
  131096. * Observers registered here will be triggered when the state of a button changes
  131097. * State change is either pressed / touched / value
  131098. */
  131099. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131100. /**
  131101. * Creates a new component for a motion controller.
  131102. * It is created by the motion controller itself
  131103. *
  131104. * @param id the id of this component
  131105. * @param type the type of the component
  131106. * @param _buttonIndex index in the buttons array of the gamepad
  131107. * @param _axesIndices indices of the values in the axes array of the gamepad
  131108. */
  131109. constructor(
  131110. /**
  131111. * the id of this component
  131112. */
  131113. id: string,
  131114. /**
  131115. * the type of the component
  131116. */
  131117. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131118. /**
  131119. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131120. */
  131121. get axes(): IWebXRMotionControllerAxesValue;
  131122. /**
  131123. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131124. */
  131125. get changes(): IWebXRMotionControllerComponentChanges;
  131126. /**
  131127. * Return whether or not the component changed the last frame
  131128. */
  131129. get hasChanges(): boolean;
  131130. /**
  131131. * is the button currently pressed
  131132. */
  131133. get pressed(): boolean;
  131134. /**
  131135. * is the button currently touched
  131136. */
  131137. get touched(): boolean;
  131138. /**
  131139. * Get the current value of this component
  131140. */
  131141. get value(): number;
  131142. /**
  131143. * Dispose this component
  131144. */
  131145. dispose(): void;
  131146. /**
  131147. * Are there axes correlating to this component
  131148. * @return true is axes data is available
  131149. */
  131150. isAxes(): boolean;
  131151. /**
  131152. * Is this component a button (hence - pressable)
  131153. * @returns true if can be pressed
  131154. */
  131155. isButton(): boolean;
  131156. /**
  131157. * update this component using the gamepad object it is in. Called on every frame
  131158. * @param nativeController the native gamepad controller object
  131159. */
  131160. update(nativeController: IMinimalMotionControllerObject): void;
  131161. }
  131162. }
  131163. declare module BABYLON {
  131164. /**
  131165. * Interface used to represent data loading progression
  131166. */
  131167. export interface ISceneLoaderProgressEvent {
  131168. /**
  131169. * Defines if data length to load can be evaluated
  131170. */
  131171. readonly lengthComputable: boolean;
  131172. /**
  131173. * Defines the loaded data length
  131174. */
  131175. readonly loaded: number;
  131176. /**
  131177. * Defines the data length to load
  131178. */
  131179. readonly total: number;
  131180. }
  131181. /**
  131182. * Interface used by SceneLoader plugins to define supported file extensions
  131183. */
  131184. export interface ISceneLoaderPluginExtensions {
  131185. /**
  131186. * Defines the list of supported extensions
  131187. */
  131188. [extension: string]: {
  131189. isBinary: boolean;
  131190. };
  131191. }
  131192. /**
  131193. * Interface used by SceneLoader plugin factory
  131194. */
  131195. export interface ISceneLoaderPluginFactory {
  131196. /**
  131197. * Defines the name of the factory
  131198. */
  131199. name: string;
  131200. /**
  131201. * Function called to create a new plugin
  131202. * @return the new plugin
  131203. */
  131204. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131205. /**
  131206. * The callback that returns true if the data can be directly loaded.
  131207. * @param data string containing the file data
  131208. * @returns if the data can be loaded directly
  131209. */
  131210. canDirectLoad?(data: string): boolean;
  131211. }
  131212. /**
  131213. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131214. */
  131215. export interface ISceneLoaderPluginBase {
  131216. /**
  131217. * The friendly name of this plugin.
  131218. */
  131219. name: string;
  131220. /**
  131221. * The file extensions supported by this plugin.
  131222. */
  131223. extensions: string | ISceneLoaderPluginExtensions;
  131224. /**
  131225. * The callback called when loading from a url.
  131226. * @param scene scene loading this url
  131227. * @param url url to load
  131228. * @param onSuccess callback called when the file successfully loads
  131229. * @param onProgress callback called while file is loading (if the server supports this mode)
  131230. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131231. * @param onError callback called when the file fails to load
  131232. * @returns a file request object
  131233. */
  131234. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131235. /**
  131236. * The callback called when loading from a file object.
  131237. * @param scene scene loading this file
  131238. * @param file defines the file to load
  131239. * @param onSuccess defines the callback to call when data is loaded
  131240. * @param onProgress defines the callback to call during loading process
  131241. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131242. * @param onError defines the callback to call when an error occurs
  131243. * @returns a file request object
  131244. */
  131245. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131246. /**
  131247. * The callback that returns true if the data can be directly loaded.
  131248. * @param data string containing the file data
  131249. * @returns if the data can be loaded directly
  131250. */
  131251. canDirectLoad?(data: string): boolean;
  131252. /**
  131253. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131254. * @param scene scene loading this data
  131255. * @param data string containing the data
  131256. * @returns data to pass to the plugin
  131257. */
  131258. directLoad?(scene: Scene, data: string): any;
  131259. /**
  131260. * The callback that allows custom handling of the root url based on the response url.
  131261. * @param rootUrl the original root url
  131262. * @param responseURL the response url if available
  131263. * @returns the new root url
  131264. */
  131265. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131266. }
  131267. /**
  131268. * Interface used to define a SceneLoader plugin
  131269. */
  131270. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131271. /**
  131272. * Import meshes into a scene.
  131273. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131274. * @param scene The scene to import into
  131275. * @param data The data to import
  131276. * @param rootUrl The root url for scene and resources
  131277. * @param meshes The meshes array to import into
  131278. * @param particleSystems The particle systems array to import into
  131279. * @param skeletons The skeletons array to import into
  131280. * @param onError The callback when import fails
  131281. * @returns True if successful or false otherwise
  131282. */
  131283. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131284. /**
  131285. * Load into a scene.
  131286. * @param scene The scene to load into
  131287. * @param data The data to import
  131288. * @param rootUrl The root url for scene and resources
  131289. * @param onError The callback when import fails
  131290. * @returns True if successful or false otherwise
  131291. */
  131292. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131293. /**
  131294. * Load into an asset container.
  131295. * @param scene The scene to load into
  131296. * @param data The data to import
  131297. * @param rootUrl The root url for scene and resources
  131298. * @param onError The callback when import fails
  131299. * @returns The loaded asset container
  131300. */
  131301. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131302. }
  131303. /**
  131304. * Interface used to define an async SceneLoader plugin
  131305. */
  131306. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131307. /**
  131308. * Import meshes into a scene.
  131309. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131310. * @param scene The scene to import into
  131311. * @param data The data to import
  131312. * @param rootUrl The root url for scene and resources
  131313. * @param onProgress The callback when the load progresses
  131314. * @param fileName Defines the name of the file to load
  131315. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131316. */
  131317. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131318. meshes: AbstractMesh[];
  131319. particleSystems: IParticleSystem[];
  131320. skeletons: Skeleton[];
  131321. animationGroups: AnimationGroup[];
  131322. }>;
  131323. /**
  131324. * Load into a scene.
  131325. * @param scene The scene to load into
  131326. * @param data The data to import
  131327. * @param rootUrl The root url for scene and resources
  131328. * @param onProgress The callback when the load progresses
  131329. * @param fileName Defines the name of the file to load
  131330. * @returns Nothing
  131331. */
  131332. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131333. /**
  131334. * Load into an asset container.
  131335. * @param scene The scene to load into
  131336. * @param data The data to import
  131337. * @param rootUrl The root url for scene and resources
  131338. * @param onProgress The callback when the load progresses
  131339. * @param fileName Defines the name of the file to load
  131340. * @returns The loaded asset container
  131341. */
  131342. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131343. }
  131344. /**
  131345. * Mode that determines how to handle old animation groups before loading new ones.
  131346. */
  131347. export enum SceneLoaderAnimationGroupLoadingMode {
  131348. /**
  131349. * Reset all old animations to initial state then dispose them.
  131350. */
  131351. Clean = 0,
  131352. /**
  131353. * Stop all old animations.
  131354. */
  131355. Stop = 1,
  131356. /**
  131357. * Restart old animations from first frame.
  131358. */
  131359. Sync = 2,
  131360. /**
  131361. * Old animations remains untouched.
  131362. */
  131363. NoSync = 3
  131364. }
  131365. /**
  131366. * Defines a plugin registered by the SceneLoader
  131367. */
  131368. interface IRegisteredPlugin {
  131369. /**
  131370. * Defines the plugin to use
  131371. */
  131372. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131373. /**
  131374. * Defines if the plugin supports binary data
  131375. */
  131376. isBinary: boolean;
  131377. }
  131378. /**
  131379. * Class used to load scene from various file formats using registered plugins
  131380. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131381. */
  131382. export class SceneLoader {
  131383. /**
  131384. * No logging while loading
  131385. */
  131386. static readonly NO_LOGGING: number;
  131387. /**
  131388. * Minimal logging while loading
  131389. */
  131390. static readonly MINIMAL_LOGGING: number;
  131391. /**
  131392. * Summary logging while loading
  131393. */
  131394. static readonly SUMMARY_LOGGING: number;
  131395. /**
  131396. * Detailled logging while loading
  131397. */
  131398. static readonly DETAILED_LOGGING: number;
  131399. /**
  131400. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131401. */
  131402. static get ForceFullSceneLoadingForIncremental(): boolean;
  131403. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131404. /**
  131405. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131406. */
  131407. static get ShowLoadingScreen(): boolean;
  131408. static set ShowLoadingScreen(value: boolean);
  131409. /**
  131410. * Defines the current logging level (while loading the scene)
  131411. * @ignorenaming
  131412. */
  131413. static get loggingLevel(): number;
  131414. static set loggingLevel(value: number);
  131415. /**
  131416. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131417. */
  131418. static get CleanBoneMatrixWeights(): boolean;
  131419. static set CleanBoneMatrixWeights(value: boolean);
  131420. /**
  131421. * Event raised when a plugin is used to load a scene
  131422. */
  131423. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131424. private static _registeredPlugins;
  131425. private static _showingLoadingScreen;
  131426. /**
  131427. * Gets the default plugin (used to load Babylon files)
  131428. * @returns the .babylon plugin
  131429. */
  131430. static GetDefaultPlugin(): IRegisteredPlugin;
  131431. private static _GetPluginForExtension;
  131432. private static _GetPluginForDirectLoad;
  131433. private static _GetPluginForFilename;
  131434. private static _GetDirectLoad;
  131435. private static _LoadData;
  131436. private static _GetFileInfo;
  131437. /**
  131438. * Gets a plugin that can load the given extension
  131439. * @param extension defines the extension to load
  131440. * @returns a plugin or null if none works
  131441. */
  131442. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131443. /**
  131444. * Gets a boolean indicating that the given extension can be loaded
  131445. * @param extension defines the extension to load
  131446. * @returns true if the extension is supported
  131447. */
  131448. static IsPluginForExtensionAvailable(extension: string): boolean;
  131449. /**
  131450. * Adds a new plugin to the list of registered plugins
  131451. * @param plugin defines the plugin to add
  131452. */
  131453. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131454. /**
  131455. * Import meshes into a scene
  131456. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131457. * @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)
  131458. * @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)
  131459. * @param scene the instance of BABYLON.Scene to append to
  131460. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131461. * @param onProgress a callback with a progress event for each file being loaded
  131462. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131463. * @param pluginExtension the extension used to determine the plugin
  131464. * @returns The loaded plugin
  131465. */
  131466. 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>;
  131467. /**
  131468. * Import meshes into a scene
  131469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131470. * @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)
  131471. * @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)
  131472. * @param scene the instance of BABYLON.Scene to append to
  131473. * @param onProgress a callback with a progress event for each file being loaded
  131474. * @param pluginExtension the extension used to determine the plugin
  131475. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131476. */
  131477. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131478. meshes: AbstractMesh[];
  131479. particleSystems: IParticleSystem[];
  131480. skeletons: Skeleton[];
  131481. animationGroups: AnimationGroup[];
  131482. }>;
  131483. /**
  131484. * Load a scene
  131485. * @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)
  131486. * @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)
  131487. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131488. * @param onSuccess a callback with the scene when import succeeds
  131489. * @param onProgress a callback with a progress event for each file being loaded
  131490. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131491. * @param pluginExtension the extension used to determine the plugin
  131492. * @returns The loaded plugin
  131493. */
  131494. 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>;
  131495. /**
  131496. * Load a scene
  131497. * @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)
  131498. * @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)
  131499. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131500. * @param onProgress a callback with a progress event for each file being loaded
  131501. * @param pluginExtension the extension used to determine the plugin
  131502. * @returns The loaded scene
  131503. */
  131504. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131505. /**
  131506. * Append a scene
  131507. * @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)
  131508. * @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)
  131509. * @param scene is the instance of BABYLON.Scene to append to
  131510. * @param onSuccess a callback with the scene when import succeeds
  131511. * @param onProgress a callback with a progress event for each file being loaded
  131512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131513. * @param pluginExtension the extension used to determine the plugin
  131514. * @returns The loaded plugin
  131515. */
  131516. 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>;
  131517. /**
  131518. * Append a scene
  131519. * @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)
  131520. * @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)
  131521. * @param scene is the instance of BABYLON.Scene to append to
  131522. * @param onProgress a callback with a progress event for each file being loaded
  131523. * @param pluginExtension the extension used to determine the plugin
  131524. * @returns The given scene
  131525. */
  131526. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131527. /**
  131528. * Load a scene into an asset container
  131529. * @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)
  131530. * @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)
  131531. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131532. * @param onSuccess a callback with the scene when import succeeds
  131533. * @param onProgress a callback with a progress event for each file being loaded
  131534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131535. * @param pluginExtension the extension used to determine the plugin
  131536. * @returns The loaded plugin
  131537. */
  131538. 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>;
  131539. /**
  131540. * Load a scene into an asset container
  131541. * @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)
  131542. * @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)
  131543. * @param scene is the instance of Scene to append to
  131544. * @param onProgress a callback with a progress event for each file being loaded
  131545. * @param pluginExtension the extension used to determine the plugin
  131546. * @returns The loaded asset container
  131547. */
  131548. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131549. /**
  131550. * Import animations from a file into a scene
  131551. * @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)
  131552. * @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)
  131553. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131554. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131555. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131556. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131557. * @param onSuccess a callback with the scene when import succeeds
  131558. * @param onProgress a callback with a progress event for each file being loaded
  131559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131560. * @param pluginExtension the extension used to determine the plugin
  131561. */
  131562. 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;
  131563. /**
  131564. * Import animations from a file into a scene
  131565. * @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)
  131566. * @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)
  131567. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131568. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131569. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131570. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131571. * @param onSuccess a callback with the scene when import succeeds
  131572. * @param onProgress a callback with a progress event for each file being loaded
  131573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131574. * @param pluginExtension the extension used to determine the plugin
  131575. * @returns the updated scene with imported animations
  131576. */
  131577. 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>;
  131578. }
  131579. }
  131580. declare module BABYLON {
  131581. /**
  131582. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131583. */
  131584. export type MotionControllerHandedness = "none" | "left" | "right";
  131585. /**
  131586. * The type of components available in motion controllers.
  131587. * This is not the name of the component.
  131588. */
  131589. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131590. /**
  131591. * The state of a controller component
  131592. */
  131593. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131594. /**
  131595. * The schema of motion controller layout.
  131596. * No object will be initialized using this interface
  131597. * This is used just to define the profile.
  131598. */
  131599. export interface IMotionControllerLayout {
  131600. /**
  131601. * Path to load the assets. Usually relative to the base path
  131602. */
  131603. assetPath: string;
  131604. /**
  131605. * Available components (unsorted)
  131606. */
  131607. components: {
  131608. /**
  131609. * A map of component Ids
  131610. */
  131611. [componentId: string]: {
  131612. /**
  131613. * The type of input the component outputs
  131614. */
  131615. type: MotionControllerComponentType;
  131616. /**
  131617. * The indices of this component in the gamepad object
  131618. */
  131619. gamepadIndices: {
  131620. /**
  131621. * Index of button
  131622. */
  131623. button?: number;
  131624. /**
  131625. * If available, index of x-axis
  131626. */
  131627. xAxis?: number;
  131628. /**
  131629. * If available, index of y-axis
  131630. */
  131631. yAxis?: number;
  131632. };
  131633. /**
  131634. * The mesh's root node name
  131635. */
  131636. rootNodeName: string;
  131637. /**
  131638. * Animation definitions for this model
  131639. */
  131640. visualResponses: {
  131641. [stateKey: string]: {
  131642. /**
  131643. * What property will be animated
  131644. */
  131645. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131646. /**
  131647. * What states influence this visual response
  131648. */
  131649. states: MotionControllerComponentStateType[];
  131650. /**
  131651. * Type of animation - movement or visibility
  131652. */
  131653. valueNodeProperty: "transform" | "visibility";
  131654. /**
  131655. * Base node name to move. Its position will be calculated according to the min and max nodes
  131656. */
  131657. valueNodeName?: string;
  131658. /**
  131659. * Minimum movement node
  131660. */
  131661. minNodeName?: string;
  131662. /**
  131663. * Max movement node
  131664. */
  131665. maxNodeName?: string;
  131666. };
  131667. };
  131668. /**
  131669. * If touch enabled, what is the name of node to display user feedback
  131670. */
  131671. touchPointNodeName?: string;
  131672. };
  131673. };
  131674. /**
  131675. * Is it xr standard mapping or not
  131676. */
  131677. gamepadMapping: "" | "xr-standard";
  131678. /**
  131679. * Base root node of this entire model
  131680. */
  131681. rootNodeName: string;
  131682. /**
  131683. * Defines the main button component id
  131684. */
  131685. selectComponentId: string;
  131686. }
  131687. /**
  131688. * A definition for the layout map in the input profile
  131689. */
  131690. export interface IMotionControllerLayoutMap {
  131691. /**
  131692. * Layouts with handedness type as a key
  131693. */
  131694. [handedness: string]: IMotionControllerLayout;
  131695. }
  131696. /**
  131697. * The XR Input profile schema
  131698. * Profiles can be found here:
  131699. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131700. */
  131701. export interface IMotionControllerProfile {
  131702. /**
  131703. * fallback profiles for this profileId
  131704. */
  131705. fallbackProfileIds: string[];
  131706. /**
  131707. * The layout map, with handedness as key
  131708. */
  131709. layouts: IMotionControllerLayoutMap;
  131710. /**
  131711. * The id of this profile
  131712. * correlates to the profile(s) in the xrInput.profiles array
  131713. */
  131714. profileId: string;
  131715. }
  131716. /**
  131717. * A helper-interface for the 3 meshes needed for controller button animation
  131718. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131719. */
  131720. export interface IMotionControllerButtonMeshMap {
  131721. /**
  131722. * the mesh that defines the pressed value mesh position.
  131723. * This is used to find the max-position of this button
  131724. */
  131725. pressedMesh: AbstractMesh;
  131726. /**
  131727. * the mesh that defines the unpressed value mesh position.
  131728. * This is used to find the min (or initial) position of this button
  131729. */
  131730. unpressedMesh: AbstractMesh;
  131731. /**
  131732. * The mesh that will be changed when value changes
  131733. */
  131734. valueMesh: AbstractMesh;
  131735. }
  131736. /**
  131737. * A helper-interface for the 3 meshes needed for controller axis animation.
  131738. * This will be expanded when touchpad animations are fully supported
  131739. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131740. */
  131741. export interface IMotionControllerMeshMap {
  131742. /**
  131743. * the mesh that defines the maximum value mesh position.
  131744. */
  131745. maxMesh?: AbstractMesh;
  131746. /**
  131747. * the mesh that defines the minimum value mesh position.
  131748. */
  131749. minMesh?: AbstractMesh;
  131750. /**
  131751. * The mesh that will be changed when axis value changes
  131752. */
  131753. valueMesh?: AbstractMesh;
  131754. }
  131755. /**
  131756. * The elements needed for change-detection of the gamepad objects in motion controllers
  131757. */
  131758. export interface IMinimalMotionControllerObject {
  131759. /**
  131760. * Available axes of this controller
  131761. */
  131762. axes: number[];
  131763. /**
  131764. * An array of available buttons
  131765. */
  131766. buttons: Array<{
  131767. /**
  131768. * Value of the button/trigger
  131769. */
  131770. value: number;
  131771. /**
  131772. * If the button/trigger is currently touched
  131773. */
  131774. touched: boolean;
  131775. /**
  131776. * If the button/trigger is currently pressed
  131777. */
  131778. pressed: boolean;
  131779. }>;
  131780. /**
  131781. * EXPERIMENTAL haptic support.
  131782. */
  131783. hapticActuators?: Array<{
  131784. pulse: (value: number, duration: number) => Promise<boolean>;
  131785. }>;
  131786. }
  131787. /**
  131788. * An Abstract Motion controller
  131789. * This class receives an xrInput and a profile layout and uses those to initialize the components
  131790. * Each component has an observable to check for changes in value and state
  131791. */
  131792. export abstract class WebXRAbstractMotionController implements IDisposable {
  131793. protected scene: Scene;
  131794. protected layout: IMotionControllerLayout;
  131795. /**
  131796. * The gamepad object correlating to this controller
  131797. */
  131798. gamepadObject: IMinimalMotionControllerObject;
  131799. /**
  131800. * handedness (left/right/none) of this controller
  131801. */
  131802. handedness: MotionControllerHandedness;
  131803. private _initComponent;
  131804. private _modelReady;
  131805. /**
  131806. * A map of components (WebXRControllerComponent) in this motion controller
  131807. * Components have a ComponentType and can also have both button and axis definitions
  131808. */
  131809. readonly components: {
  131810. [id: string]: WebXRControllerComponent;
  131811. };
  131812. /**
  131813. * Disable the model's animation. Can be set at any time.
  131814. */
  131815. disableAnimation: boolean;
  131816. /**
  131817. * Observers registered here will be triggered when the model of this controller is done loading
  131818. */
  131819. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  131820. /**
  131821. * The profile id of this motion controller
  131822. */
  131823. abstract profileId: string;
  131824. /**
  131825. * The root mesh of the model. It is null if the model was not yet initialized
  131826. */
  131827. rootMesh: Nullable<AbstractMesh>;
  131828. /**
  131829. * constructs a new abstract motion controller
  131830. * @param scene the scene to which the model of the controller will be added
  131831. * @param layout The profile layout to load
  131832. * @param gamepadObject The gamepad object correlating to this controller
  131833. * @param handedness handedness (left/right/none) of this controller
  131834. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  131835. */
  131836. constructor(scene: Scene, layout: IMotionControllerLayout,
  131837. /**
  131838. * The gamepad object correlating to this controller
  131839. */
  131840. gamepadObject: IMinimalMotionControllerObject,
  131841. /**
  131842. * handedness (left/right/none) of this controller
  131843. */
  131844. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  131845. /**
  131846. * Dispose this controller, the model mesh and all its components
  131847. */
  131848. dispose(): void;
  131849. /**
  131850. * Returns all components of specific type
  131851. * @param type the type to search for
  131852. * @return an array of components with this type
  131853. */
  131854. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  131855. /**
  131856. * get a component based an its component id as defined in layout.components
  131857. * @param id the id of the component
  131858. * @returns the component correlates to the id or undefined if not found
  131859. */
  131860. getComponent(id: string): WebXRControllerComponent;
  131861. /**
  131862. * Get the list of components available in this motion controller
  131863. * @returns an array of strings correlating to available components
  131864. */
  131865. getComponentIds(): string[];
  131866. /**
  131867. * Get the first component of specific type
  131868. * @param type type of component to find
  131869. * @return a controller component or null if not found
  131870. */
  131871. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  131872. /**
  131873. * Get the main (Select) component of this controller as defined in the layout
  131874. * @returns the main component of this controller
  131875. */
  131876. getMainComponent(): WebXRControllerComponent;
  131877. /**
  131878. * Loads the model correlating to this controller
  131879. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  131880. * @returns A promise fulfilled with the result of the model loading
  131881. */
  131882. loadModel(): Promise<boolean>;
  131883. /**
  131884. * Update this model using the current XRFrame
  131885. * @param xrFrame the current xr frame to use and update the model
  131886. */
  131887. updateFromXRFrame(xrFrame: XRFrame): void;
  131888. /**
  131889. * Backwards compatibility due to a deeply-integrated typo
  131890. */
  131891. get handness(): XREye;
  131892. /**
  131893. * Pulse (vibrate) this controller
  131894. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  131895. * Consecutive calls to this function will cancel the last pulse call
  131896. *
  131897. * @param value the strength of the pulse in 0.0...1.0 range
  131898. * @param duration Duration of the pulse in milliseconds
  131899. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  131900. * @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
  131901. */
  131902. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  131903. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131904. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  131905. /**
  131906. * Moves the axis on the controller mesh based on its current state
  131907. * @param axis the index of the axis
  131908. * @param axisValue the value of the axis which determines the meshes new position
  131909. * @hidden
  131910. */
  131911. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  131912. /**
  131913. * Update the model itself with the current frame data
  131914. * @param xrFrame the frame to use for updating the model mesh
  131915. */
  131916. protected updateModel(xrFrame: XRFrame): void;
  131917. /**
  131918. * Get the filename and path for this controller's model
  131919. * @returns a map of filename and path
  131920. */
  131921. protected abstract _getFilenameAndPath(): {
  131922. filename: string;
  131923. path: string;
  131924. };
  131925. /**
  131926. * This function is called before the mesh is loaded. It checks for loading constraints.
  131927. * For example, this function can check if the GLB loader is available
  131928. * If this function returns false, the generic controller will be loaded instead
  131929. * @returns Is the client ready to load the mesh
  131930. */
  131931. protected abstract _getModelLoadingConstraints(): boolean;
  131932. /**
  131933. * This function will be called after the model was successfully loaded and can be used
  131934. * for mesh transformations before it is available for the user
  131935. * @param meshes the loaded meshes
  131936. */
  131937. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  131938. /**
  131939. * Set the root mesh for this controller. Important for the WebXR controller class
  131940. * @param meshes the loaded meshes
  131941. */
  131942. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  131943. /**
  131944. * A function executed each frame that updates the mesh (if needed)
  131945. * @param xrFrame the current xrFrame
  131946. */
  131947. protected abstract _updateModel(xrFrame: XRFrame): void;
  131948. private _getGenericFilenameAndPath;
  131949. private _getGenericParentMesh;
  131950. }
  131951. }
  131952. declare module BABYLON {
  131953. /**
  131954. * A generic trigger-only motion controller for WebXR
  131955. */
  131956. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  131957. /**
  131958. * Static version of the profile id of this controller
  131959. */
  131960. static ProfileId: string;
  131961. profileId: string;
  131962. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  131963. protected _getFilenameAndPath(): {
  131964. filename: string;
  131965. path: string;
  131966. };
  131967. protected _getModelLoadingConstraints(): boolean;
  131968. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  131969. protected _setRootMesh(meshes: AbstractMesh[]): void;
  131970. protected _updateModel(): void;
  131971. }
  131972. }
  131973. declare module BABYLON {
  131974. /**
  131975. * Class containing static functions to help procedurally build meshes
  131976. */
  131977. export class SphereBuilder {
  131978. /**
  131979. * Creates a sphere mesh
  131980. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131981. * * 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`)
  131982. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131983. * * 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
  131984. * * 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)
  131985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131988. * @param name defines the name of the mesh
  131989. * @param options defines the options used to create the mesh
  131990. * @param scene defines the hosting scene
  131991. * @returns the sphere mesh
  131992. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131993. */
  131994. static CreateSphere(name: string, options: {
  131995. segments?: number;
  131996. diameter?: number;
  131997. diameterX?: number;
  131998. diameterY?: number;
  131999. diameterZ?: number;
  132000. arc?: number;
  132001. slice?: number;
  132002. sideOrientation?: number;
  132003. frontUVs?: Vector4;
  132004. backUVs?: Vector4;
  132005. updatable?: boolean;
  132006. }, scene?: Nullable<Scene>): Mesh;
  132007. }
  132008. }
  132009. declare module BABYLON {
  132010. /**
  132011. * A profiled motion controller has its profile loaded from an online repository.
  132012. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132013. */
  132014. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132015. private _repositoryUrl;
  132016. private _buttonMeshMapping;
  132017. private _touchDots;
  132018. /**
  132019. * The profile ID of this controller. Will be populated when the controller initializes.
  132020. */
  132021. profileId: string;
  132022. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132023. dispose(): void;
  132024. protected _getFilenameAndPath(): {
  132025. filename: string;
  132026. path: string;
  132027. };
  132028. protected _getModelLoadingConstraints(): boolean;
  132029. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132030. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132031. protected _updateModel(_xrFrame: XRFrame): void;
  132032. }
  132033. }
  132034. declare module BABYLON {
  132035. /**
  132036. * A construction function type to create a new controller based on an xrInput object
  132037. */
  132038. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132039. /**
  132040. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132041. *
  132042. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132043. * it should be replaced with auto-loaded controllers.
  132044. *
  132045. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132046. */
  132047. export class WebXRMotionControllerManager {
  132048. private static _AvailableControllers;
  132049. private static _Fallbacks;
  132050. private static _ProfileLoadingPromises;
  132051. private static _ProfilesList;
  132052. /**
  132053. * The base URL of the online controller repository. Can be changed at any time.
  132054. */
  132055. static BaseRepositoryUrl: string;
  132056. /**
  132057. * Which repository gets priority - local or online
  132058. */
  132059. static PrioritizeOnlineRepository: boolean;
  132060. /**
  132061. * Use the online repository, or use only locally-defined controllers
  132062. */
  132063. static UseOnlineRepository: boolean;
  132064. /**
  132065. * Clear the cache used for profile loading and reload when requested again
  132066. */
  132067. static ClearProfilesCache(): void;
  132068. /**
  132069. * Register the default fallbacks.
  132070. * This function is called automatically when this file is imported.
  132071. */
  132072. static DefaultFallbacks(): void;
  132073. /**
  132074. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132075. * @param profileId the profile to which a fallback needs to be found
  132076. * @return an array with corresponding fallback profiles
  132077. */
  132078. static FindFallbackWithProfileId(profileId: string): string[];
  132079. /**
  132080. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132081. * The order of search:
  132082. *
  132083. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132084. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132085. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132086. * 4) return the generic trigger controller if none were found
  132087. *
  132088. * @param xrInput the xrInput to which a new controller is initialized
  132089. * @param scene the scene to which the model will be added
  132090. * @param forceProfile force a certain profile for this controller
  132091. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132092. */
  132093. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132094. /**
  132095. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132096. *
  132097. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132098. *
  132099. * @param type the profile type to register
  132100. * @param constructFunction the function to be called when loading this profile
  132101. */
  132102. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132103. /**
  132104. * Register a fallback to a specific profile.
  132105. * @param profileId the profileId that will receive the fallbacks
  132106. * @param fallbacks A list of fallback profiles
  132107. */
  132108. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132109. /**
  132110. * Will update the list of profiles available in the repository
  132111. * @return a promise that resolves to a map of profiles available online
  132112. */
  132113. static UpdateProfilesList(): Promise<{
  132114. [profile: string]: string;
  132115. }>;
  132116. private static _LoadProfileFromRepository;
  132117. private static _LoadProfilesFromAvailableControllers;
  132118. }
  132119. }
  132120. declare module BABYLON {
  132121. /**
  132122. * Configuration options for the WebXR controller creation
  132123. */
  132124. export interface IWebXRControllerOptions {
  132125. /**
  132126. * Should the controller mesh be animated when a user interacts with it
  132127. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132128. */
  132129. disableMotionControllerAnimation?: boolean;
  132130. /**
  132131. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132132. */
  132133. doNotLoadControllerMesh?: boolean;
  132134. /**
  132135. * Force a specific controller type for this controller.
  132136. * This can be used when creating your own profile or when testing different controllers
  132137. */
  132138. forceControllerProfile?: string;
  132139. /**
  132140. * Defines a rendering group ID for meshes that will be loaded.
  132141. * This is for the default controllers only.
  132142. */
  132143. renderingGroupId?: number;
  132144. }
  132145. /**
  132146. * Represents an XR controller
  132147. */
  132148. export class WebXRInputSource {
  132149. private _scene;
  132150. /** The underlying input source for the controller */
  132151. inputSource: XRInputSource;
  132152. private _options;
  132153. private _tmpVector;
  132154. private _uniqueId;
  132155. private _disposed;
  132156. /**
  132157. * 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
  132158. */
  132159. grip?: AbstractMesh;
  132160. /**
  132161. * If available, this is the gamepad object related to this controller.
  132162. * Using this object it is possible to get click events and trackpad changes of the
  132163. * webxr controller that is currently being used.
  132164. */
  132165. motionController?: WebXRAbstractMotionController;
  132166. /**
  132167. * Event that fires when the controller is removed/disposed.
  132168. * The object provided as event data is this controller, after associated assets were disposed.
  132169. * uniqueId is still available.
  132170. */
  132171. onDisposeObservable: Observable<WebXRInputSource>;
  132172. /**
  132173. * Will be triggered when the mesh associated with the motion controller is done loading.
  132174. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132175. * A shortened version of controller -> motion controller -> on mesh loaded.
  132176. */
  132177. onMeshLoadedObservable: Observable<AbstractMesh>;
  132178. /**
  132179. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132180. */
  132181. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132182. /**
  132183. * Pointer which can be used to select objects or attach a visible laser to
  132184. */
  132185. pointer: AbstractMesh;
  132186. /**
  132187. * Creates the input source object
  132188. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132189. * @param _scene the scene which the controller should be associated to
  132190. * @param inputSource the underlying input source for the controller
  132191. * @param _options options for this controller creation
  132192. */
  132193. constructor(_scene: Scene,
  132194. /** The underlying input source for the controller */
  132195. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132196. /**
  132197. * Get this controllers unique id
  132198. */
  132199. get uniqueId(): string;
  132200. /**
  132201. * Disposes of the object
  132202. */
  132203. dispose(): void;
  132204. /**
  132205. * Gets a world space ray coming from the pointer or grip
  132206. * @param result the resulting ray
  132207. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132208. */
  132209. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132210. /**
  132211. * Updates the controller pose based on the given XRFrame
  132212. * @param xrFrame xr frame to update the pose with
  132213. * @param referenceSpace reference space to use
  132214. */
  132215. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132216. }
  132217. }
  132218. declare module BABYLON {
  132219. /**
  132220. * The schema for initialization options of the XR Input class
  132221. */
  132222. export interface IWebXRInputOptions {
  132223. /**
  132224. * If set to true no model will be automatically loaded
  132225. */
  132226. doNotLoadControllerMeshes?: boolean;
  132227. /**
  132228. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132229. * If not found, the xr input profile data will be used.
  132230. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132231. */
  132232. forceInputProfile?: string;
  132233. /**
  132234. * Do not send a request to the controller repository to load the profile.
  132235. *
  132236. * Instead, use the controllers available in babylon itself.
  132237. */
  132238. disableOnlineControllerRepository?: boolean;
  132239. /**
  132240. * A custom URL for the controllers repository
  132241. */
  132242. customControllersRepositoryURL?: string;
  132243. /**
  132244. * Should the controller model's components not move according to the user input
  132245. */
  132246. disableControllerAnimation?: boolean;
  132247. /**
  132248. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132249. */
  132250. controllerOptions?: IWebXRControllerOptions;
  132251. }
  132252. /**
  132253. * XR input used to track XR inputs such as controllers/rays
  132254. */
  132255. export class WebXRInput implements IDisposable {
  132256. /**
  132257. * the xr session manager for this session
  132258. */
  132259. xrSessionManager: WebXRSessionManager;
  132260. /**
  132261. * the WebXR camera for this session. Mainly used for teleportation
  132262. */
  132263. xrCamera: WebXRCamera;
  132264. private readonly options;
  132265. /**
  132266. * XR controllers being tracked
  132267. */
  132268. controllers: Array<WebXRInputSource>;
  132269. private _frameObserver;
  132270. private _sessionEndedObserver;
  132271. private _sessionInitObserver;
  132272. /**
  132273. * Event when a controller has been connected/added
  132274. */
  132275. onControllerAddedObservable: Observable<WebXRInputSource>;
  132276. /**
  132277. * Event when a controller has been removed/disconnected
  132278. */
  132279. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132280. /**
  132281. * Initializes the WebXRInput
  132282. * @param xrSessionManager the xr session manager for this session
  132283. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132284. * @param options = initialization options for this xr input
  132285. */
  132286. constructor(
  132287. /**
  132288. * the xr session manager for this session
  132289. */
  132290. xrSessionManager: WebXRSessionManager,
  132291. /**
  132292. * the WebXR camera for this session. Mainly used for teleportation
  132293. */
  132294. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132295. private _onInputSourcesChange;
  132296. private _addAndRemoveControllers;
  132297. /**
  132298. * Disposes of the object
  132299. */
  132300. dispose(): void;
  132301. }
  132302. }
  132303. declare module BABYLON {
  132304. /**
  132305. * This is the base class for all WebXR features.
  132306. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132307. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132308. */
  132309. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132310. protected _xrSessionManager: WebXRSessionManager;
  132311. private _attached;
  132312. private _removeOnDetach;
  132313. /**
  132314. * Is this feature disposed?
  132315. */
  132316. isDisposed: boolean;
  132317. /**
  132318. * Should auto-attach be disabled?
  132319. */
  132320. disableAutoAttach: boolean;
  132321. /**
  132322. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132323. */
  132324. xrNativeFeatureName: string;
  132325. /**
  132326. * Construct a new (abstract) WebXR feature
  132327. * @param _xrSessionManager the xr session manager for this feature
  132328. */
  132329. constructor(_xrSessionManager: WebXRSessionManager);
  132330. /**
  132331. * Is this feature attached
  132332. */
  132333. get attached(): boolean;
  132334. /**
  132335. * attach this feature
  132336. *
  132337. * @param force should attachment be forced (even when already attached)
  132338. * @returns true if successful, false is failed or already attached
  132339. */
  132340. attach(force?: boolean): boolean;
  132341. /**
  132342. * detach this feature.
  132343. *
  132344. * @returns true if successful, false if failed or already detached
  132345. */
  132346. detach(): boolean;
  132347. /**
  132348. * Dispose this feature and all of the resources attached
  132349. */
  132350. dispose(): void;
  132351. /**
  132352. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132353. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132354. *
  132355. * @returns whether or not the feature is compatible in this environment
  132356. */
  132357. isCompatible(): boolean;
  132358. /**
  132359. * This is used to register callbacks that will automatically be removed when detach is called.
  132360. * @param observable the observable to which the observer will be attached
  132361. * @param callback the callback to register
  132362. */
  132363. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132364. /**
  132365. * Code in this function will be executed on each xrFrame received from the browser.
  132366. * This function will not execute after the feature is detached.
  132367. * @param _xrFrame the current frame
  132368. */
  132369. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132370. }
  132371. }
  132372. declare module BABYLON {
  132373. /**
  132374. * Renders a layer on top of an existing scene
  132375. */
  132376. export class UtilityLayerRenderer implements IDisposable {
  132377. /** the original scene that will be rendered on top of */
  132378. originalScene: Scene;
  132379. private _pointerCaptures;
  132380. private _lastPointerEvents;
  132381. private static _DefaultUtilityLayer;
  132382. private static _DefaultKeepDepthUtilityLayer;
  132383. private _sharedGizmoLight;
  132384. private _renderCamera;
  132385. /**
  132386. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132387. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132388. * @returns the camera that is used when rendering the utility layer
  132389. */
  132390. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132391. /**
  132392. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132393. * @param cam the camera that should be used when rendering the utility layer
  132394. */
  132395. setRenderCamera(cam: Nullable<Camera>): void;
  132396. /**
  132397. * @hidden
  132398. * Light which used by gizmos to get light shading
  132399. */
  132400. _getSharedGizmoLight(): HemisphericLight;
  132401. /**
  132402. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132403. */
  132404. pickUtilitySceneFirst: boolean;
  132405. /**
  132406. * 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)
  132407. */
  132408. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132409. /**
  132410. * 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)
  132411. */
  132412. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132413. /**
  132414. * The scene that is rendered on top of the original scene
  132415. */
  132416. utilityLayerScene: Scene;
  132417. /**
  132418. * If the utility layer should automatically be rendered on top of existing scene
  132419. */
  132420. shouldRender: boolean;
  132421. /**
  132422. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132423. */
  132424. onlyCheckPointerDownEvents: boolean;
  132425. /**
  132426. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132427. */
  132428. processAllEvents: boolean;
  132429. /**
  132430. * Observable raised when the pointer move from the utility layer scene to the main scene
  132431. */
  132432. onPointerOutObservable: Observable<number>;
  132433. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132434. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132435. private _afterRenderObserver;
  132436. private _sceneDisposeObserver;
  132437. private _originalPointerObserver;
  132438. /**
  132439. * Instantiates a UtilityLayerRenderer
  132440. * @param originalScene the original scene that will be rendered on top of
  132441. * @param handleEvents boolean indicating if the utility layer should handle events
  132442. */
  132443. constructor(
  132444. /** the original scene that will be rendered on top of */
  132445. originalScene: Scene, handleEvents?: boolean);
  132446. private _notifyObservers;
  132447. /**
  132448. * Renders the utility layers scene on top of the original scene
  132449. */
  132450. render(): void;
  132451. /**
  132452. * Disposes of the renderer
  132453. */
  132454. dispose(): void;
  132455. private _updateCamera;
  132456. }
  132457. }
  132458. declare module BABYLON {
  132459. /**
  132460. * Options interface for the pointer selection module
  132461. */
  132462. export interface IWebXRControllerPointerSelectionOptions {
  132463. /**
  132464. * if provided, this scene will be used to render meshes.
  132465. */
  132466. customUtilityLayerScene?: Scene;
  132467. /**
  132468. * 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)
  132469. * If not disabled, the last picked point will be used to execute a pointer up event
  132470. * If disabled, pointer up event will be triggered right after the pointer down event.
  132471. * Used in screen and gaze target ray mode only
  132472. */
  132473. disablePointerUpOnTouchOut: boolean;
  132474. /**
  132475. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132476. */
  132477. forceGazeMode: boolean;
  132478. /**
  132479. * 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
  132480. * to start a new countdown to the pointer down event.
  132481. * Defaults to 1.
  132482. */
  132483. gazeModePointerMovedFactor?: number;
  132484. /**
  132485. * Different button type to use instead of the main component
  132486. */
  132487. overrideButtonId?: string;
  132488. /**
  132489. * use this rendering group id for the meshes (optional)
  132490. */
  132491. renderingGroupId?: number;
  132492. /**
  132493. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132494. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132495. * 3000 means 3 seconds between pointing at something and selecting it
  132496. */
  132497. timeToSelect?: number;
  132498. /**
  132499. * Should meshes created here be added to a utility layer or the main scene
  132500. */
  132501. useUtilityLayer?: boolean;
  132502. /**
  132503. * Optional WebXR camera to be used for gaze selection
  132504. */
  132505. gazeCamera?: WebXRCamera;
  132506. /**
  132507. * the xr input to use with this pointer selection
  132508. */
  132509. xrInput: WebXRInput;
  132510. }
  132511. /**
  132512. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132513. */
  132514. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132515. private readonly _options;
  132516. private static _idCounter;
  132517. private _attachController;
  132518. private _controllers;
  132519. private _scene;
  132520. private _tmpVectorForPickCompare;
  132521. /**
  132522. * The module's name
  132523. */
  132524. static readonly Name: string;
  132525. /**
  132526. * The (Babylon) version of this module.
  132527. * This is an integer representing the implementation version.
  132528. * This number does not correspond to the WebXR specs version
  132529. */
  132530. static readonly Version: number;
  132531. /**
  132532. * Disable lighting on the laser pointer (so it will always be visible)
  132533. */
  132534. disablePointerLighting: boolean;
  132535. /**
  132536. * Disable lighting on the selection mesh (so it will always be visible)
  132537. */
  132538. disableSelectionMeshLighting: boolean;
  132539. /**
  132540. * Should the laser pointer be displayed
  132541. */
  132542. displayLaserPointer: boolean;
  132543. /**
  132544. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132545. */
  132546. displaySelectionMesh: boolean;
  132547. /**
  132548. * This color will be set to the laser pointer when selection is triggered
  132549. */
  132550. laserPointerPickedColor: Color3;
  132551. /**
  132552. * Default color of the laser pointer
  132553. */
  132554. laserPointerDefaultColor: Color3;
  132555. /**
  132556. * default color of the selection ring
  132557. */
  132558. selectionMeshDefaultColor: Color3;
  132559. /**
  132560. * This color will be applied to the selection ring when selection is triggered
  132561. */
  132562. selectionMeshPickedColor: Color3;
  132563. /**
  132564. * Optional filter to be used for ray selection. This predicate shares behavior with
  132565. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132566. */
  132567. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132568. /**
  132569. * constructs a new background remover module
  132570. * @param _xrSessionManager the session manager for this module
  132571. * @param _options read-only options to be used in this module
  132572. */
  132573. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132574. /**
  132575. * attach this feature
  132576. * Will usually be called by the features manager
  132577. *
  132578. * @returns true if successful.
  132579. */
  132580. attach(): boolean;
  132581. /**
  132582. * detach this feature.
  132583. * Will usually be called by the features manager
  132584. *
  132585. * @returns true if successful.
  132586. */
  132587. detach(): boolean;
  132588. /**
  132589. * Will get the mesh under a specific pointer.
  132590. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132591. * @param controllerId the controllerId to check
  132592. * @returns The mesh under pointer or null if no mesh is under the pointer
  132593. */
  132594. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132595. /**
  132596. * Get the xr controller that correlates to the pointer id in the pointer event
  132597. *
  132598. * @param id the pointer id to search for
  132599. * @returns the controller that correlates to this id or null if not found
  132600. */
  132601. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132602. protected _onXRFrame(_xrFrame: XRFrame): void;
  132603. private _attachGazeMode;
  132604. private _attachScreenRayMode;
  132605. private _attachTrackedPointerRayMode;
  132606. private _convertNormalToDirectionOfRay;
  132607. private _detachController;
  132608. private _generateNewMeshPair;
  132609. private _pickingMoved;
  132610. private _updatePointerDistance;
  132611. /** @hidden */
  132612. get lasterPointerDefaultColor(): Color3;
  132613. }
  132614. }
  132615. declare module BABYLON {
  132616. /**
  132617. * Button which can be used to enter a different mode of XR
  132618. */
  132619. export class WebXREnterExitUIButton {
  132620. /** button element */
  132621. element: HTMLElement;
  132622. /** XR initialization options for the button */
  132623. sessionMode: XRSessionMode;
  132624. /** Reference space type */
  132625. referenceSpaceType: XRReferenceSpaceType;
  132626. /**
  132627. * Creates a WebXREnterExitUIButton
  132628. * @param element button element
  132629. * @param sessionMode XR initialization session mode
  132630. * @param referenceSpaceType the type of reference space to be used
  132631. */
  132632. constructor(
  132633. /** button element */
  132634. element: HTMLElement,
  132635. /** XR initialization options for the button */
  132636. sessionMode: XRSessionMode,
  132637. /** Reference space type */
  132638. referenceSpaceType: XRReferenceSpaceType);
  132639. /**
  132640. * Extendable function which can be used to update the button's visuals when the state changes
  132641. * @param activeButton the current active button in the UI
  132642. */
  132643. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132644. }
  132645. /**
  132646. * Options to create the webXR UI
  132647. */
  132648. export class WebXREnterExitUIOptions {
  132649. /**
  132650. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132651. */
  132652. customButtons?: Array<WebXREnterExitUIButton>;
  132653. /**
  132654. * A reference space type to use when creating the default button.
  132655. * Default is local-floor
  132656. */
  132657. referenceSpaceType?: XRReferenceSpaceType;
  132658. /**
  132659. * Context to enter xr with
  132660. */
  132661. renderTarget?: Nullable<WebXRRenderTarget>;
  132662. /**
  132663. * A session mode to use when creating the default button.
  132664. * Default is immersive-vr
  132665. */
  132666. sessionMode?: XRSessionMode;
  132667. /**
  132668. * A list of optional features to init the session with
  132669. */
  132670. optionalFeatures?: string[];
  132671. /**
  132672. * A list of optional features to init the session with
  132673. */
  132674. requiredFeatures?: string[];
  132675. }
  132676. /**
  132677. * UI to allow the user to enter/exit XR mode
  132678. */
  132679. export class WebXREnterExitUI implements IDisposable {
  132680. private scene;
  132681. /** version of the options passed to this UI */
  132682. options: WebXREnterExitUIOptions;
  132683. private _activeButton;
  132684. private _buttons;
  132685. /**
  132686. * The HTML Div Element to which buttons are added.
  132687. */
  132688. readonly overlay: HTMLDivElement;
  132689. /**
  132690. * Fired every time the active button is changed.
  132691. *
  132692. * When xr is entered via a button that launches xr that button will be the callback parameter
  132693. *
  132694. * When exiting xr the callback parameter will be null)
  132695. */
  132696. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132697. /**
  132698. *
  132699. * @param scene babylon scene object to use
  132700. * @param options (read-only) version of the options passed to this UI
  132701. */
  132702. private constructor();
  132703. /**
  132704. * Creates UI to allow the user to enter/exit XR mode
  132705. * @param scene the scene to add the ui to
  132706. * @param helper the xr experience helper to enter/exit xr with
  132707. * @param options options to configure the UI
  132708. * @returns the created ui
  132709. */
  132710. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132711. /**
  132712. * Disposes of the XR UI component
  132713. */
  132714. dispose(): void;
  132715. private _updateButtons;
  132716. }
  132717. }
  132718. declare module BABYLON {
  132719. /**
  132720. * Class containing static functions to help procedurally build meshes
  132721. */
  132722. export class LinesBuilder {
  132723. /**
  132724. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132725. * * 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
  132726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132727. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132728. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132729. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132730. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132731. * * 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
  132732. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132735. * @param name defines the name of the new line system
  132736. * @param options defines the options used to create the line system
  132737. * @param scene defines the hosting scene
  132738. * @returns a new line system mesh
  132739. */
  132740. static CreateLineSystem(name: string, options: {
  132741. lines: Vector3[][];
  132742. updatable?: boolean;
  132743. instance?: Nullable<LinesMesh>;
  132744. colors?: Nullable<Color4[][]>;
  132745. useVertexAlpha?: boolean;
  132746. }, scene: Nullable<Scene>): LinesMesh;
  132747. /**
  132748. * Creates a line mesh
  132749. * 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
  132750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132751. * * The parameter `points` is an array successive Vector3
  132752. * * 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
  132753. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132754. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  132755. * * When updating an instance, remember that only point positions can change, not the number of points
  132756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  132758. * @param name defines the name of the new line system
  132759. * @param options defines the options used to create the line system
  132760. * @param scene defines the hosting scene
  132761. * @returns a new line mesh
  132762. */
  132763. static CreateLines(name: string, options: {
  132764. points: Vector3[];
  132765. updatable?: boolean;
  132766. instance?: Nullable<LinesMesh>;
  132767. colors?: Color4[];
  132768. useVertexAlpha?: boolean;
  132769. }, scene?: Nullable<Scene>): LinesMesh;
  132770. /**
  132771. * Creates a dashed line mesh
  132772. * * 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
  132773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132774. * * The parameter `points` is an array successive Vector3
  132775. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  132776. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  132777. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  132778. * * 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
  132779. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132780. * * When updating an instance, remember that only point positions can change, not the number of points
  132781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132782. * @param name defines the name of the mesh
  132783. * @param options defines the options used to create the mesh
  132784. * @param scene defines the hosting scene
  132785. * @returns the dashed line mesh
  132786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  132787. */
  132788. static CreateDashedLines(name: string, options: {
  132789. points: Vector3[];
  132790. dashSize?: number;
  132791. gapSize?: number;
  132792. dashNb?: number;
  132793. updatable?: boolean;
  132794. instance?: LinesMesh;
  132795. useVertexAlpha?: boolean;
  132796. }, scene?: Nullable<Scene>): LinesMesh;
  132797. }
  132798. }
  132799. declare module BABYLON {
  132800. /**
  132801. * Construction options for a timer
  132802. */
  132803. export interface ITimerOptions<T> {
  132804. /**
  132805. * Time-to-end
  132806. */
  132807. timeout: number;
  132808. /**
  132809. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  132810. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  132811. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  132812. */
  132813. contextObservable: Observable<T>;
  132814. /**
  132815. * Optional parameters when adding an observer to the observable
  132816. */
  132817. observableParameters?: {
  132818. mask?: number;
  132819. insertFirst?: boolean;
  132820. scope?: any;
  132821. };
  132822. /**
  132823. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  132824. */
  132825. breakCondition?: (data?: ITimerData<T>) => boolean;
  132826. /**
  132827. * Will be triggered when the time condition has met
  132828. */
  132829. onEnded?: (data: ITimerData<any>) => void;
  132830. /**
  132831. * Will be triggered when the break condition has met (prematurely ended)
  132832. */
  132833. onAborted?: (data: ITimerData<any>) => void;
  132834. /**
  132835. * Optional function to execute on each tick (or count)
  132836. */
  132837. onTick?: (data: ITimerData<any>) => void;
  132838. }
  132839. /**
  132840. * An interface defining the data sent by the timer
  132841. */
  132842. export interface ITimerData<T> {
  132843. /**
  132844. * When did it start
  132845. */
  132846. startTime: number;
  132847. /**
  132848. * Time now
  132849. */
  132850. currentTime: number;
  132851. /**
  132852. * Time passed since started
  132853. */
  132854. deltaTime: number;
  132855. /**
  132856. * How much is completed, in [0.0...1.0].
  132857. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  132858. */
  132859. completeRate: number;
  132860. /**
  132861. * What the registered observable sent in the last count
  132862. */
  132863. payload: T;
  132864. }
  132865. /**
  132866. * The current state of the timer
  132867. */
  132868. export enum TimerState {
  132869. /**
  132870. * Timer initialized, not yet started
  132871. */
  132872. INIT = 0,
  132873. /**
  132874. * Timer started and counting
  132875. */
  132876. STARTED = 1,
  132877. /**
  132878. * Timer ended (whether aborted or time reached)
  132879. */
  132880. ENDED = 2
  132881. }
  132882. /**
  132883. * A simple version of the timer. Will take options and start the timer immediately after calling it
  132884. *
  132885. * @param options options with which to initialize this timer
  132886. */
  132887. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  132888. /**
  132889. * An advanced implementation of a timer class
  132890. */
  132891. export class AdvancedTimer<T = any> implements IDisposable {
  132892. /**
  132893. * Will notify each time the timer calculates the remaining time
  132894. */
  132895. onEachCountObservable: Observable<ITimerData<T>>;
  132896. /**
  132897. * Will trigger when the timer was aborted due to the break condition
  132898. */
  132899. onTimerAbortedObservable: Observable<ITimerData<T>>;
  132900. /**
  132901. * Will trigger when the timer ended successfully
  132902. */
  132903. onTimerEndedObservable: Observable<ITimerData<T>>;
  132904. /**
  132905. * Will trigger when the timer state has changed
  132906. */
  132907. onStateChangedObservable: Observable<TimerState>;
  132908. private _observer;
  132909. private _contextObservable;
  132910. private _observableParameters;
  132911. private _startTime;
  132912. private _timer;
  132913. private _state;
  132914. private _breakCondition;
  132915. private _timeToEnd;
  132916. private _breakOnNextTick;
  132917. /**
  132918. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  132919. * @param options construction options for this advanced timer
  132920. */
  132921. constructor(options: ITimerOptions<T>);
  132922. /**
  132923. * set a breaking condition for this timer. Default is to never break during count
  132924. * @param predicate the new break condition. Returns true to break, false otherwise
  132925. */
  132926. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  132927. /**
  132928. * Reset ALL associated observables in this advanced timer
  132929. */
  132930. clearObservables(): void;
  132931. /**
  132932. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  132933. *
  132934. * @param timeToEnd how much time to measure until timer ended
  132935. */
  132936. start(timeToEnd?: number): void;
  132937. /**
  132938. * Will force a stop on the next tick.
  132939. */
  132940. stop(): void;
  132941. /**
  132942. * Dispose this timer, clearing all resources
  132943. */
  132944. dispose(): void;
  132945. private _setState;
  132946. private _tick;
  132947. private _stop;
  132948. }
  132949. }
  132950. declare module BABYLON {
  132951. /**
  132952. * The options container for the teleportation module
  132953. */
  132954. export interface IWebXRTeleportationOptions {
  132955. /**
  132956. * if provided, this scene will be used to render meshes.
  132957. */
  132958. customUtilityLayerScene?: Scene;
  132959. /**
  132960. * Values to configure the default target mesh
  132961. */
  132962. defaultTargetMeshOptions?: {
  132963. /**
  132964. * Fill color of the teleportation area
  132965. */
  132966. teleportationFillColor?: string;
  132967. /**
  132968. * Border color for the teleportation area
  132969. */
  132970. teleportationBorderColor?: string;
  132971. /**
  132972. * Disable the mesh's animation sequence
  132973. */
  132974. disableAnimation?: boolean;
  132975. /**
  132976. * Disable lighting on the material or the ring and arrow
  132977. */
  132978. disableLighting?: boolean;
  132979. /**
  132980. * Override the default material of the torus and arrow
  132981. */
  132982. torusArrowMaterial?: Material;
  132983. };
  132984. /**
  132985. * A list of meshes to use as floor meshes.
  132986. * Meshes can be added and removed after initializing the feature using the
  132987. * addFloorMesh and removeFloorMesh functions
  132988. * If empty, rotation will still work
  132989. */
  132990. floorMeshes?: AbstractMesh[];
  132991. /**
  132992. * use this rendering group id for the meshes (optional)
  132993. */
  132994. renderingGroupId?: number;
  132995. /**
  132996. * Should teleportation move only to snap points
  132997. */
  132998. snapPointsOnly?: boolean;
  132999. /**
  133000. * An array of points to which the teleportation will snap to.
  133001. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133002. */
  133003. snapPositions?: Vector3[];
  133004. /**
  133005. * How close should the teleportation ray be in order to snap to position.
  133006. * Default to 0.8 units (meters)
  133007. */
  133008. snapToPositionRadius?: number;
  133009. /**
  133010. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133011. * If you want to support rotation, make sure your mesh has a direction indicator.
  133012. *
  133013. * When left untouched, the default mesh will be initialized.
  133014. */
  133015. teleportationTargetMesh?: AbstractMesh;
  133016. /**
  133017. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133018. */
  133019. timeToTeleport?: number;
  133020. /**
  133021. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133022. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133023. */
  133024. useMainComponentOnly?: boolean;
  133025. /**
  133026. * Should meshes created here be added to a utility layer or the main scene
  133027. */
  133028. useUtilityLayer?: boolean;
  133029. /**
  133030. * Babylon XR Input class for controller
  133031. */
  133032. xrInput: WebXRInput;
  133033. /**
  133034. * Meshes that the teleportation ray cannot go through
  133035. */
  133036. pickBlockerMeshes?: AbstractMesh[];
  133037. }
  133038. /**
  133039. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133040. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133041. * the input of the attached controllers.
  133042. */
  133043. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133044. private _options;
  133045. private _controllers;
  133046. private _currentTeleportationControllerId;
  133047. private _floorMeshes;
  133048. private _quadraticBezierCurve;
  133049. private _selectionFeature;
  133050. private _snapToPositions;
  133051. private _snappedToPoint;
  133052. private _teleportationRingMaterial?;
  133053. private _tmpRay;
  133054. private _tmpVector;
  133055. private _tmpQuaternion;
  133056. /**
  133057. * The module's name
  133058. */
  133059. static readonly Name: string;
  133060. /**
  133061. * The (Babylon) version of this module.
  133062. * This is an integer representing the implementation version.
  133063. * This number does not correspond to the webxr specs version
  133064. */
  133065. static readonly Version: number;
  133066. /**
  133067. * Is movement backwards enabled
  133068. */
  133069. backwardsMovementEnabled: boolean;
  133070. /**
  133071. * Distance to travel when moving backwards
  133072. */
  133073. backwardsTeleportationDistance: number;
  133074. /**
  133075. * The distance from the user to the inspection point in the direction of the controller
  133076. * A higher number will allow the user to move further
  133077. * defaults to 5 (meters, in xr units)
  133078. */
  133079. parabolicCheckRadius: number;
  133080. /**
  133081. * Should the module support parabolic ray on top of direct ray
  133082. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133083. * Very helpful when moving between floors / different heights
  133084. */
  133085. parabolicRayEnabled: boolean;
  133086. /**
  133087. * How much rotation should be applied when rotating right and left
  133088. */
  133089. rotationAngle: number;
  133090. /**
  133091. * Is rotation enabled when moving forward?
  133092. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133093. */
  133094. rotationEnabled: boolean;
  133095. /**
  133096. * constructs a new anchor system
  133097. * @param _xrSessionManager an instance of WebXRSessionManager
  133098. * @param _options configuration object for this feature
  133099. */
  133100. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133101. /**
  133102. * Get the snapPointsOnly flag
  133103. */
  133104. get snapPointsOnly(): boolean;
  133105. /**
  133106. * Sets the snapPointsOnly flag
  133107. * @param snapToPoints should teleportation be exclusively to snap points
  133108. */
  133109. set snapPointsOnly(snapToPoints: boolean);
  133110. /**
  133111. * Add a new mesh to the floor meshes array
  133112. * @param mesh the mesh to use as floor mesh
  133113. */
  133114. addFloorMesh(mesh: AbstractMesh): void;
  133115. /**
  133116. * Add a new snap-to point to fix teleportation to this position
  133117. * @param newSnapPoint The new Snap-To point
  133118. */
  133119. addSnapPoint(newSnapPoint: Vector3): void;
  133120. attach(): boolean;
  133121. detach(): boolean;
  133122. dispose(): void;
  133123. /**
  133124. * Remove a mesh from the floor meshes array
  133125. * @param mesh the mesh to remove
  133126. */
  133127. removeFloorMesh(mesh: AbstractMesh): void;
  133128. /**
  133129. * Remove a mesh from the floor meshes array using its name
  133130. * @param name the mesh name to remove
  133131. */
  133132. removeFloorMeshByName(name: string): void;
  133133. /**
  133134. * 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
  133135. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133136. * @returns was the point found and removed or not
  133137. */
  133138. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133139. /**
  133140. * This function sets a selection feature that will be disabled when
  133141. * the forward ray is shown and will be reattached when hidden.
  133142. * This is used to remove the selection rays when moving.
  133143. * @param selectionFeature the feature to disable when forward movement is enabled
  133144. */
  133145. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133146. protected _onXRFrame(_xrFrame: XRFrame): void;
  133147. private _attachController;
  133148. private _createDefaultTargetMesh;
  133149. private _detachController;
  133150. private _findClosestSnapPointWithRadius;
  133151. private _setTargetMeshPosition;
  133152. private _setTargetMeshVisibility;
  133153. private _showParabolicPath;
  133154. private _teleportForward;
  133155. }
  133156. }
  133157. declare module BABYLON {
  133158. /**
  133159. * Options for the default xr helper
  133160. */
  133161. export class WebXRDefaultExperienceOptions {
  133162. /**
  133163. * Enable or disable default UI to enter XR
  133164. */
  133165. disableDefaultUI?: boolean;
  133166. /**
  133167. * Should teleportation not initialize. defaults to false.
  133168. */
  133169. disableTeleportation?: boolean;
  133170. /**
  133171. * Floor meshes that will be used for teleport
  133172. */
  133173. floorMeshes?: Array<AbstractMesh>;
  133174. /**
  133175. * If set to true, the first frame will not be used to reset position
  133176. * The first frame is mainly used when copying transformation from the old camera
  133177. * Mainly used in AR
  133178. */
  133179. ignoreNativeCameraTransformation?: boolean;
  133180. /**
  133181. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133182. */
  133183. inputOptions?: IWebXRInputOptions;
  133184. /**
  133185. * optional configuration for the output canvas
  133186. */
  133187. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133188. /**
  133189. * optional UI options. This can be used among other to change session mode and reference space type
  133190. */
  133191. uiOptions?: WebXREnterExitUIOptions;
  133192. /**
  133193. * When loading teleportation and pointer select, use stable versions instead of latest.
  133194. */
  133195. useStablePlugins?: boolean;
  133196. /**
  133197. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133198. */
  133199. renderingGroupId?: number;
  133200. /**
  133201. * A list of optional features to init the session with
  133202. * If set to true, all features we support will be added
  133203. */
  133204. optionalFeatures?: boolean | string[];
  133205. }
  133206. /**
  133207. * Default experience which provides a similar setup to the previous webVRExperience
  133208. */
  133209. export class WebXRDefaultExperience {
  133210. /**
  133211. * Base experience
  133212. */
  133213. baseExperience: WebXRExperienceHelper;
  133214. /**
  133215. * Enables ui for entering/exiting xr
  133216. */
  133217. enterExitUI: WebXREnterExitUI;
  133218. /**
  133219. * Input experience extension
  133220. */
  133221. input: WebXRInput;
  133222. /**
  133223. * Enables laser pointer and selection
  133224. */
  133225. pointerSelection: WebXRControllerPointerSelection;
  133226. /**
  133227. * Default target xr should render to
  133228. */
  133229. renderTarget: WebXRRenderTarget;
  133230. /**
  133231. * Enables teleportation
  133232. */
  133233. teleportation: WebXRMotionControllerTeleportation;
  133234. private constructor();
  133235. /**
  133236. * Creates the default xr experience
  133237. * @param scene scene
  133238. * @param options options for basic configuration
  133239. * @returns resulting WebXRDefaultExperience
  133240. */
  133241. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133242. /**
  133243. * DIsposes of the experience helper
  133244. */
  133245. dispose(): void;
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /**
  133250. * Options to modify the vr teleportation behavior.
  133251. */
  133252. export interface VRTeleportationOptions {
  133253. /**
  133254. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133255. */
  133256. floorMeshName?: string;
  133257. /**
  133258. * A list of meshes to be used as the teleportation floor. (default: empty)
  133259. */
  133260. floorMeshes?: Mesh[];
  133261. /**
  133262. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133263. */
  133264. teleportationMode?: number;
  133265. /**
  133266. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133267. */
  133268. teleportationTime?: number;
  133269. /**
  133270. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133271. */
  133272. teleportationSpeed?: number;
  133273. /**
  133274. * The easing function used in the animation or null for Linear. (default CircleEase)
  133275. */
  133276. easingFunction?: EasingFunction;
  133277. }
  133278. /**
  133279. * Options to modify the vr experience helper's behavior.
  133280. */
  133281. export interface VRExperienceHelperOptions extends WebVROptions {
  133282. /**
  133283. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133284. */
  133285. createDeviceOrientationCamera?: boolean;
  133286. /**
  133287. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133288. */
  133289. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133290. /**
  133291. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133292. */
  133293. laserToggle?: boolean;
  133294. /**
  133295. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133296. */
  133297. floorMeshes?: Mesh[];
  133298. /**
  133299. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133300. */
  133301. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133302. /**
  133303. * Defines if WebXR should be used instead of WebVR (if available)
  133304. */
  133305. useXR?: boolean;
  133306. }
  133307. /**
  133308. * Event containing information after VR has been entered
  133309. */
  133310. export class OnAfterEnteringVRObservableEvent {
  133311. /**
  133312. * If entering vr was successful
  133313. */
  133314. success: boolean;
  133315. }
  133316. /**
  133317. * Helps to quickly add VR support to an existing scene.
  133318. * See https://doc.babylonjs.com/how_to/webvr_helper
  133319. */
  133320. export class VRExperienceHelper {
  133321. /** Options to modify the vr experience helper's behavior. */
  133322. webVROptions: VRExperienceHelperOptions;
  133323. private _scene;
  133324. private _position;
  133325. private _btnVR;
  133326. private _btnVRDisplayed;
  133327. private _webVRsupported;
  133328. private _webVRready;
  133329. private _webVRrequesting;
  133330. private _webVRpresenting;
  133331. private _hasEnteredVR;
  133332. private _fullscreenVRpresenting;
  133333. private _inputElement;
  133334. private _webVRCamera;
  133335. private _vrDeviceOrientationCamera;
  133336. private _deviceOrientationCamera;
  133337. private _existingCamera;
  133338. private _onKeyDown;
  133339. private _onVrDisplayPresentChange;
  133340. private _onVRDisplayChanged;
  133341. private _onVRRequestPresentStart;
  133342. private _onVRRequestPresentComplete;
  133343. /**
  133344. * 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)
  133345. */
  133346. enableGazeEvenWhenNoPointerLock: boolean;
  133347. /**
  133348. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133349. */
  133350. exitVROnDoubleTap: boolean;
  133351. /**
  133352. * Observable raised right before entering VR.
  133353. */
  133354. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133355. /**
  133356. * Observable raised when entering VR has completed.
  133357. */
  133358. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133359. /**
  133360. * Observable raised when exiting VR.
  133361. */
  133362. onExitingVRObservable: Observable<VRExperienceHelper>;
  133363. /**
  133364. * Observable raised when controller mesh is loaded.
  133365. */
  133366. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133367. /** Return this.onEnteringVRObservable
  133368. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133369. */
  133370. get onEnteringVR(): Observable<VRExperienceHelper>;
  133371. /** Return this.onExitingVRObservable
  133372. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133373. */
  133374. get onExitingVR(): Observable<VRExperienceHelper>;
  133375. /** Return this.onControllerMeshLoadedObservable
  133376. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133377. */
  133378. get onControllerMeshLoaded(): Observable<WebVRController>;
  133379. private _rayLength;
  133380. private _useCustomVRButton;
  133381. private _teleportationRequested;
  133382. private _teleportActive;
  133383. private _floorMeshName;
  133384. private _floorMeshesCollection;
  133385. private _teleportationMode;
  133386. private _teleportationTime;
  133387. private _teleportationSpeed;
  133388. private _teleportationEasing;
  133389. private _rotationAllowed;
  133390. private _teleportBackwardsVector;
  133391. private _teleportationTarget;
  133392. private _isDefaultTeleportationTarget;
  133393. private _postProcessMove;
  133394. private _teleportationFillColor;
  133395. private _teleportationBorderColor;
  133396. private _rotationAngle;
  133397. private _haloCenter;
  133398. private _cameraGazer;
  133399. private _padSensibilityUp;
  133400. private _padSensibilityDown;
  133401. private _leftController;
  133402. private _rightController;
  133403. private _gazeColor;
  133404. private _laserColor;
  133405. private _pickedLaserColor;
  133406. private _pickedGazeColor;
  133407. /**
  133408. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133409. */
  133410. onNewMeshSelected: Observable<AbstractMesh>;
  133411. /**
  133412. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133413. * This observable will provide the mesh and the controller used to select the mesh
  133414. */
  133415. onMeshSelectedWithController: Observable<{
  133416. mesh: AbstractMesh;
  133417. controller: WebVRController;
  133418. }>;
  133419. /**
  133420. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133421. */
  133422. onNewMeshPicked: Observable<PickingInfo>;
  133423. private _circleEase;
  133424. /**
  133425. * Observable raised before camera teleportation
  133426. */
  133427. onBeforeCameraTeleport: Observable<Vector3>;
  133428. /**
  133429. * Observable raised after camera teleportation
  133430. */
  133431. onAfterCameraTeleport: Observable<Vector3>;
  133432. /**
  133433. * Observable raised when current selected mesh gets unselected
  133434. */
  133435. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133436. private _raySelectionPredicate;
  133437. /**
  133438. * To be optionaly changed by user to define custom ray selection
  133439. */
  133440. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133441. /**
  133442. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133443. */
  133444. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133445. /**
  133446. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133447. */
  133448. teleportationEnabled: boolean;
  133449. private _defaultHeight;
  133450. private _teleportationInitialized;
  133451. private _interactionsEnabled;
  133452. private _interactionsRequested;
  133453. private _displayGaze;
  133454. private _displayLaserPointer;
  133455. /**
  133456. * The mesh used to display where the user is going to teleport.
  133457. */
  133458. get teleportationTarget(): Mesh;
  133459. /**
  133460. * Sets the mesh to be used to display where the user is going to teleport.
  133461. */
  133462. set teleportationTarget(value: Mesh);
  133463. /**
  133464. * 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
  133465. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133466. * See https://doc.babylonjs.com/resources/baking_transformations
  133467. */
  133468. get gazeTrackerMesh(): Mesh;
  133469. set gazeTrackerMesh(value: Mesh);
  133470. /**
  133471. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133472. */
  133473. updateGazeTrackerScale: boolean;
  133474. /**
  133475. * If the gaze trackers color should be updated when selecting meshes
  133476. */
  133477. updateGazeTrackerColor: boolean;
  133478. /**
  133479. * If the controller laser color should be updated when selecting meshes
  133480. */
  133481. updateControllerLaserColor: boolean;
  133482. /**
  133483. * The gaze tracking mesh corresponding to the left controller
  133484. */
  133485. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133486. /**
  133487. * The gaze tracking mesh corresponding to the right controller
  133488. */
  133489. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133490. /**
  133491. * If the ray of the gaze should be displayed.
  133492. */
  133493. get displayGaze(): boolean;
  133494. /**
  133495. * Sets if the ray of the gaze should be displayed.
  133496. */
  133497. set displayGaze(value: boolean);
  133498. /**
  133499. * If the ray of the LaserPointer should be displayed.
  133500. */
  133501. get displayLaserPointer(): boolean;
  133502. /**
  133503. * Sets if the ray of the LaserPointer should be displayed.
  133504. */
  133505. set displayLaserPointer(value: boolean);
  133506. /**
  133507. * The deviceOrientationCamera used as the camera when not in VR.
  133508. */
  133509. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133510. /**
  133511. * Based on the current WebVR support, returns the current VR camera used.
  133512. */
  133513. get currentVRCamera(): Nullable<Camera>;
  133514. /**
  133515. * The webVRCamera which is used when in VR.
  133516. */
  133517. get webVRCamera(): WebVRFreeCamera;
  133518. /**
  133519. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133520. */
  133521. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133522. /**
  133523. * The html button that is used to trigger entering into VR.
  133524. */
  133525. get vrButton(): Nullable<HTMLButtonElement>;
  133526. private get _teleportationRequestInitiated();
  133527. /**
  133528. * Defines whether or not Pointer lock should be requested when switching to
  133529. * full screen.
  133530. */
  133531. requestPointerLockOnFullScreen: boolean;
  133532. /**
  133533. * If asking to force XR, this will be populated with the default xr experience
  133534. */
  133535. xr: WebXRDefaultExperience;
  133536. /**
  133537. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133538. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133539. */
  133540. xrTestDone: boolean;
  133541. /**
  133542. * Instantiates a VRExperienceHelper.
  133543. * Helps to quickly add VR support to an existing scene.
  133544. * @param scene The scene the VRExperienceHelper belongs to.
  133545. * @param webVROptions Options to modify the vr experience helper's behavior.
  133546. */
  133547. constructor(scene: Scene,
  133548. /** Options to modify the vr experience helper's behavior. */
  133549. webVROptions?: VRExperienceHelperOptions);
  133550. private completeVRInit;
  133551. private _onDefaultMeshLoaded;
  133552. private _onResize;
  133553. private _onFullscreenChange;
  133554. /**
  133555. * Gets a value indicating if we are currently in VR mode.
  133556. */
  133557. get isInVRMode(): boolean;
  133558. private onVrDisplayPresentChange;
  133559. private onVRDisplayChanged;
  133560. private moveButtonToBottomRight;
  133561. private displayVRButton;
  133562. private updateButtonVisibility;
  133563. private _cachedAngularSensibility;
  133564. /**
  133565. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133566. * Otherwise, will use the fullscreen API.
  133567. */
  133568. enterVR(): void;
  133569. /**
  133570. * Attempt to exit VR, or fullscreen.
  133571. */
  133572. exitVR(): void;
  133573. /**
  133574. * The position of the vr experience helper.
  133575. */
  133576. get position(): Vector3;
  133577. /**
  133578. * Sets the position of the vr experience helper.
  133579. */
  133580. set position(value: Vector3);
  133581. /**
  133582. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133583. */
  133584. enableInteractions(): void;
  133585. private get _noControllerIsActive();
  133586. private beforeRender;
  133587. private _isTeleportationFloor;
  133588. /**
  133589. * Adds a floor mesh to be used for teleportation.
  133590. * @param floorMesh the mesh to be used for teleportation.
  133591. */
  133592. addFloorMesh(floorMesh: Mesh): void;
  133593. /**
  133594. * Removes a floor mesh from being used for teleportation.
  133595. * @param floorMesh the mesh to be removed.
  133596. */
  133597. removeFloorMesh(floorMesh: Mesh): void;
  133598. /**
  133599. * Enables interactions and teleportation using the VR controllers and gaze.
  133600. * @param vrTeleportationOptions options to modify teleportation behavior.
  133601. */
  133602. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133603. private _onNewGamepadConnected;
  133604. private _tryEnableInteractionOnController;
  133605. private _onNewGamepadDisconnected;
  133606. private _enableInteractionOnController;
  133607. private _checkTeleportWithRay;
  133608. private _checkRotate;
  133609. private _checkTeleportBackwards;
  133610. private _enableTeleportationOnController;
  133611. private _createTeleportationCircles;
  133612. private _displayTeleportationTarget;
  133613. private _hideTeleportationTarget;
  133614. private _rotateCamera;
  133615. private _moveTeleportationSelectorTo;
  133616. private _workingVector;
  133617. private _workingQuaternion;
  133618. private _workingMatrix;
  133619. /**
  133620. * Time Constant Teleportation Mode
  133621. */
  133622. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133623. /**
  133624. * Speed Constant Teleportation Mode
  133625. */
  133626. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133627. /**
  133628. * Teleports the users feet to the desired location
  133629. * @param location The location where the user's feet should be placed
  133630. */
  133631. teleportCamera(location: Vector3): void;
  133632. private _convertNormalToDirectionOfRay;
  133633. private _castRayAndSelectObject;
  133634. private _notifySelectedMeshUnselected;
  133635. /**
  133636. * Permanently set new colors for the laser pointer
  133637. * @param color the new laser color
  133638. * @param pickedColor the new laser color when picked mesh detected
  133639. */
  133640. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133641. /**
  133642. * Set lighting enabled / disabled on the laser pointer of both controllers
  133643. * @param enabled should the lighting be enabled on the laser pointer
  133644. */
  133645. setLaserLightingState(enabled?: boolean): void;
  133646. /**
  133647. * Permanently set new colors for the gaze pointer
  133648. * @param color the new gaze color
  133649. * @param pickedColor the new gaze color when picked mesh detected
  133650. */
  133651. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133652. /**
  133653. * Sets the color of the laser ray from the vr controllers.
  133654. * @param color new color for the ray.
  133655. */
  133656. changeLaserColor(color: Color3): void;
  133657. /**
  133658. * Sets the color of the ray from the vr headsets gaze.
  133659. * @param color new color for the ray.
  133660. */
  133661. changeGazeColor(color: Color3): void;
  133662. /**
  133663. * Exits VR and disposes of the vr experience helper
  133664. */
  133665. dispose(): void;
  133666. /**
  133667. * Gets the name of the VRExperienceHelper class
  133668. * @returns "VRExperienceHelper"
  133669. */
  133670. getClassName(): string;
  133671. }
  133672. }
  133673. declare module BABYLON {
  133674. /**
  133675. * Contains an array of blocks representing the octree
  133676. */
  133677. export interface IOctreeContainer<T> {
  133678. /**
  133679. * Blocks within the octree
  133680. */
  133681. blocks: Array<OctreeBlock<T>>;
  133682. }
  133683. /**
  133684. * Class used to store a cell in an octree
  133685. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133686. */
  133687. export class OctreeBlock<T> {
  133688. /**
  133689. * Gets the content of the current block
  133690. */
  133691. entries: T[];
  133692. /**
  133693. * Gets the list of block children
  133694. */
  133695. blocks: Array<OctreeBlock<T>>;
  133696. private _depth;
  133697. private _maxDepth;
  133698. private _capacity;
  133699. private _minPoint;
  133700. private _maxPoint;
  133701. private _boundingVectors;
  133702. private _creationFunc;
  133703. /**
  133704. * Creates a new block
  133705. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133706. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133707. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133708. * @param depth defines the current depth of this block in the octree
  133709. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133710. * @param creationFunc defines a callback to call when an element is added to the block
  133711. */
  133712. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133713. /**
  133714. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133715. */
  133716. get capacity(): number;
  133717. /**
  133718. * Gets the minimum vector (in world space) of the block's bounding box
  133719. */
  133720. get minPoint(): Vector3;
  133721. /**
  133722. * Gets the maximum vector (in world space) of the block's bounding box
  133723. */
  133724. get maxPoint(): Vector3;
  133725. /**
  133726. * Add a new element to this block
  133727. * @param entry defines the element to add
  133728. */
  133729. addEntry(entry: T): void;
  133730. /**
  133731. * Remove an element from this block
  133732. * @param entry defines the element to remove
  133733. */
  133734. removeEntry(entry: T): void;
  133735. /**
  133736. * Add an array of elements to this block
  133737. * @param entries defines the array of elements to add
  133738. */
  133739. addEntries(entries: T[]): void;
  133740. /**
  133741. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133742. * @param frustumPlanes defines the frustum planes to test
  133743. * @param selection defines the array to store current content if selection is positive
  133744. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133745. */
  133746. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133747. /**
  133748. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133749. * @param sphereCenter defines the bounding sphere center
  133750. * @param sphereRadius defines the bounding sphere radius
  133751. * @param selection defines the array to store current content if selection is positive
  133752. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133753. */
  133754. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133755. /**
  133756. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  133757. * @param ray defines the ray to test with
  133758. * @param selection defines the array to store current content if selection is positive
  133759. */
  133760. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  133761. /**
  133762. * Subdivide the content into child blocks (this block will then be empty)
  133763. */
  133764. createInnerBlocks(): void;
  133765. /**
  133766. * @hidden
  133767. */
  133768. 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;
  133769. }
  133770. }
  133771. declare module BABYLON {
  133772. /**
  133773. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  133774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133775. */
  133776. export class Octree<T> {
  133777. /** 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.) */
  133778. maxDepth: number;
  133779. /**
  133780. * Blocks within the octree containing objects
  133781. */
  133782. blocks: Array<OctreeBlock<T>>;
  133783. /**
  133784. * Content stored in the octree
  133785. */
  133786. dynamicContent: T[];
  133787. private _maxBlockCapacity;
  133788. private _selectionContent;
  133789. private _creationFunc;
  133790. /**
  133791. * Creates a octree
  133792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133793. * @param creationFunc function to be used to instatiate the octree
  133794. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  133795. * @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.)
  133796. */
  133797. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  133798. /** 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.) */
  133799. maxDepth?: number);
  133800. /**
  133801. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  133802. * @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);
  133803. * @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);
  133804. * @param entries meshes to be added to the octree blocks
  133805. */
  133806. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  133807. /**
  133808. * Adds a mesh to the octree
  133809. * @param entry Mesh to add to the octree
  133810. */
  133811. addMesh(entry: T): void;
  133812. /**
  133813. * Remove an element from the octree
  133814. * @param entry defines the element to remove
  133815. */
  133816. removeMesh(entry: T): void;
  133817. /**
  133818. * Selects an array of meshes within the frustum
  133819. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  133820. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  133821. * @returns array of meshes within the frustum
  133822. */
  133823. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  133824. /**
  133825. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  133826. * @param sphereCenter defines the bounding sphere center
  133827. * @param sphereRadius defines the bounding sphere radius
  133828. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133829. * @returns an array of objects that intersect the sphere
  133830. */
  133831. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  133832. /**
  133833. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  133834. * @param ray defines the ray to test with
  133835. * @returns array of intersected objects
  133836. */
  133837. intersectsRay(ray: Ray): SmartArray<T>;
  133838. /**
  133839. * Adds a mesh into the octree block if it intersects the block
  133840. */
  133841. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  133842. /**
  133843. * Adds a submesh into the octree block if it intersects the block
  133844. */
  133845. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  133846. }
  133847. }
  133848. declare module BABYLON {
  133849. interface Scene {
  133850. /**
  133851. * @hidden
  133852. * Backing Filed
  133853. */
  133854. _selectionOctree: Octree<AbstractMesh>;
  133855. /**
  133856. * Gets the octree used to boost mesh selection (picking)
  133857. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133858. */
  133859. selectionOctree: Octree<AbstractMesh>;
  133860. /**
  133861. * Creates or updates the octree used to boost selection (picking)
  133862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133863. * @param maxCapacity defines the maximum capacity per leaf
  133864. * @param maxDepth defines the maximum depth of the octree
  133865. * @returns an octree of AbstractMesh
  133866. */
  133867. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  133868. }
  133869. interface AbstractMesh {
  133870. /**
  133871. * @hidden
  133872. * Backing Field
  133873. */
  133874. _submeshesOctree: Octree<SubMesh>;
  133875. /**
  133876. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  133877. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  133878. * @param maxCapacity defines the maximum size of each block (64 by default)
  133879. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  133880. * @returns the new octree
  133881. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  133882. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133883. */
  133884. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  133885. }
  133886. /**
  133887. * Defines the octree scene component responsible to manage any octrees
  133888. * in a given scene.
  133889. */
  133890. export class OctreeSceneComponent {
  133891. /**
  133892. * The component name help to identify the component in the list of scene components.
  133893. */
  133894. readonly name: string;
  133895. /**
  133896. * The scene the component belongs to.
  133897. */
  133898. scene: Scene;
  133899. /**
  133900. * Indicates if the meshes have been checked to make sure they are isEnabled()
  133901. */
  133902. readonly checksIsEnabled: boolean;
  133903. /**
  133904. * Creates a new instance of the component for the given scene
  133905. * @param scene Defines the scene to register the component in
  133906. */
  133907. constructor(scene: Scene);
  133908. /**
  133909. * Registers the component in a given scene
  133910. */
  133911. register(): void;
  133912. /**
  133913. * Return the list of active meshes
  133914. * @returns the list of active meshes
  133915. */
  133916. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  133917. /**
  133918. * Return the list of active sub meshes
  133919. * @param mesh The mesh to get the candidates sub meshes from
  133920. * @returns the list of active sub meshes
  133921. */
  133922. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  133923. private _tempRay;
  133924. /**
  133925. * Return the list of sub meshes intersecting with a given local ray
  133926. * @param mesh defines the mesh to find the submesh for
  133927. * @param localRay defines the ray in local space
  133928. * @returns the list of intersecting sub meshes
  133929. */
  133930. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  133931. /**
  133932. * Return the list of sub meshes colliding with a collider
  133933. * @param mesh defines the mesh to find the submesh for
  133934. * @param collider defines the collider to evaluate the collision against
  133935. * @returns the list of colliding sub meshes
  133936. */
  133937. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  133938. /**
  133939. * Rebuilds the elements related to this component in case of
  133940. * context lost for instance.
  133941. */
  133942. rebuild(): void;
  133943. /**
  133944. * Disposes the component and the associated ressources.
  133945. */
  133946. dispose(): void;
  133947. }
  133948. }
  133949. declare module BABYLON {
  133950. /**
  133951. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  133952. */
  133953. export class Gizmo implements IDisposable {
  133954. /** The utility layer the gizmo will be added to */
  133955. gizmoLayer: UtilityLayerRenderer;
  133956. /**
  133957. * The root mesh of the gizmo
  133958. */
  133959. _rootMesh: Mesh;
  133960. private _attachedMesh;
  133961. private _attachedNode;
  133962. /**
  133963. * Ratio for the scale of the gizmo (Default: 1)
  133964. */
  133965. protected _scaleRatio: number;
  133966. /**
  133967. * boolean updated by pointermove when a gizmo mesh is hovered
  133968. */
  133969. protected _isHovered: boolean;
  133970. /**
  133971. * Ratio for the scale of the gizmo (Default: 1)
  133972. */
  133973. set scaleRatio(value: number);
  133974. get scaleRatio(): number;
  133975. /**
  133976. * True when the mouse pointer is hovered a gizmo mesh
  133977. */
  133978. get isHovered(): boolean;
  133979. /**
  133980. * If a custom mesh has been set (Default: false)
  133981. */
  133982. protected _customMeshSet: boolean;
  133983. /**
  133984. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  133985. * * When set, interactions will be enabled
  133986. */
  133987. get attachedMesh(): Nullable<AbstractMesh>;
  133988. set attachedMesh(value: Nullable<AbstractMesh>);
  133989. /**
  133990. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  133991. * * When set, interactions will be enabled
  133992. */
  133993. get attachedNode(): Nullable<Node>;
  133994. set attachedNode(value: Nullable<Node>);
  133995. /**
  133996. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133997. * @param mesh The mesh to replace the default mesh of the gizmo
  133998. */
  133999. setCustomMesh(mesh: Mesh): void;
  134000. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134001. /**
  134002. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134003. */
  134004. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134005. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134006. /**
  134007. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134008. */
  134009. updateGizmoPositionToMatchAttachedMesh: boolean;
  134010. /**
  134011. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134012. */
  134013. updateScale: boolean;
  134014. protected _interactionsEnabled: boolean;
  134015. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134016. private _beforeRenderObserver;
  134017. private _tempQuaternion;
  134018. private _tempVector;
  134019. private _tempVector2;
  134020. private _tempMatrix1;
  134021. private _tempMatrix2;
  134022. private _rightHandtoLeftHandMatrix;
  134023. /**
  134024. * Creates a gizmo
  134025. * @param gizmoLayer The utility layer the gizmo will be added to
  134026. */
  134027. constructor(
  134028. /** The utility layer the gizmo will be added to */
  134029. gizmoLayer?: UtilityLayerRenderer);
  134030. /**
  134031. * Updates the gizmo to match the attached mesh's position/rotation
  134032. */
  134033. protected _update(): void;
  134034. /**
  134035. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134036. * @param value Node, TransformNode or mesh
  134037. */
  134038. protected _matrixChanged(): void;
  134039. /**
  134040. * Disposes of the gizmo
  134041. */
  134042. dispose(): void;
  134043. }
  134044. }
  134045. declare module BABYLON {
  134046. /**
  134047. * Single plane drag gizmo
  134048. */
  134049. export class PlaneDragGizmo extends Gizmo {
  134050. /**
  134051. * Drag behavior responsible for the gizmos dragging interactions
  134052. */
  134053. dragBehavior: PointerDragBehavior;
  134054. private _pointerObserver;
  134055. /**
  134056. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134057. */
  134058. snapDistance: number;
  134059. /**
  134060. * Event that fires each time the gizmo snaps to a new location.
  134061. * * snapDistance is the the change in distance
  134062. */
  134063. onSnapObservable: Observable<{
  134064. snapDistance: number;
  134065. }>;
  134066. private _plane;
  134067. private _coloredMaterial;
  134068. private _hoverMaterial;
  134069. private _isEnabled;
  134070. private _parent;
  134071. /** @hidden */
  134072. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134073. /** @hidden */
  134074. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134075. /**
  134076. * Creates a PlaneDragGizmo
  134077. * @param gizmoLayer The utility layer the gizmo will be added to
  134078. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134079. * @param color The color of the gizmo
  134080. */
  134081. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134082. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134083. /**
  134084. * If the gizmo is enabled
  134085. */
  134086. set isEnabled(value: boolean);
  134087. get isEnabled(): boolean;
  134088. /**
  134089. * Disposes of the gizmo
  134090. */
  134091. dispose(): void;
  134092. }
  134093. }
  134094. declare module BABYLON {
  134095. /**
  134096. * Gizmo that enables dragging a mesh along 3 axis
  134097. */
  134098. export class PositionGizmo extends Gizmo {
  134099. /**
  134100. * Internal gizmo used for interactions on the x axis
  134101. */
  134102. xGizmo: AxisDragGizmo;
  134103. /**
  134104. * Internal gizmo used for interactions on the y axis
  134105. */
  134106. yGizmo: AxisDragGizmo;
  134107. /**
  134108. * Internal gizmo used for interactions on the z axis
  134109. */
  134110. zGizmo: AxisDragGizmo;
  134111. /**
  134112. * Internal gizmo used for interactions on the yz plane
  134113. */
  134114. xPlaneGizmo: PlaneDragGizmo;
  134115. /**
  134116. * Internal gizmo used for interactions on the xz plane
  134117. */
  134118. yPlaneGizmo: PlaneDragGizmo;
  134119. /**
  134120. * Internal gizmo used for interactions on the xy plane
  134121. */
  134122. zPlaneGizmo: PlaneDragGizmo;
  134123. /**
  134124. * private variables
  134125. */
  134126. private _meshAttached;
  134127. private _nodeAttached;
  134128. private _snapDistance;
  134129. /** Fires an event when any of it's sub gizmos are dragged */
  134130. onDragStartObservable: Observable<unknown>;
  134131. /** Fires an event when any of it's sub gizmos are released from dragging */
  134132. onDragEndObservable: Observable<unknown>;
  134133. /**
  134134. * If set to true, planar drag is enabled
  134135. */
  134136. private _planarGizmoEnabled;
  134137. get attachedMesh(): Nullable<AbstractMesh>;
  134138. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134139. get attachedNode(): Nullable<Node>;
  134140. set attachedNode(node: Nullable<Node>);
  134141. /**
  134142. * True when the mouse pointer is hovering a gizmo mesh
  134143. */
  134144. get isHovered(): boolean;
  134145. /**
  134146. * Creates a PositionGizmo
  134147. * @param gizmoLayer The utility layer the gizmo will be added to
  134148. @param thickness display gizmo axis thickness
  134149. */
  134150. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134151. /**
  134152. * If the planar drag gizmo is enabled
  134153. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134154. */
  134155. set planarGizmoEnabled(value: boolean);
  134156. get planarGizmoEnabled(): boolean;
  134157. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134158. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134159. /**
  134160. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134161. */
  134162. set snapDistance(value: number);
  134163. get snapDistance(): number;
  134164. /**
  134165. * Ratio for the scale of the gizmo (Default: 1)
  134166. */
  134167. set scaleRatio(value: number);
  134168. get scaleRatio(): number;
  134169. /**
  134170. * Disposes of the gizmo
  134171. */
  134172. dispose(): void;
  134173. /**
  134174. * CustomMeshes are not supported by this gizmo
  134175. * @param mesh The mesh to replace the default mesh of the gizmo
  134176. */
  134177. setCustomMesh(mesh: Mesh): void;
  134178. }
  134179. }
  134180. declare module BABYLON {
  134181. /**
  134182. * Single axis drag gizmo
  134183. */
  134184. export class AxisDragGizmo extends Gizmo {
  134185. /**
  134186. * Drag behavior responsible for the gizmos dragging interactions
  134187. */
  134188. dragBehavior: PointerDragBehavior;
  134189. private _pointerObserver;
  134190. /**
  134191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134192. */
  134193. snapDistance: number;
  134194. /**
  134195. * Event that fires each time the gizmo snaps to a new location.
  134196. * * snapDistance is the the change in distance
  134197. */
  134198. onSnapObservable: Observable<{
  134199. snapDistance: number;
  134200. }>;
  134201. private _isEnabled;
  134202. private _parent;
  134203. private _arrow;
  134204. private _coloredMaterial;
  134205. private _hoverMaterial;
  134206. /** @hidden */
  134207. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134208. /** @hidden */
  134209. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134210. /**
  134211. * Creates an AxisDragGizmo
  134212. * @param gizmoLayer The utility layer the gizmo will be added to
  134213. * @param dragAxis The axis which the gizmo will be able to drag on
  134214. * @param color The color of the gizmo
  134215. * @param thickness display gizmo axis thickness
  134216. */
  134217. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134218. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134219. /**
  134220. * If the gizmo is enabled
  134221. */
  134222. set isEnabled(value: boolean);
  134223. get isEnabled(): boolean;
  134224. /**
  134225. * Disposes of the gizmo
  134226. */
  134227. dispose(): void;
  134228. }
  134229. }
  134230. declare module BABYLON.Debug {
  134231. /**
  134232. * The Axes viewer will show 3 axes in a specific point in space
  134233. */
  134234. export class AxesViewer {
  134235. private _xAxis;
  134236. private _yAxis;
  134237. private _zAxis;
  134238. private _scaleLinesFactor;
  134239. private _instanced;
  134240. /**
  134241. * Gets the hosting scene
  134242. */
  134243. scene: Nullable<Scene>;
  134244. /**
  134245. * Gets or sets a number used to scale line length
  134246. */
  134247. scaleLines: number;
  134248. /** Gets the node hierarchy used to render x-axis */
  134249. get xAxis(): TransformNode;
  134250. /** Gets the node hierarchy used to render y-axis */
  134251. get yAxis(): TransformNode;
  134252. /** Gets the node hierarchy used to render z-axis */
  134253. get zAxis(): TransformNode;
  134254. /**
  134255. * Creates a new AxesViewer
  134256. * @param scene defines the hosting scene
  134257. * @param scaleLines defines a number used to scale line length (1 by default)
  134258. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134259. * @param xAxis defines the node hierarchy used to render the x-axis
  134260. * @param yAxis defines the node hierarchy used to render the y-axis
  134261. * @param zAxis defines the node hierarchy used to render the z-axis
  134262. */
  134263. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134264. /**
  134265. * Force the viewer to update
  134266. * @param position defines the position of the viewer
  134267. * @param xaxis defines the x axis of the viewer
  134268. * @param yaxis defines the y axis of the viewer
  134269. * @param zaxis defines the z axis of the viewer
  134270. */
  134271. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134272. /**
  134273. * Creates an instance of this axes viewer.
  134274. * @returns a new axes viewer with instanced meshes
  134275. */
  134276. createInstance(): AxesViewer;
  134277. /** Releases resources */
  134278. dispose(): void;
  134279. private static _SetRenderingGroupId;
  134280. }
  134281. }
  134282. declare module BABYLON.Debug {
  134283. /**
  134284. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134285. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134286. */
  134287. export class BoneAxesViewer extends AxesViewer {
  134288. /**
  134289. * Gets or sets the target mesh where to display the axes viewer
  134290. */
  134291. mesh: Nullable<Mesh>;
  134292. /**
  134293. * Gets or sets the target bone where to display the axes viewer
  134294. */
  134295. bone: Nullable<Bone>;
  134296. /** Gets current position */
  134297. pos: Vector3;
  134298. /** Gets direction of X axis */
  134299. xaxis: Vector3;
  134300. /** Gets direction of Y axis */
  134301. yaxis: Vector3;
  134302. /** Gets direction of Z axis */
  134303. zaxis: Vector3;
  134304. /**
  134305. * Creates a new BoneAxesViewer
  134306. * @param scene defines the hosting scene
  134307. * @param bone defines the target bone
  134308. * @param mesh defines the target mesh
  134309. * @param scaleLines defines a scaling factor for line length (1 by default)
  134310. */
  134311. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134312. /**
  134313. * Force the viewer to update
  134314. */
  134315. update(): void;
  134316. /** Releases resources */
  134317. dispose(): void;
  134318. }
  134319. }
  134320. declare module BABYLON {
  134321. /**
  134322. * Interface used to define scene explorer extensibility option
  134323. */
  134324. export interface IExplorerExtensibilityOption {
  134325. /**
  134326. * Define the option label
  134327. */
  134328. label: string;
  134329. /**
  134330. * Defines the action to execute on click
  134331. */
  134332. action: (entity: any) => void;
  134333. }
  134334. /**
  134335. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134336. */
  134337. export interface IExplorerExtensibilityGroup {
  134338. /**
  134339. * Defines a predicate to test if a given type mut be extended
  134340. */
  134341. predicate: (entity: any) => boolean;
  134342. /**
  134343. * Gets the list of options added to a type
  134344. */
  134345. entries: IExplorerExtensibilityOption[];
  134346. }
  134347. /**
  134348. * Interface used to define the options to use to create the Inspector
  134349. */
  134350. export interface IInspectorOptions {
  134351. /**
  134352. * Display in overlay mode (default: false)
  134353. */
  134354. overlay?: boolean;
  134355. /**
  134356. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134357. */
  134358. globalRoot?: HTMLElement;
  134359. /**
  134360. * Display the Scene explorer
  134361. */
  134362. showExplorer?: boolean;
  134363. /**
  134364. * Display the property inspector
  134365. */
  134366. showInspector?: boolean;
  134367. /**
  134368. * Display in embed mode (both panes on the right)
  134369. */
  134370. embedMode?: boolean;
  134371. /**
  134372. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134373. */
  134374. handleResize?: boolean;
  134375. /**
  134376. * Allow the panes to popup (default: true)
  134377. */
  134378. enablePopup?: boolean;
  134379. /**
  134380. * Allow the panes to be closed by users (default: true)
  134381. */
  134382. enableClose?: boolean;
  134383. /**
  134384. * Optional list of extensibility entries
  134385. */
  134386. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134387. /**
  134388. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134389. */
  134390. inspectorURL?: string;
  134391. /**
  134392. * Optional initial tab (default to DebugLayerTab.Properties)
  134393. */
  134394. initialTab?: DebugLayerTab;
  134395. }
  134396. interface Scene {
  134397. /**
  134398. * @hidden
  134399. * Backing field
  134400. */
  134401. _debugLayer: DebugLayer;
  134402. /**
  134403. * Gets the debug layer (aka Inspector) associated with the scene
  134404. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134405. */
  134406. debugLayer: DebugLayer;
  134407. }
  134408. /**
  134409. * Enum of inspector action tab
  134410. */
  134411. export enum DebugLayerTab {
  134412. /**
  134413. * Properties tag (default)
  134414. */
  134415. Properties = 0,
  134416. /**
  134417. * Debug tab
  134418. */
  134419. Debug = 1,
  134420. /**
  134421. * Statistics tab
  134422. */
  134423. Statistics = 2,
  134424. /**
  134425. * Tools tab
  134426. */
  134427. Tools = 3,
  134428. /**
  134429. * Settings tab
  134430. */
  134431. Settings = 4
  134432. }
  134433. /**
  134434. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134435. * what is happening in your scene
  134436. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134437. */
  134438. export class DebugLayer {
  134439. /**
  134440. * Define the url to get the inspector script from.
  134441. * By default it uses the babylonjs CDN.
  134442. * @ignoreNaming
  134443. */
  134444. static InspectorURL: string;
  134445. private _scene;
  134446. private BJSINSPECTOR;
  134447. private _onPropertyChangedObservable?;
  134448. /**
  134449. * Observable triggered when a property is changed through the inspector.
  134450. */
  134451. get onPropertyChangedObservable(): any;
  134452. /**
  134453. * Instantiates a new debug layer.
  134454. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134455. * what is happening in your scene
  134456. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134457. * @param scene Defines the scene to inspect
  134458. */
  134459. constructor(scene: Scene);
  134460. /** Creates the inspector window. */
  134461. private _createInspector;
  134462. /**
  134463. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134464. * @param entity defines the entity to select
  134465. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134466. */
  134467. select(entity: any, lineContainerTitles?: string | string[]): void;
  134468. /** Get the inspector from bundle or global */
  134469. private _getGlobalInspector;
  134470. /**
  134471. * Get if the inspector is visible or not.
  134472. * @returns true if visible otherwise, false
  134473. */
  134474. isVisible(): boolean;
  134475. /**
  134476. * Hide the inspector and close its window.
  134477. */
  134478. hide(): void;
  134479. /**
  134480. * Update the scene in the inspector
  134481. */
  134482. setAsActiveScene(): void;
  134483. /**
  134484. * Launch the debugLayer.
  134485. * @param config Define the configuration of the inspector
  134486. * @return a promise fulfilled when the debug layer is visible
  134487. */
  134488. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134489. }
  134490. }
  134491. declare module BABYLON {
  134492. /**
  134493. * Class containing static functions to help procedurally build meshes
  134494. */
  134495. export class BoxBuilder {
  134496. /**
  134497. * Creates a box mesh
  134498. * * The parameter `size` sets the size (float) of each box side (default 1)
  134499. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134500. * * 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)
  134501. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134505. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134506. * @param name defines the name of the mesh
  134507. * @param options defines the options used to create the mesh
  134508. * @param scene defines the hosting scene
  134509. * @returns the box mesh
  134510. */
  134511. static CreateBox(name: string, options: {
  134512. size?: number;
  134513. width?: number;
  134514. height?: number;
  134515. depth?: number;
  134516. faceUV?: Vector4[];
  134517. faceColors?: Color4[];
  134518. sideOrientation?: number;
  134519. frontUVs?: Vector4;
  134520. backUVs?: Vector4;
  134521. wrap?: boolean;
  134522. topBaseAt?: number;
  134523. bottomBaseAt?: number;
  134524. updatable?: boolean;
  134525. }, scene?: Nullable<Scene>): Mesh;
  134526. }
  134527. }
  134528. declare module BABYLON.Debug {
  134529. /**
  134530. * Used to show the physics impostor around the specific mesh
  134531. */
  134532. export class PhysicsViewer {
  134533. /** @hidden */
  134534. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134535. /** @hidden */
  134536. protected _meshes: Array<Nullable<AbstractMesh>>;
  134537. /** @hidden */
  134538. protected _scene: Nullable<Scene>;
  134539. /** @hidden */
  134540. protected _numMeshes: number;
  134541. /** @hidden */
  134542. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134543. private _renderFunction;
  134544. private _utilityLayer;
  134545. private _debugBoxMesh;
  134546. private _debugSphereMesh;
  134547. private _debugCylinderMesh;
  134548. private _debugMaterial;
  134549. private _debugMeshMeshes;
  134550. /**
  134551. * Creates a new PhysicsViewer
  134552. * @param scene defines the hosting scene
  134553. */
  134554. constructor(scene: Scene);
  134555. /** @hidden */
  134556. protected _updateDebugMeshes(): void;
  134557. /**
  134558. * Renders a specified physic impostor
  134559. * @param impostor defines the impostor to render
  134560. * @param targetMesh defines the mesh represented by the impostor
  134561. * @returns the new debug mesh used to render the impostor
  134562. */
  134563. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134564. /**
  134565. * Hides a specified physic impostor
  134566. * @param impostor defines the impostor to hide
  134567. */
  134568. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134569. private _getDebugMaterial;
  134570. private _getDebugBoxMesh;
  134571. private _getDebugSphereMesh;
  134572. private _getDebugCylinderMesh;
  134573. private _getDebugMeshMesh;
  134574. private _getDebugMesh;
  134575. /** Releases all resources */
  134576. dispose(): void;
  134577. }
  134578. }
  134579. declare module BABYLON {
  134580. /**
  134581. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134582. * in order to better appreciate the issue one might have.
  134583. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134584. */
  134585. export class RayHelper {
  134586. /**
  134587. * Defines the ray we are currently tryin to visualize.
  134588. */
  134589. ray: Nullable<Ray>;
  134590. private _renderPoints;
  134591. private _renderLine;
  134592. private _renderFunction;
  134593. private _scene;
  134594. private _onAfterRenderObserver;
  134595. private _onAfterStepObserver;
  134596. private _attachedToMesh;
  134597. private _meshSpaceDirection;
  134598. private _meshSpaceOrigin;
  134599. /**
  134600. * Helper function to create a colored helper in a scene in one line.
  134601. * @param ray Defines the ray we are currently tryin to visualize
  134602. * @param scene Defines the scene the ray is used in
  134603. * @param color Defines the color we want to see the ray in
  134604. * @returns The newly created ray helper.
  134605. */
  134606. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134607. /**
  134608. * Instantiate a new ray helper.
  134609. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134610. * in order to better appreciate the issue one might have.
  134611. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134612. * @param ray Defines the ray we are currently tryin to visualize
  134613. */
  134614. constructor(ray: Ray);
  134615. /**
  134616. * Shows the ray we are willing to debug.
  134617. * @param scene Defines the scene the ray needs to be rendered in
  134618. * @param color Defines the color the ray needs to be rendered in
  134619. */
  134620. show(scene: Scene, color?: Color3): void;
  134621. /**
  134622. * Hides the ray we are debugging.
  134623. */
  134624. hide(): void;
  134625. private _render;
  134626. /**
  134627. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134628. * @param mesh Defines the mesh we want the helper attached to
  134629. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134630. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134631. * @param length Defines the length of the ray
  134632. */
  134633. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134634. /**
  134635. * Detach the ray helper from the mesh it has previously been attached to.
  134636. */
  134637. detachFromMesh(): void;
  134638. private _updateToMesh;
  134639. /**
  134640. * Dispose the helper and release its associated resources.
  134641. */
  134642. dispose(): void;
  134643. }
  134644. }
  134645. declare module BABYLON {
  134646. /**
  134647. * Defines the options associated with the creation of a SkeletonViewer.
  134648. */
  134649. export interface ISkeletonViewerOptions {
  134650. /** Should the system pause animations before building the Viewer? */
  134651. pauseAnimations: boolean;
  134652. /** Should the system return the skeleton to rest before building? */
  134653. returnToRest: boolean;
  134654. /** public Display Mode of the Viewer */
  134655. displayMode: number;
  134656. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134657. displayOptions: ISkeletonViewerDisplayOptions;
  134658. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134659. computeBonesUsingShaders: boolean;
  134660. /** Flag ignore non weighted bones */
  134661. useAllBones: boolean;
  134662. }
  134663. /**
  134664. * Defines how to display the various bone meshes for the viewer.
  134665. */
  134666. export interface ISkeletonViewerDisplayOptions {
  134667. /** How far down to start tapering the bone spurs */
  134668. midStep?: number;
  134669. /** How big is the midStep? */
  134670. midStepFactor?: number;
  134671. /** Base for the Sphere Size */
  134672. sphereBaseSize?: number;
  134673. /** The ratio of the sphere to the longest bone in units */
  134674. sphereScaleUnit?: number;
  134675. /** Ratio for the Sphere Size */
  134676. sphereFactor?: number;
  134677. /** Whether a spur should attach its far end to the child bone position */
  134678. spurFollowsChild?: boolean;
  134679. /** Whether to show local axes or not */
  134680. showLocalAxes?: boolean;
  134681. /** Length of each local axis */
  134682. localAxesSize?: number;
  134683. }
  134684. /**
  134685. * Defines the constructor options for the BoneWeight Shader.
  134686. */
  134687. export interface IBoneWeightShaderOptions {
  134688. /** Skeleton to Map */
  134689. skeleton: Skeleton;
  134690. /** Colors for Uninfluenced bones */
  134691. colorBase?: Color3;
  134692. /** Colors for 0.0-0.25 Weight bones */
  134693. colorZero?: Color3;
  134694. /** Color for 0.25-0.5 Weight Influence */
  134695. colorQuarter?: Color3;
  134696. /** Color for 0.5-0.75 Weight Influence */
  134697. colorHalf?: Color3;
  134698. /** Color for 0.75-1 Weight Influence */
  134699. colorFull?: Color3;
  134700. /** Color for Zero Weight Influence */
  134701. targetBoneIndex?: number;
  134702. }
  134703. /**
  134704. * Simple structure of the gradient steps for the Color Map.
  134705. */
  134706. export interface ISkeletonMapShaderColorMapKnot {
  134707. /** Color of the Knot */
  134708. color: Color3;
  134709. /** Location of the Knot */
  134710. location: number;
  134711. }
  134712. /**
  134713. * Defines the constructor options for the SkeletonMap Shader.
  134714. */
  134715. export interface ISkeletonMapShaderOptions {
  134716. /** Skeleton to Map */
  134717. skeleton: Skeleton;
  134718. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134719. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134720. }
  134721. }
  134722. declare module BABYLON {
  134723. /**
  134724. * Class containing static functions to help procedurally build meshes
  134725. */
  134726. export class RibbonBuilder {
  134727. /**
  134728. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134729. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134730. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134731. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134732. * * 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
  134733. * * 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
  134734. * * 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
  134735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134738. * * 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
  134739. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134740. * * 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
  134741. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134743. * @param name defines the name of the mesh
  134744. * @param options defines the options used to create the mesh
  134745. * @param scene defines the hosting scene
  134746. * @returns the ribbon mesh
  134747. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134749. */
  134750. static CreateRibbon(name: string, options: {
  134751. pathArray: Vector3[][];
  134752. closeArray?: boolean;
  134753. closePath?: boolean;
  134754. offset?: number;
  134755. updatable?: boolean;
  134756. sideOrientation?: number;
  134757. frontUVs?: Vector4;
  134758. backUVs?: Vector4;
  134759. instance?: Mesh;
  134760. invertUV?: boolean;
  134761. uvs?: Vector2[];
  134762. colors?: Color4[];
  134763. }, scene?: Nullable<Scene>): Mesh;
  134764. }
  134765. }
  134766. declare module BABYLON {
  134767. /**
  134768. * Class containing static functions to help procedurally build meshes
  134769. */
  134770. export class ShapeBuilder {
  134771. /**
  134772. * 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.
  134773. * * 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.
  134774. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134775. * * 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.
  134776. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134777. * * 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
  134778. * * 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
  134779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134784. * @param name defines the name of the mesh
  134785. * @param options defines the options used to create the mesh
  134786. * @param scene defines the hosting scene
  134787. * @returns the extruded shape mesh
  134788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134790. */
  134791. static ExtrudeShape(name: string, options: {
  134792. shape: Vector3[];
  134793. path: Vector3[];
  134794. scale?: number;
  134795. rotation?: number;
  134796. cap?: number;
  134797. updatable?: boolean;
  134798. sideOrientation?: number;
  134799. frontUVs?: Vector4;
  134800. backUVs?: Vector4;
  134801. instance?: Mesh;
  134802. invertUV?: boolean;
  134803. }, scene?: Nullable<Scene>): Mesh;
  134804. /**
  134805. * Creates an custom extruded shape mesh.
  134806. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134807. * * 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.
  134808. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134809. * * 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
  134810. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134811. * * 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
  134812. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134813. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134814. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134815. * * 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
  134816. * * 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
  134817. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134822. * @param name defines the name of the mesh
  134823. * @param options defines the options used to create the mesh
  134824. * @param scene defines the hosting scene
  134825. * @returns the custom extruded shape mesh
  134826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134829. */
  134830. static ExtrudeShapeCustom(name: string, options: {
  134831. shape: Vector3[];
  134832. path: Vector3[];
  134833. scaleFunction?: any;
  134834. rotationFunction?: any;
  134835. ribbonCloseArray?: boolean;
  134836. ribbonClosePath?: boolean;
  134837. cap?: number;
  134838. updatable?: boolean;
  134839. sideOrientation?: number;
  134840. frontUVs?: Vector4;
  134841. backUVs?: Vector4;
  134842. instance?: Mesh;
  134843. invertUV?: boolean;
  134844. }, scene?: Nullable<Scene>): Mesh;
  134845. private static _ExtrudeShapeGeneric;
  134846. }
  134847. }
  134848. declare module BABYLON.Debug {
  134849. /**
  134850. * Class used to render a debug view of a given skeleton
  134851. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  134852. */
  134853. export class SkeletonViewer {
  134854. /** defines the skeleton to render */
  134855. skeleton: Skeleton;
  134856. /** defines the mesh attached to the skeleton */
  134857. mesh: AbstractMesh;
  134858. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134859. autoUpdateBonesMatrices: boolean;
  134860. /** defines the rendering group id to use with the viewer */
  134861. renderingGroupId: number;
  134862. /** is the options for the viewer */
  134863. options: Partial<ISkeletonViewerOptions>;
  134864. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  134865. static readonly DISPLAY_LINES: number;
  134866. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  134867. static readonly DISPLAY_SPHERES: number;
  134868. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  134869. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  134870. /** public static method to create a BoneWeight Shader
  134871. * @param options The constructor options
  134872. * @param scene The scene that the shader is scoped to
  134873. * @returns The created ShaderMaterial
  134874. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  134875. */
  134876. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  134877. /** public static method to create a BoneWeight Shader
  134878. * @param options The constructor options
  134879. * @param scene The scene that the shader is scoped to
  134880. * @returns The created ShaderMaterial
  134881. */
  134882. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  134883. /** private static method to create a BoneWeight Shader
  134884. * @param size The size of the buffer to create (usually the bone count)
  134885. * @param colorMap The gradient data to generate
  134886. * @param scene The scene that the shader is scoped to
  134887. * @returns an Array of floats from the color gradient values
  134888. */
  134889. private static _CreateBoneMapColorBuffer;
  134890. /** If SkeletonViewer scene scope. */
  134891. private _scene;
  134892. /** Gets or sets the color used to render the skeleton */
  134893. color: Color3;
  134894. /** Array of the points of the skeleton fo the line view. */
  134895. private _debugLines;
  134896. /** The SkeletonViewers Mesh. */
  134897. private _debugMesh;
  134898. /** The local axes Meshes. */
  134899. private _localAxes;
  134900. /** If SkeletonViewer is enabled. */
  134901. private _isEnabled;
  134902. /** If SkeletonViewer is ready. */
  134903. private _ready;
  134904. /** SkeletonViewer render observable. */
  134905. private _obs;
  134906. /** The Utility Layer to render the gizmos in. */
  134907. private _utilityLayer;
  134908. private _boneIndices;
  134909. /** Gets the Scene. */
  134910. get scene(): Scene;
  134911. /** Gets the utilityLayer. */
  134912. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  134913. /** Checks Ready Status. */
  134914. get isReady(): Boolean;
  134915. /** Sets Ready Status. */
  134916. set ready(value: boolean);
  134917. /** Gets the debugMesh */
  134918. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  134919. /** Sets the debugMesh */
  134920. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  134921. /** Gets the displayMode */
  134922. get displayMode(): number;
  134923. /** Sets the displayMode */
  134924. set displayMode(value: number);
  134925. /**
  134926. * Creates a new SkeletonViewer
  134927. * @param skeleton defines the skeleton to render
  134928. * @param mesh defines the mesh attached to the skeleton
  134929. * @param scene defines the hosting scene
  134930. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  134931. * @param renderingGroupId defines the rendering group id to use with the viewer
  134932. * @param options All of the extra constructor options for the SkeletonViewer
  134933. */
  134934. constructor(
  134935. /** defines the skeleton to render */
  134936. skeleton: Skeleton,
  134937. /** defines the mesh attached to the skeleton */
  134938. mesh: AbstractMesh,
  134939. /** The Scene scope*/
  134940. scene: Scene,
  134941. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134942. autoUpdateBonesMatrices?: boolean,
  134943. /** defines the rendering group id to use with the viewer */
  134944. renderingGroupId?: number,
  134945. /** is the options for the viewer */
  134946. options?: Partial<ISkeletonViewerOptions>);
  134947. /** The Dynamic bindings for the update functions */
  134948. private _bindObs;
  134949. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  134950. update(): void;
  134951. /** Gets or sets a boolean indicating if the viewer is enabled */
  134952. set isEnabled(value: boolean);
  134953. get isEnabled(): boolean;
  134954. private _getBonePosition;
  134955. private _getLinesForBonesWithLength;
  134956. private _getLinesForBonesNoLength;
  134957. /** function to revert the mesh and scene back to the initial state. */
  134958. private _revert;
  134959. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  134960. private _getAbsoluteBindPoseToRef;
  134961. /** function to build and bind sphere joint points and spur bone representations. */
  134962. private _buildSpheresAndSpurs;
  134963. private _buildLocalAxes;
  134964. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  134965. private _displayLinesUpdate;
  134966. /** Changes the displayMode of the skeleton viewer
  134967. * @param mode The displayMode numerical value
  134968. */
  134969. changeDisplayMode(mode: number): void;
  134970. /** Sets a display option of the skeleton viewer
  134971. *
  134972. * | Option | Type | Default | Description |
  134973. * | ---------------- | ------- | ------- | ----------- |
  134974. * | 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`. |
  134975. * | 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`. |
  134976. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  134977. * | 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`. |
  134978. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  134979. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  134980. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  134981. *
  134982. * @param option String of the option name
  134983. * @param value The numerical option value
  134984. */
  134985. changeDisplayOptions(option: string, value: number): void;
  134986. /** Release associated resources */
  134987. dispose(): void;
  134988. }
  134989. }
  134990. declare module BABYLON {
  134991. /**
  134992. * Enum for Device Types
  134993. */
  134994. export enum DeviceType {
  134995. /** Generic */
  134996. Generic = 0,
  134997. /** Keyboard */
  134998. Keyboard = 1,
  134999. /** Mouse */
  135000. Mouse = 2,
  135001. /** Touch Pointers */
  135002. Touch = 3,
  135003. /** PS4 Dual Shock */
  135004. DualShock = 4,
  135005. /** Xbox */
  135006. Xbox = 5,
  135007. /** Switch Controller */
  135008. Switch = 6
  135009. }
  135010. /**
  135011. * Enum for All Pointers (Touch/Mouse)
  135012. */
  135013. export enum PointerInput {
  135014. /** Horizontal Axis */
  135015. Horizontal = 0,
  135016. /** Vertical Axis */
  135017. Vertical = 1,
  135018. /** Left Click or Touch */
  135019. LeftClick = 2,
  135020. /** Middle Click */
  135021. MiddleClick = 3,
  135022. /** Right Click */
  135023. RightClick = 4,
  135024. /** Browser Back */
  135025. BrowserBack = 5,
  135026. /** Browser Forward */
  135027. BrowserForward = 6
  135028. }
  135029. /**
  135030. * Enum for Dual Shock Gamepad
  135031. */
  135032. export enum DualShockInput {
  135033. /** Cross */
  135034. Cross = 0,
  135035. /** Circle */
  135036. Circle = 1,
  135037. /** Square */
  135038. Square = 2,
  135039. /** Triangle */
  135040. Triangle = 3,
  135041. /** L1 */
  135042. L1 = 4,
  135043. /** R1 */
  135044. R1 = 5,
  135045. /** L2 */
  135046. L2 = 6,
  135047. /** R2 */
  135048. R2 = 7,
  135049. /** Share */
  135050. Share = 8,
  135051. /** Options */
  135052. Options = 9,
  135053. /** L3 */
  135054. L3 = 10,
  135055. /** R3 */
  135056. R3 = 11,
  135057. /** DPadUp */
  135058. DPadUp = 12,
  135059. /** DPadDown */
  135060. DPadDown = 13,
  135061. /** DPadLeft */
  135062. DPadLeft = 14,
  135063. /** DRight */
  135064. DPadRight = 15,
  135065. /** Home */
  135066. Home = 16,
  135067. /** TouchPad */
  135068. TouchPad = 17,
  135069. /** LStickXAxis */
  135070. LStickXAxis = 18,
  135071. /** LStickYAxis */
  135072. LStickYAxis = 19,
  135073. /** RStickXAxis */
  135074. RStickXAxis = 20,
  135075. /** RStickYAxis */
  135076. RStickYAxis = 21
  135077. }
  135078. /**
  135079. * Enum for Xbox Gamepad
  135080. */
  135081. export enum XboxInput {
  135082. /** A */
  135083. A = 0,
  135084. /** B */
  135085. B = 1,
  135086. /** X */
  135087. X = 2,
  135088. /** Y */
  135089. Y = 3,
  135090. /** LB */
  135091. LB = 4,
  135092. /** RB */
  135093. RB = 5,
  135094. /** LT */
  135095. LT = 6,
  135096. /** RT */
  135097. RT = 7,
  135098. /** Back */
  135099. Back = 8,
  135100. /** Start */
  135101. Start = 9,
  135102. /** LS */
  135103. LS = 10,
  135104. /** RS */
  135105. RS = 11,
  135106. /** DPadUp */
  135107. DPadUp = 12,
  135108. /** DPadDown */
  135109. DPadDown = 13,
  135110. /** DPadLeft */
  135111. DPadLeft = 14,
  135112. /** DRight */
  135113. DPadRight = 15,
  135114. /** Home */
  135115. Home = 16,
  135116. /** LStickXAxis */
  135117. LStickXAxis = 17,
  135118. /** LStickYAxis */
  135119. LStickYAxis = 18,
  135120. /** RStickXAxis */
  135121. RStickXAxis = 19,
  135122. /** RStickYAxis */
  135123. RStickYAxis = 20
  135124. }
  135125. /**
  135126. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135127. */
  135128. export enum SwitchInput {
  135129. /** B */
  135130. B = 0,
  135131. /** A */
  135132. A = 1,
  135133. /** Y */
  135134. Y = 2,
  135135. /** X */
  135136. X = 3,
  135137. /** L */
  135138. L = 4,
  135139. /** R */
  135140. R = 5,
  135141. /** ZL */
  135142. ZL = 6,
  135143. /** ZR */
  135144. ZR = 7,
  135145. /** Minus */
  135146. Minus = 8,
  135147. /** Plus */
  135148. Plus = 9,
  135149. /** LS */
  135150. LS = 10,
  135151. /** RS */
  135152. RS = 11,
  135153. /** DPadUp */
  135154. DPadUp = 12,
  135155. /** DPadDown */
  135156. DPadDown = 13,
  135157. /** DPadLeft */
  135158. DPadLeft = 14,
  135159. /** DRight */
  135160. DPadRight = 15,
  135161. /** Home */
  135162. Home = 16,
  135163. /** Capture */
  135164. Capture = 17,
  135165. /** LStickXAxis */
  135166. LStickXAxis = 18,
  135167. /** LStickYAxis */
  135168. LStickYAxis = 19,
  135169. /** RStickXAxis */
  135170. RStickXAxis = 20,
  135171. /** RStickYAxis */
  135172. RStickYAxis = 21
  135173. }
  135174. }
  135175. declare module BABYLON {
  135176. /**
  135177. * This class will take all inputs from Keyboard, Pointer, and
  135178. * any Gamepads and provide a polling system that all devices
  135179. * will use. This class assumes that there will only be one
  135180. * pointer device and one keyboard.
  135181. */
  135182. export class DeviceInputSystem implements IDisposable {
  135183. /**
  135184. * Callback to be triggered when a device is connected
  135185. */
  135186. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135187. /**
  135188. * Callback to be triggered when a device is disconnected
  135189. */
  135190. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135191. /**
  135192. * Callback to be triggered when event driven input is updated
  135193. */
  135194. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135195. private _inputs;
  135196. private _gamepads;
  135197. private _keyboardActive;
  135198. private _pointerActive;
  135199. private _elementToAttachTo;
  135200. private _keyboardDownEvent;
  135201. private _keyboardUpEvent;
  135202. private _pointerMoveEvent;
  135203. private _pointerDownEvent;
  135204. private _pointerUpEvent;
  135205. private _gamepadConnectedEvent;
  135206. private _gamepadDisconnectedEvent;
  135207. private static _MAX_KEYCODES;
  135208. private static _MAX_POINTER_INPUTS;
  135209. private constructor();
  135210. /**
  135211. * Creates a new DeviceInputSystem instance
  135212. * @param engine Engine to pull input element from
  135213. * @returns The new instance
  135214. */
  135215. static Create(engine: Engine): DeviceInputSystem;
  135216. /**
  135217. * Checks for current device input value, given an id and input index
  135218. * @param deviceName Id of connected device
  135219. * @param inputIndex Index of device input
  135220. * @returns Current value of input
  135221. */
  135222. /**
  135223. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135224. * @param deviceType Enum specifiying device type
  135225. * @param deviceSlot "Slot" or index that device is referenced in
  135226. * @param inputIndex Id of input to be checked
  135227. * @returns Current value of input
  135228. */
  135229. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135230. /**
  135231. * Dispose of all the eventlisteners
  135232. */
  135233. dispose(): void;
  135234. /**
  135235. * Add device and inputs to device array
  135236. * @param deviceType Enum specifiying device type
  135237. * @param deviceSlot "Slot" or index that device is referenced in
  135238. * @param numberOfInputs Number of input entries to create for given device
  135239. */
  135240. private _registerDevice;
  135241. /**
  135242. * Given a specific device name, remove that device from the device map
  135243. * @param deviceType Enum specifiying device type
  135244. * @param deviceSlot "Slot" or index that device is referenced in
  135245. */
  135246. private _unregisterDevice;
  135247. /**
  135248. * Handle all actions that come from keyboard interaction
  135249. */
  135250. private _handleKeyActions;
  135251. /**
  135252. * Handle all actions that come from pointer interaction
  135253. */
  135254. private _handlePointerActions;
  135255. /**
  135256. * Handle all actions that come from gamepad interaction
  135257. */
  135258. private _handleGamepadActions;
  135259. /**
  135260. * Update all non-event based devices with each frame
  135261. * @param deviceType Enum specifiying device type
  135262. * @param deviceSlot "Slot" or index that device is referenced in
  135263. * @param inputIndex Id of input to be checked
  135264. */
  135265. private _updateDevice;
  135266. /**
  135267. * Gets DeviceType from the device name
  135268. * @param deviceName Name of Device from DeviceInputSystem
  135269. * @returns DeviceType enum value
  135270. */
  135271. private _getGamepadDeviceType;
  135272. }
  135273. }
  135274. declare module BABYLON {
  135275. /**
  135276. * Type to handle enforcement of inputs
  135277. */
  135278. 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;
  135279. }
  135280. declare module BABYLON {
  135281. /**
  135282. * Class that handles all input for a specific device
  135283. */
  135284. export class DeviceSource<T extends DeviceType> {
  135285. /** Type of device */
  135286. readonly deviceType: DeviceType;
  135287. /** "Slot" or index that device is referenced in */
  135288. readonly deviceSlot: number;
  135289. /**
  135290. * Observable to handle device input changes per device
  135291. */
  135292. readonly onInputChangedObservable: Observable<{
  135293. inputIndex: DeviceInput<T>;
  135294. previousState: Nullable<number>;
  135295. currentState: Nullable<number>;
  135296. }>;
  135297. private readonly _deviceInputSystem;
  135298. /**
  135299. * Default Constructor
  135300. * @param deviceInputSystem Reference to DeviceInputSystem
  135301. * @param deviceType Type of device
  135302. * @param deviceSlot "Slot" or index that device is referenced in
  135303. */
  135304. constructor(deviceInputSystem: DeviceInputSystem,
  135305. /** Type of device */
  135306. deviceType: DeviceType,
  135307. /** "Slot" or index that device is referenced in */
  135308. deviceSlot?: number);
  135309. /**
  135310. * Get input for specific input
  135311. * @param inputIndex index of specific input on device
  135312. * @returns Input value from DeviceInputSystem
  135313. */
  135314. getInput(inputIndex: DeviceInput<T>): number;
  135315. }
  135316. /**
  135317. * Class to keep track of devices
  135318. */
  135319. export class DeviceSourceManager implements IDisposable {
  135320. /**
  135321. * Observable to be triggered when before a device is connected
  135322. */
  135323. readonly onBeforeDeviceConnectedObservable: Observable<{
  135324. deviceType: DeviceType;
  135325. deviceSlot: number;
  135326. }>;
  135327. /**
  135328. * Observable to be triggered when before a device is disconnected
  135329. */
  135330. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135331. deviceType: DeviceType;
  135332. deviceSlot: number;
  135333. }>;
  135334. /**
  135335. * Observable to be triggered when after a device is connected
  135336. */
  135337. readonly onAfterDeviceConnectedObservable: Observable<{
  135338. deviceType: DeviceType;
  135339. deviceSlot: number;
  135340. }>;
  135341. /**
  135342. * Observable to be triggered when after a device is disconnected
  135343. */
  135344. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135345. deviceType: DeviceType;
  135346. deviceSlot: number;
  135347. }>;
  135348. private readonly _devices;
  135349. private readonly _firstDevice;
  135350. private readonly _deviceInputSystem;
  135351. /**
  135352. * Default Constructor
  135353. * @param engine engine to pull input element from
  135354. */
  135355. constructor(engine: Engine);
  135356. /**
  135357. * Gets a DeviceSource, given a type and slot
  135358. * @param deviceType Enum specifying device type
  135359. * @param deviceSlot "Slot" or index that device is referenced in
  135360. * @returns DeviceSource object
  135361. */
  135362. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135363. /**
  135364. * Gets an array of DeviceSource objects for a given device type
  135365. * @param deviceType Enum specifying device type
  135366. * @returns Array of DeviceSource objects
  135367. */
  135368. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135369. /**
  135370. * Dispose of DeviceInputSystem and other parts
  135371. */
  135372. dispose(): void;
  135373. /**
  135374. * Function to add device name to device list
  135375. * @param deviceType Enum specifying device type
  135376. * @param deviceSlot "Slot" or index that device is referenced in
  135377. */
  135378. private _addDevice;
  135379. /**
  135380. * Function to remove device name to device list
  135381. * @param deviceType Enum specifying device type
  135382. * @param deviceSlot "Slot" or index that device is referenced in
  135383. */
  135384. private _removeDevice;
  135385. /**
  135386. * Updates array storing first connected device of each type
  135387. * @param type Type of Device
  135388. */
  135389. private _updateFirstDevices;
  135390. }
  135391. }
  135392. declare module BABYLON {
  135393. /**
  135394. * Options to create the null engine
  135395. */
  135396. export class NullEngineOptions {
  135397. /**
  135398. * Render width (Default: 512)
  135399. */
  135400. renderWidth: number;
  135401. /**
  135402. * Render height (Default: 256)
  135403. */
  135404. renderHeight: number;
  135405. /**
  135406. * Texture size (Default: 512)
  135407. */
  135408. textureSize: number;
  135409. /**
  135410. * If delta time between frames should be constant
  135411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135412. */
  135413. deterministicLockstep: boolean;
  135414. /**
  135415. * Maximum about of steps between frames (Default: 4)
  135416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135417. */
  135418. lockstepMaxSteps: number;
  135419. /**
  135420. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135421. */
  135422. useHighPrecisionMatrix?: boolean;
  135423. }
  135424. /**
  135425. * The null engine class provides support for headless version of babylon.js.
  135426. * This can be used in server side scenario or for testing purposes
  135427. */
  135428. export class NullEngine extends Engine {
  135429. private _options;
  135430. /**
  135431. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135432. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135433. * @returns true if engine is in deterministic lock step mode
  135434. */
  135435. isDeterministicLockStep(): boolean;
  135436. /**
  135437. * Gets the max steps when engine is running in deterministic lock step
  135438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135439. * @returns the max steps
  135440. */
  135441. getLockstepMaxSteps(): number;
  135442. /**
  135443. * Gets the current hardware scaling level.
  135444. * By default the hardware scaling level is computed from the window device ratio.
  135445. * 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.
  135446. * @returns a number indicating the current hardware scaling level
  135447. */
  135448. getHardwareScalingLevel(): number;
  135449. constructor(options?: NullEngineOptions);
  135450. /**
  135451. * Creates a vertex buffer
  135452. * @param vertices the data for the vertex buffer
  135453. * @returns the new WebGL static buffer
  135454. */
  135455. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135456. /**
  135457. * Creates a new index buffer
  135458. * @param indices defines the content of the index buffer
  135459. * @param updatable defines if the index buffer must be updatable
  135460. * @returns a new webGL buffer
  135461. */
  135462. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135463. /**
  135464. * Clear the current render buffer or the current render target (if any is set up)
  135465. * @param color defines the color to use
  135466. * @param backBuffer defines if the back buffer must be cleared
  135467. * @param depth defines if the depth buffer must be cleared
  135468. * @param stencil defines if the stencil buffer must be cleared
  135469. */
  135470. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135471. /**
  135472. * Gets the current render width
  135473. * @param useScreen defines if screen size must be used (or the current render target if any)
  135474. * @returns a number defining the current render width
  135475. */
  135476. getRenderWidth(useScreen?: boolean): number;
  135477. /**
  135478. * Gets the current render height
  135479. * @param useScreen defines if screen size must be used (or the current render target if any)
  135480. * @returns a number defining the current render height
  135481. */
  135482. getRenderHeight(useScreen?: boolean): number;
  135483. /**
  135484. * Set the WebGL's viewport
  135485. * @param viewport defines the viewport element to be used
  135486. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135487. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135488. */
  135489. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135490. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135491. /**
  135492. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135493. * @param pipelineContext defines the pipeline context to use
  135494. * @param uniformsNames defines the list of uniform names
  135495. * @returns an array of webGL uniform locations
  135496. */
  135497. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135498. /**
  135499. * Gets the lsit of active attributes for a given webGL program
  135500. * @param pipelineContext defines the pipeline context to use
  135501. * @param attributesNames defines the list of attribute names to get
  135502. * @returns an array of indices indicating the offset of each attribute
  135503. */
  135504. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135505. /**
  135506. * Binds an effect to the webGL context
  135507. * @param effect defines the effect to bind
  135508. */
  135509. bindSamplers(effect: Effect): void;
  135510. /**
  135511. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135512. * @param effect defines the effect to activate
  135513. */
  135514. enableEffect(effect: Effect): void;
  135515. /**
  135516. * Set various states to the webGL context
  135517. * @param culling defines backface culling state
  135518. * @param zOffset defines the value to apply to zOffset (0 by default)
  135519. * @param force defines if states must be applied even if cache is up to date
  135520. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135521. */
  135522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135523. /**
  135524. * Set the value of an uniform to an array of int32
  135525. * @param uniform defines the webGL uniform location where to store the value
  135526. * @param array defines the array of int32 to store
  135527. * @returns true if value was set
  135528. */
  135529. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135530. /**
  135531. * Set the value of an uniform to an array of int32 (stored as vec2)
  135532. * @param uniform defines the webGL uniform location where to store the value
  135533. * @param array defines the array of int32 to store
  135534. * @returns true if value was set
  135535. */
  135536. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135537. /**
  135538. * Set the value of an uniform to an array of int32 (stored as vec3)
  135539. * @param uniform defines the webGL uniform location where to store the value
  135540. * @param array defines the array of int32 to store
  135541. * @returns true if value was set
  135542. */
  135543. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135544. /**
  135545. * Set the value of an uniform to an array of int32 (stored as vec4)
  135546. * @param uniform defines the webGL uniform location where to store the value
  135547. * @param array defines the array of int32 to store
  135548. * @returns true if value was set
  135549. */
  135550. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135551. /**
  135552. * Set the value of an uniform to an array of float32
  135553. * @param uniform defines the webGL uniform location where to store the value
  135554. * @param array defines the array of float32 to store
  135555. * @returns true if value was set
  135556. */
  135557. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135558. /**
  135559. * Set the value of an uniform to an array of float32 (stored as vec2)
  135560. * @param uniform defines the webGL uniform location where to store the value
  135561. * @param array defines the array of float32 to store
  135562. * @returns true if value was set
  135563. */
  135564. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135565. /**
  135566. * Set the value of an uniform to an array of float32 (stored as vec3)
  135567. * @param uniform defines the webGL uniform location where to store the value
  135568. * @param array defines the array of float32 to store
  135569. * @returns true if value was set
  135570. */
  135571. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135572. /**
  135573. * Set the value of an uniform to an array of float32 (stored as vec4)
  135574. * @param uniform defines the webGL uniform location where to store the value
  135575. * @param array defines the array of float32 to store
  135576. * @returns true if value was set
  135577. */
  135578. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135579. /**
  135580. * Set the value of an uniform to an array of number
  135581. * @param uniform defines the webGL uniform location where to store the value
  135582. * @param array defines the array of number to store
  135583. * @returns true if value was set
  135584. */
  135585. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135586. /**
  135587. * Set the value of an uniform to an array of number (stored as vec2)
  135588. * @param uniform defines the webGL uniform location where to store the value
  135589. * @param array defines the array of number to store
  135590. * @returns true if value was set
  135591. */
  135592. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135593. /**
  135594. * Set the value of an uniform to an array of number (stored as vec3)
  135595. * @param uniform defines the webGL uniform location where to store the value
  135596. * @param array defines the array of number to store
  135597. * @returns true if value was set
  135598. */
  135599. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135600. /**
  135601. * Set the value of an uniform to an array of number (stored as vec4)
  135602. * @param uniform defines the webGL uniform location where to store the value
  135603. * @param array defines the array of number to store
  135604. * @returns true if value was set
  135605. */
  135606. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135607. /**
  135608. * Set the value of an uniform to an array of float32 (stored as matrices)
  135609. * @param uniform defines the webGL uniform location where to store the value
  135610. * @param matrices defines the array of float32 to store
  135611. * @returns true if value was set
  135612. */
  135613. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135614. /**
  135615. * Set the value of an uniform to a matrix (3x3)
  135616. * @param uniform defines the webGL uniform location where to store the value
  135617. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135618. * @returns true if value was set
  135619. */
  135620. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135621. /**
  135622. * Set the value of an uniform to a matrix (2x2)
  135623. * @param uniform defines the webGL uniform location where to store the value
  135624. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135625. * @returns true if value was set
  135626. */
  135627. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135628. /**
  135629. * Set the value of an uniform to a number (float)
  135630. * @param uniform defines the webGL uniform location where to store the value
  135631. * @param value defines the float number to store
  135632. * @returns true if value was set
  135633. */
  135634. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135635. /**
  135636. * Set the value of an uniform to a vec2
  135637. * @param uniform defines the webGL uniform location where to store the value
  135638. * @param x defines the 1st component of the value
  135639. * @param y defines the 2nd component of the value
  135640. * @returns true if value was set
  135641. */
  135642. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135643. /**
  135644. * Set the value of an uniform to a vec3
  135645. * @param uniform defines the webGL uniform location where to store the value
  135646. * @param x defines the 1st component of the value
  135647. * @param y defines the 2nd component of the value
  135648. * @param z defines the 3rd component of the value
  135649. * @returns true if value was set
  135650. */
  135651. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135652. /**
  135653. * Set the value of an uniform to a boolean
  135654. * @param uniform defines the webGL uniform location where to store the value
  135655. * @param bool defines the boolean to store
  135656. * @returns true if value was set
  135657. */
  135658. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135659. /**
  135660. * Set the value of an uniform to a vec4
  135661. * @param uniform defines the webGL uniform location where to store the value
  135662. * @param x defines the 1st component of the value
  135663. * @param y defines the 2nd component of the value
  135664. * @param z defines the 3rd component of the value
  135665. * @param w defines the 4th component of the value
  135666. * @returns true if value was set
  135667. */
  135668. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135669. /**
  135670. * Sets the current alpha mode
  135671. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135672. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135673. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135674. */
  135675. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135676. /**
  135677. * Bind webGl buffers directly to the webGL context
  135678. * @param vertexBuffers defines the vertex buffer to bind
  135679. * @param indexBuffer defines the index buffer to bind
  135680. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135681. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135682. * @param effect defines the effect associated with the vertex buffer
  135683. */
  135684. bindBuffers(vertexBuffers: {
  135685. [key: string]: VertexBuffer;
  135686. }, indexBuffer: DataBuffer, effect: Effect): void;
  135687. /**
  135688. * Force the entire cache to be cleared
  135689. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135690. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135691. */
  135692. wipeCaches(bruteForce?: boolean): void;
  135693. /**
  135694. * Send a draw order
  135695. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135696. * @param indexStart defines the starting index
  135697. * @param indexCount defines the number of index to draw
  135698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135699. */
  135700. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135701. /**
  135702. * Draw a list of indexed primitives
  135703. * @param fillMode defines the primitive to use
  135704. * @param indexStart defines the starting index
  135705. * @param indexCount defines the number of index to draw
  135706. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135707. */
  135708. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135709. /**
  135710. * Draw a list of unindexed primitives
  135711. * @param fillMode defines the primitive to use
  135712. * @param verticesStart defines the index of first vertex to draw
  135713. * @param verticesCount defines the count of vertices to draw
  135714. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135715. */
  135716. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135717. /** @hidden */
  135718. _createTexture(): WebGLTexture;
  135719. /** @hidden */
  135720. _releaseTexture(texture: InternalTexture): void;
  135721. /**
  135722. * Usually called from Texture.ts.
  135723. * Passed information to create a WebGLTexture
  135724. * @param urlArg defines a value which contains one of the following:
  135725. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135726. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135727. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135728. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135729. * @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)
  135730. * @param scene needed for loading to the correct scene
  135731. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135732. * @param onLoad optional callback to be called upon successful completion
  135733. * @param onError optional callback to be called upon failure
  135734. * @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
  135735. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135736. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135737. * @param forcedExtension defines the extension to use to pick the right loader
  135738. * @param mimeType defines an optional mime type
  135739. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135740. */
  135741. 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;
  135742. /**
  135743. * Creates a new render target texture
  135744. * @param size defines the size of the texture
  135745. * @param options defines the options used to create the texture
  135746. * @returns a new render target texture stored in an InternalTexture
  135747. */
  135748. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135749. /**
  135750. * Update the sampling mode of a given texture
  135751. * @param samplingMode defines the required sampling mode
  135752. * @param texture defines the texture to update
  135753. */
  135754. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  135755. /**
  135756. * Binds the frame buffer to the specified texture.
  135757. * @param texture The texture to render to or null for the default canvas
  135758. * @param faceIndex The face of the texture to render to in case of cube texture
  135759. * @param requiredWidth The width of the target to render to
  135760. * @param requiredHeight The height of the target to render to
  135761. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  135762. * @param lodLevel defines le lod level to bind to the frame buffer
  135763. */
  135764. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  135765. /**
  135766. * Unbind the current render target texture from the webGL context
  135767. * @param texture defines the render target texture to unbind
  135768. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  135769. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  135770. */
  135771. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  135772. /**
  135773. * Creates a dynamic vertex buffer
  135774. * @param vertices the data for the dynamic vertex buffer
  135775. * @returns the new WebGL dynamic buffer
  135776. */
  135777. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  135778. /**
  135779. * Update the content of a dynamic texture
  135780. * @param texture defines the texture to update
  135781. * @param canvas defines the canvas containing the source
  135782. * @param invertY defines if data must be stored with Y axis inverted
  135783. * @param premulAlpha defines if alpha is stored as premultiplied
  135784. * @param format defines the format of the data
  135785. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  135786. */
  135787. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  135788. /**
  135789. * Gets a boolean indicating if all created effects are ready
  135790. * @returns true if all effects are ready
  135791. */
  135792. areAllEffectsReady(): boolean;
  135793. /**
  135794. * @hidden
  135795. * Get the current error code of the webGL context
  135796. * @returns the error code
  135797. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  135798. */
  135799. getError(): number;
  135800. /** @hidden */
  135801. _getUnpackAlignement(): number;
  135802. /** @hidden */
  135803. _unpackFlipY(value: boolean): void;
  135804. /**
  135805. * Update a dynamic index buffer
  135806. * @param indexBuffer defines the target index buffer
  135807. * @param indices defines the data to update
  135808. * @param offset defines the offset in the target index buffer where update should start
  135809. */
  135810. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  135811. /**
  135812. * Updates a dynamic vertex buffer.
  135813. * @param vertexBuffer the vertex buffer to update
  135814. * @param vertices the data used to update the vertex buffer
  135815. * @param byteOffset the byte offset of the data (optional)
  135816. * @param byteLength the byte length of the data (optional)
  135817. */
  135818. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  135819. /** @hidden */
  135820. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  135821. /** @hidden */
  135822. _bindTexture(channel: number, texture: InternalTexture): void;
  135823. protected _deleteBuffer(buffer: WebGLBuffer): void;
  135824. /**
  135825. * 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
  135826. */
  135827. releaseEffects(): void;
  135828. displayLoadingUI(): void;
  135829. hideLoadingUI(): void;
  135830. /** @hidden */
  135831. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135832. /** @hidden */
  135833. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135834. /** @hidden */
  135835. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135836. /** @hidden */
  135837. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  135838. }
  135839. }
  135840. declare module BABYLON {
  135841. /**
  135842. * @hidden
  135843. **/
  135844. export class _TimeToken {
  135845. _startTimeQuery: Nullable<WebGLQuery>;
  135846. _endTimeQuery: Nullable<WebGLQuery>;
  135847. _timeElapsedQuery: Nullable<WebGLQuery>;
  135848. _timeElapsedQueryEnded: boolean;
  135849. }
  135850. }
  135851. declare module BABYLON {
  135852. /** @hidden */
  135853. export class _OcclusionDataStorage {
  135854. /** @hidden */
  135855. occlusionInternalRetryCounter: number;
  135856. /** @hidden */
  135857. isOcclusionQueryInProgress: boolean;
  135858. /** @hidden */
  135859. isOccluded: boolean;
  135860. /** @hidden */
  135861. occlusionRetryCount: number;
  135862. /** @hidden */
  135863. occlusionType: number;
  135864. /** @hidden */
  135865. occlusionQueryAlgorithmType: number;
  135866. }
  135867. interface Engine {
  135868. /**
  135869. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  135870. * @return the new query
  135871. */
  135872. createQuery(): WebGLQuery;
  135873. /**
  135874. * Delete and release a webGL query
  135875. * @param query defines the query to delete
  135876. * @return the current engine
  135877. */
  135878. deleteQuery(query: WebGLQuery): Engine;
  135879. /**
  135880. * Check if a given query has resolved and got its value
  135881. * @param query defines the query to check
  135882. * @returns true if the query got its value
  135883. */
  135884. isQueryResultAvailable(query: WebGLQuery): boolean;
  135885. /**
  135886. * Gets the value of a given query
  135887. * @param query defines the query to check
  135888. * @returns the value of the query
  135889. */
  135890. getQueryResult(query: WebGLQuery): number;
  135891. /**
  135892. * Initiates an occlusion query
  135893. * @param algorithmType defines the algorithm to use
  135894. * @param query defines the query to use
  135895. * @returns the current engine
  135896. * @see https://doc.babylonjs.com/features/occlusionquery
  135897. */
  135898. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  135899. /**
  135900. * Ends an occlusion query
  135901. * @see https://doc.babylonjs.com/features/occlusionquery
  135902. * @param algorithmType defines the algorithm to use
  135903. * @returns the current engine
  135904. */
  135905. endOcclusionQuery(algorithmType: number): Engine;
  135906. /**
  135907. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  135908. * Please note that only one query can be issued at a time
  135909. * @returns a time token used to track the time span
  135910. */
  135911. startTimeQuery(): Nullable<_TimeToken>;
  135912. /**
  135913. * Ends a time query
  135914. * @param token defines the token used to measure the time span
  135915. * @returns the time spent (in ns)
  135916. */
  135917. endTimeQuery(token: _TimeToken): int;
  135918. /** @hidden */
  135919. _currentNonTimestampToken: Nullable<_TimeToken>;
  135920. /** @hidden */
  135921. _createTimeQuery(): WebGLQuery;
  135922. /** @hidden */
  135923. _deleteTimeQuery(query: WebGLQuery): void;
  135924. /** @hidden */
  135925. _getGlAlgorithmType(algorithmType: number): number;
  135926. /** @hidden */
  135927. _getTimeQueryResult(query: WebGLQuery): any;
  135928. /** @hidden */
  135929. _getTimeQueryAvailability(query: WebGLQuery): any;
  135930. }
  135931. interface AbstractMesh {
  135932. /**
  135933. * Backing filed
  135934. * @hidden
  135935. */
  135936. __occlusionDataStorage: _OcclusionDataStorage;
  135937. /**
  135938. * Access property
  135939. * @hidden
  135940. */
  135941. _occlusionDataStorage: _OcclusionDataStorage;
  135942. /**
  135943. * 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.
  135944. * The default value is -1 which means don't break the query and wait till the result
  135945. * @see https://doc.babylonjs.com/features/occlusionquery
  135946. */
  135947. occlusionRetryCount: number;
  135948. /**
  135949. * 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:
  135950. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  135951. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  135952. * * 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.
  135953. * @see https://doc.babylonjs.com/features/occlusionquery
  135954. */
  135955. occlusionType: number;
  135956. /**
  135957. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  135958. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  135959. * * 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.
  135960. * @see https://doc.babylonjs.com/features/occlusionquery
  135961. */
  135962. occlusionQueryAlgorithmType: number;
  135963. /**
  135964. * 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
  135965. * @see https://doc.babylonjs.com/features/occlusionquery
  135966. */
  135967. isOccluded: boolean;
  135968. /**
  135969. * Flag to check the progress status of the query
  135970. * @see https://doc.babylonjs.com/features/occlusionquery
  135971. */
  135972. isOcclusionQueryInProgress: boolean;
  135973. }
  135974. }
  135975. declare module BABYLON {
  135976. /** @hidden */
  135977. export var _forceTransformFeedbackToBundle: boolean;
  135978. interface Engine {
  135979. /**
  135980. * Creates a webGL transform feedback object
  135981. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  135982. * @returns the webGL transform feedback object
  135983. */
  135984. createTransformFeedback(): WebGLTransformFeedback;
  135985. /**
  135986. * Delete a webGL transform feedback object
  135987. * @param value defines the webGL transform feedback object to delete
  135988. */
  135989. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  135990. /**
  135991. * Bind a webGL transform feedback object to the webgl context
  135992. * @param value defines the webGL transform feedback object to bind
  135993. */
  135994. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  135995. /**
  135996. * Begins a transform feedback operation
  135997. * @param usePoints defines if points or triangles must be used
  135998. */
  135999. beginTransformFeedback(usePoints: boolean): void;
  136000. /**
  136001. * Ends a transform feedback operation
  136002. */
  136003. endTransformFeedback(): void;
  136004. /**
  136005. * Specify the varyings to use with transform feedback
  136006. * @param program defines the associated webGL program
  136007. * @param value defines the list of strings representing the varying names
  136008. */
  136009. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136010. /**
  136011. * Bind a webGL buffer for a transform feedback operation
  136012. * @param value defines the webGL buffer to bind
  136013. */
  136014. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136015. }
  136016. }
  136017. declare module BABYLON {
  136018. /**
  136019. * Class used to define an additional view for the engine
  136020. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136021. */
  136022. export class EngineView {
  136023. /** Defines the canvas where to render the view */
  136024. target: HTMLCanvasElement;
  136025. /** Defines an optional camera used to render the view (will use active camera else) */
  136026. camera?: Camera;
  136027. }
  136028. interface Engine {
  136029. /**
  136030. * Gets or sets the HTML element to use for attaching events
  136031. */
  136032. inputElement: Nullable<HTMLElement>;
  136033. /**
  136034. * Gets the current engine view
  136035. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136036. */
  136037. activeView: Nullable<EngineView>;
  136038. /** Gets or sets the list of views */
  136039. views: EngineView[];
  136040. /**
  136041. * Register a new child canvas
  136042. * @param canvas defines the canvas to register
  136043. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136044. * @returns the associated view
  136045. */
  136046. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136047. /**
  136048. * Remove a registered child canvas
  136049. * @param canvas defines the canvas to remove
  136050. * @returns the current engine
  136051. */
  136052. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136053. }
  136054. }
  136055. declare module BABYLON {
  136056. interface Engine {
  136057. /** @hidden */
  136058. _excludedCompressedTextures: string[];
  136059. /** @hidden */
  136060. _textureFormatInUse: string;
  136061. /**
  136062. * Gets the list of texture formats supported
  136063. */
  136064. readonly texturesSupported: Array<string>;
  136065. /**
  136066. * Gets the texture format in use
  136067. */
  136068. readonly textureFormatInUse: Nullable<string>;
  136069. /**
  136070. * Set the compressed texture extensions or file names to skip.
  136071. *
  136072. * @param skippedFiles defines the list of those texture files you want to skip
  136073. * Example: [".dds", ".env", "myfile.png"]
  136074. */
  136075. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136076. /**
  136077. * Set the compressed texture format to use, based on the formats you have, and the formats
  136078. * supported by the hardware / browser.
  136079. *
  136080. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136081. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136082. * to API arguments needed to compressed textures. This puts the burden on the container
  136083. * generator to house the arcane code for determining these for current & future formats.
  136084. *
  136085. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136086. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136087. *
  136088. * Note: The result of this call is not taken into account when a texture is base64.
  136089. *
  136090. * @param formatsAvailable defines the list of those format families you have created
  136091. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136092. *
  136093. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136094. * @returns The extension selected.
  136095. */
  136096. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136097. }
  136098. }
  136099. declare module BABYLON {
  136100. /** @hidden */
  136101. export var rgbdEncodePixelShader: {
  136102. name: string;
  136103. shader: string;
  136104. };
  136105. }
  136106. declare module BABYLON {
  136107. /**
  136108. * Raw texture data and descriptor sufficient for WebGL texture upload
  136109. */
  136110. export interface EnvironmentTextureInfo {
  136111. /**
  136112. * Version of the environment map
  136113. */
  136114. version: number;
  136115. /**
  136116. * Width of image
  136117. */
  136118. width: number;
  136119. /**
  136120. * Irradiance information stored in the file.
  136121. */
  136122. irradiance: any;
  136123. /**
  136124. * Specular information stored in the file.
  136125. */
  136126. specular: any;
  136127. }
  136128. /**
  136129. * Defines One Image in the file. It requires only the position in the file
  136130. * as well as the length.
  136131. */
  136132. interface BufferImageData {
  136133. /**
  136134. * Length of the image data.
  136135. */
  136136. length: number;
  136137. /**
  136138. * Position of the data from the null terminator delimiting the end of the JSON.
  136139. */
  136140. position: number;
  136141. }
  136142. /**
  136143. * Defines the specular data enclosed in the file.
  136144. * This corresponds to the version 1 of the data.
  136145. */
  136146. export interface EnvironmentTextureSpecularInfoV1 {
  136147. /**
  136148. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136149. */
  136150. specularDataPosition?: number;
  136151. /**
  136152. * This contains all the images data needed to reconstruct the cubemap.
  136153. */
  136154. mipmaps: Array<BufferImageData>;
  136155. /**
  136156. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136157. */
  136158. lodGenerationScale: number;
  136159. }
  136160. /**
  136161. * Sets of helpers addressing the serialization and deserialization of environment texture
  136162. * stored in a BabylonJS env file.
  136163. * Those files are usually stored as .env files.
  136164. */
  136165. export class EnvironmentTextureTools {
  136166. /**
  136167. * Magic number identifying the env file.
  136168. */
  136169. private static _MagicBytes;
  136170. /**
  136171. * Gets the environment info from an env file.
  136172. * @param data The array buffer containing the .env bytes.
  136173. * @returns the environment file info (the json header) if successfully parsed.
  136174. */
  136175. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136176. /**
  136177. * Creates an environment texture from a loaded cube texture.
  136178. * @param texture defines the cube texture to convert in env file
  136179. * @return a promise containing the environment data if succesfull.
  136180. */
  136181. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136182. /**
  136183. * Creates a JSON representation of the spherical data.
  136184. * @param texture defines the texture containing the polynomials
  136185. * @return the JSON representation of the spherical info
  136186. */
  136187. private static _CreateEnvTextureIrradiance;
  136188. /**
  136189. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136190. * @param data the image data
  136191. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136192. * @return the views described by info providing access to the underlying buffer
  136193. */
  136194. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136195. /**
  136196. * Uploads the texture info contained in the env file to the GPU.
  136197. * @param texture defines the internal texture to upload to
  136198. * @param data defines the data to load
  136199. * @param info defines the texture info retrieved through the GetEnvInfo method
  136200. * @returns a promise
  136201. */
  136202. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136203. private static _OnImageReadyAsync;
  136204. /**
  136205. * Uploads the levels of image data to the GPU.
  136206. * @param texture defines the internal texture to upload to
  136207. * @param imageData defines the array buffer views of image data [mipmap][face]
  136208. * @returns a promise
  136209. */
  136210. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136211. /**
  136212. * Uploads spherical polynomials information to the texture.
  136213. * @param texture defines the texture we are trying to upload the information to
  136214. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136215. */
  136216. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136217. /** @hidden */
  136218. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136219. }
  136220. }
  136221. declare module BABYLON {
  136222. /**
  136223. * Class used to inline functions in shader code
  136224. */
  136225. export class ShaderCodeInliner {
  136226. private static readonly _RegexpFindFunctionNameAndType;
  136227. private _sourceCode;
  136228. private _functionDescr;
  136229. private _numMaxIterations;
  136230. /** Gets or sets the token used to mark the functions to inline */
  136231. inlineToken: string;
  136232. /** Gets or sets the debug mode */
  136233. debug: boolean;
  136234. /** Gets the code after the inlining process */
  136235. get code(): string;
  136236. /**
  136237. * Initializes the inliner
  136238. * @param sourceCode shader code source to inline
  136239. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136240. */
  136241. constructor(sourceCode: string, numMaxIterations?: number);
  136242. /**
  136243. * Start the processing of the shader code
  136244. */
  136245. processCode(): void;
  136246. private _collectFunctions;
  136247. private _processInlining;
  136248. private _extractBetweenMarkers;
  136249. private _skipWhitespaces;
  136250. private _removeComments;
  136251. private _replaceFunctionCallsByCode;
  136252. private _findBackward;
  136253. private _escapeRegExp;
  136254. private _replaceNames;
  136255. }
  136256. }
  136257. declare module BABYLON {
  136258. /**
  136259. * Container for accessors for natively-stored mesh data buffers.
  136260. */
  136261. class NativeDataBuffer extends DataBuffer {
  136262. /**
  136263. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136264. */
  136265. nativeIndexBuffer?: any;
  136266. /**
  136267. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136268. */
  136269. nativeVertexBuffer?: any;
  136270. }
  136271. /** @hidden */
  136272. class NativeTexture extends InternalTexture {
  136273. getInternalTexture(): InternalTexture;
  136274. getViewCount(): number;
  136275. }
  136276. /** @hidden */
  136277. export class NativeEngine extends Engine {
  136278. private readonly _native;
  136279. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136280. private readonly INVALID_HANDLE;
  136281. private _boundBuffersVertexArray;
  136282. private _currentDepthTest;
  136283. getHardwareScalingLevel(): number;
  136284. constructor();
  136285. dispose(): void;
  136286. /**
  136287. * Can be used to override the current requestAnimationFrame requester.
  136288. * @hidden
  136289. */
  136290. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136291. /**
  136292. * Override default engine behavior.
  136293. * @param color
  136294. * @param backBuffer
  136295. * @param depth
  136296. * @param stencil
  136297. */
  136298. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136299. /**
  136300. * Gets host document
  136301. * @returns the host document object
  136302. */
  136303. getHostDocument(): Nullable<Document>;
  136304. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136305. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136306. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136307. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136308. [key: string]: VertexBuffer;
  136309. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136310. bindBuffers(vertexBuffers: {
  136311. [key: string]: VertexBuffer;
  136312. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136313. recordVertexArrayObject(vertexBuffers: {
  136314. [key: string]: VertexBuffer;
  136315. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136316. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136317. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136318. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136319. /**
  136320. * Draw a list of indexed primitives
  136321. * @param fillMode defines the primitive to use
  136322. * @param indexStart defines the starting index
  136323. * @param indexCount defines the number of index to draw
  136324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136325. */
  136326. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136327. /**
  136328. * Draw a list of unindexed primitives
  136329. * @param fillMode defines the primitive to use
  136330. * @param verticesStart defines the index of first vertex to draw
  136331. * @param verticesCount defines the count of vertices to draw
  136332. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136333. */
  136334. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136335. createPipelineContext(): IPipelineContext;
  136336. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136337. /** @hidden */
  136338. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136339. /** @hidden */
  136340. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136341. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136342. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136343. protected _setProgram(program: WebGLProgram): void;
  136344. _releaseEffect(effect: Effect): void;
  136345. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136346. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136347. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136348. bindSamplers(effect: Effect): void;
  136349. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136350. getRenderWidth(useScreen?: boolean): number;
  136351. getRenderHeight(useScreen?: boolean): number;
  136352. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136353. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136354. /**
  136355. * Set the z offset to apply to current rendering
  136356. * @param value defines the offset to apply
  136357. */
  136358. setZOffset(value: number): void;
  136359. /**
  136360. * Gets the current value of the zOffset
  136361. * @returns the current zOffset state
  136362. */
  136363. getZOffset(): number;
  136364. /**
  136365. * Enable or disable depth buffering
  136366. * @param enable defines the state to set
  136367. */
  136368. setDepthBuffer(enable: boolean): void;
  136369. /**
  136370. * Gets a boolean indicating if depth writing is enabled
  136371. * @returns the current depth writing state
  136372. */
  136373. getDepthWrite(): boolean;
  136374. setDepthFunctionToGreater(): void;
  136375. setDepthFunctionToGreaterOrEqual(): void;
  136376. setDepthFunctionToLess(): void;
  136377. setDepthFunctionToLessOrEqual(): void;
  136378. /**
  136379. * Enable or disable depth writing
  136380. * @param enable defines the state to set
  136381. */
  136382. setDepthWrite(enable: boolean): void;
  136383. /**
  136384. * Enable or disable color writing
  136385. * @param enable defines the state to set
  136386. */
  136387. setColorWrite(enable: boolean): void;
  136388. /**
  136389. * Gets a boolean indicating if color writing is enabled
  136390. * @returns the current color writing state
  136391. */
  136392. getColorWrite(): boolean;
  136393. /**
  136394. * Sets alpha constants used by some alpha blending modes
  136395. * @param r defines the red component
  136396. * @param g defines the green component
  136397. * @param b defines the blue component
  136398. * @param a defines the alpha component
  136399. */
  136400. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136401. /**
  136402. * Sets the current alpha mode
  136403. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136404. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136405. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136406. */
  136407. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136408. /**
  136409. * Gets the current alpha mode
  136410. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136411. * @returns the current alpha mode
  136412. */
  136413. getAlphaMode(): number;
  136414. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136415. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136416. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136417. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136418. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136419. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136420. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136421. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136422. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136423. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136424. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136425. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136426. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136427. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136428. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136429. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136430. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136431. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136432. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136433. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136434. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136435. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136436. wipeCaches(bruteForce?: boolean): void;
  136437. _createTexture(): WebGLTexture;
  136438. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136439. /**
  136440. * Update the content of a dynamic texture
  136441. * @param texture defines the texture to update
  136442. * @param canvas defines the canvas containing the source
  136443. * @param invertY defines if data must be stored with Y axis inverted
  136444. * @param premulAlpha defines if alpha is stored as premultiplied
  136445. * @param format defines the format of the data
  136446. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136447. */
  136448. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136449. /**
  136450. * Usually called from Texture.ts.
  136451. * Passed information to create a WebGLTexture
  136452. * @param url defines a value which contains one of the following:
  136453. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136454. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136455. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136456. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136457. * @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)
  136458. * @param scene needed for loading to the correct scene
  136459. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136460. * @param onLoad optional callback to be called upon successful completion
  136461. * @param onError optional callback to be called upon failure
  136462. * @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
  136463. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136464. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136465. * @param forcedExtension defines the extension to use to pick the right loader
  136466. * @param mimeType defines an optional mime type
  136467. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136468. */
  136469. 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;
  136470. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136471. _releaseFramebufferObjects(texture: InternalTexture): void;
  136472. /**
  136473. * Creates a cube texture
  136474. * @param rootUrl defines the url where the files to load is located
  136475. * @param scene defines the current scene
  136476. * @param files defines the list of files to load (1 per face)
  136477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136478. * @param onLoad defines an optional callback raised when the texture is loaded
  136479. * @param onError defines an optional callback raised if there is an issue to load the texture
  136480. * @param format defines the format of the data
  136481. * @param forcedExtension defines the extension to use to pick the right loader
  136482. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136483. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136484. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136485. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136486. * @returns the cube texture as an InternalTexture
  136487. */
  136488. 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;
  136489. createRenderTargetTexture(size: number | {
  136490. width: number;
  136491. height: number;
  136492. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136493. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136494. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136495. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136496. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136497. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136498. /**
  136499. * Updates a dynamic vertex buffer.
  136500. * @param vertexBuffer the vertex buffer to update
  136501. * @param data the data used to update the vertex buffer
  136502. * @param byteOffset the byte offset of the data (optional)
  136503. * @param byteLength the byte length of the data (optional)
  136504. */
  136505. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136506. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136507. private _updateAnisotropicLevel;
  136508. private _getAddressMode;
  136509. /** @hidden */
  136510. _bindTexture(channel: number, texture: InternalTexture): void;
  136511. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136512. releaseEffects(): void;
  136513. /** @hidden */
  136514. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136515. /** @hidden */
  136516. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136517. /** @hidden */
  136518. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136519. /** @hidden */
  136520. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136521. private _getNativeSamplingMode;
  136522. private _getNativeTextureFormat;
  136523. private _getNativeAlphaMode;
  136524. private _getNativeAttribType;
  136525. }
  136526. }
  136527. declare module BABYLON {
  136528. /**
  136529. * Gather the list of clipboard event types as constants.
  136530. */
  136531. export class ClipboardEventTypes {
  136532. /**
  136533. * The clipboard event is fired when a copy command is active (pressed).
  136534. */
  136535. static readonly COPY: number;
  136536. /**
  136537. * The clipboard event is fired when a cut command is active (pressed).
  136538. */
  136539. static readonly CUT: number;
  136540. /**
  136541. * The clipboard event is fired when a paste command is active (pressed).
  136542. */
  136543. static readonly PASTE: number;
  136544. }
  136545. /**
  136546. * This class is used to store clipboard related info for the onClipboardObservable event.
  136547. */
  136548. export class ClipboardInfo {
  136549. /**
  136550. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136551. */
  136552. type: number;
  136553. /**
  136554. * Defines the related dom event
  136555. */
  136556. event: ClipboardEvent;
  136557. /**
  136558. *Creates an instance of ClipboardInfo.
  136559. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136560. * @param event Defines the related dom event
  136561. */
  136562. constructor(
  136563. /**
  136564. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136565. */
  136566. type: number,
  136567. /**
  136568. * Defines the related dom event
  136569. */
  136570. event: ClipboardEvent);
  136571. /**
  136572. * Get the clipboard event's type from the keycode.
  136573. * @param keyCode Defines the keyCode for the current keyboard event.
  136574. * @return {number}
  136575. */
  136576. static GetTypeFromCharacter(keyCode: number): number;
  136577. }
  136578. }
  136579. declare module BABYLON {
  136580. /**
  136581. * Google Daydream controller
  136582. */
  136583. export class DaydreamController extends WebVRController {
  136584. /**
  136585. * Base Url for the controller model.
  136586. */
  136587. static MODEL_BASE_URL: string;
  136588. /**
  136589. * File name for the controller model.
  136590. */
  136591. static MODEL_FILENAME: string;
  136592. /**
  136593. * Gamepad Id prefix used to identify Daydream Controller.
  136594. */
  136595. static readonly GAMEPAD_ID_PREFIX: string;
  136596. /**
  136597. * Creates a new DaydreamController from a gamepad
  136598. * @param vrGamepad the gamepad that the controller should be created from
  136599. */
  136600. constructor(vrGamepad: any);
  136601. /**
  136602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136603. * @param scene scene in which to add meshes
  136604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136605. */
  136606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136607. /**
  136608. * Called once for each button that changed state since the last frame
  136609. * @param buttonIdx Which button index changed
  136610. * @param state New state of the button
  136611. * @param changes Which properties on the state changed since last frame
  136612. */
  136613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136614. }
  136615. }
  136616. declare module BABYLON {
  136617. /**
  136618. * Gear VR Controller
  136619. */
  136620. export class GearVRController extends WebVRController {
  136621. /**
  136622. * Base Url for the controller model.
  136623. */
  136624. static MODEL_BASE_URL: string;
  136625. /**
  136626. * File name for the controller model.
  136627. */
  136628. static MODEL_FILENAME: string;
  136629. /**
  136630. * Gamepad Id prefix used to identify this controller.
  136631. */
  136632. static readonly GAMEPAD_ID_PREFIX: string;
  136633. private readonly _buttonIndexToObservableNameMap;
  136634. /**
  136635. * Creates a new GearVRController from a gamepad
  136636. * @param vrGamepad the gamepad that the controller should be created from
  136637. */
  136638. constructor(vrGamepad: any);
  136639. /**
  136640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136641. * @param scene scene in which to add meshes
  136642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136643. */
  136644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136645. /**
  136646. * Called once for each button that changed state since the last frame
  136647. * @param buttonIdx Which button index changed
  136648. * @param state New state of the button
  136649. * @param changes Which properties on the state changed since last frame
  136650. */
  136651. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136652. }
  136653. }
  136654. declare module BABYLON {
  136655. /**
  136656. * Generic Controller
  136657. */
  136658. export class GenericController extends WebVRController {
  136659. /**
  136660. * Base Url for the controller model.
  136661. */
  136662. static readonly MODEL_BASE_URL: string;
  136663. /**
  136664. * File name for the controller model.
  136665. */
  136666. static readonly MODEL_FILENAME: string;
  136667. /**
  136668. * Creates a new GenericController from a gamepad
  136669. * @param vrGamepad the gamepad that the controller should be created from
  136670. */
  136671. constructor(vrGamepad: any);
  136672. /**
  136673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136674. * @param scene scene in which to add meshes
  136675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136676. */
  136677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136678. /**
  136679. * Called once for each button that changed state since the last frame
  136680. * @param buttonIdx Which button index changed
  136681. * @param state New state of the button
  136682. * @param changes Which properties on the state changed since last frame
  136683. */
  136684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136685. }
  136686. }
  136687. declare module BABYLON {
  136688. /**
  136689. * Oculus Touch Controller
  136690. */
  136691. export class OculusTouchController extends WebVRController {
  136692. /**
  136693. * Base Url for the controller model.
  136694. */
  136695. static MODEL_BASE_URL: string;
  136696. /**
  136697. * File name for the left controller model.
  136698. */
  136699. static MODEL_LEFT_FILENAME: string;
  136700. /**
  136701. * File name for the right controller model.
  136702. */
  136703. static MODEL_RIGHT_FILENAME: string;
  136704. /**
  136705. * Base Url for the Quest controller model.
  136706. */
  136707. static QUEST_MODEL_BASE_URL: string;
  136708. /**
  136709. * @hidden
  136710. * If the controllers are running on a device that needs the updated Quest controller models
  136711. */
  136712. static _IsQuest: boolean;
  136713. /**
  136714. * Fired when the secondary trigger on this controller is modified
  136715. */
  136716. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136717. /**
  136718. * Fired when the thumb rest on this controller is modified
  136719. */
  136720. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136721. /**
  136722. * Creates a new OculusTouchController from a gamepad
  136723. * @param vrGamepad the gamepad that the controller should be created from
  136724. */
  136725. constructor(vrGamepad: any);
  136726. /**
  136727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136728. * @param scene scene in which to add meshes
  136729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136730. */
  136731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136732. /**
  136733. * Fired when the A button on this controller is modified
  136734. */
  136735. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136736. /**
  136737. * Fired when the B button on this controller is modified
  136738. */
  136739. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136740. /**
  136741. * Fired when the X button on this controller is modified
  136742. */
  136743. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136744. /**
  136745. * Fired when the Y button on this controller is modified
  136746. */
  136747. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136748. /**
  136749. * Called once for each button that changed state since the last frame
  136750. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136751. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136752. * 2) secondary trigger (same)
  136753. * 3) A (right) X (left), touch, pressed = value
  136754. * 4) B / Y
  136755. * 5) thumb rest
  136756. * @param buttonIdx Which button index changed
  136757. * @param state New state of the button
  136758. * @param changes Which properties on the state changed since last frame
  136759. */
  136760. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136761. }
  136762. }
  136763. declare module BABYLON {
  136764. /**
  136765. * Vive Controller
  136766. */
  136767. export class ViveController extends WebVRController {
  136768. /**
  136769. * Base Url for the controller model.
  136770. */
  136771. static MODEL_BASE_URL: string;
  136772. /**
  136773. * File name for the controller model.
  136774. */
  136775. static MODEL_FILENAME: string;
  136776. /**
  136777. * Creates a new ViveController from a gamepad
  136778. * @param vrGamepad the gamepad that the controller should be created from
  136779. */
  136780. constructor(vrGamepad: any);
  136781. /**
  136782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136783. * @param scene scene in which to add meshes
  136784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136785. */
  136786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136787. /**
  136788. * Fired when the left button on this controller is modified
  136789. */
  136790. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136791. /**
  136792. * Fired when the right button on this controller is modified
  136793. */
  136794. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136795. /**
  136796. * Fired when the menu button on this controller is modified
  136797. */
  136798. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136799. /**
  136800. * Called once for each button that changed state since the last frame
  136801. * Vive mapping:
  136802. * 0: touchpad
  136803. * 1: trigger
  136804. * 2: left AND right buttons
  136805. * 3: menu button
  136806. * @param buttonIdx Which button index changed
  136807. * @param state New state of the button
  136808. * @param changes Which properties on the state changed since last frame
  136809. */
  136810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136811. }
  136812. }
  136813. declare module BABYLON {
  136814. /**
  136815. * Defines the WindowsMotionController object that the state of the windows motion controller
  136816. */
  136817. export class WindowsMotionController extends WebVRController {
  136818. /**
  136819. * The base url used to load the left and right controller models
  136820. */
  136821. static MODEL_BASE_URL: string;
  136822. /**
  136823. * The name of the left controller model file
  136824. */
  136825. static MODEL_LEFT_FILENAME: string;
  136826. /**
  136827. * The name of the right controller model file
  136828. */
  136829. static MODEL_RIGHT_FILENAME: string;
  136830. /**
  136831. * The controller name prefix for this controller type
  136832. */
  136833. static readonly GAMEPAD_ID_PREFIX: string;
  136834. /**
  136835. * The controller id pattern for this controller type
  136836. */
  136837. private static readonly GAMEPAD_ID_PATTERN;
  136838. private _loadedMeshInfo;
  136839. protected readonly _mapping: {
  136840. buttons: string[];
  136841. buttonMeshNames: {
  136842. trigger: string;
  136843. menu: string;
  136844. grip: string;
  136845. thumbstick: string;
  136846. trackpad: string;
  136847. };
  136848. buttonObservableNames: {
  136849. trigger: string;
  136850. menu: string;
  136851. grip: string;
  136852. thumbstick: string;
  136853. trackpad: string;
  136854. };
  136855. axisMeshNames: string[];
  136856. pointingPoseMeshName: string;
  136857. };
  136858. /**
  136859. * Fired when the trackpad on this controller is clicked
  136860. */
  136861. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136862. /**
  136863. * Fired when the trackpad on this controller is modified
  136864. */
  136865. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136866. /**
  136867. * The current x and y values of this controller's trackpad
  136868. */
  136869. trackpad: StickValues;
  136870. /**
  136871. * Creates a new WindowsMotionController from a gamepad
  136872. * @param vrGamepad the gamepad that the controller should be created from
  136873. */
  136874. constructor(vrGamepad: any);
  136875. /**
  136876. * Fired when the trigger on this controller is modified
  136877. */
  136878. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136879. /**
  136880. * Fired when the menu button on this controller is modified
  136881. */
  136882. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136883. /**
  136884. * Fired when the grip button on this controller is modified
  136885. */
  136886. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136887. /**
  136888. * Fired when the thumbstick button on this controller is modified
  136889. */
  136890. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136891. /**
  136892. * Fired when the touchpad button on this controller is modified
  136893. */
  136894. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136895. /**
  136896. * Fired when the touchpad values on this controller are modified
  136897. */
  136898. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  136899. protected _updateTrackpad(): void;
  136900. /**
  136901. * Called once per frame by the engine.
  136902. */
  136903. update(): void;
  136904. /**
  136905. * Called once for each button that changed state since the last frame
  136906. * @param buttonIdx Which button index changed
  136907. * @param state New state of the button
  136908. * @param changes Which properties on the state changed since last frame
  136909. */
  136910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136911. /**
  136912. * Moves the buttons on the controller mesh based on their current state
  136913. * @param buttonName the name of the button to move
  136914. * @param buttonValue the value of the button which determines the buttons new position
  136915. */
  136916. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  136917. /**
  136918. * Moves the axis on the controller mesh based on its current state
  136919. * @param axis the index of the axis
  136920. * @param axisValue the value of the axis which determines the meshes new position
  136921. * @hidden
  136922. */
  136923. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  136924. /**
  136925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136926. * @param scene scene in which to add meshes
  136927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136928. */
  136929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  136930. /**
  136931. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  136932. * can be transformed by button presses and axes values, based on this._mapping.
  136933. *
  136934. * @param scene scene in which the meshes exist
  136935. * @param meshes list of meshes that make up the controller model to process
  136936. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  136937. */
  136938. private processModel;
  136939. private createMeshInfo;
  136940. /**
  136941. * Gets the ray of the controller in the direction the controller is pointing
  136942. * @param length the length the resulting ray should be
  136943. * @returns a ray in the direction the controller is pointing
  136944. */
  136945. getForwardRay(length?: number): Ray;
  136946. /**
  136947. * Disposes of the controller
  136948. */
  136949. dispose(): void;
  136950. }
  136951. /**
  136952. * This class represents a new windows motion controller in XR.
  136953. */
  136954. export class XRWindowsMotionController extends WindowsMotionController {
  136955. /**
  136956. * Changing the original WIndowsMotionController mapping to fir the new mapping
  136957. */
  136958. protected readonly _mapping: {
  136959. buttons: string[];
  136960. buttonMeshNames: {
  136961. trigger: string;
  136962. menu: string;
  136963. grip: string;
  136964. thumbstick: string;
  136965. trackpad: string;
  136966. };
  136967. buttonObservableNames: {
  136968. trigger: string;
  136969. menu: string;
  136970. grip: string;
  136971. thumbstick: string;
  136972. trackpad: string;
  136973. };
  136974. axisMeshNames: string[];
  136975. pointingPoseMeshName: string;
  136976. };
  136977. /**
  136978. * Construct a new XR-Based windows motion controller
  136979. *
  136980. * @param gamepadInfo the gamepad object from the browser
  136981. */
  136982. constructor(gamepadInfo: any);
  136983. /**
  136984. * holds the thumbstick values (X,Y)
  136985. */
  136986. thumbstickValues: StickValues;
  136987. /**
  136988. * Fired when the thumbstick on this controller is clicked
  136989. */
  136990. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  136991. /**
  136992. * Fired when the thumbstick on this controller is modified
  136993. */
  136994. onThumbstickValuesChangedObservable: Observable<StickValues>;
  136995. /**
  136996. * Fired when the touchpad button on this controller is modified
  136997. */
  136998. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136999. /**
  137000. * Fired when the touchpad values on this controller are modified
  137001. */
  137002. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137003. /**
  137004. * Fired when the thumbstick button on this controller is modified
  137005. * here to prevent breaking changes
  137006. */
  137007. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137008. /**
  137009. * updating the thumbstick(!) and not the trackpad.
  137010. * This is named this way due to the difference between WebVR and XR and to avoid
  137011. * changing the parent class.
  137012. */
  137013. protected _updateTrackpad(): void;
  137014. /**
  137015. * Disposes the class with joy
  137016. */
  137017. dispose(): void;
  137018. }
  137019. }
  137020. declare module BABYLON {
  137021. /**
  137022. * Class containing static functions to help procedurally build meshes
  137023. */
  137024. export class PolyhedronBuilder {
  137025. /**
  137026. * Creates a polyhedron mesh
  137027. * * 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
  137028. * * The parameter `size` (positive float, default 1) sets the polygon size
  137029. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137030. * * 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`
  137031. * * 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
  137032. * * 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)`)
  137033. * * 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
  137034. * * 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
  137035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137038. * @param name defines the name of the mesh
  137039. * @param options defines the options used to create the mesh
  137040. * @param scene defines the hosting scene
  137041. * @returns the polyhedron mesh
  137042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137043. */
  137044. static CreatePolyhedron(name: string, options: {
  137045. type?: number;
  137046. size?: number;
  137047. sizeX?: number;
  137048. sizeY?: number;
  137049. sizeZ?: number;
  137050. custom?: any;
  137051. faceUV?: Vector4[];
  137052. faceColors?: Color4[];
  137053. flat?: boolean;
  137054. updatable?: boolean;
  137055. sideOrientation?: number;
  137056. frontUVs?: Vector4;
  137057. backUVs?: Vector4;
  137058. }, scene?: Nullable<Scene>): Mesh;
  137059. }
  137060. }
  137061. declare module BABYLON {
  137062. /**
  137063. * Gizmo that enables scaling a mesh along 3 axis
  137064. */
  137065. export class ScaleGizmo extends Gizmo {
  137066. /**
  137067. * Internal gizmo used for interactions on the x axis
  137068. */
  137069. xGizmo: AxisScaleGizmo;
  137070. /**
  137071. * Internal gizmo used for interactions on the y axis
  137072. */
  137073. yGizmo: AxisScaleGizmo;
  137074. /**
  137075. * Internal gizmo used for interactions on the z axis
  137076. */
  137077. zGizmo: AxisScaleGizmo;
  137078. /**
  137079. * Internal gizmo used to scale all axis equally
  137080. */
  137081. uniformScaleGizmo: AxisScaleGizmo;
  137082. private _meshAttached;
  137083. private _nodeAttached;
  137084. private _snapDistance;
  137085. private _uniformScalingMesh;
  137086. private _octahedron;
  137087. private _sensitivity;
  137088. /** Fires an event when any of it's sub gizmos are dragged */
  137089. onDragStartObservable: Observable<unknown>;
  137090. /** Fires an event when any of it's sub gizmos are released from dragging */
  137091. onDragEndObservable: Observable<unknown>;
  137092. get attachedMesh(): Nullable<AbstractMesh>;
  137093. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137094. get attachedNode(): Nullable<Node>;
  137095. set attachedNode(node: Nullable<Node>);
  137096. /**
  137097. * True when the mouse pointer is hovering a gizmo mesh
  137098. */
  137099. get isHovered(): boolean;
  137100. /**
  137101. * Creates a ScaleGizmo
  137102. * @param gizmoLayer The utility layer the gizmo will be added to
  137103. * @param thickness display gizmo axis thickness
  137104. */
  137105. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137106. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137107. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137108. /**
  137109. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137110. */
  137111. set snapDistance(value: number);
  137112. get snapDistance(): number;
  137113. /**
  137114. * Ratio for the scale of the gizmo (Default: 1)
  137115. */
  137116. set scaleRatio(value: number);
  137117. get scaleRatio(): number;
  137118. /**
  137119. * Sensitivity factor for dragging (Default: 1)
  137120. */
  137121. set sensitivity(value: number);
  137122. get sensitivity(): number;
  137123. /**
  137124. * Disposes of the gizmo
  137125. */
  137126. dispose(): void;
  137127. }
  137128. }
  137129. declare module BABYLON {
  137130. /**
  137131. * Single axis scale gizmo
  137132. */
  137133. export class AxisScaleGizmo extends Gizmo {
  137134. /**
  137135. * Drag behavior responsible for the gizmos dragging interactions
  137136. */
  137137. dragBehavior: PointerDragBehavior;
  137138. private _pointerObserver;
  137139. /**
  137140. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137141. */
  137142. snapDistance: number;
  137143. /**
  137144. * Event that fires each time the gizmo snaps to a new location.
  137145. * * snapDistance is the the change in distance
  137146. */
  137147. onSnapObservable: Observable<{
  137148. snapDistance: number;
  137149. }>;
  137150. /**
  137151. * If the scaling operation should be done on all axis (default: false)
  137152. */
  137153. uniformScaling: boolean;
  137154. /**
  137155. * Custom sensitivity value for the drag strength
  137156. */
  137157. sensitivity: number;
  137158. private _isEnabled;
  137159. private _parent;
  137160. private _arrow;
  137161. private _coloredMaterial;
  137162. private _hoverMaterial;
  137163. /**
  137164. * Creates an AxisScaleGizmo
  137165. * @param gizmoLayer The utility layer the gizmo will be added to
  137166. * @param dragAxis The axis which the gizmo will be able to scale on
  137167. * @param color The color of the gizmo
  137168. * @param thickness display gizmo axis thickness
  137169. */
  137170. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137171. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137172. /**
  137173. * If the gizmo is enabled
  137174. */
  137175. set isEnabled(value: boolean);
  137176. get isEnabled(): boolean;
  137177. /**
  137178. * Disposes of the gizmo
  137179. */
  137180. dispose(): void;
  137181. /**
  137182. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137183. * @param mesh The mesh to replace the default mesh of the gizmo
  137184. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137185. */
  137186. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137187. }
  137188. }
  137189. declare module BABYLON {
  137190. /**
  137191. * Bounding box gizmo
  137192. */
  137193. export class BoundingBoxGizmo extends Gizmo {
  137194. private _lineBoundingBox;
  137195. private _rotateSpheresParent;
  137196. private _scaleBoxesParent;
  137197. private _boundingDimensions;
  137198. private _renderObserver;
  137199. private _pointerObserver;
  137200. private _scaleDragSpeed;
  137201. private _tmpQuaternion;
  137202. private _tmpVector;
  137203. private _tmpRotationMatrix;
  137204. /**
  137205. * 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)
  137206. */
  137207. ignoreChildren: boolean;
  137208. /**
  137209. * 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)
  137210. */
  137211. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137212. /**
  137213. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137214. */
  137215. rotationSphereSize: number;
  137216. /**
  137217. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137218. */
  137219. scaleBoxSize: number;
  137220. /**
  137221. * 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)
  137222. */
  137223. fixedDragMeshScreenSize: boolean;
  137224. /**
  137225. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137226. */
  137227. fixedDragMeshScreenSizeDistanceFactor: number;
  137228. /**
  137229. * Fired when a rotation sphere or scale box is dragged
  137230. */
  137231. onDragStartObservable: Observable<{}>;
  137232. /**
  137233. * Fired when a scale box is dragged
  137234. */
  137235. onScaleBoxDragObservable: Observable<{}>;
  137236. /**
  137237. * Fired when a scale box drag is ended
  137238. */
  137239. onScaleBoxDragEndObservable: Observable<{}>;
  137240. /**
  137241. * Fired when a rotation sphere is dragged
  137242. */
  137243. onRotationSphereDragObservable: Observable<{}>;
  137244. /**
  137245. * Fired when a rotation sphere drag is ended
  137246. */
  137247. onRotationSphereDragEndObservable: Observable<{}>;
  137248. /**
  137249. * 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)
  137250. */
  137251. scalePivot: Nullable<Vector3>;
  137252. /**
  137253. * Mesh used as a pivot to rotate the attached node
  137254. */
  137255. private _anchorMesh;
  137256. private _existingMeshScale;
  137257. private _dragMesh;
  137258. private pointerDragBehavior;
  137259. private coloredMaterial;
  137260. private hoverColoredMaterial;
  137261. /**
  137262. * Sets the color of the bounding box gizmo
  137263. * @param color the color to set
  137264. */
  137265. setColor(color: Color3): void;
  137266. /**
  137267. * Creates an BoundingBoxGizmo
  137268. * @param gizmoLayer The utility layer the gizmo will be added to
  137269. * @param color The color of the gizmo
  137270. */
  137271. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137272. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137273. private _selectNode;
  137274. /**
  137275. * Updates the bounding box information for the Gizmo
  137276. */
  137277. updateBoundingBox(): void;
  137278. private _updateRotationSpheres;
  137279. private _updateScaleBoxes;
  137280. /**
  137281. * Enables rotation on the specified axis and disables rotation on the others
  137282. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137283. */
  137284. setEnabledRotationAxis(axis: string): void;
  137285. /**
  137286. * Enables/disables scaling
  137287. * @param enable if scaling should be enabled
  137288. * @param homogeneousScaling defines if scaling should only be homogeneous
  137289. */
  137290. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137291. private _updateDummy;
  137292. /**
  137293. * Enables a pointer drag behavior on the bounding box of the gizmo
  137294. */
  137295. enableDragBehavior(): void;
  137296. /**
  137297. * Disposes of the gizmo
  137298. */
  137299. dispose(): void;
  137300. /**
  137301. * 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)
  137302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137303. * @returns the bounding box mesh with the passed in mesh as a child
  137304. */
  137305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137306. /**
  137307. * CustomMeshes are not supported by this gizmo
  137308. * @param mesh The mesh to replace the default mesh of the gizmo
  137309. */
  137310. setCustomMesh(mesh: Mesh): void;
  137311. }
  137312. }
  137313. declare module BABYLON {
  137314. /**
  137315. * Single plane rotation gizmo
  137316. */
  137317. export class PlaneRotationGizmo extends Gizmo {
  137318. /**
  137319. * Drag behavior responsible for the gizmos dragging interactions
  137320. */
  137321. dragBehavior: PointerDragBehavior;
  137322. private _pointerObserver;
  137323. /**
  137324. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137325. */
  137326. snapDistance: number;
  137327. /**
  137328. * Event that fires each time the gizmo snaps to a new location.
  137329. * * snapDistance is the the change in distance
  137330. */
  137331. onSnapObservable: Observable<{
  137332. snapDistance: number;
  137333. }>;
  137334. private _isEnabled;
  137335. private _parent;
  137336. /**
  137337. * Creates a PlaneRotationGizmo
  137338. * @param gizmoLayer The utility layer the gizmo will be added to
  137339. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137340. * @param color The color of the gizmo
  137341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137342. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137343. * @param thickness display gizmo axis thickness
  137344. */
  137345. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137346. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137347. /**
  137348. * If the gizmo is enabled
  137349. */
  137350. set isEnabled(value: boolean);
  137351. get isEnabled(): boolean;
  137352. /**
  137353. * Disposes of the gizmo
  137354. */
  137355. dispose(): void;
  137356. }
  137357. }
  137358. declare module BABYLON {
  137359. /**
  137360. * Gizmo that enables rotating a mesh along 3 axis
  137361. */
  137362. export class RotationGizmo extends Gizmo {
  137363. /**
  137364. * Internal gizmo used for interactions on the x axis
  137365. */
  137366. xGizmo: PlaneRotationGizmo;
  137367. /**
  137368. * Internal gizmo used for interactions on the y axis
  137369. */
  137370. yGizmo: PlaneRotationGizmo;
  137371. /**
  137372. * Internal gizmo used for interactions on the z axis
  137373. */
  137374. zGizmo: PlaneRotationGizmo;
  137375. /** Fires an event when any of it's sub gizmos are dragged */
  137376. onDragStartObservable: Observable<unknown>;
  137377. /** Fires an event when any of it's sub gizmos are released from dragging */
  137378. onDragEndObservable: Observable<unknown>;
  137379. private _meshAttached;
  137380. private _nodeAttached;
  137381. get attachedMesh(): Nullable<AbstractMesh>;
  137382. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137383. get attachedNode(): Nullable<Node>;
  137384. set attachedNode(node: Nullable<Node>);
  137385. /**
  137386. * True when the mouse pointer is hovering a gizmo mesh
  137387. */
  137388. get isHovered(): boolean;
  137389. /**
  137390. * Creates a RotationGizmo
  137391. * @param gizmoLayer The utility layer the gizmo will be added to
  137392. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137393. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137394. * @param thickness display gizmo axis thickness
  137395. */
  137396. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137397. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137398. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137399. /**
  137400. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137401. */
  137402. set snapDistance(value: number);
  137403. get snapDistance(): number;
  137404. /**
  137405. * Ratio for the scale of the gizmo (Default: 1)
  137406. */
  137407. set scaleRatio(value: number);
  137408. get scaleRatio(): number;
  137409. /**
  137410. * Disposes of the gizmo
  137411. */
  137412. dispose(): void;
  137413. /**
  137414. * CustomMeshes are not supported by this gizmo
  137415. * @param mesh The mesh to replace the default mesh of the gizmo
  137416. */
  137417. setCustomMesh(mesh: Mesh): void;
  137418. }
  137419. }
  137420. declare module BABYLON {
  137421. /**
  137422. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137423. */
  137424. export class GizmoManager implements IDisposable {
  137425. private scene;
  137426. /**
  137427. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137428. */
  137429. gizmos: {
  137430. positionGizmo: Nullable<PositionGizmo>;
  137431. rotationGizmo: Nullable<RotationGizmo>;
  137432. scaleGizmo: Nullable<ScaleGizmo>;
  137433. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137434. };
  137435. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137436. clearGizmoOnEmptyPointerEvent: boolean;
  137437. /** Fires an event when the manager is attached to a mesh */
  137438. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137439. /** Fires an event when the manager is attached to a node */
  137440. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137441. private _gizmosEnabled;
  137442. private _pointerObserver;
  137443. private _attachedMesh;
  137444. private _attachedNode;
  137445. private _boundingBoxColor;
  137446. private _defaultUtilityLayer;
  137447. private _defaultKeepDepthUtilityLayer;
  137448. private _thickness;
  137449. /**
  137450. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137451. */
  137452. boundingBoxDragBehavior: SixDofDragBehavior;
  137453. /**
  137454. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137455. */
  137456. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137457. /**
  137458. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137459. */
  137460. attachableNodes: Nullable<Array<Node>>;
  137461. /**
  137462. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137463. */
  137464. usePointerToAttachGizmos: boolean;
  137465. /**
  137466. * Utility layer that the bounding box gizmo belongs to
  137467. */
  137468. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137469. /**
  137470. * Utility layer that all gizmos besides bounding box belong to
  137471. */
  137472. get utilityLayer(): UtilityLayerRenderer;
  137473. /**
  137474. * True when the mouse pointer is hovering a gizmo mesh
  137475. */
  137476. get isHovered(): boolean;
  137477. /**
  137478. * Instatiates a gizmo manager
  137479. * @param scene the scene to overlay the gizmos on top of
  137480. * @param thickness display gizmo axis thickness
  137481. */
  137482. constructor(scene: Scene, thickness?: number);
  137483. /**
  137484. * Attaches a set of gizmos to the specified mesh
  137485. * @param mesh The mesh the gizmo's should be attached to
  137486. */
  137487. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137488. /**
  137489. * Attaches a set of gizmos to the specified node
  137490. * @param node The node the gizmo's should be attached to
  137491. */
  137492. attachToNode(node: Nullable<Node>): void;
  137493. /**
  137494. * If the position gizmo is enabled
  137495. */
  137496. set positionGizmoEnabled(value: boolean);
  137497. get positionGizmoEnabled(): boolean;
  137498. /**
  137499. * If the rotation gizmo is enabled
  137500. */
  137501. set rotationGizmoEnabled(value: boolean);
  137502. get rotationGizmoEnabled(): boolean;
  137503. /**
  137504. * If the scale gizmo is enabled
  137505. */
  137506. set scaleGizmoEnabled(value: boolean);
  137507. get scaleGizmoEnabled(): boolean;
  137508. /**
  137509. * If the boundingBox gizmo is enabled
  137510. */
  137511. set boundingBoxGizmoEnabled(value: boolean);
  137512. get boundingBoxGizmoEnabled(): boolean;
  137513. /**
  137514. * Disposes of the gizmo manager
  137515. */
  137516. dispose(): void;
  137517. }
  137518. }
  137519. declare module BABYLON {
  137520. /**
  137521. * A directional light is defined by a direction (what a surprise!).
  137522. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137523. * 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.
  137524. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137525. */
  137526. export class DirectionalLight extends ShadowLight {
  137527. private _shadowFrustumSize;
  137528. /**
  137529. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137530. */
  137531. get shadowFrustumSize(): number;
  137532. /**
  137533. * Specifies a fix frustum size for the shadow generation.
  137534. */
  137535. set shadowFrustumSize(value: number);
  137536. private _shadowOrthoScale;
  137537. /**
  137538. * Gets the shadow projection scale against the optimal computed one.
  137539. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137540. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137541. */
  137542. get shadowOrthoScale(): number;
  137543. /**
  137544. * Sets the shadow projection scale against the optimal computed one.
  137545. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137546. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137547. */
  137548. set shadowOrthoScale(value: number);
  137549. /**
  137550. * Automatically compute the projection matrix to best fit (including all the casters)
  137551. * on each frame.
  137552. */
  137553. autoUpdateExtends: boolean;
  137554. /**
  137555. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137556. * on each frame. autoUpdateExtends must be set to true for this to work
  137557. */
  137558. autoCalcShadowZBounds: boolean;
  137559. private _orthoLeft;
  137560. private _orthoRight;
  137561. private _orthoTop;
  137562. private _orthoBottom;
  137563. /**
  137564. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137565. * The directional light is emitted from everywhere in the given direction.
  137566. * It can cast shadows.
  137567. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137568. * @param name The friendly name of the light
  137569. * @param direction The direction of the light
  137570. * @param scene The scene the light belongs to
  137571. */
  137572. constructor(name: string, direction: Vector3, scene: Scene);
  137573. /**
  137574. * Returns the string "DirectionalLight".
  137575. * @return The class name
  137576. */
  137577. getClassName(): string;
  137578. /**
  137579. * Returns the integer 1.
  137580. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137581. */
  137582. getTypeID(): number;
  137583. /**
  137584. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137585. * Returns the DirectionalLight Shadow projection matrix.
  137586. */
  137587. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137588. /**
  137589. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137590. * Returns the DirectionalLight Shadow projection matrix.
  137591. */
  137592. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137593. /**
  137594. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137595. * Returns the DirectionalLight Shadow projection matrix.
  137596. */
  137597. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137598. protected _buildUniformLayout(): void;
  137599. /**
  137600. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137601. * @param effect The effect to update
  137602. * @param lightIndex The index of the light in the effect to update
  137603. * @returns The directional light
  137604. */
  137605. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137606. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137607. /**
  137608. * Gets the minZ used for shadow according to both the scene and the light.
  137609. *
  137610. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137611. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137612. * @param activeCamera The camera we are returning the min for
  137613. * @returns the depth min z
  137614. */
  137615. getDepthMinZ(activeCamera: Camera): number;
  137616. /**
  137617. * Gets the maxZ used for shadow according to both the scene and the light.
  137618. *
  137619. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137620. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137621. * @param activeCamera The camera we are returning the max for
  137622. * @returns the depth max z
  137623. */
  137624. getDepthMaxZ(activeCamera: Camera): number;
  137625. /**
  137626. * Prepares the list of defines specific to the light type.
  137627. * @param defines the list of defines
  137628. * @param lightIndex defines the index of the light for the effect
  137629. */
  137630. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137631. }
  137632. }
  137633. declare module BABYLON {
  137634. /**
  137635. * Class containing static functions to help procedurally build meshes
  137636. */
  137637. export class HemisphereBuilder {
  137638. /**
  137639. * Creates a hemisphere mesh
  137640. * @param name defines the name of the mesh
  137641. * @param options defines the options used to create the mesh
  137642. * @param scene defines the hosting scene
  137643. * @returns the hemisphere mesh
  137644. */
  137645. static CreateHemisphere(name: string, options: {
  137646. segments?: number;
  137647. diameter?: number;
  137648. sideOrientation?: number;
  137649. }, scene: any): Mesh;
  137650. }
  137651. }
  137652. declare module BABYLON {
  137653. /**
  137654. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137655. * These values define a cone of light starting from the position, emitting toward the direction.
  137656. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137657. * and the exponent defines the speed of the decay of the light with distance (reach).
  137658. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137659. */
  137660. export class SpotLight extends ShadowLight {
  137661. private _angle;
  137662. private _innerAngle;
  137663. private _cosHalfAngle;
  137664. private _lightAngleScale;
  137665. private _lightAngleOffset;
  137666. /**
  137667. * Gets the cone angle of the spot light in Radians.
  137668. */
  137669. get angle(): number;
  137670. /**
  137671. * Sets the cone angle of the spot light in Radians.
  137672. */
  137673. set angle(value: number);
  137674. /**
  137675. * Only used in gltf falloff mode, this defines the angle where
  137676. * the directional falloff will start before cutting at angle which could be seen
  137677. * as outer angle.
  137678. */
  137679. get innerAngle(): number;
  137680. /**
  137681. * Only used in gltf falloff mode, this defines the angle where
  137682. * the directional falloff will start before cutting at angle which could be seen
  137683. * as outer angle.
  137684. */
  137685. set innerAngle(value: number);
  137686. private _shadowAngleScale;
  137687. /**
  137688. * Allows scaling the angle of the light for shadow generation only.
  137689. */
  137690. get shadowAngleScale(): number;
  137691. /**
  137692. * Allows scaling the angle of the light for shadow generation only.
  137693. */
  137694. set shadowAngleScale(value: number);
  137695. /**
  137696. * The light decay speed with the distance from the emission spot.
  137697. */
  137698. exponent: number;
  137699. private _projectionTextureMatrix;
  137700. /**
  137701. * Allows reading the projecton texture
  137702. */
  137703. get projectionTextureMatrix(): Matrix;
  137704. protected _projectionTextureLightNear: number;
  137705. /**
  137706. * Gets the near clip of the Spotlight for texture projection.
  137707. */
  137708. get projectionTextureLightNear(): number;
  137709. /**
  137710. * Sets the near clip of the Spotlight for texture projection.
  137711. */
  137712. set projectionTextureLightNear(value: number);
  137713. protected _projectionTextureLightFar: number;
  137714. /**
  137715. * Gets the far clip of the Spotlight for texture projection.
  137716. */
  137717. get projectionTextureLightFar(): number;
  137718. /**
  137719. * Sets the far clip of the Spotlight for texture projection.
  137720. */
  137721. set projectionTextureLightFar(value: number);
  137722. protected _projectionTextureUpDirection: Vector3;
  137723. /**
  137724. * Gets the Up vector of the Spotlight for texture projection.
  137725. */
  137726. get projectionTextureUpDirection(): Vector3;
  137727. /**
  137728. * Sets the Up vector of the Spotlight for texture projection.
  137729. */
  137730. set projectionTextureUpDirection(value: Vector3);
  137731. private _projectionTexture;
  137732. /**
  137733. * Gets the projection texture of the light.
  137734. */
  137735. get projectionTexture(): Nullable<BaseTexture>;
  137736. /**
  137737. * Sets the projection texture of the light.
  137738. */
  137739. set projectionTexture(value: Nullable<BaseTexture>);
  137740. private _projectionTextureViewLightDirty;
  137741. private _projectionTextureProjectionLightDirty;
  137742. private _projectionTextureDirty;
  137743. private _projectionTextureViewTargetVector;
  137744. private _projectionTextureViewLightMatrix;
  137745. private _projectionTextureProjectionLightMatrix;
  137746. private _projectionTextureScalingMatrix;
  137747. /**
  137748. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137749. * It can cast shadows.
  137750. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137751. * @param name The light friendly name
  137752. * @param position The position of the spot light in the scene
  137753. * @param direction The direction of the light in the scene
  137754. * @param angle The cone angle of the light in Radians
  137755. * @param exponent The light decay speed with the distance from the emission spot
  137756. * @param scene The scene the lights belongs to
  137757. */
  137758. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  137759. /**
  137760. * Returns the string "SpotLight".
  137761. * @returns the class name
  137762. */
  137763. getClassName(): string;
  137764. /**
  137765. * Returns the integer 2.
  137766. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137767. */
  137768. getTypeID(): number;
  137769. /**
  137770. * Overrides the direction setter to recompute the projection texture view light Matrix.
  137771. */
  137772. protected _setDirection(value: Vector3): void;
  137773. /**
  137774. * Overrides the position setter to recompute the projection texture view light Matrix.
  137775. */
  137776. protected _setPosition(value: Vector3): void;
  137777. /**
  137778. * 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.
  137779. * Returns the SpotLight.
  137780. */
  137781. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137782. protected _computeProjectionTextureViewLightMatrix(): void;
  137783. protected _computeProjectionTextureProjectionLightMatrix(): void;
  137784. /**
  137785. * Main function for light texture projection matrix computing.
  137786. */
  137787. protected _computeProjectionTextureMatrix(): void;
  137788. protected _buildUniformLayout(): void;
  137789. private _computeAngleValues;
  137790. /**
  137791. * Sets the passed Effect "effect" with the Light textures.
  137792. * @param effect The effect to update
  137793. * @param lightIndex The index of the light in the effect to update
  137794. * @returns The light
  137795. */
  137796. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  137797. /**
  137798. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  137799. * @param effect The effect to update
  137800. * @param lightIndex The index of the light in the effect to update
  137801. * @returns The spot light
  137802. */
  137803. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  137804. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137805. /**
  137806. * Disposes the light and the associated resources.
  137807. */
  137808. dispose(): void;
  137809. /**
  137810. * Prepares the list of defines specific to the light type.
  137811. * @param defines the list of defines
  137812. * @param lightIndex defines the index of the light for the effect
  137813. */
  137814. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137815. }
  137816. }
  137817. declare module BABYLON {
  137818. /**
  137819. * Gizmo that enables viewing a light
  137820. */
  137821. export class LightGizmo extends Gizmo {
  137822. private _lightMesh;
  137823. private _material;
  137824. private _cachedPosition;
  137825. private _cachedForward;
  137826. private _attachedMeshParent;
  137827. private _pointerObserver;
  137828. /**
  137829. * Event that fires each time the gizmo is clicked
  137830. */
  137831. onClickedObservable: Observable<Light>;
  137832. /**
  137833. * Creates a LightGizmo
  137834. * @param gizmoLayer The utility layer the gizmo will be added to
  137835. */
  137836. constructor(gizmoLayer?: UtilityLayerRenderer);
  137837. private _light;
  137838. /**
  137839. * The light that the gizmo is attached to
  137840. */
  137841. set light(light: Nullable<Light>);
  137842. get light(): Nullable<Light>;
  137843. /**
  137844. * Gets the material used to render the light gizmo
  137845. */
  137846. get material(): StandardMaterial;
  137847. /**
  137848. * @hidden
  137849. * Updates the gizmo to match the attached mesh's position/rotation
  137850. */
  137851. protected _update(): void;
  137852. private static _Scale;
  137853. /**
  137854. * Creates the lines for a light mesh
  137855. */
  137856. private static _CreateLightLines;
  137857. /**
  137858. * Disposes of the light gizmo
  137859. */
  137860. dispose(): void;
  137861. private static _CreateHemisphericLightMesh;
  137862. private static _CreatePointLightMesh;
  137863. private static _CreateSpotLightMesh;
  137864. private static _CreateDirectionalLightMesh;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. /**
  137869. * Gizmo that enables viewing a camera
  137870. */
  137871. export class CameraGizmo extends Gizmo {
  137872. private _cameraMesh;
  137873. private _cameraLinesMesh;
  137874. private _material;
  137875. private _pointerObserver;
  137876. /**
  137877. * Event that fires each time the gizmo is clicked
  137878. */
  137879. onClickedObservable: Observable<Camera>;
  137880. /**
  137881. * Creates a CameraGizmo
  137882. * @param gizmoLayer The utility layer the gizmo will be added to
  137883. */
  137884. constructor(gizmoLayer?: UtilityLayerRenderer);
  137885. private _camera;
  137886. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  137887. get displayFrustum(): boolean;
  137888. set displayFrustum(value: boolean);
  137889. /**
  137890. * The camera that the gizmo is attached to
  137891. */
  137892. set camera(camera: Nullable<Camera>);
  137893. get camera(): Nullable<Camera>;
  137894. /**
  137895. * Gets the material used to render the camera gizmo
  137896. */
  137897. get material(): StandardMaterial;
  137898. /**
  137899. * @hidden
  137900. * Updates the gizmo to match the attached mesh's position/rotation
  137901. */
  137902. protected _update(): void;
  137903. private static _Scale;
  137904. private _invProjection;
  137905. /**
  137906. * Disposes of the camera gizmo
  137907. */
  137908. dispose(): void;
  137909. private static _CreateCameraMesh;
  137910. private static _CreateCameraFrustum;
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. /** @hidden */
  137915. export var backgroundFragmentDeclaration: {
  137916. name: string;
  137917. shader: string;
  137918. };
  137919. }
  137920. declare module BABYLON {
  137921. /** @hidden */
  137922. export var backgroundUboDeclaration: {
  137923. name: string;
  137924. shader: string;
  137925. };
  137926. }
  137927. declare module BABYLON {
  137928. /** @hidden */
  137929. export var backgroundPixelShader: {
  137930. name: string;
  137931. shader: string;
  137932. };
  137933. }
  137934. declare module BABYLON {
  137935. /** @hidden */
  137936. export var backgroundVertexDeclaration: {
  137937. name: string;
  137938. shader: string;
  137939. };
  137940. }
  137941. declare module BABYLON {
  137942. /** @hidden */
  137943. export var backgroundVertexShader: {
  137944. name: string;
  137945. shader: string;
  137946. };
  137947. }
  137948. declare module BABYLON {
  137949. /**
  137950. * Background material used to create an efficient environement around your scene.
  137951. */
  137952. export class BackgroundMaterial extends PushMaterial {
  137953. /**
  137954. * Standard reflectance value at parallel view angle.
  137955. */
  137956. static StandardReflectance0: number;
  137957. /**
  137958. * Standard reflectance value at grazing angle.
  137959. */
  137960. static StandardReflectance90: number;
  137961. protected _primaryColor: Color3;
  137962. /**
  137963. * Key light Color (multiply against the environement texture)
  137964. */
  137965. primaryColor: Color3;
  137966. protected __perceptualColor: Nullable<Color3>;
  137967. /**
  137968. * Experimental Internal Use Only.
  137969. *
  137970. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  137971. * This acts as a helper to set the primary color to a more "human friendly" value.
  137972. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  137973. * output color as close as possible from the chosen value.
  137974. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  137975. * part of lighting setup.)
  137976. */
  137977. get _perceptualColor(): Nullable<Color3>;
  137978. set _perceptualColor(value: Nullable<Color3>);
  137979. protected _primaryColorShadowLevel: float;
  137980. /**
  137981. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  137982. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  137983. */
  137984. get primaryColorShadowLevel(): float;
  137985. set primaryColorShadowLevel(value: float);
  137986. protected _primaryColorHighlightLevel: float;
  137987. /**
  137988. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  137989. * The primary color is used at the level chosen to define what the white area would look.
  137990. */
  137991. get primaryColorHighlightLevel(): float;
  137992. set primaryColorHighlightLevel(value: float);
  137993. protected _reflectionTexture: Nullable<BaseTexture>;
  137994. /**
  137995. * Reflection Texture used in the material.
  137996. * Should be author in a specific way for the best result (refer to the documentation).
  137997. */
  137998. reflectionTexture: Nullable<BaseTexture>;
  137999. protected _reflectionBlur: float;
  138000. /**
  138001. * Reflection Texture level of blur.
  138002. *
  138003. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138004. * texture twice.
  138005. */
  138006. reflectionBlur: float;
  138007. protected _diffuseTexture: Nullable<BaseTexture>;
  138008. /**
  138009. * Diffuse Texture used in the material.
  138010. * Should be author in a specific way for the best result (refer to the documentation).
  138011. */
  138012. diffuseTexture: Nullable<BaseTexture>;
  138013. protected _shadowLights: Nullable<IShadowLight[]>;
  138014. /**
  138015. * Specify the list of lights casting shadow on the material.
  138016. * All scene shadow lights will be included if null.
  138017. */
  138018. shadowLights: Nullable<IShadowLight[]>;
  138019. protected _shadowLevel: float;
  138020. /**
  138021. * Helps adjusting the shadow to a softer level if required.
  138022. * 0 means black shadows and 1 means no shadows.
  138023. */
  138024. shadowLevel: float;
  138025. protected _sceneCenter: Vector3;
  138026. /**
  138027. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138028. * It is usually zero but might be interesting to modify according to your setup.
  138029. */
  138030. sceneCenter: Vector3;
  138031. protected _opacityFresnel: boolean;
  138032. /**
  138033. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138034. * This helps ensuring a nice transition when the camera goes under the ground.
  138035. */
  138036. opacityFresnel: boolean;
  138037. protected _reflectionFresnel: boolean;
  138038. /**
  138039. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138040. * This helps adding a mirror texture on the ground.
  138041. */
  138042. reflectionFresnel: boolean;
  138043. protected _reflectionFalloffDistance: number;
  138044. /**
  138045. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138046. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138047. */
  138048. reflectionFalloffDistance: number;
  138049. protected _reflectionAmount: number;
  138050. /**
  138051. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138052. */
  138053. reflectionAmount: number;
  138054. protected _reflectionReflectance0: number;
  138055. /**
  138056. * This specifies the weight of the reflection at grazing angle.
  138057. */
  138058. reflectionReflectance0: number;
  138059. protected _reflectionReflectance90: number;
  138060. /**
  138061. * This specifies the weight of the reflection at a perpendicular point of view.
  138062. */
  138063. reflectionReflectance90: number;
  138064. /**
  138065. * Sets the reflection reflectance fresnel values according to the default standard
  138066. * empirically know to work well :-)
  138067. */
  138068. set reflectionStandardFresnelWeight(value: number);
  138069. protected _useRGBColor: boolean;
  138070. /**
  138071. * Helps to directly use the maps channels instead of their level.
  138072. */
  138073. useRGBColor: boolean;
  138074. protected _enableNoise: boolean;
  138075. /**
  138076. * This helps reducing the banding effect that could occur on the background.
  138077. */
  138078. enableNoise: boolean;
  138079. /**
  138080. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138081. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138082. * Recommended to be keep at 1.0 except for special cases.
  138083. */
  138084. get fovMultiplier(): number;
  138085. set fovMultiplier(value: number);
  138086. private _fovMultiplier;
  138087. /**
  138088. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138089. */
  138090. useEquirectangularFOV: boolean;
  138091. private _maxSimultaneousLights;
  138092. /**
  138093. * Number of Simultaneous lights allowed on the material.
  138094. */
  138095. maxSimultaneousLights: int;
  138096. private _shadowOnly;
  138097. /**
  138098. * Make the material only render shadows
  138099. */
  138100. shadowOnly: boolean;
  138101. /**
  138102. * Default configuration related to image processing available in the Background Material.
  138103. */
  138104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138105. /**
  138106. * Keep track of the image processing observer to allow dispose and replace.
  138107. */
  138108. private _imageProcessingObserver;
  138109. /**
  138110. * Attaches a new image processing configuration to the PBR Material.
  138111. * @param configuration (if null the scene configuration will be use)
  138112. */
  138113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138114. /**
  138115. * Gets the image processing configuration used either in this material.
  138116. */
  138117. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138118. /**
  138119. * Sets the Default image processing configuration used either in the this material.
  138120. *
  138121. * If sets to null, the scene one is in use.
  138122. */
  138123. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138124. /**
  138125. * Gets wether the color curves effect is enabled.
  138126. */
  138127. get cameraColorCurvesEnabled(): boolean;
  138128. /**
  138129. * Sets wether the color curves effect is enabled.
  138130. */
  138131. set cameraColorCurvesEnabled(value: boolean);
  138132. /**
  138133. * Gets wether the color grading effect is enabled.
  138134. */
  138135. get cameraColorGradingEnabled(): boolean;
  138136. /**
  138137. * Gets wether the color grading effect is enabled.
  138138. */
  138139. set cameraColorGradingEnabled(value: boolean);
  138140. /**
  138141. * Gets wether tonemapping is enabled or not.
  138142. */
  138143. get cameraToneMappingEnabled(): boolean;
  138144. /**
  138145. * Sets wether tonemapping is enabled or not
  138146. */
  138147. set cameraToneMappingEnabled(value: boolean);
  138148. /**
  138149. * The camera exposure used on this material.
  138150. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138151. * This corresponds to a photographic exposure.
  138152. */
  138153. get cameraExposure(): float;
  138154. /**
  138155. * The camera exposure used on this material.
  138156. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138157. * This corresponds to a photographic exposure.
  138158. */
  138159. set cameraExposure(value: float);
  138160. /**
  138161. * Gets The camera contrast used on this material.
  138162. */
  138163. get cameraContrast(): float;
  138164. /**
  138165. * Sets The camera contrast used on this material.
  138166. */
  138167. set cameraContrast(value: float);
  138168. /**
  138169. * Gets the Color Grading 2D Lookup Texture.
  138170. */
  138171. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138172. /**
  138173. * Sets the Color Grading 2D Lookup Texture.
  138174. */
  138175. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138176. /**
  138177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138179. * 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;
  138180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138181. */
  138182. get cameraColorCurves(): Nullable<ColorCurves>;
  138183. /**
  138184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138186. * 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;
  138187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138188. */
  138189. set cameraColorCurves(value: Nullable<ColorCurves>);
  138190. /**
  138191. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138192. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138193. */
  138194. switchToBGR: boolean;
  138195. private _renderTargets;
  138196. private _reflectionControls;
  138197. private _white;
  138198. private _primaryShadowColor;
  138199. private _primaryHighlightColor;
  138200. /**
  138201. * Instantiates a Background Material in the given scene
  138202. * @param name The friendly name of the material
  138203. * @param scene The scene to add the material to
  138204. */
  138205. constructor(name: string, scene: Scene);
  138206. /**
  138207. * Gets a boolean indicating that current material needs to register RTT
  138208. */
  138209. get hasRenderTargetTextures(): boolean;
  138210. /**
  138211. * The entire material has been created in order to prevent overdraw.
  138212. * @returns false
  138213. */
  138214. needAlphaTesting(): boolean;
  138215. /**
  138216. * The entire material has been created in order to prevent overdraw.
  138217. * @returns true if blending is enable
  138218. */
  138219. needAlphaBlending(): boolean;
  138220. /**
  138221. * Checks wether the material is ready to be rendered for a given mesh.
  138222. * @param mesh The mesh to render
  138223. * @param subMesh The submesh to check against
  138224. * @param useInstances Specify wether or not the material is used with instances
  138225. * @returns true if all the dependencies are ready (Textures, Effects...)
  138226. */
  138227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138228. /**
  138229. * Compute the primary color according to the chosen perceptual color.
  138230. */
  138231. private _computePrimaryColorFromPerceptualColor;
  138232. /**
  138233. * Compute the highlights and shadow colors according to their chosen levels.
  138234. */
  138235. private _computePrimaryColors;
  138236. /**
  138237. * Build the uniform buffer used in the material.
  138238. */
  138239. buildUniformLayout(): void;
  138240. /**
  138241. * Unbind the material.
  138242. */
  138243. unbind(): void;
  138244. /**
  138245. * Bind only the world matrix to the material.
  138246. * @param world The world matrix to bind.
  138247. */
  138248. bindOnlyWorldMatrix(world: Matrix): void;
  138249. /**
  138250. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138251. * @param world The world matrix to bind.
  138252. * @param subMesh The submesh to bind for.
  138253. */
  138254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138255. /**
  138256. * Checks to see if a texture is used in the material.
  138257. * @param texture - Base texture to use.
  138258. * @returns - Boolean specifying if a texture is used in the material.
  138259. */
  138260. hasTexture(texture: BaseTexture): boolean;
  138261. /**
  138262. * Dispose the material.
  138263. * @param forceDisposeEffect Force disposal of the associated effect.
  138264. * @param forceDisposeTextures Force disposal of the associated textures.
  138265. */
  138266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138267. /**
  138268. * Clones the material.
  138269. * @param name The cloned name.
  138270. * @returns The cloned material.
  138271. */
  138272. clone(name: string): BackgroundMaterial;
  138273. /**
  138274. * Serializes the current material to its JSON representation.
  138275. * @returns The JSON representation.
  138276. */
  138277. serialize(): any;
  138278. /**
  138279. * Gets the class name of the material
  138280. * @returns "BackgroundMaterial"
  138281. */
  138282. getClassName(): string;
  138283. /**
  138284. * Parse a JSON input to create back a background material.
  138285. * @param source The JSON data to parse
  138286. * @param scene The scene to create the parsed material in
  138287. * @param rootUrl The root url of the assets the material depends upon
  138288. * @returns the instantiated BackgroundMaterial.
  138289. */
  138290. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138291. }
  138292. }
  138293. declare module BABYLON {
  138294. /**
  138295. * Represents the different options available during the creation of
  138296. * a Environment helper.
  138297. *
  138298. * This can control the default ground, skybox and image processing setup of your scene.
  138299. */
  138300. export interface IEnvironmentHelperOptions {
  138301. /**
  138302. * Specifies whether or not to create a ground.
  138303. * True by default.
  138304. */
  138305. createGround: boolean;
  138306. /**
  138307. * Specifies the ground size.
  138308. * 15 by default.
  138309. */
  138310. groundSize: number;
  138311. /**
  138312. * The texture used on the ground for the main color.
  138313. * Comes from the BabylonJS CDN by default.
  138314. *
  138315. * Remarks: Can be either a texture or a url.
  138316. */
  138317. groundTexture: string | BaseTexture;
  138318. /**
  138319. * The color mixed in the ground texture by default.
  138320. * BabylonJS clearColor by default.
  138321. */
  138322. groundColor: Color3;
  138323. /**
  138324. * Specifies the ground opacity.
  138325. * 1 by default.
  138326. */
  138327. groundOpacity: number;
  138328. /**
  138329. * Enables the ground to receive shadows.
  138330. * True by default.
  138331. */
  138332. enableGroundShadow: boolean;
  138333. /**
  138334. * Helps preventing the shadow to be fully black on the ground.
  138335. * 0.5 by default.
  138336. */
  138337. groundShadowLevel: number;
  138338. /**
  138339. * Creates a mirror texture attach to the ground.
  138340. * false by default.
  138341. */
  138342. enableGroundMirror: boolean;
  138343. /**
  138344. * Specifies the ground mirror size ratio.
  138345. * 0.3 by default as the default kernel is 64.
  138346. */
  138347. groundMirrorSizeRatio: number;
  138348. /**
  138349. * Specifies the ground mirror blur kernel size.
  138350. * 64 by default.
  138351. */
  138352. groundMirrorBlurKernel: number;
  138353. /**
  138354. * Specifies the ground mirror visibility amount.
  138355. * 1 by default
  138356. */
  138357. groundMirrorAmount: number;
  138358. /**
  138359. * Specifies the ground mirror reflectance weight.
  138360. * This uses the standard weight of the background material to setup the fresnel effect
  138361. * of the mirror.
  138362. * 1 by default.
  138363. */
  138364. groundMirrorFresnelWeight: number;
  138365. /**
  138366. * Specifies the ground mirror Falloff distance.
  138367. * This can helps reducing the size of the reflection.
  138368. * 0 by Default.
  138369. */
  138370. groundMirrorFallOffDistance: number;
  138371. /**
  138372. * Specifies the ground mirror texture type.
  138373. * Unsigned Int by Default.
  138374. */
  138375. groundMirrorTextureType: number;
  138376. /**
  138377. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138378. * the shown objects.
  138379. */
  138380. groundYBias: number;
  138381. /**
  138382. * Specifies whether or not to create a skybox.
  138383. * True by default.
  138384. */
  138385. createSkybox: boolean;
  138386. /**
  138387. * Specifies the skybox size.
  138388. * 20 by default.
  138389. */
  138390. skyboxSize: number;
  138391. /**
  138392. * The texture used on the skybox for the main color.
  138393. * Comes from the BabylonJS CDN by default.
  138394. *
  138395. * Remarks: Can be either a texture or a url.
  138396. */
  138397. skyboxTexture: string | BaseTexture;
  138398. /**
  138399. * The color mixed in the skybox texture by default.
  138400. * BabylonJS clearColor by default.
  138401. */
  138402. skyboxColor: Color3;
  138403. /**
  138404. * The background rotation around the Y axis of the scene.
  138405. * This helps aligning the key lights of your scene with the background.
  138406. * 0 by default.
  138407. */
  138408. backgroundYRotation: number;
  138409. /**
  138410. * Compute automatically the size of the elements to best fit with the scene.
  138411. */
  138412. sizeAuto: boolean;
  138413. /**
  138414. * Default position of the rootMesh if autoSize is not true.
  138415. */
  138416. rootPosition: Vector3;
  138417. /**
  138418. * Sets up the image processing in the scene.
  138419. * true by default.
  138420. */
  138421. setupImageProcessing: boolean;
  138422. /**
  138423. * The texture used as your environment texture in the scene.
  138424. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138425. *
  138426. * Remarks: Can be either a texture or a url.
  138427. */
  138428. environmentTexture: string | BaseTexture;
  138429. /**
  138430. * The value of the exposure to apply to the scene.
  138431. * 0.6 by default if setupImageProcessing is true.
  138432. */
  138433. cameraExposure: number;
  138434. /**
  138435. * The value of the contrast to apply to the scene.
  138436. * 1.6 by default if setupImageProcessing is true.
  138437. */
  138438. cameraContrast: number;
  138439. /**
  138440. * Specifies whether or not tonemapping should be enabled in the scene.
  138441. * true by default if setupImageProcessing is true.
  138442. */
  138443. toneMappingEnabled: boolean;
  138444. }
  138445. /**
  138446. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138447. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138448. * It also helps with the default setup of your imageProcessing configuration.
  138449. */
  138450. export class EnvironmentHelper {
  138451. /**
  138452. * Default ground texture URL.
  138453. */
  138454. private static _groundTextureCDNUrl;
  138455. /**
  138456. * Default skybox texture URL.
  138457. */
  138458. private static _skyboxTextureCDNUrl;
  138459. /**
  138460. * Default environment texture URL.
  138461. */
  138462. private static _environmentTextureCDNUrl;
  138463. /**
  138464. * Creates the default options for the helper.
  138465. */
  138466. private static _getDefaultOptions;
  138467. private _rootMesh;
  138468. /**
  138469. * Gets the root mesh created by the helper.
  138470. */
  138471. get rootMesh(): Mesh;
  138472. private _skybox;
  138473. /**
  138474. * Gets the skybox created by the helper.
  138475. */
  138476. get skybox(): Nullable<Mesh>;
  138477. private _skyboxTexture;
  138478. /**
  138479. * Gets the skybox texture created by the helper.
  138480. */
  138481. get skyboxTexture(): Nullable<BaseTexture>;
  138482. private _skyboxMaterial;
  138483. /**
  138484. * Gets the skybox material created by the helper.
  138485. */
  138486. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138487. private _ground;
  138488. /**
  138489. * Gets the ground mesh created by the helper.
  138490. */
  138491. get ground(): Nullable<Mesh>;
  138492. private _groundTexture;
  138493. /**
  138494. * Gets the ground texture created by the helper.
  138495. */
  138496. get groundTexture(): Nullable<BaseTexture>;
  138497. private _groundMirror;
  138498. /**
  138499. * Gets the ground mirror created by the helper.
  138500. */
  138501. get groundMirror(): Nullable<MirrorTexture>;
  138502. /**
  138503. * Gets the ground mirror render list to helps pushing the meshes
  138504. * you wish in the ground reflection.
  138505. */
  138506. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138507. private _groundMaterial;
  138508. /**
  138509. * Gets the ground material created by the helper.
  138510. */
  138511. get groundMaterial(): Nullable<BackgroundMaterial>;
  138512. /**
  138513. * Stores the creation options.
  138514. */
  138515. private readonly _scene;
  138516. private _options;
  138517. /**
  138518. * This observable will be notified with any error during the creation of the environment,
  138519. * mainly texture creation errors.
  138520. */
  138521. onErrorObservable: Observable<{
  138522. message?: string;
  138523. exception?: any;
  138524. }>;
  138525. /**
  138526. * constructor
  138527. * @param options Defines the options we want to customize the helper
  138528. * @param scene The scene to add the material to
  138529. */
  138530. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138531. /**
  138532. * Updates the background according to the new options
  138533. * @param options
  138534. */
  138535. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138536. /**
  138537. * Sets the primary color of all the available elements.
  138538. * @param color the main color to affect to the ground and the background
  138539. */
  138540. setMainColor(color: Color3): void;
  138541. /**
  138542. * Setup the image processing according to the specified options.
  138543. */
  138544. private _setupImageProcessing;
  138545. /**
  138546. * Setup the environment texture according to the specified options.
  138547. */
  138548. private _setupEnvironmentTexture;
  138549. /**
  138550. * Setup the background according to the specified options.
  138551. */
  138552. private _setupBackground;
  138553. /**
  138554. * Get the scene sizes according to the setup.
  138555. */
  138556. private _getSceneSize;
  138557. /**
  138558. * Setup the ground according to the specified options.
  138559. */
  138560. private _setupGround;
  138561. /**
  138562. * Setup the ground material according to the specified options.
  138563. */
  138564. private _setupGroundMaterial;
  138565. /**
  138566. * Setup the ground diffuse texture according to the specified options.
  138567. */
  138568. private _setupGroundDiffuseTexture;
  138569. /**
  138570. * Setup the ground mirror texture according to the specified options.
  138571. */
  138572. private _setupGroundMirrorTexture;
  138573. /**
  138574. * Setup the ground to receive the mirror texture.
  138575. */
  138576. private _setupMirrorInGroundMaterial;
  138577. /**
  138578. * Setup the skybox according to the specified options.
  138579. */
  138580. private _setupSkybox;
  138581. /**
  138582. * Setup the skybox material according to the specified options.
  138583. */
  138584. private _setupSkyboxMaterial;
  138585. /**
  138586. * Setup the skybox reflection texture according to the specified options.
  138587. */
  138588. private _setupSkyboxReflectionTexture;
  138589. private _errorHandler;
  138590. /**
  138591. * Dispose all the elements created by the Helper.
  138592. */
  138593. dispose(): void;
  138594. }
  138595. }
  138596. declare module BABYLON {
  138597. /**
  138598. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138599. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138600. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138601. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138602. */
  138603. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138604. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138605. /**
  138606. * Define the source as a Monoscopic panoramic 360/180.
  138607. */
  138608. static readonly MODE_MONOSCOPIC: number;
  138609. /**
  138610. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138611. */
  138612. static readonly MODE_TOPBOTTOM: number;
  138613. /**
  138614. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138615. */
  138616. static readonly MODE_SIDEBYSIDE: number;
  138617. private _halfDome;
  138618. private _crossEye;
  138619. protected _useDirectMapping: boolean;
  138620. /**
  138621. * The texture being displayed on the sphere
  138622. */
  138623. protected _texture: T;
  138624. /**
  138625. * Gets the texture being displayed on the sphere
  138626. */
  138627. get texture(): T;
  138628. /**
  138629. * Sets the texture being displayed on the sphere
  138630. */
  138631. set texture(newTexture: T);
  138632. /**
  138633. * The skybox material
  138634. */
  138635. protected _material: BackgroundMaterial;
  138636. /**
  138637. * The surface used for the dome
  138638. */
  138639. protected _mesh: Mesh;
  138640. /**
  138641. * Gets the mesh used for the dome.
  138642. */
  138643. get mesh(): Mesh;
  138644. /**
  138645. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138646. */
  138647. private _halfDomeMask;
  138648. /**
  138649. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138650. * Also see the options.resolution property.
  138651. */
  138652. get fovMultiplier(): number;
  138653. set fovMultiplier(value: number);
  138654. protected _textureMode: number;
  138655. /**
  138656. * Gets or set the current texture mode for the texture. It can be:
  138657. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138658. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138659. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138660. */
  138661. get textureMode(): number;
  138662. /**
  138663. * Sets the current texture mode for the texture. It can be:
  138664. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138665. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138666. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138667. */
  138668. set textureMode(value: number);
  138669. /**
  138670. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138671. */
  138672. get halfDome(): boolean;
  138673. /**
  138674. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138675. */
  138676. set halfDome(enabled: boolean);
  138677. /**
  138678. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138679. */
  138680. set crossEye(enabled: boolean);
  138681. /**
  138682. * Is it a cross-eye texture?
  138683. */
  138684. get crossEye(): boolean;
  138685. /**
  138686. * Oberserver used in Stereoscopic VR Mode.
  138687. */
  138688. private _onBeforeCameraRenderObserver;
  138689. /**
  138690. * Observable raised when an error occured while loading the 360 image
  138691. */
  138692. onLoadErrorObservable: Observable<string>;
  138693. /**
  138694. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138695. * @param name Element's name, child elements will append suffixes for their own names.
  138696. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138697. * @param options An object containing optional or exposed sub element properties
  138698. */
  138699. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138700. resolution?: number;
  138701. clickToPlay?: boolean;
  138702. autoPlay?: boolean;
  138703. loop?: boolean;
  138704. size?: number;
  138705. poster?: string;
  138706. faceForward?: boolean;
  138707. useDirectMapping?: boolean;
  138708. halfDomeMode?: boolean;
  138709. crossEyeMode?: boolean;
  138710. generateMipMaps?: boolean;
  138711. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138712. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138713. protected _changeTextureMode(value: number): void;
  138714. /**
  138715. * Releases resources associated with this node.
  138716. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138717. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138718. */
  138719. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138720. }
  138721. }
  138722. declare module BABYLON {
  138723. /**
  138724. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138725. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138726. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138727. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138728. */
  138729. export class PhotoDome extends TextureDome<Texture> {
  138730. /**
  138731. * Define the image as a Monoscopic panoramic 360 image.
  138732. */
  138733. static readonly MODE_MONOSCOPIC: number;
  138734. /**
  138735. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138736. */
  138737. static readonly MODE_TOPBOTTOM: number;
  138738. /**
  138739. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138740. */
  138741. static readonly MODE_SIDEBYSIDE: number;
  138742. /**
  138743. * Gets or sets the texture being displayed on the sphere
  138744. */
  138745. get photoTexture(): Texture;
  138746. /**
  138747. * sets the texture being displayed on the sphere
  138748. */
  138749. set photoTexture(value: Texture);
  138750. /**
  138751. * Gets the current video mode for the video. It can be:
  138752. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138753. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138754. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138755. */
  138756. get imageMode(): number;
  138757. /**
  138758. * Sets the current video mode for the video. It can be:
  138759. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138760. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138761. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138762. */
  138763. set imageMode(value: number);
  138764. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  138765. }
  138766. }
  138767. declare module BABYLON {
  138768. /**
  138769. * Direct draw surface info
  138770. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138771. */
  138772. export interface DDSInfo {
  138773. /**
  138774. * Width of the texture
  138775. */
  138776. width: number;
  138777. /**
  138778. * Width of the texture
  138779. */
  138780. height: number;
  138781. /**
  138782. * Number of Mipmaps for the texture
  138783. * @see https://en.wikipedia.org/wiki/Mipmap
  138784. */
  138785. mipmapCount: number;
  138786. /**
  138787. * If the textures format is a known fourCC format
  138788. * @see https://www.fourcc.org/
  138789. */
  138790. isFourCC: boolean;
  138791. /**
  138792. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138793. */
  138794. isRGB: boolean;
  138795. /**
  138796. * If the texture is a lumincance format
  138797. */
  138798. isLuminance: boolean;
  138799. /**
  138800. * If this is a cube texture
  138801. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138802. */
  138803. isCube: boolean;
  138804. /**
  138805. * If the texture is a compressed format eg. FOURCC_DXT1
  138806. */
  138807. isCompressed: boolean;
  138808. /**
  138809. * The dxgiFormat of the texture
  138810. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138811. */
  138812. dxgiFormat: number;
  138813. /**
  138814. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138815. */
  138816. textureType: number;
  138817. /**
  138818. * Sphericle polynomial created for the dds texture
  138819. */
  138820. sphericalPolynomial?: SphericalPolynomial;
  138821. }
  138822. /**
  138823. * Class used to provide DDS decompression tools
  138824. */
  138825. export class DDSTools {
  138826. /**
  138827. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138828. */
  138829. static StoreLODInAlphaChannel: boolean;
  138830. /**
  138831. * Gets DDS information from an array buffer
  138832. * @param data defines the array buffer view to read data from
  138833. * @returns the DDS information
  138834. */
  138835. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138836. private static _FloatView;
  138837. private static _Int32View;
  138838. private static _ToHalfFloat;
  138839. private static _FromHalfFloat;
  138840. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138841. private static _GetHalfFloatRGBAArrayBuffer;
  138842. private static _GetFloatRGBAArrayBuffer;
  138843. private static _GetFloatAsUIntRGBAArrayBuffer;
  138844. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138845. private static _GetRGBAArrayBuffer;
  138846. private static _ExtractLongWordOrder;
  138847. private static _GetRGBArrayBuffer;
  138848. private static _GetLuminanceArrayBuffer;
  138849. /**
  138850. * Uploads DDS Levels to a Babylon Texture
  138851. * @hidden
  138852. */
  138853. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138854. }
  138855. interface ThinEngine {
  138856. /**
  138857. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138858. * @param rootUrl defines the url where the file to load is located
  138859. * @param scene defines the current scene
  138860. * @param lodScale defines scale to apply to the mip map selection
  138861. * @param lodOffset defines offset to apply to the mip map selection
  138862. * @param onLoad defines an optional callback raised when the texture is loaded
  138863. * @param onError defines an optional callback raised if there is an issue to load the texture
  138864. * @param format defines the format of the data
  138865. * @param forcedExtension defines the extension to use to pick the right loader
  138866. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138867. * @returns the cube texture as an InternalTexture
  138868. */
  138869. 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;
  138870. }
  138871. }
  138872. declare module BABYLON {
  138873. /**
  138874. * Implementation of the DDS Texture Loader.
  138875. * @hidden
  138876. */
  138877. export class _DDSTextureLoader implements IInternalTextureLoader {
  138878. /**
  138879. * Defines wether the loader supports cascade loading the different faces.
  138880. */
  138881. readonly supportCascades: boolean;
  138882. /**
  138883. * This returns if the loader support the current file information.
  138884. * @param extension defines the file extension of the file being loaded
  138885. * @returns true if the loader can load the specified file
  138886. */
  138887. canLoad(extension: string): boolean;
  138888. /**
  138889. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138890. * @param data contains the texture data
  138891. * @param texture defines the BabylonJS internal texture
  138892. * @param createPolynomials will be true if polynomials have been requested
  138893. * @param onLoad defines the callback to trigger once the texture is ready
  138894. * @param onError defines the callback to trigger in case of error
  138895. */
  138896. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138897. /**
  138898. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138899. * @param data contains the texture data
  138900. * @param texture defines the BabylonJS internal texture
  138901. * @param callback defines the method to call once ready to upload
  138902. */
  138903. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138904. }
  138905. }
  138906. declare module BABYLON {
  138907. /**
  138908. * Implementation of the ENV Texture Loader.
  138909. * @hidden
  138910. */
  138911. export class _ENVTextureLoader implements IInternalTextureLoader {
  138912. /**
  138913. * Defines wether the loader supports cascade loading the different faces.
  138914. */
  138915. readonly supportCascades: boolean;
  138916. /**
  138917. * This returns if the loader support the current file information.
  138918. * @param extension defines the file extension of the file being loaded
  138919. * @returns true if the loader can load the specified file
  138920. */
  138921. canLoad(extension: string): boolean;
  138922. /**
  138923. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138924. * @param data contains the texture data
  138925. * @param texture defines the BabylonJS internal texture
  138926. * @param createPolynomials will be true if polynomials have been requested
  138927. * @param onLoad defines the callback to trigger once the texture is ready
  138928. * @param onError defines the callback to trigger in case of error
  138929. */
  138930. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138931. /**
  138932. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138933. * @param data contains the texture data
  138934. * @param texture defines the BabylonJS internal texture
  138935. * @param callback defines the method to call once ready to upload
  138936. */
  138937. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138938. }
  138939. }
  138940. declare module BABYLON {
  138941. /**
  138942. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138943. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138944. */
  138945. export class KhronosTextureContainer {
  138946. /** contents of the KTX container file */
  138947. data: ArrayBufferView;
  138948. private static HEADER_LEN;
  138949. private static COMPRESSED_2D;
  138950. private static COMPRESSED_3D;
  138951. private static TEX_2D;
  138952. private static TEX_3D;
  138953. /**
  138954. * Gets the openGL type
  138955. */
  138956. glType: number;
  138957. /**
  138958. * Gets the openGL type size
  138959. */
  138960. glTypeSize: number;
  138961. /**
  138962. * Gets the openGL format
  138963. */
  138964. glFormat: number;
  138965. /**
  138966. * Gets the openGL internal format
  138967. */
  138968. glInternalFormat: number;
  138969. /**
  138970. * Gets the base internal format
  138971. */
  138972. glBaseInternalFormat: number;
  138973. /**
  138974. * Gets image width in pixel
  138975. */
  138976. pixelWidth: number;
  138977. /**
  138978. * Gets image height in pixel
  138979. */
  138980. pixelHeight: number;
  138981. /**
  138982. * Gets image depth in pixels
  138983. */
  138984. pixelDepth: number;
  138985. /**
  138986. * Gets the number of array elements
  138987. */
  138988. numberOfArrayElements: number;
  138989. /**
  138990. * Gets the number of faces
  138991. */
  138992. numberOfFaces: number;
  138993. /**
  138994. * Gets the number of mipmap levels
  138995. */
  138996. numberOfMipmapLevels: number;
  138997. /**
  138998. * Gets the bytes of key value data
  138999. */
  139000. bytesOfKeyValueData: number;
  139001. /**
  139002. * Gets the load type
  139003. */
  139004. loadType: number;
  139005. /**
  139006. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139007. */
  139008. isInvalid: boolean;
  139009. /**
  139010. * Creates a new KhronosTextureContainer
  139011. * @param data contents of the KTX container file
  139012. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139013. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139014. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139015. */
  139016. constructor(
  139017. /** contents of the KTX container file */
  139018. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139019. /**
  139020. * Uploads KTX content to a Babylon Texture.
  139021. * It is assumed that the texture has already been created & is currently bound
  139022. * @hidden
  139023. */
  139024. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139025. private _upload2DCompressedLevels;
  139026. /**
  139027. * Checks if the given data starts with a KTX file identifier.
  139028. * @param data the data to check
  139029. * @returns true if the data is a KTX file or false otherwise
  139030. */
  139031. static IsValid(data: ArrayBufferView): boolean;
  139032. }
  139033. }
  139034. declare module BABYLON {
  139035. /**
  139036. * Helper class to push actions to a pool of workers.
  139037. */
  139038. export class WorkerPool implements IDisposable {
  139039. private _workerInfos;
  139040. private _pendingActions;
  139041. /**
  139042. * Constructor
  139043. * @param workers Array of workers to use for actions
  139044. */
  139045. constructor(workers: Array<Worker>);
  139046. /**
  139047. * Terminates all workers and clears any pending actions.
  139048. */
  139049. dispose(): void;
  139050. /**
  139051. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139052. * pended until a worker has completed its action.
  139053. * @param action The action to perform. Call onComplete when the action is complete.
  139054. */
  139055. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139056. private _execute;
  139057. }
  139058. }
  139059. declare module BABYLON {
  139060. /**
  139061. * Class for loading KTX2 files
  139062. */
  139063. export class KhronosTextureContainer2 {
  139064. private static _WorkerPoolPromise?;
  139065. private static _Initialized;
  139066. private static _Ktx2Decoder;
  139067. /**
  139068. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139069. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139070. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139071. * Urls you can change:
  139072. * URLConfig.jsDecoderModule
  139073. * URLConfig.wasmUASTCToASTC
  139074. * URLConfig.wasmUASTCToBC7
  139075. * URLConfig.jsMSCTranscoder
  139076. * URLConfig.wasmMSCTranscoder
  139077. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139078. */
  139079. static URLConfig: {
  139080. jsDecoderModule: string;
  139081. wasmUASTCToASTC: null;
  139082. wasmUASTCToBC7: null;
  139083. jsMSCTranscoder: null;
  139084. wasmMSCTranscoder: null;
  139085. };
  139086. /**
  139087. * Default number of workers used to handle data decoding
  139088. */
  139089. static DefaultNumWorkers: number;
  139090. private static GetDefaultNumWorkers;
  139091. private _engine;
  139092. private static _CreateWorkerPool;
  139093. /**
  139094. * Constructor
  139095. * @param engine The engine to use
  139096. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139097. */
  139098. constructor(engine: ThinEngine, numWorkers?: number);
  139099. /** @hidden */
  139100. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139101. /**
  139102. * Stop all async operations and release resources.
  139103. */
  139104. dispose(): void;
  139105. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139106. /**
  139107. * Checks if the given data starts with a KTX2 file identifier.
  139108. * @param data the data to check
  139109. * @returns true if the data is a KTX2 file or false otherwise
  139110. */
  139111. static IsValid(data: ArrayBufferView): boolean;
  139112. }
  139113. }
  139114. declare module BABYLON {
  139115. /**
  139116. * Implementation of the KTX Texture Loader.
  139117. * @hidden
  139118. */
  139119. export class _KTXTextureLoader implements IInternalTextureLoader {
  139120. /**
  139121. * Defines wether the loader supports cascade loading the different faces.
  139122. */
  139123. readonly supportCascades: boolean;
  139124. /**
  139125. * This returns if the loader support the current file information.
  139126. * @param extension defines the file extension of the file being loaded
  139127. * @param mimeType defines the optional mime type of the file being loaded
  139128. * @returns true if the loader can load the specified file
  139129. */
  139130. canLoad(extension: string, mimeType?: string): boolean;
  139131. /**
  139132. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139133. * @param data contains the texture data
  139134. * @param texture defines the BabylonJS internal texture
  139135. * @param createPolynomials will be true if polynomials have been requested
  139136. * @param onLoad defines the callback to trigger once the texture is ready
  139137. * @param onError defines the callback to trigger in case of error
  139138. */
  139139. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139140. /**
  139141. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139142. * @param data contains the texture data
  139143. * @param texture defines the BabylonJS internal texture
  139144. * @param callback defines the method to call once ready to upload
  139145. */
  139146. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139147. }
  139148. }
  139149. declare module BABYLON {
  139150. /** @hidden */
  139151. export var _forceSceneHelpersToBundle: boolean;
  139152. interface Scene {
  139153. /**
  139154. * Creates a default light for the scene.
  139155. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139156. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139157. */
  139158. createDefaultLight(replace?: boolean): void;
  139159. /**
  139160. * Creates a default camera for the scene.
  139161. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139162. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139163. * @param replace has default false, when true replaces the active camera in the scene
  139164. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139165. */
  139166. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139167. /**
  139168. * Creates a default camera and a default light.
  139169. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139170. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139171. * @param replace has the default false, when true replaces the active camera/light in the scene
  139172. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139173. */
  139174. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139175. /**
  139176. * Creates a new sky box
  139177. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139178. * @param environmentTexture defines the texture to use as environment texture
  139179. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139180. * @param scale defines the overall scale of the skybox
  139181. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139182. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139183. * @returns a new mesh holding the sky box
  139184. */
  139185. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139186. /**
  139187. * Creates a new environment
  139188. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139189. * @param options defines the options you can use to configure the environment
  139190. * @returns the new EnvironmentHelper
  139191. */
  139192. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139193. /**
  139194. * Creates a new VREXperienceHelper
  139195. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139196. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139197. * @returns a new VREXperienceHelper
  139198. */
  139199. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139200. /**
  139201. * Creates a new WebXRDefaultExperience
  139202. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139203. * @param options experience options
  139204. * @returns a promise for a new WebXRDefaultExperience
  139205. */
  139206. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139207. }
  139208. }
  139209. declare module BABYLON {
  139210. /**
  139211. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139212. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139213. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139214. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139215. */
  139216. export class VideoDome extends TextureDome<VideoTexture> {
  139217. /**
  139218. * Define the video source as a Monoscopic panoramic 360 video.
  139219. */
  139220. static readonly MODE_MONOSCOPIC: number;
  139221. /**
  139222. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139223. */
  139224. static readonly MODE_TOPBOTTOM: number;
  139225. /**
  139226. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139227. */
  139228. static readonly MODE_SIDEBYSIDE: number;
  139229. /**
  139230. * Get the video texture associated with this video dome
  139231. */
  139232. get videoTexture(): VideoTexture;
  139233. /**
  139234. * Get the video mode of this dome
  139235. */
  139236. get videoMode(): number;
  139237. /**
  139238. * Set the video mode of this dome.
  139239. * @see textureMode
  139240. */
  139241. set videoMode(value: number);
  139242. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139243. }
  139244. }
  139245. declare module BABYLON {
  139246. /**
  139247. * This class can be used to get instrumentation data from a Babylon engine
  139248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139249. */
  139250. export class EngineInstrumentation implements IDisposable {
  139251. /**
  139252. * Define the instrumented engine.
  139253. */
  139254. engine: Engine;
  139255. private _captureGPUFrameTime;
  139256. private _gpuFrameTimeToken;
  139257. private _gpuFrameTime;
  139258. private _captureShaderCompilationTime;
  139259. private _shaderCompilationTime;
  139260. private _onBeginFrameObserver;
  139261. private _onEndFrameObserver;
  139262. private _onBeforeShaderCompilationObserver;
  139263. private _onAfterShaderCompilationObserver;
  139264. /**
  139265. * Gets the perf counter used for GPU frame time
  139266. */
  139267. get gpuFrameTimeCounter(): PerfCounter;
  139268. /**
  139269. * Gets the GPU frame time capture status
  139270. */
  139271. get captureGPUFrameTime(): boolean;
  139272. /**
  139273. * Enable or disable the GPU frame time capture
  139274. */
  139275. set captureGPUFrameTime(value: boolean);
  139276. /**
  139277. * Gets the perf counter used for shader compilation time
  139278. */
  139279. get shaderCompilationTimeCounter(): PerfCounter;
  139280. /**
  139281. * Gets the shader compilation time capture status
  139282. */
  139283. get captureShaderCompilationTime(): boolean;
  139284. /**
  139285. * Enable or disable the shader compilation time capture
  139286. */
  139287. set captureShaderCompilationTime(value: boolean);
  139288. /**
  139289. * Instantiates a new engine instrumentation.
  139290. * This class can be used to get instrumentation data from a Babylon engine
  139291. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139292. * @param engine Defines the engine to instrument
  139293. */
  139294. constructor(
  139295. /**
  139296. * Define the instrumented engine.
  139297. */
  139298. engine: Engine);
  139299. /**
  139300. * Dispose and release associated resources.
  139301. */
  139302. dispose(): void;
  139303. }
  139304. }
  139305. declare module BABYLON {
  139306. /**
  139307. * This class can be used to get instrumentation data from a Babylon engine
  139308. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139309. */
  139310. export class SceneInstrumentation implements IDisposable {
  139311. /**
  139312. * Defines the scene to instrument
  139313. */
  139314. scene: Scene;
  139315. private _captureActiveMeshesEvaluationTime;
  139316. private _activeMeshesEvaluationTime;
  139317. private _captureRenderTargetsRenderTime;
  139318. private _renderTargetsRenderTime;
  139319. private _captureFrameTime;
  139320. private _frameTime;
  139321. private _captureRenderTime;
  139322. private _renderTime;
  139323. private _captureInterFrameTime;
  139324. private _interFrameTime;
  139325. private _captureParticlesRenderTime;
  139326. private _particlesRenderTime;
  139327. private _captureSpritesRenderTime;
  139328. private _spritesRenderTime;
  139329. private _capturePhysicsTime;
  139330. private _physicsTime;
  139331. private _captureAnimationsTime;
  139332. private _animationsTime;
  139333. private _captureCameraRenderTime;
  139334. private _cameraRenderTime;
  139335. private _onBeforeActiveMeshesEvaluationObserver;
  139336. private _onAfterActiveMeshesEvaluationObserver;
  139337. private _onBeforeRenderTargetsRenderObserver;
  139338. private _onAfterRenderTargetsRenderObserver;
  139339. private _onAfterRenderObserver;
  139340. private _onBeforeDrawPhaseObserver;
  139341. private _onAfterDrawPhaseObserver;
  139342. private _onBeforeAnimationsObserver;
  139343. private _onBeforeParticlesRenderingObserver;
  139344. private _onAfterParticlesRenderingObserver;
  139345. private _onBeforeSpritesRenderingObserver;
  139346. private _onAfterSpritesRenderingObserver;
  139347. private _onBeforePhysicsObserver;
  139348. private _onAfterPhysicsObserver;
  139349. private _onAfterAnimationsObserver;
  139350. private _onBeforeCameraRenderObserver;
  139351. private _onAfterCameraRenderObserver;
  139352. /**
  139353. * Gets the perf counter used for active meshes evaluation time
  139354. */
  139355. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139356. /**
  139357. * Gets the active meshes evaluation time capture status
  139358. */
  139359. get captureActiveMeshesEvaluationTime(): boolean;
  139360. /**
  139361. * Enable or disable the active meshes evaluation time capture
  139362. */
  139363. set captureActiveMeshesEvaluationTime(value: boolean);
  139364. /**
  139365. * Gets the perf counter used for render targets render time
  139366. */
  139367. get renderTargetsRenderTimeCounter(): PerfCounter;
  139368. /**
  139369. * Gets the render targets render time capture status
  139370. */
  139371. get captureRenderTargetsRenderTime(): boolean;
  139372. /**
  139373. * Enable or disable the render targets render time capture
  139374. */
  139375. set captureRenderTargetsRenderTime(value: boolean);
  139376. /**
  139377. * Gets the perf counter used for particles render time
  139378. */
  139379. get particlesRenderTimeCounter(): PerfCounter;
  139380. /**
  139381. * Gets the particles render time capture status
  139382. */
  139383. get captureParticlesRenderTime(): boolean;
  139384. /**
  139385. * Enable or disable the particles render time capture
  139386. */
  139387. set captureParticlesRenderTime(value: boolean);
  139388. /**
  139389. * Gets the perf counter used for sprites render time
  139390. */
  139391. get spritesRenderTimeCounter(): PerfCounter;
  139392. /**
  139393. * Gets the sprites render time capture status
  139394. */
  139395. get captureSpritesRenderTime(): boolean;
  139396. /**
  139397. * Enable or disable the sprites render time capture
  139398. */
  139399. set captureSpritesRenderTime(value: boolean);
  139400. /**
  139401. * Gets the perf counter used for physics time
  139402. */
  139403. get physicsTimeCounter(): PerfCounter;
  139404. /**
  139405. * Gets the physics time capture status
  139406. */
  139407. get capturePhysicsTime(): boolean;
  139408. /**
  139409. * Enable or disable the physics time capture
  139410. */
  139411. set capturePhysicsTime(value: boolean);
  139412. /**
  139413. * Gets the perf counter used for animations time
  139414. */
  139415. get animationsTimeCounter(): PerfCounter;
  139416. /**
  139417. * Gets the animations time capture status
  139418. */
  139419. get captureAnimationsTime(): boolean;
  139420. /**
  139421. * Enable or disable the animations time capture
  139422. */
  139423. set captureAnimationsTime(value: boolean);
  139424. /**
  139425. * Gets the perf counter used for frame time capture
  139426. */
  139427. get frameTimeCounter(): PerfCounter;
  139428. /**
  139429. * Gets the frame time capture status
  139430. */
  139431. get captureFrameTime(): boolean;
  139432. /**
  139433. * Enable or disable the frame time capture
  139434. */
  139435. set captureFrameTime(value: boolean);
  139436. /**
  139437. * Gets the perf counter used for inter-frames time capture
  139438. */
  139439. get interFrameTimeCounter(): PerfCounter;
  139440. /**
  139441. * Gets the inter-frames time capture status
  139442. */
  139443. get captureInterFrameTime(): boolean;
  139444. /**
  139445. * Enable or disable the inter-frames time capture
  139446. */
  139447. set captureInterFrameTime(value: boolean);
  139448. /**
  139449. * Gets the perf counter used for render time capture
  139450. */
  139451. get renderTimeCounter(): PerfCounter;
  139452. /**
  139453. * Gets the render time capture status
  139454. */
  139455. get captureRenderTime(): boolean;
  139456. /**
  139457. * Enable or disable the render time capture
  139458. */
  139459. set captureRenderTime(value: boolean);
  139460. /**
  139461. * Gets the perf counter used for camera render time capture
  139462. */
  139463. get cameraRenderTimeCounter(): PerfCounter;
  139464. /**
  139465. * Gets the camera render time capture status
  139466. */
  139467. get captureCameraRenderTime(): boolean;
  139468. /**
  139469. * Enable or disable the camera render time capture
  139470. */
  139471. set captureCameraRenderTime(value: boolean);
  139472. /**
  139473. * Gets the perf counter used for draw calls
  139474. */
  139475. get drawCallsCounter(): PerfCounter;
  139476. /**
  139477. * Instantiates a new scene instrumentation.
  139478. * This class can be used to get instrumentation data from a Babylon engine
  139479. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139480. * @param scene Defines the scene to instrument
  139481. */
  139482. constructor(
  139483. /**
  139484. * Defines the scene to instrument
  139485. */
  139486. scene: Scene);
  139487. /**
  139488. * Dispose and release associated resources.
  139489. */
  139490. dispose(): void;
  139491. }
  139492. }
  139493. declare module BABYLON {
  139494. /** @hidden */
  139495. export var glowMapGenerationPixelShader: {
  139496. name: string;
  139497. shader: string;
  139498. };
  139499. }
  139500. declare module BABYLON {
  139501. /** @hidden */
  139502. export var glowMapGenerationVertexShader: {
  139503. name: string;
  139504. shader: string;
  139505. };
  139506. }
  139507. declare module BABYLON {
  139508. /**
  139509. * Effect layer options. This helps customizing the behaviour
  139510. * of the effect layer.
  139511. */
  139512. export interface IEffectLayerOptions {
  139513. /**
  139514. * Multiplication factor apply to the canvas size to compute the render target size
  139515. * used to generated the objects (the smaller the faster).
  139516. */
  139517. mainTextureRatio: number;
  139518. /**
  139519. * Enforces a fixed size texture to ensure effect stability across devices.
  139520. */
  139521. mainTextureFixedSize?: number;
  139522. /**
  139523. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139524. */
  139525. alphaBlendingMode: number;
  139526. /**
  139527. * The camera attached to the layer.
  139528. */
  139529. camera: Nullable<Camera>;
  139530. /**
  139531. * The rendering group to draw the layer in.
  139532. */
  139533. renderingGroupId: number;
  139534. }
  139535. /**
  139536. * The effect layer Helps adding post process effect blended with the main pass.
  139537. *
  139538. * This can be for instance use to generate glow or higlight effects on the scene.
  139539. *
  139540. * The effect layer class can not be used directly and is intented to inherited from to be
  139541. * customized per effects.
  139542. */
  139543. export abstract class EffectLayer {
  139544. private _vertexBuffers;
  139545. private _indexBuffer;
  139546. private _cachedDefines;
  139547. private _effectLayerMapGenerationEffect;
  139548. private _effectLayerOptions;
  139549. private _mergeEffect;
  139550. protected _scene: Scene;
  139551. protected _engine: Engine;
  139552. protected _maxSize: number;
  139553. protected _mainTextureDesiredSize: ISize;
  139554. protected _mainTexture: RenderTargetTexture;
  139555. protected _shouldRender: boolean;
  139556. protected _postProcesses: PostProcess[];
  139557. protected _textures: BaseTexture[];
  139558. protected _emissiveTextureAndColor: {
  139559. texture: Nullable<BaseTexture>;
  139560. color: Color4;
  139561. };
  139562. /**
  139563. * The name of the layer
  139564. */
  139565. name: string;
  139566. /**
  139567. * The clear color of the texture used to generate the glow map.
  139568. */
  139569. neutralColor: Color4;
  139570. /**
  139571. * Specifies whether the highlight layer is enabled or not.
  139572. */
  139573. isEnabled: boolean;
  139574. /**
  139575. * Gets the camera attached to the layer.
  139576. */
  139577. get camera(): Nullable<Camera>;
  139578. /**
  139579. * Gets the rendering group id the layer should render in.
  139580. */
  139581. get renderingGroupId(): number;
  139582. set renderingGroupId(renderingGroupId: number);
  139583. /**
  139584. * An event triggered when the effect layer has been disposed.
  139585. */
  139586. onDisposeObservable: Observable<EffectLayer>;
  139587. /**
  139588. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139589. */
  139590. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139591. /**
  139592. * An event triggered when the generated texture is being merged in the scene.
  139593. */
  139594. onBeforeComposeObservable: Observable<EffectLayer>;
  139595. /**
  139596. * An event triggered when the mesh is rendered into the effect render target.
  139597. */
  139598. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139599. /**
  139600. * An event triggered after the mesh has been rendered into the effect render target.
  139601. */
  139602. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139603. /**
  139604. * An event triggered when the generated texture has been merged in the scene.
  139605. */
  139606. onAfterComposeObservable: Observable<EffectLayer>;
  139607. /**
  139608. * An event triggered when the efffect layer changes its size.
  139609. */
  139610. onSizeChangedObservable: Observable<EffectLayer>;
  139611. /** @hidden */
  139612. static _SceneComponentInitialization: (scene: Scene) => void;
  139613. /**
  139614. * Instantiates a new effect Layer and references it in the scene.
  139615. * @param name The name of the layer
  139616. * @param scene The scene to use the layer in
  139617. */
  139618. constructor(
  139619. /** The Friendly of the effect in the scene */
  139620. name: string, scene: Scene);
  139621. /**
  139622. * Get the effect name of the layer.
  139623. * @return The effect name
  139624. */
  139625. abstract getEffectName(): string;
  139626. /**
  139627. * Checks for the readiness of the element composing the layer.
  139628. * @param subMesh the mesh to check for
  139629. * @param useInstances specify whether or not to use instances to render the mesh
  139630. * @return true if ready otherwise, false
  139631. */
  139632. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139633. /**
  139634. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139635. * @returns true if the effect requires stencil during the main canvas render pass.
  139636. */
  139637. abstract needStencil(): boolean;
  139638. /**
  139639. * Create the merge effect. This is the shader use to blit the information back
  139640. * to the main canvas at the end of the scene rendering.
  139641. * @returns The effect containing the shader used to merge the effect on the main canvas
  139642. */
  139643. protected abstract _createMergeEffect(): Effect;
  139644. /**
  139645. * Creates the render target textures and post processes used in the effect layer.
  139646. */
  139647. protected abstract _createTextureAndPostProcesses(): void;
  139648. /**
  139649. * Implementation specific of rendering the generating effect on the main canvas.
  139650. * @param effect The effect used to render through
  139651. */
  139652. protected abstract _internalRender(effect: Effect): void;
  139653. /**
  139654. * Sets the required values for both the emissive texture and and the main color.
  139655. */
  139656. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139657. /**
  139658. * Free any resources and references associated to a mesh.
  139659. * Internal use
  139660. * @param mesh The mesh to free.
  139661. */
  139662. abstract _disposeMesh(mesh: Mesh): void;
  139663. /**
  139664. * Serializes this layer (Glow or Highlight for example)
  139665. * @returns a serialized layer object
  139666. */
  139667. abstract serialize?(): any;
  139668. /**
  139669. * Initializes the effect layer with the required options.
  139670. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139671. */
  139672. protected _init(options: Partial<IEffectLayerOptions>): void;
  139673. /**
  139674. * Generates the index buffer of the full screen quad blending to the main canvas.
  139675. */
  139676. private _generateIndexBuffer;
  139677. /**
  139678. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139679. */
  139680. private _generateVertexBuffer;
  139681. /**
  139682. * Sets the main texture desired size which is the closest power of two
  139683. * of the engine canvas size.
  139684. */
  139685. private _setMainTextureSize;
  139686. /**
  139687. * Creates the main texture for the effect layer.
  139688. */
  139689. protected _createMainTexture(): void;
  139690. /**
  139691. * Adds specific effects defines.
  139692. * @param defines The defines to add specifics to.
  139693. */
  139694. protected _addCustomEffectDefines(defines: string[]): void;
  139695. /**
  139696. * Checks for the readiness of the element composing the layer.
  139697. * @param subMesh the mesh to check for
  139698. * @param useInstances specify whether or not to use instances to render the mesh
  139699. * @param emissiveTexture the associated emissive texture used to generate the glow
  139700. * @return true if ready otherwise, false
  139701. */
  139702. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139703. /**
  139704. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139705. */
  139706. render(): void;
  139707. /**
  139708. * Determine if a given mesh will be used in the current effect.
  139709. * @param mesh mesh to test
  139710. * @returns true if the mesh will be used
  139711. */
  139712. hasMesh(mesh: AbstractMesh): boolean;
  139713. /**
  139714. * Returns true if the layer contains information to display, otherwise false.
  139715. * @returns true if the glow layer should be rendered
  139716. */
  139717. shouldRender(): boolean;
  139718. /**
  139719. * Returns true if the mesh should render, otherwise false.
  139720. * @param mesh The mesh to render
  139721. * @returns true if it should render otherwise false
  139722. */
  139723. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139724. /**
  139725. * Returns true if the mesh can be rendered, otherwise false.
  139726. * @param mesh The mesh to render
  139727. * @param material The material used on the mesh
  139728. * @returns true if it can be rendered otherwise false
  139729. */
  139730. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139731. /**
  139732. * Returns true if the mesh should render, otherwise false.
  139733. * @param mesh The mesh to render
  139734. * @returns true if it should render otherwise false
  139735. */
  139736. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139737. /**
  139738. * Renders the submesh passed in parameter to the generation map.
  139739. */
  139740. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139741. /**
  139742. * Defines whether the current material of the mesh should be use to render the effect.
  139743. * @param mesh defines the current mesh to render
  139744. */
  139745. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139746. /**
  139747. * Rebuild the required buffers.
  139748. * @hidden Internal use only.
  139749. */
  139750. _rebuild(): void;
  139751. /**
  139752. * Dispose only the render target textures and post process.
  139753. */
  139754. private _disposeTextureAndPostProcesses;
  139755. /**
  139756. * Dispose the highlight layer and free resources.
  139757. */
  139758. dispose(): void;
  139759. /**
  139760. * Gets the class name of the effect layer
  139761. * @returns the string with the class name of the effect layer
  139762. */
  139763. getClassName(): string;
  139764. /**
  139765. * Creates an effect layer from parsed effect layer data
  139766. * @param parsedEffectLayer defines effect layer data
  139767. * @param scene defines the current scene
  139768. * @param rootUrl defines the root URL containing the effect layer information
  139769. * @returns a parsed effect Layer
  139770. */
  139771. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139772. }
  139773. }
  139774. declare module BABYLON {
  139775. interface AbstractScene {
  139776. /**
  139777. * The list of effect layers (highlights/glow) added to the scene
  139778. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139779. * @see https://doc.babylonjs.com/how_to/glow_layer
  139780. */
  139781. effectLayers: Array<EffectLayer>;
  139782. /**
  139783. * Removes the given effect layer from this scene.
  139784. * @param toRemove defines the effect layer to remove
  139785. * @returns the index of the removed effect layer
  139786. */
  139787. removeEffectLayer(toRemove: EffectLayer): number;
  139788. /**
  139789. * Adds the given effect layer to this scene
  139790. * @param newEffectLayer defines the effect layer to add
  139791. */
  139792. addEffectLayer(newEffectLayer: EffectLayer): void;
  139793. }
  139794. /**
  139795. * Defines the layer scene component responsible to manage any effect layers
  139796. * in a given scene.
  139797. */
  139798. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139799. /**
  139800. * The component name helpfull to identify the component in the list of scene components.
  139801. */
  139802. readonly name: string;
  139803. /**
  139804. * The scene the component belongs to.
  139805. */
  139806. scene: Scene;
  139807. private _engine;
  139808. private _renderEffects;
  139809. private _needStencil;
  139810. private _previousStencilState;
  139811. /**
  139812. * Creates a new instance of the component for the given scene
  139813. * @param scene Defines the scene to register the component in
  139814. */
  139815. constructor(scene: Scene);
  139816. /**
  139817. * Registers the component in a given scene
  139818. */
  139819. register(): void;
  139820. /**
  139821. * Rebuilds the elements related to this component in case of
  139822. * context lost for instance.
  139823. */
  139824. rebuild(): void;
  139825. /**
  139826. * Serializes the component data to the specified json object
  139827. * @param serializationObject The object to serialize to
  139828. */
  139829. serialize(serializationObject: any): void;
  139830. /**
  139831. * Adds all the elements from the container to the scene
  139832. * @param container the container holding the elements
  139833. */
  139834. addFromContainer(container: AbstractScene): void;
  139835. /**
  139836. * Removes all the elements in the container from the scene
  139837. * @param container contains the elements to remove
  139838. * @param dispose if the removed element should be disposed (default: false)
  139839. */
  139840. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139841. /**
  139842. * Disposes the component and the associated ressources.
  139843. */
  139844. dispose(): void;
  139845. private _isReadyForMesh;
  139846. private _renderMainTexture;
  139847. private _setStencil;
  139848. private _setStencilBack;
  139849. private _draw;
  139850. private _drawCamera;
  139851. private _drawRenderingGroup;
  139852. }
  139853. }
  139854. declare module BABYLON {
  139855. /** @hidden */
  139856. export var glowMapMergePixelShader: {
  139857. name: string;
  139858. shader: string;
  139859. };
  139860. }
  139861. declare module BABYLON {
  139862. /** @hidden */
  139863. export var glowMapMergeVertexShader: {
  139864. name: string;
  139865. shader: string;
  139866. };
  139867. }
  139868. declare module BABYLON {
  139869. interface AbstractScene {
  139870. /**
  139871. * Return a the first highlight layer of the scene with a given name.
  139872. * @param name The name of the highlight layer to look for.
  139873. * @return The highlight layer if found otherwise null.
  139874. */
  139875. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139876. }
  139877. /**
  139878. * Glow layer options. This helps customizing the behaviour
  139879. * of the glow layer.
  139880. */
  139881. export interface IGlowLayerOptions {
  139882. /**
  139883. * Multiplication factor apply to the canvas size to compute the render target size
  139884. * used to generated the glowing objects (the smaller the faster).
  139885. */
  139886. mainTextureRatio: number;
  139887. /**
  139888. * Enforces a fixed size texture to ensure resize independant blur.
  139889. */
  139890. mainTextureFixedSize?: number;
  139891. /**
  139892. * How big is the kernel of the blur texture.
  139893. */
  139894. blurKernelSize: number;
  139895. /**
  139896. * The camera attached to the layer.
  139897. */
  139898. camera: Nullable<Camera>;
  139899. /**
  139900. * Enable MSAA by chosing the number of samples.
  139901. */
  139902. mainTextureSamples?: number;
  139903. /**
  139904. * The rendering group to draw the layer in.
  139905. */
  139906. renderingGroupId: number;
  139907. }
  139908. /**
  139909. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139910. *
  139911. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139912. *
  139913. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139914. */
  139915. export class GlowLayer extends EffectLayer {
  139916. /**
  139917. * Effect Name of the layer.
  139918. */
  139919. static readonly EffectName: string;
  139920. /**
  139921. * The default blur kernel size used for the glow.
  139922. */
  139923. static DefaultBlurKernelSize: number;
  139924. /**
  139925. * The default texture size ratio used for the glow.
  139926. */
  139927. static DefaultTextureRatio: number;
  139928. /**
  139929. * Sets the kernel size of the blur.
  139930. */
  139931. set blurKernelSize(value: number);
  139932. /**
  139933. * Gets the kernel size of the blur.
  139934. */
  139935. get blurKernelSize(): number;
  139936. /**
  139937. * Sets the glow intensity.
  139938. */
  139939. set intensity(value: number);
  139940. /**
  139941. * Gets the glow intensity.
  139942. */
  139943. get intensity(): number;
  139944. private _options;
  139945. private _intensity;
  139946. private _horizontalBlurPostprocess1;
  139947. private _verticalBlurPostprocess1;
  139948. private _horizontalBlurPostprocess2;
  139949. private _verticalBlurPostprocess2;
  139950. private _blurTexture1;
  139951. private _blurTexture2;
  139952. private _postProcesses1;
  139953. private _postProcesses2;
  139954. private _includedOnlyMeshes;
  139955. private _excludedMeshes;
  139956. private _meshesUsingTheirOwnMaterials;
  139957. /**
  139958. * Callback used to let the user override the color selection on a per mesh basis
  139959. */
  139960. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139961. /**
  139962. * Callback used to let the user override the texture selection on a per mesh basis
  139963. */
  139964. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139965. /**
  139966. * Instantiates a new glow Layer and references it to the scene.
  139967. * @param name The name of the layer
  139968. * @param scene The scene to use the layer in
  139969. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139970. */
  139971. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139972. /**
  139973. * Get the effect name of the layer.
  139974. * @return The effect name
  139975. */
  139976. getEffectName(): string;
  139977. /**
  139978. * Create the merge effect. This is the shader use to blit the information back
  139979. * to the main canvas at the end of the scene rendering.
  139980. */
  139981. protected _createMergeEffect(): Effect;
  139982. /**
  139983. * Creates the render target textures and post processes used in the glow layer.
  139984. */
  139985. protected _createTextureAndPostProcesses(): void;
  139986. /**
  139987. * Checks for the readiness of the element composing the layer.
  139988. * @param subMesh the mesh to check for
  139989. * @param useInstances specify wether or not to use instances to render the mesh
  139990. * @param emissiveTexture the associated emissive texture used to generate the glow
  139991. * @return true if ready otherwise, false
  139992. */
  139993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139994. /**
  139995. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139996. */
  139997. needStencil(): boolean;
  139998. /**
  139999. * Returns true if the mesh can be rendered, otherwise false.
  140000. * @param mesh The mesh to render
  140001. * @param material The material used on the mesh
  140002. * @returns true if it can be rendered otherwise false
  140003. */
  140004. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140005. /**
  140006. * Implementation specific of rendering the generating effect on the main canvas.
  140007. * @param effect The effect used to render through
  140008. */
  140009. protected _internalRender(effect: Effect): void;
  140010. /**
  140011. * Sets the required values for both the emissive texture and and the main color.
  140012. */
  140013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140014. /**
  140015. * Returns true if the mesh should render, otherwise false.
  140016. * @param mesh The mesh to render
  140017. * @returns true if it should render otherwise false
  140018. */
  140019. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140020. /**
  140021. * Adds specific effects defines.
  140022. * @param defines The defines to add specifics to.
  140023. */
  140024. protected _addCustomEffectDefines(defines: string[]): void;
  140025. /**
  140026. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140027. * @param mesh The mesh to exclude from the glow layer
  140028. */
  140029. addExcludedMesh(mesh: Mesh): void;
  140030. /**
  140031. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140032. * @param mesh The mesh to remove
  140033. */
  140034. removeExcludedMesh(mesh: Mesh): void;
  140035. /**
  140036. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140037. * @param mesh The mesh to include in the glow layer
  140038. */
  140039. addIncludedOnlyMesh(mesh: Mesh): void;
  140040. /**
  140041. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140042. * @param mesh The mesh to remove
  140043. */
  140044. removeIncludedOnlyMesh(mesh: Mesh): void;
  140045. /**
  140046. * Determine if a given mesh will be used in the glow layer
  140047. * @param mesh The mesh to test
  140048. * @returns true if the mesh will be highlighted by the current glow layer
  140049. */
  140050. hasMesh(mesh: AbstractMesh): boolean;
  140051. /**
  140052. * Defines whether the current material of the mesh should be use to render the effect.
  140053. * @param mesh defines the current mesh to render
  140054. */
  140055. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140056. /**
  140057. * Add a mesh to be rendered through its own material and not with emissive only.
  140058. * @param mesh The mesh for which we need to use its material
  140059. */
  140060. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140061. /**
  140062. * Remove a mesh from being rendered through its own material and not with emissive only.
  140063. * @param mesh The mesh for which we need to not use its material
  140064. */
  140065. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140066. /**
  140067. * Free any resources and references associated to a mesh.
  140068. * Internal use
  140069. * @param mesh The mesh to free.
  140070. * @hidden
  140071. */
  140072. _disposeMesh(mesh: Mesh): void;
  140073. /**
  140074. * Gets the class name of the effect layer
  140075. * @returns the string with the class name of the effect layer
  140076. */
  140077. getClassName(): string;
  140078. /**
  140079. * Serializes this glow layer
  140080. * @returns a serialized glow layer object
  140081. */
  140082. serialize(): any;
  140083. /**
  140084. * Creates a Glow Layer from parsed glow layer data
  140085. * @param parsedGlowLayer defines glow layer data
  140086. * @param scene defines the current scene
  140087. * @param rootUrl defines the root URL containing the glow layer information
  140088. * @returns a parsed Glow Layer
  140089. */
  140090. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140091. }
  140092. }
  140093. declare module BABYLON {
  140094. /** @hidden */
  140095. export var glowBlurPostProcessPixelShader: {
  140096. name: string;
  140097. shader: string;
  140098. };
  140099. }
  140100. declare module BABYLON {
  140101. interface AbstractScene {
  140102. /**
  140103. * Return a the first highlight layer of the scene with a given name.
  140104. * @param name The name of the highlight layer to look for.
  140105. * @return The highlight layer if found otherwise null.
  140106. */
  140107. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140108. }
  140109. /**
  140110. * Highlight layer options. This helps customizing the behaviour
  140111. * of the highlight layer.
  140112. */
  140113. export interface IHighlightLayerOptions {
  140114. /**
  140115. * Multiplication factor apply to the canvas size to compute the render target size
  140116. * used to generated the glowing objects (the smaller the faster).
  140117. */
  140118. mainTextureRatio: number;
  140119. /**
  140120. * Enforces a fixed size texture to ensure resize independant blur.
  140121. */
  140122. mainTextureFixedSize?: number;
  140123. /**
  140124. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140125. * of the picture to blur (the smaller the faster).
  140126. */
  140127. blurTextureSizeRatio: number;
  140128. /**
  140129. * How big in texel of the blur texture is the vertical blur.
  140130. */
  140131. blurVerticalSize: number;
  140132. /**
  140133. * How big in texel of the blur texture is the horizontal blur.
  140134. */
  140135. blurHorizontalSize: number;
  140136. /**
  140137. * Alpha blending mode used to apply the blur. Default is combine.
  140138. */
  140139. alphaBlendingMode: number;
  140140. /**
  140141. * The camera attached to the layer.
  140142. */
  140143. camera: Nullable<Camera>;
  140144. /**
  140145. * Should we display highlight as a solid stroke?
  140146. */
  140147. isStroke?: boolean;
  140148. /**
  140149. * The rendering group to draw the layer in.
  140150. */
  140151. renderingGroupId: number;
  140152. }
  140153. /**
  140154. * The highlight layer Helps adding a glow effect around a mesh.
  140155. *
  140156. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140157. * glowy meshes to your scene.
  140158. *
  140159. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140160. */
  140161. export class HighlightLayer extends EffectLayer {
  140162. name: string;
  140163. /**
  140164. * Effect Name of the highlight layer.
  140165. */
  140166. static readonly EffectName: string;
  140167. /**
  140168. * The neutral color used during the preparation of the glow effect.
  140169. * This is black by default as the blend operation is a blend operation.
  140170. */
  140171. static NeutralColor: Color4;
  140172. /**
  140173. * Stencil value used for glowing meshes.
  140174. */
  140175. static GlowingMeshStencilReference: number;
  140176. /**
  140177. * Stencil value used for the other meshes in the scene.
  140178. */
  140179. static NormalMeshStencilReference: number;
  140180. /**
  140181. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140182. */
  140183. innerGlow: boolean;
  140184. /**
  140185. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140186. */
  140187. outerGlow: boolean;
  140188. /**
  140189. * Specifies the horizontal size of the blur.
  140190. */
  140191. set blurHorizontalSize(value: number);
  140192. /**
  140193. * Specifies the vertical size of the blur.
  140194. */
  140195. set blurVerticalSize(value: number);
  140196. /**
  140197. * Gets the horizontal size of the blur.
  140198. */
  140199. get blurHorizontalSize(): number;
  140200. /**
  140201. * Gets the vertical size of the blur.
  140202. */
  140203. get blurVerticalSize(): number;
  140204. /**
  140205. * An event triggered when the highlight layer is being blurred.
  140206. */
  140207. onBeforeBlurObservable: Observable<HighlightLayer>;
  140208. /**
  140209. * An event triggered when the highlight layer has been blurred.
  140210. */
  140211. onAfterBlurObservable: Observable<HighlightLayer>;
  140212. private _instanceGlowingMeshStencilReference;
  140213. private _options;
  140214. private _downSamplePostprocess;
  140215. private _horizontalBlurPostprocess;
  140216. private _verticalBlurPostprocess;
  140217. private _blurTexture;
  140218. private _meshes;
  140219. private _excludedMeshes;
  140220. /**
  140221. * Instantiates a new highlight Layer and references it to the scene..
  140222. * @param name The name of the layer
  140223. * @param scene The scene to use the layer in
  140224. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140225. */
  140226. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140227. /**
  140228. * Get the effect name of the layer.
  140229. * @return The effect name
  140230. */
  140231. getEffectName(): string;
  140232. /**
  140233. * Create the merge effect. This is the shader use to blit the information back
  140234. * to the main canvas at the end of the scene rendering.
  140235. */
  140236. protected _createMergeEffect(): Effect;
  140237. /**
  140238. * Creates the render target textures and post processes used in the highlight layer.
  140239. */
  140240. protected _createTextureAndPostProcesses(): void;
  140241. /**
  140242. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140243. */
  140244. needStencil(): boolean;
  140245. /**
  140246. * Checks for the readiness of the element composing the layer.
  140247. * @param subMesh the mesh to check for
  140248. * @param useInstances specify wether or not to use instances to render the mesh
  140249. * @param emissiveTexture the associated emissive texture used to generate the glow
  140250. * @return true if ready otherwise, false
  140251. */
  140252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140253. /**
  140254. * Implementation specific of rendering the generating effect on the main canvas.
  140255. * @param effect The effect used to render through
  140256. */
  140257. protected _internalRender(effect: Effect): void;
  140258. /**
  140259. * Returns true if the layer contains information to display, otherwise false.
  140260. */
  140261. shouldRender(): boolean;
  140262. /**
  140263. * Returns true if the mesh should render, otherwise false.
  140264. * @param mesh The mesh to render
  140265. * @returns true if it should render otherwise false
  140266. */
  140267. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140268. /**
  140269. * Returns true if the mesh can be rendered, otherwise false.
  140270. * @param mesh The mesh to render
  140271. * @param material The material used on the mesh
  140272. * @returns true if it can be rendered otherwise false
  140273. */
  140274. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140275. /**
  140276. * Adds specific effects defines.
  140277. * @param defines The defines to add specifics to.
  140278. */
  140279. protected _addCustomEffectDefines(defines: string[]): void;
  140280. /**
  140281. * Sets the required values for both the emissive texture and and the main color.
  140282. */
  140283. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140284. /**
  140285. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140286. * @param mesh The mesh to exclude from the highlight layer
  140287. */
  140288. addExcludedMesh(mesh: Mesh): void;
  140289. /**
  140290. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140291. * @param mesh The mesh to highlight
  140292. */
  140293. removeExcludedMesh(mesh: Mesh): void;
  140294. /**
  140295. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140296. * @param mesh mesh to test
  140297. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140298. */
  140299. hasMesh(mesh: AbstractMesh): boolean;
  140300. /**
  140301. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140302. * @param mesh The mesh to highlight
  140303. * @param color The color of the highlight
  140304. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140305. */
  140306. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140307. /**
  140308. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140309. * @param mesh The mesh to highlight
  140310. */
  140311. removeMesh(mesh: Mesh): void;
  140312. /**
  140313. * Remove all the meshes currently referenced in the highlight layer
  140314. */
  140315. removeAllMeshes(): void;
  140316. /**
  140317. * Force the stencil to the normal expected value for none glowing parts
  140318. */
  140319. private _defaultStencilReference;
  140320. /**
  140321. * Free any resources and references associated to a mesh.
  140322. * Internal use
  140323. * @param mesh The mesh to free.
  140324. * @hidden
  140325. */
  140326. _disposeMesh(mesh: Mesh): void;
  140327. /**
  140328. * Dispose the highlight layer and free resources.
  140329. */
  140330. dispose(): void;
  140331. /**
  140332. * Gets the class name of the effect layer
  140333. * @returns the string with the class name of the effect layer
  140334. */
  140335. getClassName(): string;
  140336. /**
  140337. * Serializes this Highlight layer
  140338. * @returns a serialized Highlight layer object
  140339. */
  140340. serialize(): any;
  140341. /**
  140342. * Creates a Highlight layer from parsed Highlight layer data
  140343. * @param parsedHightlightLayer defines the Highlight layer data
  140344. * @param scene defines the current scene
  140345. * @param rootUrl defines the root URL containing the Highlight layer information
  140346. * @returns a parsed Highlight layer
  140347. */
  140348. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140349. }
  140350. }
  140351. declare module BABYLON {
  140352. interface AbstractScene {
  140353. /**
  140354. * The list of layers (background and foreground) of the scene
  140355. */
  140356. layers: Array<Layer>;
  140357. }
  140358. /**
  140359. * Defines the layer scene component responsible to manage any layers
  140360. * in a given scene.
  140361. */
  140362. export class LayerSceneComponent implements ISceneComponent {
  140363. /**
  140364. * The component name helpfull to identify the component in the list of scene components.
  140365. */
  140366. readonly name: string;
  140367. /**
  140368. * The scene the component belongs to.
  140369. */
  140370. scene: Scene;
  140371. private _engine;
  140372. /**
  140373. * Creates a new instance of the component for the given scene
  140374. * @param scene Defines the scene to register the component in
  140375. */
  140376. constructor(scene: Scene);
  140377. /**
  140378. * Registers the component in a given scene
  140379. */
  140380. register(): void;
  140381. /**
  140382. * Rebuilds the elements related to this component in case of
  140383. * context lost for instance.
  140384. */
  140385. rebuild(): void;
  140386. /**
  140387. * Disposes the component and the associated ressources.
  140388. */
  140389. dispose(): void;
  140390. private _draw;
  140391. private _drawCameraPredicate;
  140392. private _drawCameraBackground;
  140393. private _drawCameraForeground;
  140394. private _drawRenderTargetPredicate;
  140395. private _drawRenderTargetBackground;
  140396. private _drawRenderTargetForeground;
  140397. /**
  140398. * Adds all the elements from the container to the scene
  140399. * @param container the container holding the elements
  140400. */
  140401. addFromContainer(container: AbstractScene): void;
  140402. /**
  140403. * Removes all the elements in the container from the scene
  140404. * @param container contains the elements to remove
  140405. * @param dispose if the removed element should be disposed (default: false)
  140406. */
  140407. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140408. }
  140409. }
  140410. declare module BABYLON {
  140411. /** @hidden */
  140412. export var layerPixelShader: {
  140413. name: string;
  140414. shader: string;
  140415. };
  140416. }
  140417. declare module BABYLON {
  140418. /** @hidden */
  140419. export var layerVertexShader: {
  140420. name: string;
  140421. shader: string;
  140422. };
  140423. }
  140424. declare module BABYLON {
  140425. /**
  140426. * This represents a full screen 2d layer.
  140427. * This can be useful to display a picture in the background of your scene for instance.
  140428. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140429. */
  140430. export class Layer {
  140431. /**
  140432. * Define the name of the layer.
  140433. */
  140434. name: string;
  140435. /**
  140436. * Define the texture the layer should display.
  140437. */
  140438. texture: Nullable<Texture>;
  140439. /**
  140440. * Is the layer in background or foreground.
  140441. */
  140442. isBackground: boolean;
  140443. /**
  140444. * Define the color of the layer (instead of texture).
  140445. */
  140446. color: Color4;
  140447. /**
  140448. * Define the scale of the layer in order to zoom in out of the texture.
  140449. */
  140450. scale: Vector2;
  140451. /**
  140452. * Define an offset for the layer in order to shift the texture.
  140453. */
  140454. offset: Vector2;
  140455. /**
  140456. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140457. */
  140458. alphaBlendingMode: number;
  140459. /**
  140460. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140461. * Alpha test will not mix with the background color in case of transparency.
  140462. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140463. */
  140464. alphaTest: boolean;
  140465. /**
  140466. * Define a mask to restrict the layer to only some of the scene cameras.
  140467. */
  140468. layerMask: number;
  140469. /**
  140470. * Define the list of render target the layer is visible into.
  140471. */
  140472. renderTargetTextures: RenderTargetTexture[];
  140473. /**
  140474. * Define if the layer is only used in renderTarget or if it also
  140475. * renders in the main frame buffer of the canvas.
  140476. */
  140477. renderOnlyInRenderTargetTextures: boolean;
  140478. private _scene;
  140479. private _vertexBuffers;
  140480. private _indexBuffer;
  140481. private _effect;
  140482. private _previousDefines;
  140483. /**
  140484. * An event triggered when the layer is disposed.
  140485. */
  140486. onDisposeObservable: Observable<Layer>;
  140487. private _onDisposeObserver;
  140488. /**
  140489. * Back compatibility with callback before the onDisposeObservable existed.
  140490. * The set callback will be triggered when the layer has been disposed.
  140491. */
  140492. set onDispose(callback: () => void);
  140493. /**
  140494. * An event triggered before rendering the scene
  140495. */
  140496. onBeforeRenderObservable: Observable<Layer>;
  140497. private _onBeforeRenderObserver;
  140498. /**
  140499. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140500. * The set callback will be triggered just before rendering the layer.
  140501. */
  140502. set onBeforeRender(callback: () => void);
  140503. /**
  140504. * An event triggered after rendering the scene
  140505. */
  140506. onAfterRenderObservable: Observable<Layer>;
  140507. private _onAfterRenderObserver;
  140508. /**
  140509. * Back compatibility with callback before the onAfterRenderObservable existed.
  140510. * The set callback will be triggered just after rendering the layer.
  140511. */
  140512. set onAfterRender(callback: () => void);
  140513. /**
  140514. * Instantiates a new layer.
  140515. * This represents a full screen 2d layer.
  140516. * This can be useful to display a picture in the background of your scene for instance.
  140517. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140518. * @param name Define the name of the layer in the scene
  140519. * @param imgUrl Define the url of the texture to display in the layer
  140520. * @param scene Define the scene the layer belongs to
  140521. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140522. * @param color Defines a color for the layer
  140523. */
  140524. constructor(
  140525. /**
  140526. * Define the name of the layer.
  140527. */
  140528. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140529. private _createIndexBuffer;
  140530. /** @hidden */
  140531. _rebuild(): void;
  140532. /**
  140533. * Renders the layer in the scene.
  140534. */
  140535. render(): void;
  140536. /**
  140537. * Disposes and releases the associated ressources.
  140538. */
  140539. dispose(): void;
  140540. }
  140541. }
  140542. declare module BABYLON {
  140543. /** @hidden */
  140544. export var lensFlarePixelShader: {
  140545. name: string;
  140546. shader: string;
  140547. };
  140548. }
  140549. declare module BABYLON {
  140550. /** @hidden */
  140551. export var lensFlareVertexShader: {
  140552. name: string;
  140553. shader: string;
  140554. };
  140555. }
  140556. declare module BABYLON {
  140557. /**
  140558. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140559. * It is usually composed of several `lensFlare`.
  140560. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140561. */
  140562. export class LensFlareSystem {
  140563. /**
  140564. * Define the name of the lens flare system
  140565. */
  140566. name: string;
  140567. /**
  140568. * List of lens flares used in this system.
  140569. */
  140570. lensFlares: LensFlare[];
  140571. /**
  140572. * Define a limit from the border the lens flare can be visible.
  140573. */
  140574. borderLimit: number;
  140575. /**
  140576. * Define a viewport border we do not want to see the lens flare in.
  140577. */
  140578. viewportBorder: number;
  140579. /**
  140580. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140581. */
  140582. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140583. /**
  140584. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140585. */
  140586. layerMask: number;
  140587. /**
  140588. * Define the id of the lens flare system in the scene.
  140589. * (equal to name by default)
  140590. */
  140591. id: string;
  140592. private _scene;
  140593. private _emitter;
  140594. private _vertexBuffers;
  140595. private _indexBuffer;
  140596. private _effect;
  140597. private _positionX;
  140598. private _positionY;
  140599. private _isEnabled;
  140600. /** @hidden */
  140601. static _SceneComponentInitialization: (scene: Scene) => void;
  140602. /**
  140603. * Instantiates a lens flare system.
  140604. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140605. * It is usually composed of several `lensFlare`.
  140606. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140607. * @param name Define the name of the lens flare system in the scene
  140608. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140609. * @param scene Define the scene the lens flare system belongs to
  140610. */
  140611. constructor(
  140612. /**
  140613. * Define the name of the lens flare system
  140614. */
  140615. name: string, emitter: any, scene: Scene);
  140616. /**
  140617. * Define if the lens flare system is enabled.
  140618. */
  140619. get isEnabled(): boolean;
  140620. set isEnabled(value: boolean);
  140621. /**
  140622. * Get the scene the effects belongs to.
  140623. * @returns the scene holding the lens flare system
  140624. */
  140625. getScene(): Scene;
  140626. /**
  140627. * Get the emitter of the lens flare system.
  140628. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140629. * @returns the emitter of the lens flare system
  140630. */
  140631. getEmitter(): any;
  140632. /**
  140633. * Set the emitter of the lens flare system.
  140634. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140635. * @param newEmitter Define the new emitter of the system
  140636. */
  140637. setEmitter(newEmitter: any): void;
  140638. /**
  140639. * Get the lens flare system emitter position.
  140640. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140641. * @returns the position
  140642. */
  140643. getEmitterPosition(): Vector3;
  140644. /**
  140645. * @hidden
  140646. */
  140647. computeEffectivePosition(globalViewport: Viewport): boolean;
  140648. /** @hidden */
  140649. _isVisible(): boolean;
  140650. /**
  140651. * @hidden
  140652. */
  140653. render(): boolean;
  140654. /**
  140655. * Dispose and release the lens flare with its associated resources.
  140656. */
  140657. dispose(): void;
  140658. /**
  140659. * Parse a lens flare system from a JSON repressentation
  140660. * @param parsedLensFlareSystem Define the JSON to parse
  140661. * @param scene Define the scene the parsed system should be instantiated in
  140662. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140663. * @returns the parsed system
  140664. */
  140665. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140666. /**
  140667. * Serialize the current Lens Flare System into a JSON representation.
  140668. * @returns the serialized JSON
  140669. */
  140670. serialize(): any;
  140671. }
  140672. }
  140673. declare module BABYLON {
  140674. /**
  140675. * This represents one of the lens effect in a `lensFlareSystem`.
  140676. * It controls one of the indiviual texture used in the effect.
  140677. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140678. */
  140679. export class LensFlare {
  140680. /**
  140681. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140682. */
  140683. size: number;
  140684. /**
  140685. * 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.
  140686. */
  140687. position: number;
  140688. /**
  140689. * Define the lens color.
  140690. */
  140691. color: Color3;
  140692. /**
  140693. * Define the lens texture.
  140694. */
  140695. texture: Nullable<Texture>;
  140696. /**
  140697. * Define the alpha mode to render this particular lens.
  140698. */
  140699. alphaMode: number;
  140700. private _system;
  140701. /**
  140702. * Creates a new Lens Flare.
  140703. * This represents one of the lens effect in a `lensFlareSystem`.
  140704. * It controls one of the indiviual texture used in the effect.
  140705. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140706. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140707. * @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.
  140708. * @param color Define the lens color
  140709. * @param imgUrl Define the lens texture url
  140710. * @param system Define the `lensFlareSystem` this flare is part of
  140711. * @returns The newly created Lens Flare
  140712. */
  140713. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140714. /**
  140715. * Instantiates a new Lens Flare.
  140716. * This represents one of the lens effect in a `lensFlareSystem`.
  140717. * It controls one of the indiviual texture used in the effect.
  140718. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140719. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140720. * @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.
  140721. * @param color Define the lens color
  140722. * @param imgUrl Define the lens texture url
  140723. * @param system Define the `lensFlareSystem` this flare is part of
  140724. */
  140725. constructor(
  140726. /**
  140727. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140728. */
  140729. size: number,
  140730. /**
  140731. * 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.
  140732. */
  140733. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140734. /**
  140735. * Dispose and release the lens flare with its associated resources.
  140736. */
  140737. dispose(): void;
  140738. }
  140739. }
  140740. declare module BABYLON {
  140741. interface AbstractScene {
  140742. /**
  140743. * The list of lens flare system added to the scene
  140744. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140745. */
  140746. lensFlareSystems: Array<LensFlareSystem>;
  140747. /**
  140748. * Removes the given lens flare system from this scene.
  140749. * @param toRemove The lens flare system to remove
  140750. * @returns The index of the removed lens flare system
  140751. */
  140752. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140753. /**
  140754. * Adds the given lens flare system to this scene
  140755. * @param newLensFlareSystem The lens flare system to add
  140756. */
  140757. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140758. /**
  140759. * Gets a lens flare system using its name
  140760. * @param name defines the name to look for
  140761. * @returns the lens flare system or null if not found
  140762. */
  140763. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140764. /**
  140765. * Gets a lens flare system using its id
  140766. * @param id defines the id to look for
  140767. * @returns the lens flare system or null if not found
  140768. */
  140769. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140770. }
  140771. /**
  140772. * Defines the lens flare scene component responsible to manage any lens flares
  140773. * in a given scene.
  140774. */
  140775. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140776. /**
  140777. * The component name helpfull to identify the component in the list of scene components.
  140778. */
  140779. readonly name: string;
  140780. /**
  140781. * The scene the component belongs to.
  140782. */
  140783. scene: Scene;
  140784. /**
  140785. * Creates a new instance of the component for the given scene
  140786. * @param scene Defines the scene to register the component in
  140787. */
  140788. constructor(scene: Scene);
  140789. /**
  140790. * Registers the component in a given scene
  140791. */
  140792. register(): void;
  140793. /**
  140794. * Rebuilds the elements related to this component in case of
  140795. * context lost for instance.
  140796. */
  140797. rebuild(): void;
  140798. /**
  140799. * Adds all the elements from the container to the scene
  140800. * @param container the container holding the elements
  140801. */
  140802. addFromContainer(container: AbstractScene): void;
  140803. /**
  140804. * Removes all the elements in the container from the scene
  140805. * @param container contains the elements to remove
  140806. * @param dispose if the removed element should be disposed (default: false)
  140807. */
  140808. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140809. /**
  140810. * Serializes the component data to the specified json object
  140811. * @param serializationObject The object to serialize to
  140812. */
  140813. serialize(serializationObject: any): void;
  140814. /**
  140815. * Disposes the component and the associated ressources.
  140816. */
  140817. dispose(): void;
  140818. private _draw;
  140819. }
  140820. }
  140821. declare module BABYLON {
  140822. /** @hidden */
  140823. export var depthPixelShader: {
  140824. name: string;
  140825. shader: string;
  140826. };
  140827. }
  140828. declare module BABYLON {
  140829. /** @hidden */
  140830. export var depthVertexShader: {
  140831. name: string;
  140832. shader: string;
  140833. };
  140834. }
  140835. declare module BABYLON {
  140836. /**
  140837. * This represents a depth renderer in Babylon.
  140838. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140839. */
  140840. export class DepthRenderer {
  140841. private _scene;
  140842. private _depthMap;
  140843. private _effect;
  140844. private readonly _storeNonLinearDepth;
  140845. private readonly _clearColor;
  140846. /** Get if the depth renderer is using packed depth or not */
  140847. readonly isPacked: boolean;
  140848. private _cachedDefines;
  140849. private _camera;
  140850. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140851. enabled: boolean;
  140852. /**
  140853. * Specifiess that the depth renderer will only be used within
  140854. * the camera it is created for.
  140855. * This can help forcing its rendering during the camera processing.
  140856. */
  140857. useOnlyInActiveCamera: boolean;
  140858. /** @hidden */
  140859. static _SceneComponentInitialization: (scene: Scene) => void;
  140860. /**
  140861. * Instantiates a depth renderer
  140862. * @param scene The scene the renderer belongs to
  140863. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140864. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140865. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140866. */
  140867. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140868. /**
  140869. * Creates the depth rendering effect and checks if the effect is ready.
  140870. * @param subMesh The submesh to be used to render the depth map of
  140871. * @param useInstances If multiple world instances should be used
  140872. * @returns if the depth renderer is ready to render the depth map
  140873. */
  140874. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140875. /**
  140876. * Gets the texture which the depth map will be written to.
  140877. * @returns The depth map texture
  140878. */
  140879. getDepthMap(): RenderTargetTexture;
  140880. /**
  140881. * Disposes of the depth renderer.
  140882. */
  140883. dispose(): void;
  140884. }
  140885. }
  140886. declare module BABYLON {
  140887. /** @hidden */
  140888. export var minmaxReduxPixelShader: {
  140889. name: string;
  140890. shader: string;
  140891. };
  140892. }
  140893. declare module BABYLON {
  140894. /**
  140895. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140896. * and maximum values from all values of the texture.
  140897. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140898. * The source values are read from the red channel of the texture.
  140899. */
  140900. export class MinMaxReducer {
  140901. /**
  140902. * Observable triggered when the computation has been performed
  140903. */
  140904. onAfterReductionPerformed: Observable<{
  140905. min: number;
  140906. max: number;
  140907. }>;
  140908. protected _camera: Camera;
  140909. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140910. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140911. protected _postProcessManager: PostProcessManager;
  140912. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140913. protected _forceFullscreenViewport: boolean;
  140914. /**
  140915. * Creates a min/max reducer
  140916. * @param camera The camera to use for the post processes
  140917. */
  140918. constructor(camera: Camera);
  140919. /**
  140920. * Gets the texture used to read the values from.
  140921. */
  140922. get sourceTexture(): Nullable<RenderTargetTexture>;
  140923. /**
  140924. * Sets the source texture to read the values from.
  140925. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140926. * because in such textures '1' value must not be taken into account to compute the maximum
  140927. * as this value is used to clear the texture.
  140928. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140929. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140930. * @param depthRedux Indicates if the texture is a depth texture or not
  140931. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140932. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140933. */
  140934. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140935. /**
  140936. * Defines the refresh rate of the computation.
  140937. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140938. */
  140939. get refreshRate(): number;
  140940. set refreshRate(value: number);
  140941. protected _activated: boolean;
  140942. /**
  140943. * Gets the activation status of the reducer
  140944. */
  140945. get activated(): boolean;
  140946. /**
  140947. * Activates the reduction computation.
  140948. * When activated, the observers registered in onAfterReductionPerformed are
  140949. * called after the compuation is performed
  140950. */
  140951. activate(): void;
  140952. /**
  140953. * Deactivates the reduction computation.
  140954. */
  140955. deactivate(): void;
  140956. /**
  140957. * Disposes the min/max reducer
  140958. * @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.
  140959. */
  140960. dispose(disposeAll?: boolean): void;
  140961. }
  140962. }
  140963. declare module BABYLON {
  140964. /**
  140965. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140966. */
  140967. export class DepthReducer extends MinMaxReducer {
  140968. private _depthRenderer;
  140969. private _depthRendererId;
  140970. /**
  140971. * Gets the depth renderer used for the computation.
  140972. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140973. */
  140974. get depthRenderer(): Nullable<DepthRenderer>;
  140975. /**
  140976. * Creates a depth reducer
  140977. * @param camera The camera used to render the depth texture
  140978. */
  140979. constructor(camera: Camera);
  140980. /**
  140981. * Sets the depth renderer to use to generate the depth map
  140982. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140983. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140984. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140985. */
  140986. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140987. /** @hidden */
  140988. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140989. /**
  140990. * Activates the reduction computation.
  140991. * When activated, the observers registered in onAfterReductionPerformed are
  140992. * called after the compuation is performed
  140993. */
  140994. activate(): void;
  140995. /**
  140996. * Deactivates the reduction computation.
  140997. */
  140998. deactivate(): void;
  140999. /**
  141000. * Disposes the depth reducer
  141001. * @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.
  141002. */
  141003. dispose(disposeAll?: boolean): void;
  141004. }
  141005. }
  141006. declare module BABYLON {
  141007. /**
  141008. * A CSM implementation allowing casting shadows on large scenes.
  141009. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141010. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141011. */
  141012. export class CascadedShadowGenerator extends ShadowGenerator {
  141013. private static readonly frustumCornersNDCSpace;
  141014. /**
  141015. * Name of the CSM class
  141016. */
  141017. static CLASSNAME: string;
  141018. /**
  141019. * Defines the default number of cascades used by the CSM.
  141020. */
  141021. static readonly DEFAULT_CASCADES_COUNT: number;
  141022. /**
  141023. * Defines the minimum number of cascades used by the CSM.
  141024. */
  141025. static readonly MIN_CASCADES_COUNT: number;
  141026. /**
  141027. * Defines the maximum number of cascades used by the CSM.
  141028. */
  141029. static readonly MAX_CASCADES_COUNT: number;
  141030. protected _validateFilter(filter: number): number;
  141031. /**
  141032. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141033. */
  141034. penumbraDarkness: number;
  141035. private _numCascades;
  141036. /**
  141037. * Gets or set the number of cascades used by the CSM.
  141038. */
  141039. get numCascades(): number;
  141040. set numCascades(value: number);
  141041. /**
  141042. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141043. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141044. */
  141045. stabilizeCascades: boolean;
  141046. private _freezeShadowCastersBoundingInfo;
  141047. private _freezeShadowCastersBoundingInfoObservable;
  141048. /**
  141049. * Enables or disables the shadow casters bounding info computation.
  141050. * If your shadow casters don't move, you can disable this feature.
  141051. * If it is enabled, the bounding box computation is done every frame.
  141052. */
  141053. get freezeShadowCastersBoundingInfo(): boolean;
  141054. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141055. private _scbiMin;
  141056. private _scbiMax;
  141057. protected _computeShadowCastersBoundingInfo(): void;
  141058. protected _shadowCastersBoundingInfo: BoundingInfo;
  141059. /**
  141060. * Gets or sets the shadow casters bounding info.
  141061. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141062. * so that the system won't overwrite the bounds you provide
  141063. */
  141064. get shadowCastersBoundingInfo(): BoundingInfo;
  141065. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141066. protected _breaksAreDirty: boolean;
  141067. protected _minDistance: number;
  141068. protected _maxDistance: number;
  141069. /**
  141070. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141071. *
  141072. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141073. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141074. * @param min minimal distance for the breaks (default to 0.)
  141075. * @param max maximal distance for the breaks (default to 1.)
  141076. */
  141077. setMinMaxDistance(min: number, max: number): void;
  141078. /** Gets the minimal distance used in the cascade break computation */
  141079. get minDistance(): number;
  141080. /** Gets the maximal distance used in the cascade break computation */
  141081. get maxDistance(): number;
  141082. /**
  141083. * Gets the class name of that object
  141084. * @returns "CascadedShadowGenerator"
  141085. */
  141086. getClassName(): string;
  141087. private _cascadeMinExtents;
  141088. private _cascadeMaxExtents;
  141089. /**
  141090. * Gets a cascade minimum extents
  141091. * @param cascadeIndex index of the cascade
  141092. * @returns the minimum cascade extents
  141093. */
  141094. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141095. /**
  141096. * Gets a cascade maximum extents
  141097. * @param cascadeIndex index of the cascade
  141098. * @returns the maximum cascade extents
  141099. */
  141100. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141101. private _cascades;
  141102. private _currentLayer;
  141103. private _viewSpaceFrustumsZ;
  141104. private _viewMatrices;
  141105. private _projectionMatrices;
  141106. private _transformMatrices;
  141107. private _transformMatricesAsArray;
  141108. private _frustumLengths;
  141109. private _lightSizeUVCorrection;
  141110. private _depthCorrection;
  141111. private _frustumCornersWorldSpace;
  141112. private _frustumCenter;
  141113. private _shadowCameraPos;
  141114. private _shadowMaxZ;
  141115. /**
  141116. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141117. * It defaults to camera.maxZ
  141118. */
  141119. get shadowMaxZ(): number;
  141120. /**
  141121. * Sets the shadow max z distance.
  141122. */
  141123. set shadowMaxZ(value: number);
  141124. protected _debug: boolean;
  141125. /**
  141126. * Gets or sets the debug flag.
  141127. * When enabled, the cascades are materialized by different colors on the screen.
  141128. */
  141129. get debug(): boolean;
  141130. set debug(dbg: boolean);
  141131. private _depthClamp;
  141132. /**
  141133. * Gets or sets the depth clamping value.
  141134. *
  141135. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141136. * to account for the shadow casters far away.
  141137. *
  141138. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141139. */
  141140. get depthClamp(): boolean;
  141141. set depthClamp(value: boolean);
  141142. private _cascadeBlendPercentage;
  141143. /**
  141144. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141145. * It defaults to 0.1 (10% blending).
  141146. */
  141147. get cascadeBlendPercentage(): number;
  141148. set cascadeBlendPercentage(value: number);
  141149. private _lambda;
  141150. /**
  141151. * Gets or set the lambda parameter.
  141152. * This parameter is used to split the camera frustum and create the cascades.
  141153. * 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.
  141154. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141155. */
  141156. get lambda(): number;
  141157. set lambda(value: number);
  141158. /**
  141159. * Gets the view matrix corresponding to a given cascade
  141160. * @param cascadeNum cascade to retrieve the view matrix from
  141161. * @returns the cascade view matrix
  141162. */
  141163. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141164. /**
  141165. * Gets the projection matrix corresponding to a given cascade
  141166. * @param cascadeNum cascade to retrieve the projection matrix from
  141167. * @returns the cascade projection matrix
  141168. */
  141169. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141170. /**
  141171. * Gets the transformation matrix corresponding to a given cascade
  141172. * @param cascadeNum cascade to retrieve the transformation matrix from
  141173. * @returns the cascade transformation matrix
  141174. */
  141175. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141176. private _depthRenderer;
  141177. /**
  141178. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141179. *
  141180. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141181. *
  141182. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141183. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141184. * @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
  141185. */
  141186. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141187. private _depthReducer;
  141188. private _autoCalcDepthBounds;
  141189. /**
  141190. * Gets or sets the autoCalcDepthBounds property.
  141191. *
  141192. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141193. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141194. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141195. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141196. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141197. */
  141198. get autoCalcDepthBounds(): boolean;
  141199. set autoCalcDepthBounds(value: boolean);
  141200. /**
  141201. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141202. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141203. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141204. * for setting the refresh rate on the renderer yourself!
  141205. */
  141206. get autoCalcDepthBoundsRefreshRate(): number;
  141207. set autoCalcDepthBoundsRefreshRate(value: number);
  141208. /**
  141209. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141210. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141211. * you change the camera near/far planes!
  141212. */
  141213. splitFrustum(): void;
  141214. private _splitFrustum;
  141215. private _computeMatrices;
  141216. private _computeFrustumInWorldSpace;
  141217. private _computeCascadeFrustum;
  141218. /**
  141219. * Support test.
  141220. */
  141221. static get IsSupported(): boolean;
  141222. /** @hidden */
  141223. static _SceneComponentInitialization: (scene: Scene) => void;
  141224. /**
  141225. * Creates a Cascaded Shadow Generator object.
  141226. * A ShadowGenerator is the required tool to use the shadows.
  141227. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141228. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141229. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141230. * @param light The directional light object generating the shadows.
  141231. * @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.
  141232. */
  141233. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141234. protected _initializeGenerator(): void;
  141235. protected _createTargetRenderTexture(): void;
  141236. protected _initializeShadowMap(): void;
  141237. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141238. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141239. /**
  141240. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141241. * @param defines Defines of the material we want to update
  141242. * @param lightIndex Index of the light in the enabled light list of the material
  141243. */
  141244. prepareDefines(defines: any, lightIndex: number): void;
  141245. /**
  141246. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141247. * defined in the generator but impacting the effect).
  141248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141249. * @param effect The effect we are binfing the information for
  141250. */
  141251. bindShadowLight(lightIndex: string, effect: Effect): void;
  141252. /**
  141253. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141254. * (eq to view projection * shadow projection matrices)
  141255. * @returns The transform matrix used to create the shadow map
  141256. */
  141257. getTransformMatrix(): Matrix;
  141258. /**
  141259. * Disposes the ShadowGenerator.
  141260. * Returns nothing.
  141261. */
  141262. dispose(): void;
  141263. /**
  141264. * Serializes the shadow generator setup to a json object.
  141265. * @returns The serialized JSON object
  141266. */
  141267. serialize(): any;
  141268. /**
  141269. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141270. * @param parsedShadowGenerator The JSON object to parse
  141271. * @param scene The scene to create the shadow map for
  141272. * @returns The parsed shadow generator
  141273. */
  141274. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141275. }
  141276. }
  141277. declare module BABYLON {
  141278. /**
  141279. * Defines the shadow generator component responsible to manage any shadow generators
  141280. * in a given scene.
  141281. */
  141282. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141283. /**
  141284. * The component name helpfull to identify the component in the list of scene components.
  141285. */
  141286. readonly name: string;
  141287. /**
  141288. * The scene the component belongs to.
  141289. */
  141290. scene: Scene;
  141291. /**
  141292. * Creates a new instance of the component for the given scene
  141293. * @param scene Defines the scene to register the component in
  141294. */
  141295. constructor(scene: Scene);
  141296. /**
  141297. * Registers the component in a given scene
  141298. */
  141299. register(): void;
  141300. /**
  141301. * Rebuilds the elements related to this component in case of
  141302. * context lost for instance.
  141303. */
  141304. rebuild(): void;
  141305. /**
  141306. * Serializes the component data to the specified json object
  141307. * @param serializationObject The object to serialize to
  141308. */
  141309. serialize(serializationObject: any): void;
  141310. /**
  141311. * Adds all the elements from the container to the scene
  141312. * @param container the container holding the elements
  141313. */
  141314. addFromContainer(container: AbstractScene): void;
  141315. /**
  141316. * Removes all the elements in the container from the scene
  141317. * @param container contains the elements to remove
  141318. * @param dispose if the removed element should be disposed (default: false)
  141319. */
  141320. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141321. /**
  141322. * Rebuilds the elements related to this component in case of
  141323. * context lost for instance.
  141324. */
  141325. dispose(): void;
  141326. private _gatherRenderTargets;
  141327. }
  141328. }
  141329. declare module BABYLON {
  141330. /**
  141331. * A point light is a light defined by an unique point in world space.
  141332. * The light is emitted in every direction from this point.
  141333. * A good example of a point light is a standard light bulb.
  141334. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141335. */
  141336. export class PointLight extends ShadowLight {
  141337. private _shadowAngle;
  141338. /**
  141339. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141340. * This specifies what angle the shadow will use to be created.
  141341. *
  141342. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141343. */
  141344. get shadowAngle(): number;
  141345. /**
  141346. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141347. * This specifies what angle the shadow will use to be created.
  141348. *
  141349. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141350. */
  141351. set shadowAngle(value: number);
  141352. /**
  141353. * Gets the direction if it has been set.
  141354. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141355. */
  141356. get direction(): Vector3;
  141357. /**
  141358. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141359. */
  141360. set direction(value: Vector3);
  141361. /**
  141362. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141363. * A PointLight emits the light in every direction.
  141364. * It can cast shadows.
  141365. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141366. * ```javascript
  141367. * var pointLight = new PointLight("pl", camera.position, scene);
  141368. * ```
  141369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141370. * @param name The light friendly name
  141371. * @param position The position of the point light in the scene
  141372. * @param scene The scene the lights belongs to
  141373. */
  141374. constructor(name: string, position: Vector3, scene: Scene);
  141375. /**
  141376. * Returns the string "PointLight"
  141377. * @returns the class name
  141378. */
  141379. getClassName(): string;
  141380. /**
  141381. * Returns the integer 0.
  141382. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141383. */
  141384. getTypeID(): number;
  141385. /**
  141386. * Specifies wether or not the shadowmap should be a cube texture.
  141387. * @returns true if the shadowmap needs to be a cube texture.
  141388. */
  141389. needCube(): boolean;
  141390. /**
  141391. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141392. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141393. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141394. */
  141395. getShadowDirection(faceIndex?: number): Vector3;
  141396. /**
  141397. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141398. * - fov = PI / 2
  141399. * - aspect ratio : 1.0
  141400. * - z-near and far equal to the active camera minZ and maxZ.
  141401. * Returns the PointLight.
  141402. */
  141403. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141404. protected _buildUniformLayout(): void;
  141405. /**
  141406. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141407. * @param effect The effect to update
  141408. * @param lightIndex The index of the light in the effect to update
  141409. * @returns The point light
  141410. */
  141411. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141412. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141413. /**
  141414. * Prepares the list of defines specific to the light type.
  141415. * @param defines the list of defines
  141416. * @param lightIndex defines the index of the light for the effect
  141417. */
  141418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141419. }
  141420. }
  141421. declare module BABYLON {
  141422. /**
  141423. * Header information of HDR texture files.
  141424. */
  141425. export interface HDRInfo {
  141426. /**
  141427. * The height of the texture in pixels.
  141428. */
  141429. height: number;
  141430. /**
  141431. * The width of the texture in pixels.
  141432. */
  141433. width: number;
  141434. /**
  141435. * The index of the beginning of the data in the binary file.
  141436. */
  141437. dataPosition: number;
  141438. }
  141439. /**
  141440. * This groups tools to convert HDR texture to native colors array.
  141441. */
  141442. export class HDRTools {
  141443. private static Ldexp;
  141444. private static Rgbe2float;
  141445. private static readStringLine;
  141446. /**
  141447. * Reads header information from an RGBE texture stored in a native array.
  141448. * More information on this format are available here:
  141449. * https://en.wikipedia.org/wiki/RGBE_image_format
  141450. *
  141451. * @param uint8array The binary file stored in native array.
  141452. * @return The header information.
  141453. */
  141454. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141455. /**
  141456. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141457. * This RGBE texture needs to store the information as a panorama.
  141458. *
  141459. * More information on this format are available here:
  141460. * https://en.wikipedia.org/wiki/RGBE_image_format
  141461. *
  141462. * @param buffer The binary file stored in an array buffer.
  141463. * @param size The expected size of the extracted cubemap.
  141464. * @return The Cube Map information.
  141465. */
  141466. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141467. /**
  141468. * Returns the pixels data extracted from an RGBE texture.
  141469. * This pixels will be stored left to right up to down in the R G B order in one array.
  141470. *
  141471. * More information on this format are available here:
  141472. * https://en.wikipedia.org/wiki/RGBE_image_format
  141473. *
  141474. * @param uint8array The binary file stored in an array buffer.
  141475. * @param hdrInfo The header information of the file.
  141476. * @return The pixels data in RGB right to left up to down order.
  141477. */
  141478. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141479. private static RGBE_ReadPixels_RLE;
  141480. private static RGBE_ReadPixels_NOT_RLE;
  141481. }
  141482. }
  141483. declare module BABYLON {
  141484. /**
  141485. * Effect Render Options
  141486. */
  141487. export interface IEffectRendererOptions {
  141488. /**
  141489. * Defines the vertices positions.
  141490. */
  141491. positions?: number[];
  141492. /**
  141493. * Defines the indices.
  141494. */
  141495. indices?: number[];
  141496. }
  141497. /**
  141498. * Helper class to render one or more effects.
  141499. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141500. */
  141501. export class EffectRenderer {
  141502. private engine;
  141503. private static _DefaultOptions;
  141504. private _vertexBuffers;
  141505. private _indexBuffer;
  141506. private _fullscreenViewport;
  141507. /**
  141508. * Creates an effect renderer
  141509. * @param engine the engine to use for rendering
  141510. * @param options defines the options of the effect renderer
  141511. */
  141512. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141513. /**
  141514. * Sets the current viewport in normalized coordinates 0-1
  141515. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141516. */
  141517. setViewport(viewport?: Viewport): void;
  141518. /**
  141519. * Binds the embedded attributes buffer to the effect.
  141520. * @param effect Defines the effect to bind the attributes for
  141521. */
  141522. bindBuffers(effect: Effect): void;
  141523. /**
  141524. * Sets the current effect wrapper to use during draw.
  141525. * The effect needs to be ready before calling this api.
  141526. * This also sets the default full screen position attribute.
  141527. * @param effectWrapper Defines the effect to draw with
  141528. */
  141529. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141530. /**
  141531. * Restores engine states
  141532. */
  141533. restoreStates(): void;
  141534. /**
  141535. * Draws a full screen quad.
  141536. */
  141537. draw(): void;
  141538. private isRenderTargetTexture;
  141539. /**
  141540. * renders one or more effects to a specified texture
  141541. * @param effectWrapper the effect to renderer
  141542. * @param outputTexture texture to draw to, if null it will render to the screen.
  141543. */
  141544. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141545. /**
  141546. * Disposes of the effect renderer
  141547. */
  141548. dispose(): void;
  141549. }
  141550. /**
  141551. * Options to create an EffectWrapper
  141552. */
  141553. interface EffectWrapperCreationOptions {
  141554. /**
  141555. * Engine to use to create the effect
  141556. */
  141557. engine: ThinEngine;
  141558. /**
  141559. * Fragment shader for the effect
  141560. */
  141561. fragmentShader: string;
  141562. /**
  141563. * Use the shader store instead of direct source code
  141564. */
  141565. useShaderStore?: boolean;
  141566. /**
  141567. * Vertex shader for the effect
  141568. */
  141569. vertexShader?: string;
  141570. /**
  141571. * Attributes to use in the shader
  141572. */
  141573. attributeNames?: Array<string>;
  141574. /**
  141575. * Uniforms to use in the shader
  141576. */
  141577. uniformNames?: Array<string>;
  141578. /**
  141579. * Texture sampler names to use in the shader
  141580. */
  141581. samplerNames?: Array<string>;
  141582. /**
  141583. * Defines to use in the shader
  141584. */
  141585. defines?: Array<string>;
  141586. /**
  141587. * Callback when effect is compiled
  141588. */
  141589. onCompiled?: Nullable<(effect: Effect) => void>;
  141590. /**
  141591. * The friendly name of the effect displayed in Spector.
  141592. */
  141593. name?: string;
  141594. }
  141595. /**
  141596. * Wraps an effect to be used for rendering
  141597. */
  141598. export class EffectWrapper {
  141599. /**
  141600. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141601. */
  141602. onApplyObservable: Observable<{}>;
  141603. /**
  141604. * The underlying effect
  141605. */
  141606. effect: Effect;
  141607. /**
  141608. * Creates an effect to be renderer
  141609. * @param creationOptions options to create the effect
  141610. */
  141611. constructor(creationOptions: EffectWrapperCreationOptions);
  141612. /**
  141613. * Disposes of the effect wrapper
  141614. */
  141615. dispose(): void;
  141616. }
  141617. }
  141618. declare module BABYLON {
  141619. /** @hidden */
  141620. export var hdrFilteringVertexShader: {
  141621. name: string;
  141622. shader: string;
  141623. };
  141624. }
  141625. declare module BABYLON {
  141626. /** @hidden */
  141627. export var hdrFilteringPixelShader: {
  141628. name: string;
  141629. shader: string;
  141630. };
  141631. }
  141632. declare module BABYLON {
  141633. /**
  141634. * Options for texture filtering
  141635. */
  141636. interface IHDRFilteringOptions {
  141637. /**
  141638. * Scales pixel intensity for the input HDR map.
  141639. */
  141640. hdrScale?: number;
  141641. /**
  141642. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141643. */
  141644. quality?: number;
  141645. }
  141646. /**
  141647. * Filters HDR maps to get correct renderings of PBR reflections
  141648. */
  141649. export class HDRFiltering {
  141650. private _engine;
  141651. private _effectRenderer;
  141652. private _effectWrapper;
  141653. private _lodGenerationOffset;
  141654. private _lodGenerationScale;
  141655. /**
  141656. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141657. * you care about baking speed.
  141658. */
  141659. quality: number;
  141660. /**
  141661. * Scales pixel intensity for the input HDR map.
  141662. */
  141663. hdrScale: number;
  141664. /**
  141665. * Instantiates HDR filter for reflection maps
  141666. *
  141667. * @param engine Thin engine
  141668. * @param options Options
  141669. */
  141670. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141671. private _createRenderTarget;
  141672. private _prefilterInternal;
  141673. private _createEffect;
  141674. /**
  141675. * Get a value indicating if the filter is ready to be used
  141676. * @param texture Texture to filter
  141677. * @returns true if the filter is ready
  141678. */
  141679. isReady(texture: BaseTexture): boolean;
  141680. /**
  141681. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141682. * Prefiltering will be invoked at the end of next rendering pass.
  141683. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141684. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141685. * @param texture Texture to filter
  141686. * @param onFinished Callback when filtering is done
  141687. * @return Promise called when prefiltering is done
  141688. */
  141689. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141690. }
  141691. }
  141692. declare module BABYLON {
  141693. /**
  141694. * This represents a texture coming from an HDR input.
  141695. *
  141696. * The only supported format is currently panorama picture stored in RGBE format.
  141697. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141698. */
  141699. export class HDRCubeTexture extends BaseTexture {
  141700. private static _facesMapping;
  141701. private _generateHarmonics;
  141702. private _noMipmap;
  141703. private _prefilterOnLoad;
  141704. private _textureMatrix;
  141705. private _size;
  141706. private _onLoad;
  141707. private _onError;
  141708. /**
  141709. * The texture URL.
  141710. */
  141711. url: string;
  141712. protected _isBlocking: boolean;
  141713. /**
  141714. * Sets wether or not the texture is blocking during loading.
  141715. */
  141716. set isBlocking(value: boolean);
  141717. /**
  141718. * Gets wether or not the texture is blocking during loading.
  141719. */
  141720. get isBlocking(): boolean;
  141721. protected _rotationY: number;
  141722. /**
  141723. * Sets texture matrix rotation angle around Y axis in radians.
  141724. */
  141725. set rotationY(value: number);
  141726. /**
  141727. * Gets texture matrix rotation angle around Y axis radians.
  141728. */
  141729. get rotationY(): number;
  141730. /**
  141731. * Gets or sets the center of the bounding box associated with the cube texture
  141732. * It must define where the camera used to render the texture was set
  141733. */
  141734. boundingBoxPosition: Vector3;
  141735. private _boundingBoxSize;
  141736. /**
  141737. * Gets or sets the size of the bounding box associated with the cube texture
  141738. * When defined, the cubemap will switch to local mode
  141739. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141740. * @example https://www.babylonjs-playground.com/#RNASML
  141741. */
  141742. set boundingBoxSize(value: Vector3);
  141743. get boundingBoxSize(): Vector3;
  141744. /**
  141745. * Instantiates an HDRTexture from the following parameters.
  141746. *
  141747. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141748. * @param sceneOrEngine The scene or engine the texture will be used in
  141749. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141750. * @param noMipmap Forces to not generate the mipmap if true
  141751. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141752. * @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)
  141753. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141754. */
  141755. 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>);
  141756. /**
  141757. * Get the current class name of the texture useful for serialization or dynamic coding.
  141758. * @returns "HDRCubeTexture"
  141759. */
  141760. getClassName(): string;
  141761. /**
  141762. * Occurs when the file is raw .hdr file.
  141763. */
  141764. private loadTexture;
  141765. clone(): HDRCubeTexture;
  141766. delayLoad(): void;
  141767. /**
  141768. * Get the texture reflection matrix used to rotate/transform the reflection.
  141769. * @returns the reflection matrix
  141770. */
  141771. getReflectionTextureMatrix(): Matrix;
  141772. /**
  141773. * Set the texture reflection matrix used to rotate/transform the reflection.
  141774. * @param value Define the reflection matrix to set
  141775. */
  141776. setReflectionTextureMatrix(value: Matrix): void;
  141777. /**
  141778. * Parses a JSON representation of an HDR Texture in order to create the texture
  141779. * @param parsedTexture Define the JSON representation
  141780. * @param scene Define the scene the texture should be created in
  141781. * @param rootUrl Define the root url in case we need to load relative dependencies
  141782. * @returns the newly created texture after parsing
  141783. */
  141784. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141785. serialize(): any;
  141786. }
  141787. }
  141788. declare module BABYLON {
  141789. /**
  141790. * Class used to control physics engine
  141791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141792. */
  141793. export class PhysicsEngine implements IPhysicsEngine {
  141794. private _physicsPlugin;
  141795. /**
  141796. * Global value used to control the smallest number supported by the simulation
  141797. */
  141798. static Epsilon: number;
  141799. private _impostors;
  141800. private _joints;
  141801. private _subTimeStep;
  141802. /**
  141803. * Gets the gravity vector used by the simulation
  141804. */
  141805. gravity: Vector3;
  141806. /**
  141807. * Factory used to create the default physics plugin.
  141808. * @returns The default physics plugin
  141809. */
  141810. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141811. /**
  141812. * Creates a new Physics Engine
  141813. * @param gravity defines the gravity vector used by the simulation
  141814. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141815. */
  141816. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141817. /**
  141818. * Sets the gravity vector used by the simulation
  141819. * @param gravity defines the gravity vector to use
  141820. */
  141821. setGravity(gravity: Vector3): void;
  141822. /**
  141823. * Set the time step of the physics engine.
  141824. * Default is 1/60.
  141825. * To slow it down, enter 1/600 for example.
  141826. * To speed it up, 1/30
  141827. * @param newTimeStep defines the new timestep to apply to this world.
  141828. */
  141829. setTimeStep(newTimeStep?: number): void;
  141830. /**
  141831. * Get the time step of the physics engine.
  141832. * @returns the current time step
  141833. */
  141834. getTimeStep(): number;
  141835. /**
  141836. * Set the sub time step of the physics engine.
  141837. * Default is 0 meaning there is no sub steps
  141838. * To increase physics resolution precision, set a small value (like 1 ms)
  141839. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141840. */
  141841. setSubTimeStep(subTimeStep?: number): void;
  141842. /**
  141843. * Get the sub time step of the physics engine.
  141844. * @returns the current sub time step
  141845. */
  141846. getSubTimeStep(): number;
  141847. /**
  141848. * Release all resources
  141849. */
  141850. dispose(): void;
  141851. /**
  141852. * Gets the name of the current physics plugin
  141853. * @returns the name of the plugin
  141854. */
  141855. getPhysicsPluginName(): string;
  141856. /**
  141857. * Adding a new impostor for the impostor tracking.
  141858. * This will be done by the impostor itself.
  141859. * @param impostor the impostor to add
  141860. */
  141861. addImpostor(impostor: PhysicsImpostor): void;
  141862. /**
  141863. * Remove an impostor from the engine.
  141864. * This impostor and its mesh will not longer be updated by the physics engine.
  141865. * @param impostor the impostor to remove
  141866. */
  141867. removeImpostor(impostor: PhysicsImpostor): void;
  141868. /**
  141869. * Add a joint to the physics engine
  141870. * @param mainImpostor defines the main impostor to which the joint is added.
  141871. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141872. * @param joint defines the joint that will connect both impostors.
  141873. */
  141874. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141875. /**
  141876. * Removes a joint from the simulation
  141877. * @param mainImpostor defines the impostor used with the joint
  141878. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141879. * @param joint defines the joint to remove
  141880. */
  141881. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141882. /**
  141883. * Called by the scene. No need to call it.
  141884. * @param delta defines the timespam between frames
  141885. */
  141886. _step(delta: number): void;
  141887. /**
  141888. * Gets the current plugin used to run the simulation
  141889. * @returns current plugin
  141890. */
  141891. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141892. /**
  141893. * Gets the list of physic impostors
  141894. * @returns an array of PhysicsImpostor
  141895. */
  141896. getImpostors(): Array<PhysicsImpostor>;
  141897. /**
  141898. * Gets the impostor for a physics enabled object
  141899. * @param object defines the object impersonated by the impostor
  141900. * @returns the PhysicsImpostor or null if not found
  141901. */
  141902. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141903. /**
  141904. * Gets the impostor for a physics body object
  141905. * @param body defines physics body used by the impostor
  141906. * @returns the PhysicsImpostor or null if not found
  141907. */
  141908. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141909. /**
  141910. * Does a raycast in the physics world
  141911. * @param from when should the ray start?
  141912. * @param to when should the ray end?
  141913. * @returns PhysicsRaycastResult
  141914. */
  141915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141916. }
  141917. }
  141918. declare module BABYLON {
  141919. /** @hidden */
  141920. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141921. private _useDeltaForWorldStep;
  141922. world: any;
  141923. name: string;
  141924. private _physicsMaterials;
  141925. private _fixedTimeStep;
  141926. private _cannonRaycastResult;
  141927. private _raycastResult;
  141928. private _physicsBodysToRemoveAfterStep;
  141929. private _firstFrame;
  141930. BJSCANNON: any;
  141931. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141932. setGravity(gravity: Vector3): void;
  141933. setTimeStep(timeStep: number): void;
  141934. getTimeStep(): number;
  141935. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141936. private _removeMarkedPhysicsBodiesFromWorld;
  141937. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141938. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141939. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141940. private _processChildMeshes;
  141941. removePhysicsBody(impostor: PhysicsImpostor): void;
  141942. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141943. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141944. private _addMaterial;
  141945. private _checkWithEpsilon;
  141946. private _createShape;
  141947. private _createHeightmap;
  141948. private _minus90X;
  141949. private _plus90X;
  141950. private _tmpPosition;
  141951. private _tmpDeltaPosition;
  141952. private _tmpUnityRotation;
  141953. private _updatePhysicsBodyTransformation;
  141954. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141955. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141956. isSupported(): boolean;
  141957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141958. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141959. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141960. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141962. getBodyMass(impostor: PhysicsImpostor): number;
  141963. getBodyFriction(impostor: PhysicsImpostor): number;
  141964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141965. getBodyRestitution(impostor: PhysicsImpostor): number;
  141966. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141967. sleepBody(impostor: PhysicsImpostor): void;
  141968. wakeUpBody(impostor: PhysicsImpostor): void;
  141969. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141970. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141971. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141972. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141973. getRadius(impostor: PhysicsImpostor): number;
  141974. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141975. dispose(): void;
  141976. private _extendNamespace;
  141977. /**
  141978. * Does a raycast in the physics world
  141979. * @param from when should the ray start?
  141980. * @param to when should the ray end?
  141981. * @returns PhysicsRaycastResult
  141982. */
  141983. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141984. }
  141985. }
  141986. declare module BABYLON {
  141987. /** @hidden */
  141988. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141989. private _useDeltaForWorldStep;
  141990. world: any;
  141991. name: string;
  141992. BJSOIMO: any;
  141993. private _raycastResult;
  141994. private _fixedTimeStep;
  141995. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141996. setGravity(gravity: Vector3): void;
  141997. setTimeStep(timeStep: number): void;
  141998. getTimeStep(): number;
  141999. private _tmpImpostorsArray;
  142000. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142001. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142002. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142003. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142004. private _tmpPositionVector;
  142005. removePhysicsBody(impostor: PhysicsImpostor): void;
  142006. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142007. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142008. isSupported(): boolean;
  142009. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142010. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142011. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142012. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142013. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142014. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142016. getBodyMass(impostor: PhysicsImpostor): number;
  142017. getBodyFriction(impostor: PhysicsImpostor): number;
  142018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142019. getBodyRestitution(impostor: PhysicsImpostor): number;
  142020. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142021. sleepBody(impostor: PhysicsImpostor): void;
  142022. wakeUpBody(impostor: PhysicsImpostor): void;
  142023. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142024. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142025. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142026. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142027. getRadius(impostor: PhysicsImpostor): number;
  142028. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142029. dispose(): void;
  142030. /**
  142031. * Does a raycast in the physics world
  142032. * @param from when should the ray start?
  142033. * @param to when should the ray end?
  142034. * @returns PhysicsRaycastResult
  142035. */
  142036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142037. }
  142038. }
  142039. declare module BABYLON {
  142040. /**
  142041. * AmmoJS Physics plugin
  142042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142043. * @see https://github.com/kripken/ammo.js/
  142044. */
  142045. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142046. private _useDeltaForWorldStep;
  142047. /**
  142048. * Reference to the Ammo library
  142049. */
  142050. bjsAMMO: any;
  142051. /**
  142052. * Created ammoJS world which physics bodies are added to
  142053. */
  142054. world: any;
  142055. /**
  142056. * Name of the plugin
  142057. */
  142058. name: string;
  142059. private _timeStep;
  142060. private _fixedTimeStep;
  142061. private _maxSteps;
  142062. private _tmpQuaternion;
  142063. private _tmpAmmoTransform;
  142064. private _tmpAmmoQuaternion;
  142065. private _tmpAmmoConcreteContactResultCallback;
  142066. private _collisionConfiguration;
  142067. private _dispatcher;
  142068. private _overlappingPairCache;
  142069. private _solver;
  142070. private _softBodySolver;
  142071. private _tmpAmmoVectorA;
  142072. private _tmpAmmoVectorB;
  142073. private _tmpAmmoVectorC;
  142074. private _tmpAmmoVectorD;
  142075. private _tmpContactCallbackResult;
  142076. private _tmpAmmoVectorRCA;
  142077. private _tmpAmmoVectorRCB;
  142078. private _raycastResult;
  142079. private static readonly DISABLE_COLLISION_FLAG;
  142080. private static readonly KINEMATIC_FLAG;
  142081. private static readonly DISABLE_DEACTIVATION_FLAG;
  142082. /**
  142083. * Initializes the ammoJS plugin
  142084. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142085. * @param ammoInjection can be used to inject your own ammo reference
  142086. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142087. */
  142088. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142089. /**
  142090. * Sets the gravity of the physics world (m/(s^2))
  142091. * @param gravity Gravity to set
  142092. */
  142093. setGravity(gravity: Vector3): void;
  142094. /**
  142095. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142096. * @param timeStep timestep to use in seconds
  142097. */
  142098. setTimeStep(timeStep: number): void;
  142099. /**
  142100. * 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)
  142101. * @param fixedTimeStep fixedTimeStep to use in seconds
  142102. */
  142103. setFixedTimeStep(fixedTimeStep: number): void;
  142104. /**
  142105. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142106. * @param maxSteps the maximum number of steps by the physics engine per frame
  142107. */
  142108. setMaxSteps(maxSteps: number): void;
  142109. /**
  142110. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142111. * @returns the current timestep in seconds
  142112. */
  142113. getTimeStep(): number;
  142114. /**
  142115. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142116. */
  142117. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142118. private _isImpostorInContact;
  142119. private _isImpostorPairInContact;
  142120. private _stepSimulation;
  142121. /**
  142122. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142123. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142124. * After the step the babylon meshes are set to the position of the physics imposters
  142125. * @param delta amount of time to step forward
  142126. * @param impostors array of imposters to update before/after the step
  142127. */
  142128. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142129. /**
  142130. * Update babylon mesh to match physics world object
  142131. * @param impostor imposter to match
  142132. */
  142133. private _afterSoftStep;
  142134. /**
  142135. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142136. * @param impostor imposter to match
  142137. */
  142138. private _ropeStep;
  142139. /**
  142140. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142141. * @param impostor imposter to match
  142142. */
  142143. private _softbodyOrClothStep;
  142144. private _tmpMatrix;
  142145. /**
  142146. * Applies an impulse on the imposter
  142147. * @param impostor imposter to apply impulse to
  142148. * @param force amount of force to be applied to the imposter
  142149. * @param contactPoint the location to apply the impulse on the imposter
  142150. */
  142151. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142152. /**
  142153. * Applies a force on the imposter
  142154. * @param impostor imposter to apply force
  142155. * @param force amount of force to be applied to the imposter
  142156. * @param contactPoint the location to apply the force on the imposter
  142157. */
  142158. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142159. /**
  142160. * Creates a physics body using the plugin
  142161. * @param impostor the imposter to create the physics body on
  142162. */
  142163. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142164. /**
  142165. * Removes the physics body from the imposter and disposes of the body's memory
  142166. * @param impostor imposter to remove the physics body from
  142167. */
  142168. removePhysicsBody(impostor: PhysicsImpostor): void;
  142169. /**
  142170. * Generates a joint
  142171. * @param impostorJoint the imposter joint to create the joint with
  142172. */
  142173. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142174. /**
  142175. * Removes a joint
  142176. * @param impostorJoint the imposter joint to remove the joint from
  142177. */
  142178. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142179. private _addMeshVerts;
  142180. /**
  142181. * Initialise the soft body vertices to match its object's (mesh) vertices
  142182. * Softbody vertices (nodes) are in world space and to match this
  142183. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142184. * @param impostor to create the softbody for
  142185. */
  142186. private _softVertexData;
  142187. /**
  142188. * Create an impostor's soft body
  142189. * @param impostor to create the softbody for
  142190. */
  142191. private _createSoftbody;
  142192. /**
  142193. * Create cloth for an impostor
  142194. * @param impostor to create the softbody for
  142195. */
  142196. private _createCloth;
  142197. /**
  142198. * Create rope for an impostor
  142199. * @param impostor to create the softbody for
  142200. */
  142201. private _createRope;
  142202. /**
  142203. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142204. * @param impostor to create the custom physics shape for
  142205. */
  142206. private _createCustom;
  142207. private _addHullVerts;
  142208. private _createShape;
  142209. /**
  142210. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142211. * @param impostor imposter containing the physics body and babylon object
  142212. */
  142213. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142214. /**
  142215. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142216. * @param impostor imposter containing the physics body and babylon object
  142217. * @param newPosition new position
  142218. * @param newRotation new rotation
  142219. */
  142220. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142221. /**
  142222. * If this plugin is supported
  142223. * @returns true if its supported
  142224. */
  142225. isSupported(): boolean;
  142226. /**
  142227. * Sets the linear velocity of the physics body
  142228. * @param impostor imposter to set the velocity on
  142229. * @param velocity velocity to set
  142230. */
  142231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142232. /**
  142233. * Sets the angular velocity of the physics body
  142234. * @param impostor imposter to set the velocity on
  142235. * @param velocity velocity to set
  142236. */
  142237. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142238. /**
  142239. * gets the linear velocity
  142240. * @param impostor imposter to get linear velocity from
  142241. * @returns linear velocity
  142242. */
  142243. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142244. /**
  142245. * gets the angular velocity
  142246. * @param impostor imposter to get angular velocity from
  142247. * @returns angular velocity
  142248. */
  142249. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142250. /**
  142251. * Sets the mass of physics body
  142252. * @param impostor imposter to set the mass on
  142253. * @param mass mass to set
  142254. */
  142255. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142256. /**
  142257. * Gets the mass of the physics body
  142258. * @param impostor imposter to get the mass from
  142259. * @returns mass
  142260. */
  142261. getBodyMass(impostor: PhysicsImpostor): number;
  142262. /**
  142263. * Gets friction of the impostor
  142264. * @param impostor impostor to get friction from
  142265. * @returns friction value
  142266. */
  142267. getBodyFriction(impostor: PhysicsImpostor): number;
  142268. /**
  142269. * Sets friction of the impostor
  142270. * @param impostor impostor to set friction on
  142271. * @param friction friction value
  142272. */
  142273. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142274. /**
  142275. * Gets restitution of the impostor
  142276. * @param impostor impostor to get restitution from
  142277. * @returns restitution value
  142278. */
  142279. getBodyRestitution(impostor: PhysicsImpostor): number;
  142280. /**
  142281. * Sets resitution of the impostor
  142282. * @param impostor impostor to set resitution on
  142283. * @param restitution resitution value
  142284. */
  142285. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142286. /**
  142287. * Gets pressure inside the impostor
  142288. * @param impostor impostor to get pressure from
  142289. * @returns pressure value
  142290. */
  142291. getBodyPressure(impostor: PhysicsImpostor): number;
  142292. /**
  142293. * Sets pressure inside a soft body impostor
  142294. * Cloth and rope must remain 0 pressure
  142295. * @param impostor impostor to set pressure on
  142296. * @param pressure pressure value
  142297. */
  142298. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142299. /**
  142300. * Gets stiffness of the impostor
  142301. * @param impostor impostor to get stiffness from
  142302. * @returns pressure value
  142303. */
  142304. getBodyStiffness(impostor: PhysicsImpostor): number;
  142305. /**
  142306. * Sets stiffness of the impostor
  142307. * @param impostor impostor to set stiffness on
  142308. * @param stiffness stiffness value from 0 to 1
  142309. */
  142310. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142311. /**
  142312. * Gets velocityIterations of the impostor
  142313. * @param impostor impostor to get velocity iterations from
  142314. * @returns velocityIterations value
  142315. */
  142316. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142317. /**
  142318. * Sets velocityIterations of the impostor
  142319. * @param impostor impostor to set velocity iterations on
  142320. * @param velocityIterations velocityIterations value
  142321. */
  142322. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142323. /**
  142324. * Gets positionIterations of the impostor
  142325. * @param impostor impostor to get position iterations from
  142326. * @returns positionIterations value
  142327. */
  142328. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142329. /**
  142330. * Sets positionIterations of the impostor
  142331. * @param impostor impostor to set position on
  142332. * @param positionIterations positionIterations value
  142333. */
  142334. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142335. /**
  142336. * Append an anchor to a cloth object
  142337. * @param impostor is the cloth impostor to add anchor to
  142338. * @param otherImpostor is the rigid impostor to anchor to
  142339. * @param width ratio across width from 0 to 1
  142340. * @param height ratio up height from 0 to 1
  142341. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142342. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142343. */
  142344. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142345. /**
  142346. * Append an hook to a rope object
  142347. * @param impostor is the rope impostor to add hook to
  142348. * @param otherImpostor is the rigid impostor to hook to
  142349. * @param length ratio along the rope from 0 to 1
  142350. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142351. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142352. */
  142353. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142354. /**
  142355. * Sleeps the physics body and stops it from being active
  142356. * @param impostor impostor to sleep
  142357. */
  142358. sleepBody(impostor: PhysicsImpostor): void;
  142359. /**
  142360. * Activates the physics body
  142361. * @param impostor impostor to activate
  142362. */
  142363. wakeUpBody(impostor: PhysicsImpostor): void;
  142364. /**
  142365. * Updates the distance parameters of the joint
  142366. * @param joint joint to update
  142367. * @param maxDistance maximum distance of the joint
  142368. * @param minDistance minimum distance of the joint
  142369. */
  142370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142371. /**
  142372. * Sets a motor on the joint
  142373. * @param joint joint to set motor on
  142374. * @param speed speed of the motor
  142375. * @param maxForce maximum force of the motor
  142376. * @param motorIndex index of the motor
  142377. */
  142378. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142379. /**
  142380. * Sets the motors limit
  142381. * @param joint joint to set limit on
  142382. * @param upperLimit upper limit
  142383. * @param lowerLimit lower limit
  142384. */
  142385. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142386. /**
  142387. * Syncs the position and rotation of a mesh with the impostor
  142388. * @param mesh mesh to sync
  142389. * @param impostor impostor to update the mesh with
  142390. */
  142391. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142392. /**
  142393. * Gets the radius of the impostor
  142394. * @param impostor impostor to get radius from
  142395. * @returns the radius
  142396. */
  142397. getRadius(impostor: PhysicsImpostor): number;
  142398. /**
  142399. * Gets the box size of the impostor
  142400. * @param impostor impostor to get box size from
  142401. * @param result the resulting box size
  142402. */
  142403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142404. /**
  142405. * Disposes of the impostor
  142406. */
  142407. dispose(): void;
  142408. /**
  142409. * Does a raycast in the physics world
  142410. * @param from when should the ray start?
  142411. * @param to when should the ray end?
  142412. * @returns PhysicsRaycastResult
  142413. */
  142414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142415. }
  142416. }
  142417. declare module BABYLON {
  142418. interface AbstractScene {
  142419. /**
  142420. * The list of reflection probes added to the scene
  142421. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142422. */
  142423. reflectionProbes: Array<ReflectionProbe>;
  142424. /**
  142425. * Removes the given reflection probe from this scene.
  142426. * @param toRemove The reflection probe to remove
  142427. * @returns The index of the removed reflection probe
  142428. */
  142429. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142430. /**
  142431. * Adds the given reflection probe to this scene.
  142432. * @param newReflectionProbe The reflection probe to add
  142433. */
  142434. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142435. }
  142436. /**
  142437. * Class used to generate realtime reflection / refraction cube textures
  142438. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142439. */
  142440. export class ReflectionProbe {
  142441. /** defines the name of the probe */
  142442. name: string;
  142443. private _scene;
  142444. private _renderTargetTexture;
  142445. private _projectionMatrix;
  142446. private _viewMatrix;
  142447. private _target;
  142448. private _add;
  142449. private _attachedMesh;
  142450. private _invertYAxis;
  142451. /** Gets or sets probe position (center of the cube map) */
  142452. position: Vector3;
  142453. /**
  142454. * Creates a new reflection probe
  142455. * @param name defines the name of the probe
  142456. * @param size defines the texture resolution (for each face)
  142457. * @param scene defines the hosting scene
  142458. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142459. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142460. */
  142461. constructor(
  142462. /** defines the name of the probe */
  142463. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142464. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142465. get samples(): number;
  142466. set samples(value: number);
  142467. /** Gets or sets the refresh rate to use (on every frame by default) */
  142468. get refreshRate(): number;
  142469. set refreshRate(value: number);
  142470. /**
  142471. * Gets the hosting scene
  142472. * @returns a Scene
  142473. */
  142474. getScene(): Scene;
  142475. /** Gets the internal CubeTexture used to render to */
  142476. get cubeTexture(): RenderTargetTexture;
  142477. /** Gets the list of meshes to render */
  142478. get renderList(): Nullable<AbstractMesh[]>;
  142479. /**
  142480. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142481. * @param mesh defines the mesh to attach to
  142482. */
  142483. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142484. /**
  142485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142486. * @param renderingGroupId The rendering group id corresponding to its index
  142487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142488. */
  142489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142490. /**
  142491. * Clean all associated resources
  142492. */
  142493. dispose(): void;
  142494. /**
  142495. * Converts the reflection probe information to a readable string for debug purpose.
  142496. * @param fullDetails Supports for multiple levels of logging within scene loading
  142497. * @returns the human readable reflection probe info
  142498. */
  142499. toString(fullDetails?: boolean): string;
  142500. /**
  142501. * Get the class name of the relfection probe.
  142502. * @returns "ReflectionProbe"
  142503. */
  142504. getClassName(): string;
  142505. /**
  142506. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142507. * @returns The JSON representation of the texture
  142508. */
  142509. serialize(): any;
  142510. /**
  142511. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142512. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142513. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142514. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142515. * @returns The parsed reflection probe if successful
  142516. */
  142517. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142518. }
  142519. }
  142520. declare module BABYLON {
  142521. /** @hidden */
  142522. export var _BabylonLoaderRegistered: boolean;
  142523. /**
  142524. * Helps setting up some configuration for the babylon file loader.
  142525. */
  142526. export class BabylonFileLoaderConfiguration {
  142527. /**
  142528. * The loader does not allow injecting custom physix engine into the plugins.
  142529. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142530. * So you could set this variable to your engine import to make it work.
  142531. */
  142532. static LoaderInjectedPhysicsEngine: any;
  142533. }
  142534. }
  142535. declare module BABYLON {
  142536. /**
  142537. * The Physically based simple base material of BJS.
  142538. *
  142539. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142540. * It is used as the base class for both the specGloss and metalRough conventions.
  142541. */
  142542. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142543. /**
  142544. * Number of Simultaneous lights allowed on the material.
  142545. */
  142546. maxSimultaneousLights: number;
  142547. /**
  142548. * If sets to true, disables all the lights affecting the material.
  142549. */
  142550. disableLighting: boolean;
  142551. /**
  142552. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142553. */
  142554. environmentTexture: BaseTexture;
  142555. /**
  142556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142557. */
  142558. invertNormalMapX: boolean;
  142559. /**
  142560. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142561. */
  142562. invertNormalMapY: boolean;
  142563. /**
  142564. * Normal map used in the model.
  142565. */
  142566. normalTexture: BaseTexture;
  142567. /**
  142568. * Emissivie color used to self-illuminate the model.
  142569. */
  142570. emissiveColor: Color3;
  142571. /**
  142572. * Emissivie texture used to self-illuminate the model.
  142573. */
  142574. emissiveTexture: BaseTexture;
  142575. /**
  142576. * Occlusion Channel Strenght.
  142577. */
  142578. occlusionStrength: number;
  142579. /**
  142580. * Occlusion Texture of the material (adding extra occlusion effects).
  142581. */
  142582. occlusionTexture: BaseTexture;
  142583. /**
  142584. * Defines the alpha limits in alpha test mode.
  142585. */
  142586. alphaCutOff: number;
  142587. /**
  142588. * Gets the current double sided mode.
  142589. */
  142590. get doubleSided(): boolean;
  142591. /**
  142592. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142593. */
  142594. set doubleSided(value: boolean);
  142595. /**
  142596. * Stores the pre-calculated light information of a mesh in a texture.
  142597. */
  142598. lightmapTexture: BaseTexture;
  142599. /**
  142600. * If true, the light map contains occlusion information instead of lighting info.
  142601. */
  142602. useLightmapAsShadowmap: boolean;
  142603. /**
  142604. * Instantiates a new PBRMaterial instance.
  142605. *
  142606. * @param name The material name
  142607. * @param scene The scene the material will be use in.
  142608. */
  142609. constructor(name: string, scene: Scene);
  142610. getClassName(): string;
  142611. }
  142612. }
  142613. declare module BABYLON {
  142614. /**
  142615. * The PBR material of BJS following the metal roughness convention.
  142616. *
  142617. * This fits to the PBR convention in the GLTF definition:
  142618. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142619. */
  142620. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142621. /**
  142622. * The base color has two different interpretations depending on the value of metalness.
  142623. * When the material is a metal, the base color is the specific measured reflectance value
  142624. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142625. * of the material.
  142626. */
  142627. baseColor: Color3;
  142628. /**
  142629. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142630. * well as opacity information in the alpha channel.
  142631. */
  142632. baseTexture: BaseTexture;
  142633. /**
  142634. * Specifies the metallic scalar value of the material.
  142635. * Can also be used to scale the metalness values of the metallic texture.
  142636. */
  142637. metallic: number;
  142638. /**
  142639. * Specifies the roughness scalar value of the material.
  142640. * Can also be used to scale the roughness values of the metallic texture.
  142641. */
  142642. roughness: number;
  142643. /**
  142644. * Texture containing both the metallic value in the B channel and the
  142645. * roughness value in the G channel to keep better precision.
  142646. */
  142647. metallicRoughnessTexture: BaseTexture;
  142648. /**
  142649. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142650. *
  142651. * @param name The material name
  142652. * @param scene The scene the material will be use in.
  142653. */
  142654. constructor(name: string, scene: Scene);
  142655. /**
  142656. * Return the currrent class name of the material.
  142657. */
  142658. getClassName(): string;
  142659. /**
  142660. * Makes a duplicate of the current material.
  142661. * @param name - name to use for the new material.
  142662. */
  142663. clone(name: string): PBRMetallicRoughnessMaterial;
  142664. /**
  142665. * Serialize the material to a parsable JSON object.
  142666. */
  142667. serialize(): any;
  142668. /**
  142669. * Parses a JSON object correponding to the serialize function.
  142670. */
  142671. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142672. }
  142673. }
  142674. declare module BABYLON {
  142675. /**
  142676. * The PBR material of BJS following the specular glossiness convention.
  142677. *
  142678. * This fits to the PBR convention in the GLTF definition:
  142679. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142680. */
  142681. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142682. /**
  142683. * Specifies the diffuse color of the material.
  142684. */
  142685. diffuseColor: Color3;
  142686. /**
  142687. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142688. * channel.
  142689. */
  142690. diffuseTexture: BaseTexture;
  142691. /**
  142692. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142693. */
  142694. specularColor: Color3;
  142695. /**
  142696. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142697. */
  142698. glossiness: number;
  142699. /**
  142700. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142701. */
  142702. specularGlossinessTexture: BaseTexture;
  142703. /**
  142704. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142705. *
  142706. * @param name The material name
  142707. * @param scene The scene the material will be use in.
  142708. */
  142709. constructor(name: string, scene: Scene);
  142710. /**
  142711. * Return the currrent class name of the material.
  142712. */
  142713. getClassName(): string;
  142714. /**
  142715. * Makes a duplicate of the current material.
  142716. * @param name - name to use for the new material.
  142717. */
  142718. clone(name: string): PBRSpecularGlossinessMaterial;
  142719. /**
  142720. * Serialize the material to a parsable JSON object.
  142721. */
  142722. serialize(): any;
  142723. /**
  142724. * Parses a JSON object correponding to the serialize function.
  142725. */
  142726. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /**
  142731. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142732. * It can help converting any input color in a desired output one. This can then be used to create effects
  142733. * from sepia, black and white to sixties or futuristic rendering...
  142734. *
  142735. * The only supported format is currently 3dl.
  142736. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142737. */
  142738. export class ColorGradingTexture extends BaseTexture {
  142739. /**
  142740. * The texture URL.
  142741. */
  142742. url: string;
  142743. /**
  142744. * Empty line regex stored for GC.
  142745. */
  142746. private static _noneEmptyLineRegex;
  142747. private _textureMatrix;
  142748. private _onLoad;
  142749. /**
  142750. * Instantiates a ColorGradingTexture from the following parameters.
  142751. *
  142752. * @param url The location of the color gradind data (currently only supporting 3dl)
  142753. * @param sceneOrEngine The scene or engine the texture will be used in
  142754. * @param onLoad defines a callback triggered when the texture has been loaded
  142755. */
  142756. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142757. /**
  142758. * Fires the onload event from the constructor if requested.
  142759. */
  142760. private _triggerOnLoad;
  142761. /**
  142762. * Returns the texture matrix used in most of the material.
  142763. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142764. */
  142765. getTextureMatrix(): Matrix;
  142766. /**
  142767. * Occurs when the file being loaded is a .3dl LUT file.
  142768. */
  142769. private load3dlTexture;
  142770. /**
  142771. * Starts the loading process of the texture.
  142772. */
  142773. private loadTexture;
  142774. /**
  142775. * Clones the color gradind texture.
  142776. */
  142777. clone(): ColorGradingTexture;
  142778. /**
  142779. * Called during delayed load for textures.
  142780. */
  142781. delayLoad(): void;
  142782. /**
  142783. * Parses a color grading texture serialized by Babylon.
  142784. * @param parsedTexture The texture information being parsedTexture
  142785. * @param scene The scene to load the texture in
  142786. * @param rootUrl The root url of the data assets to load
  142787. * @return A color gradind texture
  142788. */
  142789. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142790. /**
  142791. * Serializes the LUT texture to json format.
  142792. */
  142793. serialize(): any;
  142794. }
  142795. }
  142796. declare module BABYLON {
  142797. /**
  142798. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142799. */
  142800. export class EquiRectangularCubeTexture extends BaseTexture {
  142801. /** The six faces of the cube. */
  142802. private static _FacesMapping;
  142803. private _noMipmap;
  142804. private _onLoad;
  142805. private _onError;
  142806. /** The size of the cubemap. */
  142807. private _size;
  142808. /** The buffer of the image. */
  142809. private _buffer;
  142810. /** The width of the input image. */
  142811. private _width;
  142812. /** The height of the input image. */
  142813. private _height;
  142814. /** The URL to the image. */
  142815. url: string;
  142816. /**
  142817. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142818. * @param url The location of the image
  142819. * @param scene The scene the texture will be used in
  142820. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142821. * @param noMipmap Forces to not generate the mipmap if true
  142822. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142823. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142824. * @param onLoad — defines a callback called when texture is loaded
  142825. * @param onError — defines a callback called if there is an error
  142826. */
  142827. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142828. /**
  142829. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142830. */
  142831. private loadImage;
  142832. /**
  142833. * Convert the image buffer into a cubemap and create a CubeTexture.
  142834. */
  142835. private loadTexture;
  142836. /**
  142837. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142838. * @param buffer The ArrayBuffer that should be converted.
  142839. * @returns The buffer as Float32Array.
  142840. */
  142841. private getFloat32ArrayFromArrayBuffer;
  142842. /**
  142843. * Get the current class name of the texture useful for serialization or dynamic coding.
  142844. * @returns "EquiRectangularCubeTexture"
  142845. */
  142846. getClassName(): string;
  142847. /**
  142848. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142849. * @returns A clone of the current EquiRectangularCubeTexture.
  142850. */
  142851. clone(): EquiRectangularCubeTexture;
  142852. }
  142853. }
  142854. declare module BABYLON {
  142855. /**
  142856. * Defines the options related to the creation of an HtmlElementTexture
  142857. */
  142858. export interface IHtmlElementTextureOptions {
  142859. /**
  142860. * Defines wether mip maps should be created or not.
  142861. */
  142862. generateMipMaps?: boolean;
  142863. /**
  142864. * Defines the sampling mode of the texture.
  142865. */
  142866. samplingMode?: number;
  142867. /**
  142868. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142869. */
  142870. engine: Nullable<ThinEngine>;
  142871. /**
  142872. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142873. */
  142874. scene: Nullable<Scene>;
  142875. }
  142876. /**
  142877. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142878. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142879. * is automatically managed.
  142880. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142881. * in your application.
  142882. *
  142883. * As the update is not automatic, you need to call them manually.
  142884. */
  142885. export class HtmlElementTexture extends BaseTexture {
  142886. /**
  142887. * The texture URL.
  142888. */
  142889. element: HTMLVideoElement | HTMLCanvasElement;
  142890. private static readonly DefaultOptions;
  142891. private _textureMatrix;
  142892. private _isVideo;
  142893. private _generateMipMaps;
  142894. private _samplingMode;
  142895. /**
  142896. * Instantiates a HtmlElementTexture from the following parameters.
  142897. *
  142898. * @param name Defines the name of the texture
  142899. * @param element Defines the video or canvas the texture is filled with
  142900. * @param options Defines the other none mandatory texture creation options
  142901. */
  142902. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142903. private _createInternalTexture;
  142904. /**
  142905. * Returns the texture matrix used in most of the material.
  142906. */
  142907. getTextureMatrix(): Matrix;
  142908. /**
  142909. * Updates the content of the texture.
  142910. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142911. */
  142912. update(invertY?: Nullable<boolean>): void;
  142913. }
  142914. }
  142915. declare module BABYLON {
  142916. /**
  142917. * Based on jsTGALoader - Javascript loader for TGA file
  142918. * By Vincent Thibault
  142919. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142920. */
  142921. export class TGATools {
  142922. private static _TYPE_INDEXED;
  142923. private static _TYPE_RGB;
  142924. private static _TYPE_GREY;
  142925. private static _TYPE_RLE_INDEXED;
  142926. private static _TYPE_RLE_RGB;
  142927. private static _TYPE_RLE_GREY;
  142928. private static _ORIGIN_MASK;
  142929. private static _ORIGIN_SHIFT;
  142930. private static _ORIGIN_BL;
  142931. private static _ORIGIN_BR;
  142932. private static _ORIGIN_UL;
  142933. private static _ORIGIN_UR;
  142934. /**
  142935. * Gets the header of a TGA file
  142936. * @param data defines the TGA data
  142937. * @returns the header
  142938. */
  142939. static GetTGAHeader(data: Uint8Array): any;
  142940. /**
  142941. * Uploads TGA content to a Babylon Texture
  142942. * @hidden
  142943. */
  142944. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142945. /** @hidden */
  142946. 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;
  142947. /** @hidden */
  142948. 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;
  142949. /** @hidden */
  142950. 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;
  142951. /** @hidden */
  142952. 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;
  142953. /** @hidden */
  142954. 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;
  142955. /** @hidden */
  142956. 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;
  142957. }
  142958. }
  142959. declare module BABYLON {
  142960. /**
  142961. * Implementation of the TGA Texture Loader.
  142962. * @hidden
  142963. */
  142964. export class _TGATextureLoader implements IInternalTextureLoader {
  142965. /**
  142966. * Defines wether the loader supports cascade loading the different faces.
  142967. */
  142968. readonly supportCascades: boolean;
  142969. /**
  142970. * This returns if the loader support the current file information.
  142971. * @param extension defines the file extension of the file being loaded
  142972. * @returns true if the loader can load the specified file
  142973. */
  142974. canLoad(extension: string): boolean;
  142975. /**
  142976. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142977. * @param data contains the texture data
  142978. * @param texture defines the BabylonJS internal texture
  142979. * @param createPolynomials will be true if polynomials have been requested
  142980. * @param onLoad defines the callback to trigger once the texture is ready
  142981. * @param onError defines the callback to trigger in case of error
  142982. */
  142983. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142984. /**
  142985. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142986. * @param data contains the texture data
  142987. * @param texture defines the BabylonJS internal texture
  142988. * @param callback defines the method to call once ready to upload
  142989. */
  142990. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142991. }
  142992. }
  142993. declare module BABYLON {
  142994. /**
  142995. * Info about the .basis files
  142996. */
  142997. class BasisFileInfo {
  142998. /**
  142999. * If the file has alpha
  143000. */
  143001. hasAlpha: boolean;
  143002. /**
  143003. * Info about each image of the basis file
  143004. */
  143005. images: Array<{
  143006. levels: Array<{
  143007. width: number;
  143008. height: number;
  143009. transcodedPixels: ArrayBufferView;
  143010. }>;
  143011. }>;
  143012. }
  143013. /**
  143014. * Result of transcoding a basis file
  143015. */
  143016. class TranscodeResult {
  143017. /**
  143018. * Info about the .basis file
  143019. */
  143020. fileInfo: BasisFileInfo;
  143021. /**
  143022. * Format to use when loading the file
  143023. */
  143024. format: number;
  143025. }
  143026. /**
  143027. * Configuration options for the Basis transcoder
  143028. */
  143029. export class BasisTranscodeConfiguration {
  143030. /**
  143031. * Supported compression formats used to determine the supported output format of the transcoder
  143032. */
  143033. supportedCompressionFormats?: {
  143034. /**
  143035. * etc1 compression format
  143036. */
  143037. etc1?: boolean;
  143038. /**
  143039. * s3tc compression format
  143040. */
  143041. s3tc?: boolean;
  143042. /**
  143043. * pvrtc compression format
  143044. */
  143045. pvrtc?: boolean;
  143046. /**
  143047. * etc2 compression format
  143048. */
  143049. etc2?: boolean;
  143050. };
  143051. /**
  143052. * If mipmap levels should be loaded for transcoded images (Default: true)
  143053. */
  143054. loadMipmapLevels?: boolean;
  143055. /**
  143056. * Index of a single image to load (Default: all images)
  143057. */
  143058. loadSingleImage?: number;
  143059. }
  143060. /**
  143061. * Used to load .Basis files
  143062. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143063. */
  143064. export class BasisTools {
  143065. private static _IgnoreSupportedFormats;
  143066. /**
  143067. * URL to use when loading the basis transcoder
  143068. */
  143069. static JSModuleURL: string;
  143070. /**
  143071. * URL to use when loading the wasm module for the transcoder
  143072. */
  143073. static WasmModuleURL: string;
  143074. /**
  143075. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143076. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143077. * @returns internal format corresponding to the Basis format
  143078. */
  143079. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143080. private static _WorkerPromise;
  143081. private static _Worker;
  143082. private static _actionId;
  143083. private static _CreateWorkerAsync;
  143084. /**
  143085. * Transcodes a loaded image file to compressed pixel data
  143086. * @param data image data to transcode
  143087. * @param config configuration options for the transcoding
  143088. * @returns a promise resulting in the transcoded image
  143089. */
  143090. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143091. /**
  143092. * Loads a texture from the transcode result
  143093. * @param texture texture load to
  143094. * @param transcodeResult the result of transcoding the basis file to load from
  143095. */
  143096. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143097. }
  143098. }
  143099. declare module BABYLON {
  143100. /**
  143101. * Loader for .basis file format
  143102. */
  143103. export class _BasisTextureLoader implements IInternalTextureLoader {
  143104. /**
  143105. * Defines whether the loader supports cascade loading the different faces.
  143106. */
  143107. readonly supportCascades: boolean;
  143108. /**
  143109. * This returns if the loader support the current file information.
  143110. * @param extension defines the file extension of the file being loaded
  143111. * @returns true if the loader can load the specified file
  143112. */
  143113. canLoad(extension: string): boolean;
  143114. /**
  143115. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143116. * @param data contains the texture data
  143117. * @param texture defines the BabylonJS internal texture
  143118. * @param createPolynomials will be true if polynomials have been requested
  143119. * @param onLoad defines the callback to trigger once the texture is ready
  143120. * @param onError defines the callback to trigger in case of error
  143121. */
  143122. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143123. /**
  143124. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143125. * @param data contains the texture data
  143126. * @param texture defines the BabylonJS internal texture
  143127. * @param callback defines the method to call once ready to upload
  143128. */
  143129. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143130. }
  143131. }
  143132. declare module BABYLON {
  143133. /**
  143134. * Defines the basic options interface of a TexturePacker Frame
  143135. */
  143136. export interface ITexturePackerFrame {
  143137. /**
  143138. * The frame ID
  143139. */
  143140. id: number;
  143141. /**
  143142. * The frames Scale
  143143. */
  143144. scale: Vector2;
  143145. /**
  143146. * The Frames offset
  143147. */
  143148. offset: Vector2;
  143149. }
  143150. /**
  143151. * This is a support class for frame Data on texture packer sets.
  143152. */
  143153. export class TexturePackerFrame implements ITexturePackerFrame {
  143154. /**
  143155. * The frame ID
  143156. */
  143157. id: number;
  143158. /**
  143159. * The frames Scale
  143160. */
  143161. scale: Vector2;
  143162. /**
  143163. * The Frames offset
  143164. */
  143165. offset: Vector2;
  143166. /**
  143167. * Initializes a texture package frame.
  143168. * @param id The numerical frame identifier
  143169. * @param scale Scalar Vector2 for UV frame
  143170. * @param offset Vector2 for the frame position in UV units.
  143171. * @returns TexturePackerFrame
  143172. */
  143173. constructor(id: number, scale: Vector2, offset: Vector2);
  143174. }
  143175. }
  143176. declare module BABYLON {
  143177. /**
  143178. * Defines the basic options interface of a TexturePacker
  143179. */
  143180. export interface ITexturePackerOptions {
  143181. /**
  143182. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143183. */
  143184. map?: string[];
  143185. /**
  143186. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143187. */
  143188. uvsIn?: string;
  143189. /**
  143190. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143191. */
  143192. uvsOut?: string;
  143193. /**
  143194. * number representing the layout style. Defaults to LAYOUT_STRIP
  143195. */
  143196. layout?: number;
  143197. /**
  143198. * number of columns if using custom column count layout(2). This defaults to 4.
  143199. */
  143200. colnum?: number;
  143201. /**
  143202. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143203. */
  143204. updateInputMeshes?: boolean;
  143205. /**
  143206. * boolean flag to dispose all the source textures. Defaults to true.
  143207. */
  143208. disposeSources?: boolean;
  143209. /**
  143210. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143211. */
  143212. fillBlanks?: boolean;
  143213. /**
  143214. * string value representing the context fill style color. Defaults to 'black'.
  143215. */
  143216. customFillColor?: string;
  143217. /**
  143218. * Width and Height Value of each Frame in the TexturePacker Sets
  143219. */
  143220. frameSize?: number;
  143221. /**
  143222. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143223. */
  143224. paddingRatio?: number;
  143225. /**
  143226. * Number that declares the fill method for the padding gutter.
  143227. */
  143228. paddingMode?: number;
  143229. /**
  143230. * If in SUBUV_COLOR padding mode what color to use.
  143231. */
  143232. paddingColor?: Color3 | Color4;
  143233. }
  143234. /**
  143235. * Defines the basic interface of a TexturePacker JSON File
  143236. */
  143237. export interface ITexturePackerJSON {
  143238. /**
  143239. * The frame ID
  143240. */
  143241. name: string;
  143242. /**
  143243. * The base64 channel data
  143244. */
  143245. sets: any;
  143246. /**
  143247. * The options of the Packer
  143248. */
  143249. options: ITexturePackerOptions;
  143250. /**
  143251. * The frame data of the Packer
  143252. */
  143253. frames: Array<number>;
  143254. }
  143255. /**
  143256. * This is a support class that generates a series of packed texture sets.
  143257. * @see https://doc.babylonjs.com/babylon101/materials
  143258. */
  143259. export class TexturePacker {
  143260. /** Packer Layout Constant 0 */
  143261. static readonly LAYOUT_STRIP: number;
  143262. /** Packer Layout Constant 1 */
  143263. static readonly LAYOUT_POWER2: number;
  143264. /** Packer Layout Constant 2 */
  143265. static readonly LAYOUT_COLNUM: number;
  143266. /** Packer Layout Constant 0 */
  143267. static readonly SUBUV_WRAP: number;
  143268. /** Packer Layout Constant 1 */
  143269. static readonly SUBUV_EXTEND: number;
  143270. /** Packer Layout Constant 2 */
  143271. static readonly SUBUV_COLOR: number;
  143272. /** The Name of the Texture Package */
  143273. name: string;
  143274. /** The scene scope of the TexturePacker */
  143275. scene: Scene;
  143276. /** The Meshes to target */
  143277. meshes: AbstractMesh[];
  143278. /** Arguments passed with the Constructor */
  143279. options: ITexturePackerOptions;
  143280. /** The promise that is started upon initialization */
  143281. promise: Nullable<Promise<TexturePacker | string>>;
  143282. /** The Container object for the channel sets that are generated */
  143283. sets: object;
  143284. /** The Container array for the frames that are generated */
  143285. frames: TexturePackerFrame[];
  143286. /** The expected number of textures the system is parsing. */
  143287. private _expecting;
  143288. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143289. private _paddingValue;
  143290. /**
  143291. * Initializes a texture package series from an array of meshes or a single mesh.
  143292. * @param name The name of the package
  143293. * @param meshes The target meshes to compose the package from
  143294. * @param options The arguments that texture packer should follow while building.
  143295. * @param scene The scene which the textures are scoped to.
  143296. * @returns TexturePacker
  143297. */
  143298. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143299. /**
  143300. * Starts the package process
  143301. * @param resolve The promises resolution function
  143302. * @returns TexturePacker
  143303. */
  143304. private _createFrames;
  143305. /**
  143306. * Calculates the Size of the Channel Sets
  143307. * @returns Vector2
  143308. */
  143309. private _calculateSize;
  143310. /**
  143311. * Calculates the UV data for the frames.
  143312. * @param baseSize the base frameSize
  143313. * @param padding the base frame padding
  143314. * @param dtSize size of the Dynamic Texture for that channel
  143315. * @param dtUnits is 1/dtSize
  143316. * @param update flag to update the input meshes
  143317. */
  143318. private _calculateMeshUVFrames;
  143319. /**
  143320. * Calculates the frames Offset.
  143321. * @param index of the frame
  143322. * @returns Vector2
  143323. */
  143324. private _getFrameOffset;
  143325. /**
  143326. * Updates a Mesh to the frame data
  143327. * @param mesh that is the target
  143328. * @param frameID or the frame index
  143329. */
  143330. private _updateMeshUV;
  143331. /**
  143332. * Updates a Meshes materials to use the texture packer channels
  143333. * @param m is the mesh to target
  143334. * @param force all channels on the packer to be set.
  143335. */
  143336. private _updateTextureReferences;
  143337. /**
  143338. * Public method to set a Mesh to a frame
  143339. * @param m that is the target
  143340. * @param frameID or the frame index
  143341. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143342. */
  143343. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143344. /**
  143345. * Starts the async promise to compile the texture packer.
  143346. * @returns Promise<void>
  143347. */
  143348. processAsync(): Promise<void>;
  143349. /**
  143350. * Disposes all textures associated with this packer
  143351. */
  143352. dispose(): void;
  143353. /**
  143354. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143355. * @param imageType is the image type to use.
  143356. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143357. */
  143358. download(imageType?: string, quality?: number): void;
  143359. /**
  143360. * Public method to load a texturePacker JSON file.
  143361. * @param data of the JSON file in string format.
  143362. */
  143363. updateFromJSON(data: string): void;
  143364. }
  143365. }
  143366. declare module BABYLON {
  143367. /**
  143368. * 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.
  143369. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143370. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143371. */
  143372. export class CustomProceduralTexture extends ProceduralTexture {
  143373. private _animate;
  143374. private _time;
  143375. private _config;
  143376. private _texturePath;
  143377. /**
  143378. * Instantiates a new Custom Procedural Texture.
  143379. * 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.
  143380. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143381. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143382. * @param name Define the name of the texture
  143383. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143384. * @param size Define the size of the texture to create
  143385. * @param scene Define the scene the texture belongs to
  143386. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143387. * @param generateMipMaps Define if the texture should creates mip maps or not
  143388. */
  143389. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143390. private _loadJson;
  143391. /**
  143392. * Is the texture ready to be used ? (rendered at least once)
  143393. * @returns true if ready, otherwise, false.
  143394. */
  143395. isReady(): boolean;
  143396. /**
  143397. * Render the texture to its associated render target.
  143398. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143399. */
  143400. render(useCameraPostProcess?: boolean): void;
  143401. /**
  143402. * Update the list of dependant textures samplers in the shader.
  143403. */
  143404. updateTextures(): void;
  143405. /**
  143406. * Update the uniform values of the procedural texture in the shader.
  143407. */
  143408. updateShaderUniforms(): void;
  143409. /**
  143410. * Define if the texture animates or not.
  143411. */
  143412. get animate(): boolean;
  143413. set animate(value: boolean);
  143414. }
  143415. }
  143416. declare module BABYLON {
  143417. /** @hidden */
  143418. export var noisePixelShader: {
  143419. name: string;
  143420. shader: string;
  143421. };
  143422. }
  143423. declare module BABYLON {
  143424. /**
  143425. * Class used to generate noise procedural textures
  143426. */
  143427. export class NoiseProceduralTexture extends ProceduralTexture {
  143428. /** Gets or sets the start time (default is 0) */
  143429. time: number;
  143430. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143431. brightness: number;
  143432. /** Defines the number of octaves to process */
  143433. octaves: number;
  143434. /** Defines the level of persistence (0.8 by default) */
  143435. persistence: number;
  143436. /** Gets or sets animation speed factor (default is 1) */
  143437. animationSpeedFactor: number;
  143438. /**
  143439. * Creates a new NoiseProceduralTexture
  143440. * @param name defines the name fo the texture
  143441. * @param size defines the size of the texture (default is 256)
  143442. * @param scene defines the hosting scene
  143443. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143444. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143445. */
  143446. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143447. private _updateShaderUniforms;
  143448. protected _getDefines(): string;
  143449. /** Generate the current state of the procedural texture */
  143450. render(useCameraPostProcess?: boolean): void;
  143451. /**
  143452. * Serializes this noise procedural texture
  143453. * @returns a serialized noise procedural texture object
  143454. */
  143455. serialize(): any;
  143456. /**
  143457. * Clone the texture.
  143458. * @returns the cloned texture
  143459. */
  143460. clone(): NoiseProceduralTexture;
  143461. /**
  143462. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143463. * @param parsedTexture defines parsed texture data
  143464. * @param scene defines the current scene
  143465. * @param rootUrl defines the root URL containing noise procedural texture information
  143466. * @returns a parsed NoiseProceduralTexture
  143467. */
  143468. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143469. }
  143470. }
  143471. declare module BABYLON {
  143472. /**
  143473. * Raw cube texture where the raw buffers are passed in
  143474. */
  143475. export class RawCubeTexture extends CubeTexture {
  143476. /**
  143477. * Creates a cube texture where the raw buffers are passed in.
  143478. * @param scene defines the scene the texture is attached to
  143479. * @param data defines the array of data to use to create each face
  143480. * @param size defines the size of the textures
  143481. * @param format defines the format of the data
  143482. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143483. * @param generateMipMaps defines if the engine should generate the mip levels
  143484. * @param invertY defines if data must be stored with Y axis inverted
  143485. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143486. * @param compression defines the compression used (null by default)
  143487. */
  143488. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143489. /**
  143490. * Updates the raw cube texture.
  143491. * @param data defines the data to store
  143492. * @param format defines the data format
  143493. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143494. * @param invertY defines if data must be stored with Y axis inverted
  143495. * @param compression defines the compression used (null by default)
  143496. * @param level defines which level of the texture to update
  143497. */
  143498. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143499. /**
  143500. * Updates a raw cube texture with RGBD encoded data.
  143501. * @param data defines the array of data [mipmap][face] to use to create each face
  143502. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143505. * @returns a promsie that resolves when the operation is complete
  143506. */
  143507. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143508. /**
  143509. * Clones the raw cube texture.
  143510. * @return a new cube texture
  143511. */
  143512. clone(): CubeTexture;
  143513. /** @hidden */
  143514. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143515. }
  143516. }
  143517. declare module BABYLON {
  143518. /**
  143519. * Class used to store 2D array textures containing user data
  143520. */
  143521. export class RawTexture2DArray extends Texture {
  143522. /** Gets or sets the texture format to use */
  143523. format: number;
  143524. /**
  143525. * Create a new RawTexture2DArray
  143526. * @param data defines the data of the texture
  143527. * @param width defines the width of the texture
  143528. * @param height defines the height of the texture
  143529. * @param depth defines the number of layers of the texture
  143530. * @param format defines the texture format to use
  143531. * @param scene defines the hosting scene
  143532. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143533. * @param invertY defines if texture must be stored with Y axis inverted
  143534. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143536. */
  143537. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143538. /** Gets or sets the texture format to use */
  143539. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143540. /**
  143541. * Update the texture with new data
  143542. * @param data defines the data to store in the texture
  143543. */
  143544. update(data: ArrayBufferView): void;
  143545. }
  143546. }
  143547. declare module BABYLON {
  143548. /**
  143549. * Class used to store 3D textures containing user data
  143550. */
  143551. export class RawTexture3D extends Texture {
  143552. /** Gets or sets the texture format to use */
  143553. format: number;
  143554. /**
  143555. * Create a new RawTexture3D
  143556. * @param data defines the data of the texture
  143557. * @param width defines the width of the texture
  143558. * @param height defines the height of the texture
  143559. * @param depth defines the depth of the texture
  143560. * @param format defines the texture format to use
  143561. * @param scene defines the hosting scene
  143562. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143563. * @param invertY defines if texture must be stored with Y axis inverted
  143564. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143565. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143566. */
  143567. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143568. /** Gets or sets the texture format to use */
  143569. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143570. /**
  143571. * Update the texture with new data
  143572. * @param data defines the data to store in the texture
  143573. */
  143574. update(data: ArrayBufferView): void;
  143575. }
  143576. }
  143577. declare module BABYLON {
  143578. /**
  143579. * Creates a refraction texture used by refraction channel of the standard material.
  143580. * It is like a mirror but to see through a material.
  143581. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143582. */
  143583. export class RefractionTexture extends RenderTargetTexture {
  143584. /**
  143585. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143586. * 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.
  143587. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143588. */
  143589. refractionPlane: Plane;
  143590. /**
  143591. * Define how deep under the surface we should see.
  143592. */
  143593. depth: number;
  143594. /**
  143595. * Creates a refraction texture used by refraction channel of the standard material.
  143596. * It is like a mirror but to see through a material.
  143597. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143598. * @param name Define the texture name
  143599. * @param size Define the size of the underlying texture
  143600. * @param scene Define the scene the refraction belongs to
  143601. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143602. */
  143603. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143604. /**
  143605. * Clone the refraction texture.
  143606. * @returns the cloned texture
  143607. */
  143608. clone(): RefractionTexture;
  143609. /**
  143610. * Serialize the texture to a JSON representation you could use in Parse later on
  143611. * @returns the serialized JSON representation
  143612. */
  143613. serialize(): any;
  143614. }
  143615. }
  143616. declare module BABYLON {
  143617. /**
  143618. * Block used to add support for vertex skinning (bones)
  143619. */
  143620. export class BonesBlock extends NodeMaterialBlock {
  143621. /**
  143622. * Creates a new BonesBlock
  143623. * @param name defines the block name
  143624. */
  143625. constructor(name: string);
  143626. /**
  143627. * Initialize the block and prepare the context for build
  143628. * @param state defines the state that will be used for the build
  143629. */
  143630. initialize(state: NodeMaterialBuildState): void;
  143631. /**
  143632. * Gets the current class name
  143633. * @returns the class name
  143634. */
  143635. getClassName(): string;
  143636. /**
  143637. * Gets the matrix indices input component
  143638. */
  143639. get matricesIndices(): NodeMaterialConnectionPoint;
  143640. /**
  143641. * Gets the matrix weights input component
  143642. */
  143643. get matricesWeights(): NodeMaterialConnectionPoint;
  143644. /**
  143645. * Gets the extra matrix indices input component
  143646. */
  143647. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143648. /**
  143649. * Gets the extra matrix weights input component
  143650. */
  143651. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143652. /**
  143653. * Gets the world input component
  143654. */
  143655. get world(): NodeMaterialConnectionPoint;
  143656. /**
  143657. * Gets the output component
  143658. */
  143659. get output(): NodeMaterialConnectionPoint;
  143660. autoConfigure(material: NodeMaterial): void;
  143661. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143664. protected _buildBlock(state: NodeMaterialBuildState): this;
  143665. }
  143666. }
  143667. declare module BABYLON {
  143668. /**
  143669. * Block used to add support for instances
  143670. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143671. */
  143672. export class InstancesBlock extends NodeMaterialBlock {
  143673. /**
  143674. * Creates a new InstancesBlock
  143675. * @param name defines the block name
  143676. */
  143677. constructor(name: string);
  143678. /**
  143679. * Gets the current class name
  143680. * @returns the class name
  143681. */
  143682. getClassName(): string;
  143683. /**
  143684. * Gets the first world row input component
  143685. */
  143686. get world0(): NodeMaterialConnectionPoint;
  143687. /**
  143688. * Gets the second world row input component
  143689. */
  143690. get world1(): NodeMaterialConnectionPoint;
  143691. /**
  143692. * Gets the third world row input component
  143693. */
  143694. get world2(): NodeMaterialConnectionPoint;
  143695. /**
  143696. * Gets the forth world row input component
  143697. */
  143698. get world3(): NodeMaterialConnectionPoint;
  143699. /**
  143700. * Gets the world input component
  143701. */
  143702. get world(): NodeMaterialConnectionPoint;
  143703. /**
  143704. * Gets the output component
  143705. */
  143706. get output(): NodeMaterialConnectionPoint;
  143707. /**
  143708. * Gets the isntanceID component
  143709. */
  143710. get instanceID(): NodeMaterialConnectionPoint;
  143711. autoConfigure(material: NodeMaterial): void;
  143712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143713. protected _buildBlock(state: NodeMaterialBuildState): this;
  143714. }
  143715. }
  143716. declare module BABYLON {
  143717. /**
  143718. * Block used to add morph targets support to vertex shader
  143719. */
  143720. export class MorphTargetsBlock extends NodeMaterialBlock {
  143721. private _repeatableContentAnchor;
  143722. /**
  143723. * Create a new MorphTargetsBlock
  143724. * @param name defines the block name
  143725. */
  143726. constructor(name: string);
  143727. /**
  143728. * Gets the current class name
  143729. * @returns the class name
  143730. */
  143731. getClassName(): string;
  143732. /**
  143733. * Gets the position input component
  143734. */
  143735. get position(): NodeMaterialConnectionPoint;
  143736. /**
  143737. * Gets the normal input component
  143738. */
  143739. get normal(): NodeMaterialConnectionPoint;
  143740. /**
  143741. * Gets the tangent input component
  143742. */
  143743. get tangent(): NodeMaterialConnectionPoint;
  143744. /**
  143745. * Gets the tangent input component
  143746. */
  143747. get uv(): NodeMaterialConnectionPoint;
  143748. /**
  143749. * Gets the position output component
  143750. */
  143751. get positionOutput(): NodeMaterialConnectionPoint;
  143752. /**
  143753. * Gets the normal output component
  143754. */
  143755. get normalOutput(): NodeMaterialConnectionPoint;
  143756. /**
  143757. * Gets the tangent output component
  143758. */
  143759. get tangentOutput(): NodeMaterialConnectionPoint;
  143760. /**
  143761. * Gets the tangent output component
  143762. */
  143763. get uvOutput(): NodeMaterialConnectionPoint;
  143764. initialize(state: NodeMaterialBuildState): void;
  143765. autoConfigure(material: NodeMaterial): void;
  143766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143768. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143769. protected _buildBlock(state: NodeMaterialBuildState): this;
  143770. }
  143771. }
  143772. declare module BABYLON {
  143773. /**
  143774. * Block used to get data information from a light
  143775. */
  143776. export class LightInformationBlock extends NodeMaterialBlock {
  143777. private _lightDataUniformName;
  143778. private _lightColorUniformName;
  143779. private _lightTypeDefineName;
  143780. /**
  143781. * Gets or sets the light associated with this block
  143782. */
  143783. light: Nullable<Light>;
  143784. /**
  143785. * Creates a new LightInformationBlock
  143786. * @param name defines the block name
  143787. */
  143788. constructor(name: string);
  143789. /**
  143790. * Gets the current class name
  143791. * @returns the class name
  143792. */
  143793. getClassName(): string;
  143794. /**
  143795. * Gets the world position input component
  143796. */
  143797. get worldPosition(): NodeMaterialConnectionPoint;
  143798. /**
  143799. * Gets the direction output component
  143800. */
  143801. get direction(): NodeMaterialConnectionPoint;
  143802. /**
  143803. * Gets the direction output component
  143804. */
  143805. get color(): NodeMaterialConnectionPoint;
  143806. /**
  143807. * Gets the direction output component
  143808. */
  143809. get intensity(): NodeMaterialConnectionPoint;
  143810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143812. protected _buildBlock(state: NodeMaterialBuildState): this;
  143813. serialize(): any;
  143814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143815. }
  143816. }
  143817. declare module BABYLON {
  143818. /**
  143819. * Block used to add image processing support to fragment shader
  143820. */
  143821. export class ImageProcessingBlock extends NodeMaterialBlock {
  143822. /**
  143823. * Create a new ImageProcessingBlock
  143824. * @param name defines the block name
  143825. */
  143826. constructor(name: string);
  143827. /**
  143828. * Gets the current class name
  143829. * @returns the class name
  143830. */
  143831. getClassName(): string;
  143832. /**
  143833. * Gets the color input component
  143834. */
  143835. get color(): NodeMaterialConnectionPoint;
  143836. /**
  143837. * Gets the output component
  143838. */
  143839. get output(): NodeMaterialConnectionPoint;
  143840. /**
  143841. * Initialize the block and prepare the context for build
  143842. * @param state defines the state that will be used for the build
  143843. */
  143844. initialize(state: NodeMaterialBuildState): void;
  143845. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143848. protected _buildBlock(state: NodeMaterialBuildState): this;
  143849. }
  143850. }
  143851. declare module BABYLON {
  143852. /**
  143853. * Block used to pertub normals based on a normal map
  143854. */
  143855. export class PerturbNormalBlock extends NodeMaterialBlock {
  143856. private _tangentSpaceParameterName;
  143857. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143858. invertX: boolean;
  143859. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143860. invertY: boolean;
  143861. /**
  143862. * Create a new PerturbNormalBlock
  143863. * @param name defines the block name
  143864. */
  143865. constructor(name: string);
  143866. /**
  143867. * Gets the current class name
  143868. * @returns the class name
  143869. */
  143870. getClassName(): string;
  143871. /**
  143872. * Gets the world position input component
  143873. */
  143874. get worldPosition(): NodeMaterialConnectionPoint;
  143875. /**
  143876. * Gets the world normal input component
  143877. */
  143878. get worldNormal(): NodeMaterialConnectionPoint;
  143879. /**
  143880. * Gets the world tangent input component
  143881. */
  143882. get worldTangent(): NodeMaterialConnectionPoint;
  143883. /**
  143884. * Gets the uv input component
  143885. */
  143886. get uv(): NodeMaterialConnectionPoint;
  143887. /**
  143888. * Gets the normal map color input component
  143889. */
  143890. get normalMapColor(): NodeMaterialConnectionPoint;
  143891. /**
  143892. * Gets the strength input component
  143893. */
  143894. get strength(): NodeMaterialConnectionPoint;
  143895. /**
  143896. * Gets the output component
  143897. */
  143898. get output(): NodeMaterialConnectionPoint;
  143899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143900. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143901. autoConfigure(material: NodeMaterial): void;
  143902. protected _buildBlock(state: NodeMaterialBuildState): this;
  143903. protected _dumpPropertiesCode(): string;
  143904. serialize(): any;
  143905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143906. }
  143907. }
  143908. declare module BABYLON {
  143909. /**
  143910. * Block used to discard a pixel if a value is smaller than a cutoff
  143911. */
  143912. export class DiscardBlock extends NodeMaterialBlock {
  143913. /**
  143914. * Create a new DiscardBlock
  143915. * @param name defines the block name
  143916. */
  143917. constructor(name: string);
  143918. /**
  143919. * Gets the current class name
  143920. * @returns the class name
  143921. */
  143922. getClassName(): string;
  143923. /**
  143924. * Gets the color input component
  143925. */
  143926. get value(): NodeMaterialConnectionPoint;
  143927. /**
  143928. * Gets the cutoff input component
  143929. */
  143930. get cutoff(): NodeMaterialConnectionPoint;
  143931. protected _buildBlock(state: NodeMaterialBuildState): this;
  143932. }
  143933. }
  143934. declare module BABYLON {
  143935. /**
  143936. * Block used to test if the fragment shader is front facing
  143937. */
  143938. export class FrontFacingBlock extends NodeMaterialBlock {
  143939. /**
  143940. * Creates a new FrontFacingBlock
  143941. * @param name defines the block name
  143942. */
  143943. constructor(name: string);
  143944. /**
  143945. * Gets the current class name
  143946. * @returns the class name
  143947. */
  143948. getClassName(): string;
  143949. /**
  143950. * Gets the output component
  143951. */
  143952. get output(): NodeMaterialConnectionPoint;
  143953. protected _buildBlock(state: NodeMaterialBuildState): this;
  143954. }
  143955. }
  143956. declare module BABYLON {
  143957. /**
  143958. * Block used to get the derivative value on x and y of a given input
  143959. */
  143960. export class DerivativeBlock extends NodeMaterialBlock {
  143961. /**
  143962. * Create a new DerivativeBlock
  143963. * @param name defines the block name
  143964. */
  143965. constructor(name: string);
  143966. /**
  143967. * Gets the current class name
  143968. * @returns the class name
  143969. */
  143970. getClassName(): string;
  143971. /**
  143972. * Gets the input component
  143973. */
  143974. get input(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the derivative output on x
  143977. */
  143978. get dx(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the derivative output on y
  143981. */
  143982. get dy(): NodeMaterialConnectionPoint;
  143983. protected _buildBlock(state: NodeMaterialBuildState): this;
  143984. }
  143985. }
  143986. declare module BABYLON {
  143987. /**
  143988. * Block used to make gl_FragCoord available
  143989. */
  143990. export class FragCoordBlock extends NodeMaterialBlock {
  143991. /**
  143992. * Creates a new FragCoordBlock
  143993. * @param name defines the block name
  143994. */
  143995. constructor(name: string);
  143996. /**
  143997. * Gets the current class name
  143998. * @returns the class name
  143999. */
  144000. getClassName(): string;
  144001. /**
  144002. * Gets the xy component
  144003. */
  144004. get xy(): NodeMaterialConnectionPoint;
  144005. /**
  144006. * Gets the xyz component
  144007. */
  144008. get xyz(): NodeMaterialConnectionPoint;
  144009. /**
  144010. * Gets the xyzw component
  144011. */
  144012. get xyzw(): NodeMaterialConnectionPoint;
  144013. /**
  144014. * Gets the x component
  144015. */
  144016. get x(): NodeMaterialConnectionPoint;
  144017. /**
  144018. * Gets the y component
  144019. */
  144020. get y(): NodeMaterialConnectionPoint;
  144021. /**
  144022. * Gets the z component
  144023. */
  144024. get z(): NodeMaterialConnectionPoint;
  144025. /**
  144026. * Gets the w component
  144027. */
  144028. get output(): NodeMaterialConnectionPoint;
  144029. protected writeOutputs(state: NodeMaterialBuildState): string;
  144030. protected _buildBlock(state: NodeMaterialBuildState): this;
  144031. }
  144032. }
  144033. declare module BABYLON {
  144034. /**
  144035. * Block used to get the screen sizes
  144036. */
  144037. export class ScreenSizeBlock extends NodeMaterialBlock {
  144038. private _varName;
  144039. private _scene;
  144040. /**
  144041. * Creates a new ScreenSizeBlock
  144042. * @param name defines the block name
  144043. */
  144044. constructor(name: string);
  144045. /**
  144046. * Gets the current class name
  144047. * @returns the class name
  144048. */
  144049. getClassName(): string;
  144050. /**
  144051. * Gets the xy component
  144052. */
  144053. get xy(): NodeMaterialConnectionPoint;
  144054. /**
  144055. * Gets the x component
  144056. */
  144057. get x(): NodeMaterialConnectionPoint;
  144058. /**
  144059. * Gets the y component
  144060. */
  144061. get y(): NodeMaterialConnectionPoint;
  144062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144063. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144064. protected _buildBlock(state: NodeMaterialBuildState): this;
  144065. }
  144066. }
  144067. declare module BABYLON {
  144068. /**
  144069. * Block used to add support for scene fog
  144070. */
  144071. export class FogBlock extends NodeMaterialBlock {
  144072. private _fogDistanceName;
  144073. private _fogParameters;
  144074. /**
  144075. * Create a new FogBlock
  144076. * @param name defines the block name
  144077. */
  144078. constructor(name: string);
  144079. /**
  144080. * Gets the current class name
  144081. * @returns the class name
  144082. */
  144083. getClassName(): string;
  144084. /**
  144085. * Gets the world position input component
  144086. */
  144087. get worldPosition(): NodeMaterialConnectionPoint;
  144088. /**
  144089. * Gets the view input component
  144090. */
  144091. get view(): NodeMaterialConnectionPoint;
  144092. /**
  144093. * Gets the color input component
  144094. */
  144095. get input(): NodeMaterialConnectionPoint;
  144096. /**
  144097. * Gets the fog color input component
  144098. */
  144099. get fogColor(): NodeMaterialConnectionPoint;
  144100. /**
  144101. * Gets the output component
  144102. */
  144103. get output(): NodeMaterialConnectionPoint;
  144104. autoConfigure(material: NodeMaterial): void;
  144105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144107. protected _buildBlock(state: NodeMaterialBuildState): this;
  144108. }
  144109. }
  144110. declare module BABYLON {
  144111. /**
  144112. * Block used to add light in the fragment shader
  144113. */
  144114. export class LightBlock extends NodeMaterialBlock {
  144115. private _lightId;
  144116. /**
  144117. * Gets or sets the light associated with this block
  144118. */
  144119. light: Nullable<Light>;
  144120. /**
  144121. * Create a new LightBlock
  144122. * @param name defines the block name
  144123. */
  144124. constructor(name: string);
  144125. /**
  144126. * Gets the current class name
  144127. * @returns the class name
  144128. */
  144129. getClassName(): string;
  144130. /**
  144131. * Gets the world position input component
  144132. */
  144133. get worldPosition(): NodeMaterialConnectionPoint;
  144134. /**
  144135. * Gets the world normal input component
  144136. */
  144137. get worldNormal(): NodeMaterialConnectionPoint;
  144138. /**
  144139. * Gets the camera (or eye) position component
  144140. */
  144141. get cameraPosition(): NodeMaterialConnectionPoint;
  144142. /**
  144143. * Gets the glossiness component
  144144. */
  144145. get glossiness(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the glossinness power component
  144148. */
  144149. get glossPower(): NodeMaterialConnectionPoint;
  144150. /**
  144151. * Gets the diffuse color component
  144152. */
  144153. get diffuseColor(): NodeMaterialConnectionPoint;
  144154. /**
  144155. * Gets the specular color component
  144156. */
  144157. get specularColor(): NodeMaterialConnectionPoint;
  144158. /**
  144159. * Gets the diffuse output component
  144160. */
  144161. get diffuseOutput(): NodeMaterialConnectionPoint;
  144162. /**
  144163. * Gets the specular output component
  144164. */
  144165. get specularOutput(): NodeMaterialConnectionPoint;
  144166. /**
  144167. * Gets the shadow output component
  144168. */
  144169. get shadow(): NodeMaterialConnectionPoint;
  144170. autoConfigure(material: NodeMaterial): void;
  144171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144172. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144174. private _injectVertexCode;
  144175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144176. serialize(): any;
  144177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144178. }
  144179. }
  144180. declare module BABYLON {
  144181. /**
  144182. * Block used to read a reflection texture from a sampler
  144183. */
  144184. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144185. /**
  144186. * Create a new ReflectionTextureBlock
  144187. * @param name defines the block name
  144188. */
  144189. constructor(name: string);
  144190. /**
  144191. * Gets the current class name
  144192. * @returns the class name
  144193. */
  144194. getClassName(): string;
  144195. /**
  144196. * Gets the world position input component
  144197. */
  144198. get position(): NodeMaterialConnectionPoint;
  144199. /**
  144200. * Gets the world position input component
  144201. */
  144202. get worldPosition(): NodeMaterialConnectionPoint;
  144203. /**
  144204. * Gets the world normal input component
  144205. */
  144206. get worldNormal(): NodeMaterialConnectionPoint;
  144207. /**
  144208. * Gets the world input component
  144209. */
  144210. get world(): NodeMaterialConnectionPoint;
  144211. /**
  144212. * Gets the camera (or eye) position component
  144213. */
  144214. get cameraPosition(): NodeMaterialConnectionPoint;
  144215. /**
  144216. * Gets the view input component
  144217. */
  144218. get view(): NodeMaterialConnectionPoint;
  144219. /**
  144220. * Gets the rgb output component
  144221. */
  144222. get rgb(): NodeMaterialConnectionPoint;
  144223. /**
  144224. * Gets the rgba output component
  144225. */
  144226. get rgba(): NodeMaterialConnectionPoint;
  144227. /**
  144228. * Gets the r output component
  144229. */
  144230. get r(): NodeMaterialConnectionPoint;
  144231. /**
  144232. * Gets the g output component
  144233. */
  144234. get g(): NodeMaterialConnectionPoint;
  144235. /**
  144236. * Gets the b output component
  144237. */
  144238. get b(): NodeMaterialConnectionPoint;
  144239. /**
  144240. * Gets the a output component
  144241. */
  144242. get a(): NodeMaterialConnectionPoint;
  144243. autoConfigure(material: NodeMaterial): void;
  144244. protected _buildBlock(state: NodeMaterialBuildState): this;
  144245. }
  144246. }
  144247. declare module BABYLON {
  144248. /**
  144249. * Block used to add 2 vectors
  144250. */
  144251. export class AddBlock extends NodeMaterialBlock {
  144252. /**
  144253. * Creates a new AddBlock
  144254. * @param name defines the block name
  144255. */
  144256. constructor(name: string);
  144257. /**
  144258. * Gets the current class name
  144259. * @returns the class name
  144260. */
  144261. getClassName(): string;
  144262. /**
  144263. * Gets the left operand input component
  144264. */
  144265. get left(): NodeMaterialConnectionPoint;
  144266. /**
  144267. * Gets the right operand input component
  144268. */
  144269. get right(): NodeMaterialConnectionPoint;
  144270. /**
  144271. * Gets the output component
  144272. */
  144273. get output(): NodeMaterialConnectionPoint;
  144274. protected _buildBlock(state: NodeMaterialBuildState): this;
  144275. }
  144276. }
  144277. declare module BABYLON {
  144278. /**
  144279. * Block used to scale a vector by a float
  144280. */
  144281. export class ScaleBlock extends NodeMaterialBlock {
  144282. /**
  144283. * Creates a new ScaleBlock
  144284. * @param name defines the block name
  144285. */
  144286. constructor(name: string);
  144287. /**
  144288. * Gets the current class name
  144289. * @returns the class name
  144290. */
  144291. getClassName(): string;
  144292. /**
  144293. * Gets the input component
  144294. */
  144295. get input(): NodeMaterialConnectionPoint;
  144296. /**
  144297. * Gets the factor input component
  144298. */
  144299. get factor(): NodeMaterialConnectionPoint;
  144300. /**
  144301. * Gets the output component
  144302. */
  144303. get output(): NodeMaterialConnectionPoint;
  144304. protected _buildBlock(state: NodeMaterialBuildState): this;
  144305. }
  144306. }
  144307. declare module BABYLON {
  144308. /**
  144309. * Block used to clamp a float
  144310. */
  144311. export class ClampBlock extends NodeMaterialBlock {
  144312. /** Gets or sets the minimum range */
  144313. minimum: number;
  144314. /** Gets or sets the maximum range */
  144315. maximum: number;
  144316. /**
  144317. * Creates a new ClampBlock
  144318. * @param name defines the block name
  144319. */
  144320. constructor(name: string);
  144321. /**
  144322. * Gets the current class name
  144323. * @returns the class name
  144324. */
  144325. getClassName(): string;
  144326. /**
  144327. * Gets the value input component
  144328. */
  144329. get value(): NodeMaterialConnectionPoint;
  144330. /**
  144331. * Gets the output component
  144332. */
  144333. get output(): NodeMaterialConnectionPoint;
  144334. protected _buildBlock(state: NodeMaterialBuildState): this;
  144335. protected _dumpPropertiesCode(): string;
  144336. serialize(): any;
  144337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144338. }
  144339. }
  144340. declare module BABYLON {
  144341. /**
  144342. * Block used to apply a cross product between 2 vectors
  144343. */
  144344. export class CrossBlock extends NodeMaterialBlock {
  144345. /**
  144346. * Creates a new CrossBlock
  144347. * @param name defines the block name
  144348. */
  144349. constructor(name: string);
  144350. /**
  144351. * Gets the current class name
  144352. * @returns the class name
  144353. */
  144354. getClassName(): string;
  144355. /**
  144356. * Gets the left operand input component
  144357. */
  144358. get left(): NodeMaterialConnectionPoint;
  144359. /**
  144360. * Gets the right operand input component
  144361. */
  144362. get right(): NodeMaterialConnectionPoint;
  144363. /**
  144364. * Gets the output component
  144365. */
  144366. get output(): NodeMaterialConnectionPoint;
  144367. protected _buildBlock(state: NodeMaterialBuildState): this;
  144368. }
  144369. }
  144370. declare module BABYLON {
  144371. /**
  144372. * Block used to apply a dot product between 2 vectors
  144373. */
  144374. export class DotBlock extends NodeMaterialBlock {
  144375. /**
  144376. * Creates a new DotBlock
  144377. * @param name defines the block name
  144378. */
  144379. constructor(name: string);
  144380. /**
  144381. * Gets the current class name
  144382. * @returns the class name
  144383. */
  144384. getClassName(): string;
  144385. /**
  144386. * Gets the left operand input component
  144387. */
  144388. get left(): NodeMaterialConnectionPoint;
  144389. /**
  144390. * Gets the right operand input component
  144391. */
  144392. get right(): NodeMaterialConnectionPoint;
  144393. /**
  144394. * Gets the output component
  144395. */
  144396. get output(): NodeMaterialConnectionPoint;
  144397. protected _buildBlock(state: NodeMaterialBuildState): this;
  144398. }
  144399. }
  144400. declare module BABYLON {
  144401. /**
  144402. * Block used to normalize a vector
  144403. */
  144404. export class NormalizeBlock extends NodeMaterialBlock {
  144405. /**
  144406. * Creates a new NormalizeBlock
  144407. * @param name defines the block name
  144408. */
  144409. constructor(name: string);
  144410. /**
  144411. * Gets the current class name
  144412. * @returns the class name
  144413. */
  144414. getClassName(): string;
  144415. /**
  144416. * Gets the input component
  144417. */
  144418. get input(): NodeMaterialConnectionPoint;
  144419. /**
  144420. * Gets the output component
  144421. */
  144422. get output(): NodeMaterialConnectionPoint;
  144423. protected _buildBlock(state: NodeMaterialBuildState): this;
  144424. }
  144425. }
  144426. declare module BABYLON {
  144427. /**
  144428. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144429. */
  144430. export class ColorMergerBlock extends NodeMaterialBlock {
  144431. /**
  144432. * Create a new ColorMergerBlock
  144433. * @param name defines the block name
  144434. */
  144435. constructor(name: string);
  144436. /**
  144437. * Gets the current class name
  144438. * @returns the class name
  144439. */
  144440. getClassName(): string;
  144441. /**
  144442. * Gets the rgb component (input)
  144443. */
  144444. get rgbIn(): NodeMaterialConnectionPoint;
  144445. /**
  144446. * Gets the r component (input)
  144447. */
  144448. get r(): NodeMaterialConnectionPoint;
  144449. /**
  144450. * Gets the g component (input)
  144451. */
  144452. get g(): NodeMaterialConnectionPoint;
  144453. /**
  144454. * Gets the b component (input)
  144455. */
  144456. get b(): NodeMaterialConnectionPoint;
  144457. /**
  144458. * Gets the a component (input)
  144459. */
  144460. get a(): NodeMaterialConnectionPoint;
  144461. /**
  144462. * Gets the rgba component (output)
  144463. */
  144464. get rgba(): NodeMaterialConnectionPoint;
  144465. /**
  144466. * Gets the rgb component (output)
  144467. */
  144468. get rgbOut(): NodeMaterialConnectionPoint;
  144469. /**
  144470. * Gets the rgb component (output)
  144471. * @deprecated Please use rgbOut instead.
  144472. */
  144473. get rgb(): NodeMaterialConnectionPoint;
  144474. protected _buildBlock(state: NodeMaterialBuildState): this;
  144475. }
  144476. }
  144477. declare module BABYLON {
  144478. /**
  144479. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144480. */
  144481. export class VectorSplitterBlock extends NodeMaterialBlock {
  144482. /**
  144483. * Create a new VectorSplitterBlock
  144484. * @param name defines the block name
  144485. */
  144486. constructor(name: string);
  144487. /**
  144488. * Gets the current class name
  144489. * @returns the class name
  144490. */
  144491. getClassName(): string;
  144492. /**
  144493. * Gets the xyzw component (input)
  144494. */
  144495. get xyzw(): NodeMaterialConnectionPoint;
  144496. /**
  144497. * Gets the xyz component (input)
  144498. */
  144499. get xyzIn(): NodeMaterialConnectionPoint;
  144500. /**
  144501. * Gets the xy component (input)
  144502. */
  144503. get xyIn(): NodeMaterialConnectionPoint;
  144504. /**
  144505. * Gets the xyz component (output)
  144506. */
  144507. get xyzOut(): NodeMaterialConnectionPoint;
  144508. /**
  144509. * Gets the xy component (output)
  144510. */
  144511. get xyOut(): NodeMaterialConnectionPoint;
  144512. /**
  144513. * Gets the x component (output)
  144514. */
  144515. get x(): NodeMaterialConnectionPoint;
  144516. /**
  144517. * Gets the y component (output)
  144518. */
  144519. get y(): NodeMaterialConnectionPoint;
  144520. /**
  144521. * Gets the z component (output)
  144522. */
  144523. get z(): NodeMaterialConnectionPoint;
  144524. /**
  144525. * Gets the w component (output)
  144526. */
  144527. get w(): NodeMaterialConnectionPoint;
  144528. protected _inputRename(name: string): string;
  144529. protected _outputRename(name: string): string;
  144530. protected _buildBlock(state: NodeMaterialBuildState): this;
  144531. }
  144532. }
  144533. declare module BABYLON {
  144534. /**
  144535. * Block used to lerp between 2 values
  144536. */
  144537. export class LerpBlock extends NodeMaterialBlock {
  144538. /**
  144539. * Creates a new LerpBlock
  144540. * @param name defines the block name
  144541. */
  144542. constructor(name: string);
  144543. /**
  144544. * Gets the current class name
  144545. * @returns the class name
  144546. */
  144547. getClassName(): string;
  144548. /**
  144549. * Gets the left operand input component
  144550. */
  144551. get left(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the right operand input component
  144554. */
  144555. get right(): NodeMaterialConnectionPoint;
  144556. /**
  144557. * Gets the gradient operand input component
  144558. */
  144559. get gradient(): NodeMaterialConnectionPoint;
  144560. /**
  144561. * Gets the output component
  144562. */
  144563. get output(): NodeMaterialConnectionPoint;
  144564. protected _buildBlock(state: NodeMaterialBuildState): this;
  144565. }
  144566. }
  144567. declare module BABYLON {
  144568. /**
  144569. * Block used to divide 2 vectors
  144570. */
  144571. export class DivideBlock extends NodeMaterialBlock {
  144572. /**
  144573. * Creates a new DivideBlock
  144574. * @param name defines the block name
  144575. */
  144576. constructor(name: string);
  144577. /**
  144578. * Gets the current class name
  144579. * @returns the class name
  144580. */
  144581. getClassName(): string;
  144582. /**
  144583. * Gets the left operand input component
  144584. */
  144585. get left(): NodeMaterialConnectionPoint;
  144586. /**
  144587. * Gets the right operand input component
  144588. */
  144589. get right(): NodeMaterialConnectionPoint;
  144590. /**
  144591. * Gets the output component
  144592. */
  144593. get output(): NodeMaterialConnectionPoint;
  144594. protected _buildBlock(state: NodeMaterialBuildState): this;
  144595. }
  144596. }
  144597. declare module BABYLON {
  144598. /**
  144599. * Block used to subtract 2 vectors
  144600. */
  144601. export class SubtractBlock extends NodeMaterialBlock {
  144602. /**
  144603. * Creates a new SubtractBlock
  144604. * @param name defines the block name
  144605. */
  144606. constructor(name: string);
  144607. /**
  144608. * Gets the current class name
  144609. * @returns the class name
  144610. */
  144611. getClassName(): string;
  144612. /**
  144613. * Gets the left operand input component
  144614. */
  144615. get left(): NodeMaterialConnectionPoint;
  144616. /**
  144617. * Gets the right operand input component
  144618. */
  144619. get right(): NodeMaterialConnectionPoint;
  144620. /**
  144621. * Gets the output component
  144622. */
  144623. get output(): NodeMaterialConnectionPoint;
  144624. protected _buildBlock(state: NodeMaterialBuildState): this;
  144625. }
  144626. }
  144627. declare module BABYLON {
  144628. /**
  144629. * Block used to step a value
  144630. */
  144631. export class StepBlock extends NodeMaterialBlock {
  144632. /**
  144633. * Creates a new StepBlock
  144634. * @param name defines the block name
  144635. */
  144636. constructor(name: string);
  144637. /**
  144638. * Gets the current class name
  144639. * @returns the class name
  144640. */
  144641. getClassName(): string;
  144642. /**
  144643. * Gets the value operand input component
  144644. */
  144645. get value(): NodeMaterialConnectionPoint;
  144646. /**
  144647. * Gets the edge operand input component
  144648. */
  144649. get edge(): NodeMaterialConnectionPoint;
  144650. /**
  144651. * Gets the output component
  144652. */
  144653. get output(): NodeMaterialConnectionPoint;
  144654. protected _buildBlock(state: NodeMaterialBuildState): this;
  144655. }
  144656. }
  144657. declare module BABYLON {
  144658. /**
  144659. * Block used to get the opposite (1 - x) of a value
  144660. */
  144661. export class OneMinusBlock extends NodeMaterialBlock {
  144662. /**
  144663. * Creates a new OneMinusBlock
  144664. * @param name defines the block name
  144665. */
  144666. constructor(name: string);
  144667. /**
  144668. * Gets the current class name
  144669. * @returns the class name
  144670. */
  144671. getClassName(): string;
  144672. /**
  144673. * Gets the input component
  144674. */
  144675. get input(): NodeMaterialConnectionPoint;
  144676. /**
  144677. * Gets the output component
  144678. */
  144679. get output(): NodeMaterialConnectionPoint;
  144680. protected _buildBlock(state: NodeMaterialBuildState): this;
  144681. }
  144682. }
  144683. declare module BABYLON {
  144684. /**
  144685. * Block used to get the view direction
  144686. */
  144687. export class ViewDirectionBlock extends NodeMaterialBlock {
  144688. /**
  144689. * Creates a new ViewDirectionBlock
  144690. * @param name defines the block name
  144691. */
  144692. constructor(name: string);
  144693. /**
  144694. * Gets the current class name
  144695. * @returns the class name
  144696. */
  144697. getClassName(): string;
  144698. /**
  144699. * Gets the world position component
  144700. */
  144701. get worldPosition(): NodeMaterialConnectionPoint;
  144702. /**
  144703. * Gets the camera position component
  144704. */
  144705. get cameraPosition(): NodeMaterialConnectionPoint;
  144706. /**
  144707. * Gets the output component
  144708. */
  144709. get output(): NodeMaterialConnectionPoint;
  144710. autoConfigure(material: NodeMaterial): void;
  144711. protected _buildBlock(state: NodeMaterialBuildState): this;
  144712. }
  144713. }
  144714. declare module BABYLON {
  144715. /**
  144716. * Block used to compute fresnel value
  144717. */
  144718. export class FresnelBlock extends NodeMaterialBlock {
  144719. /**
  144720. * Create a new FresnelBlock
  144721. * @param name defines the block name
  144722. */
  144723. constructor(name: string);
  144724. /**
  144725. * Gets the current class name
  144726. * @returns the class name
  144727. */
  144728. getClassName(): string;
  144729. /**
  144730. * Gets the world normal input component
  144731. */
  144732. get worldNormal(): NodeMaterialConnectionPoint;
  144733. /**
  144734. * Gets the view direction input component
  144735. */
  144736. get viewDirection(): NodeMaterialConnectionPoint;
  144737. /**
  144738. * Gets the bias input component
  144739. */
  144740. get bias(): NodeMaterialConnectionPoint;
  144741. /**
  144742. * Gets the camera (or eye) position component
  144743. */
  144744. get power(): NodeMaterialConnectionPoint;
  144745. /**
  144746. * Gets the fresnel output component
  144747. */
  144748. get fresnel(): NodeMaterialConnectionPoint;
  144749. autoConfigure(material: NodeMaterial): void;
  144750. protected _buildBlock(state: NodeMaterialBuildState): this;
  144751. }
  144752. }
  144753. declare module BABYLON {
  144754. /**
  144755. * Block used to get the max of 2 values
  144756. */
  144757. export class MaxBlock extends NodeMaterialBlock {
  144758. /**
  144759. * Creates a new MaxBlock
  144760. * @param name defines the block name
  144761. */
  144762. constructor(name: string);
  144763. /**
  144764. * Gets the current class name
  144765. * @returns the class name
  144766. */
  144767. getClassName(): string;
  144768. /**
  144769. * Gets the left operand input component
  144770. */
  144771. get left(): NodeMaterialConnectionPoint;
  144772. /**
  144773. * Gets the right operand input component
  144774. */
  144775. get right(): NodeMaterialConnectionPoint;
  144776. /**
  144777. * Gets the output component
  144778. */
  144779. get output(): NodeMaterialConnectionPoint;
  144780. protected _buildBlock(state: NodeMaterialBuildState): this;
  144781. }
  144782. }
  144783. declare module BABYLON {
  144784. /**
  144785. * Block used to get the min of 2 values
  144786. */
  144787. export class MinBlock extends NodeMaterialBlock {
  144788. /**
  144789. * Creates a new MinBlock
  144790. * @param name defines the block name
  144791. */
  144792. constructor(name: string);
  144793. /**
  144794. * Gets the current class name
  144795. * @returns the class name
  144796. */
  144797. getClassName(): string;
  144798. /**
  144799. * Gets the left operand input component
  144800. */
  144801. get left(): NodeMaterialConnectionPoint;
  144802. /**
  144803. * Gets the right operand input component
  144804. */
  144805. get right(): NodeMaterialConnectionPoint;
  144806. /**
  144807. * Gets the output component
  144808. */
  144809. get output(): NodeMaterialConnectionPoint;
  144810. protected _buildBlock(state: NodeMaterialBuildState): this;
  144811. }
  144812. }
  144813. declare module BABYLON {
  144814. /**
  144815. * Block used to get the distance between 2 values
  144816. */
  144817. export class DistanceBlock extends NodeMaterialBlock {
  144818. /**
  144819. * Creates a new DistanceBlock
  144820. * @param name defines the block name
  144821. */
  144822. constructor(name: string);
  144823. /**
  144824. * Gets the current class name
  144825. * @returns the class name
  144826. */
  144827. getClassName(): string;
  144828. /**
  144829. * Gets the left operand input component
  144830. */
  144831. get left(): NodeMaterialConnectionPoint;
  144832. /**
  144833. * Gets the right operand input component
  144834. */
  144835. get right(): NodeMaterialConnectionPoint;
  144836. /**
  144837. * Gets the output component
  144838. */
  144839. get output(): NodeMaterialConnectionPoint;
  144840. protected _buildBlock(state: NodeMaterialBuildState): this;
  144841. }
  144842. }
  144843. declare module BABYLON {
  144844. /**
  144845. * Block used to get the length of a vector
  144846. */
  144847. export class LengthBlock extends NodeMaterialBlock {
  144848. /**
  144849. * Creates a new LengthBlock
  144850. * @param name defines the block name
  144851. */
  144852. constructor(name: string);
  144853. /**
  144854. * Gets the current class name
  144855. * @returns the class name
  144856. */
  144857. getClassName(): string;
  144858. /**
  144859. * Gets the value input component
  144860. */
  144861. get value(): NodeMaterialConnectionPoint;
  144862. /**
  144863. * Gets the output component
  144864. */
  144865. get output(): NodeMaterialConnectionPoint;
  144866. protected _buildBlock(state: NodeMaterialBuildState): this;
  144867. }
  144868. }
  144869. declare module BABYLON {
  144870. /**
  144871. * Block used to get negative version of a value (i.e. x * -1)
  144872. */
  144873. export class NegateBlock extends NodeMaterialBlock {
  144874. /**
  144875. * Creates a new NegateBlock
  144876. * @param name defines the block name
  144877. */
  144878. constructor(name: string);
  144879. /**
  144880. * Gets the current class name
  144881. * @returns the class name
  144882. */
  144883. getClassName(): string;
  144884. /**
  144885. * Gets the value input component
  144886. */
  144887. get value(): NodeMaterialConnectionPoint;
  144888. /**
  144889. * Gets the output component
  144890. */
  144891. get output(): NodeMaterialConnectionPoint;
  144892. protected _buildBlock(state: NodeMaterialBuildState): this;
  144893. }
  144894. }
  144895. declare module BABYLON {
  144896. /**
  144897. * Block used to get the value of the first parameter raised to the power of the second
  144898. */
  144899. export class PowBlock extends NodeMaterialBlock {
  144900. /**
  144901. * Creates a new PowBlock
  144902. * @param name defines the block name
  144903. */
  144904. constructor(name: string);
  144905. /**
  144906. * Gets the current class name
  144907. * @returns the class name
  144908. */
  144909. getClassName(): string;
  144910. /**
  144911. * Gets the value operand input component
  144912. */
  144913. get value(): NodeMaterialConnectionPoint;
  144914. /**
  144915. * Gets the power operand input component
  144916. */
  144917. get power(): NodeMaterialConnectionPoint;
  144918. /**
  144919. * Gets the output component
  144920. */
  144921. get output(): NodeMaterialConnectionPoint;
  144922. protected _buildBlock(state: NodeMaterialBuildState): this;
  144923. }
  144924. }
  144925. declare module BABYLON {
  144926. /**
  144927. * Block used to get a random number
  144928. */
  144929. export class RandomNumberBlock extends NodeMaterialBlock {
  144930. /**
  144931. * Creates a new RandomNumberBlock
  144932. * @param name defines the block name
  144933. */
  144934. constructor(name: string);
  144935. /**
  144936. * Gets the current class name
  144937. * @returns the class name
  144938. */
  144939. getClassName(): string;
  144940. /**
  144941. * Gets the seed input component
  144942. */
  144943. get seed(): NodeMaterialConnectionPoint;
  144944. /**
  144945. * Gets the output component
  144946. */
  144947. get output(): NodeMaterialConnectionPoint;
  144948. protected _buildBlock(state: NodeMaterialBuildState): this;
  144949. }
  144950. }
  144951. declare module BABYLON {
  144952. /**
  144953. * Block used to compute arc tangent of 2 values
  144954. */
  144955. export class ArcTan2Block extends NodeMaterialBlock {
  144956. /**
  144957. * Creates a new ArcTan2Block
  144958. * @param name defines the block name
  144959. */
  144960. constructor(name: string);
  144961. /**
  144962. * Gets the current class name
  144963. * @returns the class name
  144964. */
  144965. getClassName(): string;
  144966. /**
  144967. * Gets the x operand input component
  144968. */
  144969. get x(): NodeMaterialConnectionPoint;
  144970. /**
  144971. * Gets the y operand input component
  144972. */
  144973. get y(): NodeMaterialConnectionPoint;
  144974. /**
  144975. * Gets the output component
  144976. */
  144977. get output(): NodeMaterialConnectionPoint;
  144978. protected _buildBlock(state: NodeMaterialBuildState): this;
  144979. }
  144980. }
  144981. declare module BABYLON {
  144982. /**
  144983. * Block used to smooth step a value
  144984. */
  144985. export class SmoothStepBlock extends NodeMaterialBlock {
  144986. /**
  144987. * Creates a new SmoothStepBlock
  144988. * @param name defines the block name
  144989. */
  144990. constructor(name: string);
  144991. /**
  144992. * Gets the current class name
  144993. * @returns the class name
  144994. */
  144995. getClassName(): string;
  144996. /**
  144997. * Gets the value operand input component
  144998. */
  144999. get value(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the first edge operand input component
  145002. */
  145003. get edge0(): NodeMaterialConnectionPoint;
  145004. /**
  145005. * Gets the second edge operand input component
  145006. */
  145007. get edge1(): NodeMaterialConnectionPoint;
  145008. /**
  145009. * Gets the output component
  145010. */
  145011. get output(): NodeMaterialConnectionPoint;
  145012. protected _buildBlock(state: NodeMaterialBuildState): this;
  145013. }
  145014. }
  145015. declare module BABYLON {
  145016. /**
  145017. * Block used to get the reciprocal (1 / x) of a value
  145018. */
  145019. export class ReciprocalBlock extends NodeMaterialBlock {
  145020. /**
  145021. * Creates a new ReciprocalBlock
  145022. * @param name defines the block name
  145023. */
  145024. constructor(name: string);
  145025. /**
  145026. * Gets the current class name
  145027. * @returns the class name
  145028. */
  145029. getClassName(): string;
  145030. /**
  145031. * Gets the input component
  145032. */
  145033. get input(): NodeMaterialConnectionPoint;
  145034. /**
  145035. * Gets the output component
  145036. */
  145037. get output(): NodeMaterialConnectionPoint;
  145038. protected _buildBlock(state: NodeMaterialBuildState): this;
  145039. }
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * Block used to replace a color by another one
  145044. */
  145045. export class ReplaceColorBlock extends NodeMaterialBlock {
  145046. /**
  145047. * Creates a new ReplaceColorBlock
  145048. * @param name defines the block name
  145049. */
  145050. constructor(name: string);
  145051. /**
  145052. * Gets the current class name
  145053. * @returns the class name
  145054. */
  145055. getClassName(): string;
  145056. /**
  145057. * Gets the value input component
  145058. */
  145059. get value(): NodeMaterialConnectionPoint;
  145060. /**
  145061. * Gets the reference input component
  145062. */
  145063. get reference(): NodeMaterialConnectionPoint;
  145064. /**
  145065. * Gets the distance input component
  145066. */
  145067. get distance(): NodeMaterialConnectionPoint;
  145068. /**
  145069. * Gets the replacement input component
  145070. */
  145071. get replacement(): NodeMaterialConnectionPoint;
  145072. /**
  145073. * Gets the output component
  145074. */
  145075. get output(): NodeMaterialConnectionPoint;
  145076. protected _buildBlock(state: NodeMaterialBuildState): this;
  145077. }
  145078. }
  145079. declare module BABYLON {
  145080. /**
  145081. * Block used to posterize a value
  145082. * @see https://en.wikipedia.org/wiki/Posterization
  145083. */
  145084. export class PosterizeBlock extends NodeMaterialBlock {
  145085. /**
  145086. * Creates a new PosterizeBlock
  145087. * @param name defines the block name
  145088. */
  145089. constructor(name: string);
  145090. /**
  145091. * Gets the current class name
  145092. * @returns the class name
  145093. */
  145094. getClassName(): string;
  145095. /**
  145096. * Gets the value input component
  145097. */
  145098. get value(): NodeMaterialConnectionPoint;
  145099. /**
  145100. * Gets the steps input component
  145101. */
  145102. get steps(): NodeMaterialConnectionPoint;
  145103. /**
  145104. * Gets the output component
  145105. */
  145106. get output(): NodeMaterialConnectionPoint;
  145107. protected _buildBlock(state: NodeMaterialBuildState): this;
  145108. }
  145109. }
  145110. declare module BABYLON {
  145111. /**
  145112. * Operations supported by the Wave block
  145113. */
  145114. export enum WaveBlockKind {
  145115. /** SawTooth */
  145116. SawTooth = 0,
  145117. /** Square */
  145118. Square = 1,
  145119. /** Triangle */
  145120. Triangle = 2
  145121. }
  145122. /**
  145123. * Block used to apply wave operation to floats
  145124. */
  145125. export class WaveBlock extends NodeMaterialBlock {
  145126. /**
  145127. * Gets or sets the kibnd of wave to be applied by the block
  145128. */
  145129. kind: WaveBlockKind;
  145130. /**
  145131. * Creates a new WaveBlock
  145132. * @param name defines the block name
  145133. */
  145134. constructor(name: string);
  145135. /**
  145136. * Gets the current class name
  145137. * @returns the class name
  145138. */
  145139. getClassName(): string;
  145140. /**
  145141. * Gets the input component
  145142. */
  145143. get input(): NodeMaterialConnectionPoint;
  145144. /**
  145145. * Gets the output component
  145146. */
  145147. get output(): NodeMaterialConnectionPoint;
  145148. protected _buildBlock(state: NodeMaterialBuildState): this;
  145149. serialize(): any;
  145150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145151. }
  145152. }
  145153. declare module BABYLON {
  145154. /**
  145155. * Class used to store a color step for the GradientBlock
  145156. */
  145157. export class GradientBlockColorStep {
  145158. private _step;
  145159. /**
  145160. * Gets value indicating which step this color is associated with (between 0 and 1)
  145161. */
  145162. get step(): number;
  145163. /**
  145164. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145165. */
  145166. set step(val: number);
  145167. private _color;
  145168. /**
  145169. * Gets the color associated with this step
  145170. */
  145171. get color(): Color3;
  145172. /**
  145173. * Sets the color associated with this step
  145174. */
  145175. set color(val: Color3);
  145176. /**
  145177. * Creates a new GradientBlockColorStep
  145178. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145179. * @param color defines the color associated with this step
  145180. */
  145181. constructor(step: number, color: Color3);
  145182. }
  145183. /**
  145184. * Block used to return a color from a gradient based on an input value between 0 and 1
  145185. */
  145186. export class GradientBlock extends NodeMaterialBlock {
  145187. /**
  145188. * Gets or sets the list of color steps
  145189. */
  145190. colorSteps: GradientBlockColorStep[];
  145191. /** Gets an observable raised when the value is changed */
  145192. onValueChangedObservable: Observable<GradientBlock>;
  145193. /** calls observable when the value is changed*/
  145194. colorStepsUpdated(): void;
  145195. /**
  145196. * Creates a new GradientBlock
  145197. * @param name defines the block name
  145198. */
  145199. constructor(name: string);
  145200. /**
  145201. * Gets the current class name
  145202. * @returns the class name
  145203. */
  145204. getClassName(): string;
  145205. /**
  145206. * Gets the gradient input component
  145207. */
  145208. get gradient(): NodeMaterialConnectionPoint;
  145209. /**
  145210. * Gets the output component
  145211. */
  145212. get output(): NodeMaterialConnectionPoint;
  145213. private _writeColorConstant;
  145214. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145215. serialize(): any;
  145216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145217. protected _dumpPropertiesCode(): string;
  145218. }
  145219. }
  145220. declare module BABYLON {
  145221. /**
  145222. * Block used to normalize lerp between 2 values
  145223. */
  145224. export class NLerpBlock extends NodeMaterialBlock {
  145225. /**
  145226. * Creates a new NLerpBlock
  145227. * @param name defines the block name
  145228. */
  145229. constructor(name: string);
  145230. /**
  145231. * Gets the current class name
  145232. * @returns the class name
  145233. */
  145234. getClassName(): string;
  145235. /**
  145236. * Gets the left operand input component
  145237. */
  145238. get left(): NodeMaterialConnectionPoint;
  145239. /**
  145240. * Gets the right operand input component
  145241. */
  145242. get right(): NodeMaterialConnectionPoint;
  145243. /**
  145244. * Gets the gradient operand input component
  145245. */
  145246. get gradient(): NodeMaterialConnectionPoint;
  145247. /**
  145248. * Gets the output component
  145249. */
  145250. get output(): NodeMaterialConnectionPoint;
  145251. protected _buildBlock(state: NodeMaterialBuildState): this;
  145252. }
  145253. }
  145254. declare module BABYLON {
  145255. /**
  145256. * block used to Generate a Worley Noise 3D Noise Pattern
  145257. */
  145258. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145259. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145260. manhattanDistance: boolean;
  145261. /**
  145262. * Creates a new WorleyNoise3DBlock
  145263. * @param name defines the block name
  145264. */
  145265. constructor(name: string);
  145266. /**
  145267. * Gets the current class name
  145268. * @returns the class name
  145269. */
  145270. getClassName(): string;
  145271. /**
  145272. * Gets the seed input component
  145273. */
  145274. get seed(): NodeMaterialConnectionPoint;
  145275. /**
  145276. * Gets the jitter input component
  145277. */
  145278. get jitter(): NodeMaterialConnectionPoint;
  145279. /**
  145280. * Gets the output component
  145281. */
  145282. get output(): NodeMaterialConnectionPoint;
  145283. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145284. /**
  145285. * Exposes the properties to the UI?
  145286. */
  145287. protected _dumpPropertiesCode(): string;
  145288. /**
  145289. * Exposes the properties to the Seralize?
  145290. */
  145291. serialize(): any;
  145292. /**
  145293. * Exposes the properties to the deseralize?
  145294. */
  145295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145296. }
  145297. }
  145298. declare module BABYLON {
  145299. /**
  145300. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145301. */
  145302. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145303. /**
  145304. * Creates a new SimplexPerlin3DBlock
  145305. * @param name defines the block name
  145306. */
  145307. constructor(name: string);
  145308. /**
  145309. * Gets the current class name
  145310. * @returns the class name
  145311. */
  145312. getClassName(): string;
  145313. /**
  145314. * Gets the seed operand input component
  145315. */
  145316. get seed(): NodeMaterialConnectionPoint;
  145317. /**
  145318. * Gets the output component
  145319. */
  145320. get output(): NodeMaterialConnectionPoint;
  145321. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145322. }
  145323. }
  145324. declare module BABYLON {
  145325. /**
  145326. * Block used to blend normals
  145327. */
  145328. export class NormalBlendBlock extends NodeMaterialBlock {
  145329. /**
  145330. * Creates a new NormalBlendBlock
  145331. * @param name defines the block name
  145332. */
  145333. constructor(name: string);
  145334. /**
  145335. * Gets the current class name
  145336. * @returns the class name
  145337. */
  145338. getClassName(): string;
  145339. /**
  145340. * Gets the first input component
  145341. */
  145342. get normalMap0(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the second input component
  145345. */
  145346. get normalMap1(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the output component
  145349. */
  145350. get output(): NodeMaterialConnectionPoint;
  145351. protected _buildBlock(state: NodeMaterialBuildState): this;
  145352. }
  145353. }
  145354. declare module BABYLON {
  145355. /**
  145356. * Block used to rotate a 2d vector by a given angle
  145357. */
  145358. export class Rotate2dBlock extends NodeMaterialBlock {
  145359. /**
  145360. * Creates a new Rotate2dBlock
  145361. * @param name defines the block name
  145362. */
  145363. constructor(name: string);
  145364. /**
  145365. * Gets the current class name
  145366. * @returns the class name
  145367. */
  145368. getClassName(): string;
  145369. /**
  145370. * Gets the input vector
  145371. */
  145372. get input(): NodeMaterialConnectionPoint;
  145373. /**
  145374. * Gets the input angle
  145375. */
  145376. get angle(): NodeMaterialConnectionPoint;
  145377. /**
  145378. * Gets the output component
  145379. */
  145380. get output(): NodeMaterialConnectionPoint;
  145381. autoConfigure(material: NodeMaterial): void;
  145382. protected _buildBlock(state: NodeMaterialBuildState): this;
  145383. }
  145384. }
  145385. declare module BABYLON {
  145386. /**
  145387. * Block used to get the reflected vector from a direction and a normal
  145388. */
  145389. export class ReflectBlock extends NodeMaterialBlock {
  145390. /**
  145391. * Creates a new ReflectBlock
  145392. * @param name defines the block name
  145393. */
  145394. constructor(name: string);
  145395. /**
  145396. * Gets the current class name
  145397. * @returns the class name
  145398. */
  145399. getClassName(): string;
  145400. /**
  145401. * Gets the incident component
  145402. */
  145403. get incident(): NodeMaterialConnectionPoint;
  145404. /**
  145405. * Gets the normal component
  145406. */
  145407. get normal(): NodeMaterialConnectionPoint;
  145408. /**
  145409. * Gets the output component
  145410. */
  145411. get output(): NodeMaterialConnectionPoint;
  145412. protected _buildBlock(state: NodeMaterialBuildState): this;
  145413. }
  145414. }
  145415. declare module BABYLON {
  145416. /**
  145417. * Block used to get the refracted vector from a direction and a normal
  145418. */
  145419. export class RefractBlock extends NodeMaterialBlock {
  145420. /**
  145421. * Creates a new RefractBlock
  145422. * @param name defines the block name
  145423. */
  145424. constructor(name: string);
  145425. /**
  145426. * Gets the current class name
  145427. * @returns the class name
  145428. */
  145429. getClassName(): string;
  145430. /**
  145431. * Gets the incident component
  145432. */
  145433. get incident(): NodeMaterialConnectionPoint;
  145434. /**
  145435. * Gets the normal component
  145436. */
  145437. get normal(): NodeMaterialConnectionPoint;
  145438. /**
  145439. * Gets the index of refraction component
  145440. */
  145441. get ior(): NodeMaterialConnectionPoint;
  145442. /**
  145443. * Gets the output component
  145444. */
  145445. get output(): NodeMaterialConnectionPoint;
  145446. protected _buildBlock(state: NodeMaterialBuildState): this;
  145447. }
  145448. }
  145449. declare module BABYLON {
  145450. /**
  145451. * Block used to desaturate a color
  145452. */
  145453. export class DesaturateBlock extends NodeMaterialBlock {
  145454. /**
  145455. * Creates a new DesaturateBlock
  145456. * @param name defines the block name
  145457. */
  145458. constructor(name: string);
  145459. /**
  145460. * Gets the current class name
  145461. * @returns the class name
  145462. */
  145463. getClassName(): string;
  145464. /**
  145465. * Gets the color operand input component
  145466. */
  145467. get color(): NodeMaterialConnectionPoint;
  145468. /**
  145469. * Gets the level operand input component
  145470. */
  145471. get level(): NodeMaterialConnectionPoint;
  145472. /**
  145473. * Gets the output component
  145474. */
  145475. get output(): NodeMaterialConnectionPoint;
  145476. protected _buildBlock(state: NodeMaterialBuildState): this;
  145477. }
  145478. }
  145479. declare module BABYLON {
  145480. /**
  145481. * Block used to implement the ambient occlusion module of the PBR material
  145482. */
  145483. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145484. /**
  145485. * Create a new AmbientOcclusionBlock
  145486. * @param name defines the block name
  145487. */
  145488. constructor(name: string);
  145489. /**
  145490. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145491. */
  145492. useAmbientInGrayScale: boolean;
  145493. /**
  145494. * Initialize the block and prepare the context for build
  145495. * @param state defines the state that will be used for the build
  145496. */
  145497. initialize(state: NodeMaterialBuildState): void;
  145498. /**
  145499. * Gets the current class name
  145500. * @returns the class name
  145501. */
  145502. getClassName(): string;
  145503. /**
  145504. * Gets the texture input component
  145505. */
  145506. get texture(): NodeMaterialConnectionPoint;
  145507. /**
  145508. * Gets the texture intensity component
  145509. */
  145510. get intensity(): NodeMaterialConnectionPoint;
  145511. /**
  145512. * Gets the direct light intensity input component
  145513. */
  145514. get directLightIntensity(): NodeMaterialConnectionPoint;
  145515. /**
  145516. * Gets the ambient occlusion object output component
  145517. */
  145518. get ambientOcc(): NodeMaterialConnectionPoint;
  145519. /**
  145520. * Gets the main code of the block (fragment side)
  145521. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145522. * @returns the shader code
  145523. */
  145524. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145526. protected _buildBlock(state: NodeMaterialBuildState): this;
  145527. protected _dumpPropertiesCode(): string;
  145528. serialize(): any;
  145529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145530. }
  145531. }
  145532. declare module BABYLON {
  145533. /**
  145534. * Block used to implement the reflection module of the PBR material
  145535. */
  145536. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145537. /** @hidden */
  145538. _defineLODReflectionAlpha: string;
  145539. /** @hidden */
  145540. _defineLinearSpecularReflection: string;
  145541. private _vEnvironmentIrradianceName;
  145542. /** @hidden */
  145543. _vReflectionMicrosurfaceInfosName: string;
  145544. /** @hidden */
  145545. _vReflectionInfosName: string;
  145546. /** @hidden */
  145547. _vReflectionFilteringInfoName: string;
  145548. private _scene;
  145549. /**
  145550. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145551. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145552. * It's less burden on the user side in the editor part.
  145553. */
  145554. /** @hidden */
  145555. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145556. /** @hidden */
  145557. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145558. /** @hidden */
  145559. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145560. /**
  145561. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145562. * diffuse part of the IBL.
  145563. */
  145564. useSphericalHarmonics: boolean;
  145565. /**
  145566. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145567. */
  145568. forceIrradianceInFragment: boolean;
  145569. /**
  145570. * Create a new ReflectionBlock
  145571. * @param name defines the block name
  145572. */
  145573. constructor(name: string);
  145574. /**
  145575. * Gets the current class name
  145576. * @returns the class name
  145577. */
  145578. getClassName(): string;
  145579. /**
  145580. * Gets the position input component
  145581. */
  145582. get position(): NodeMaterialConnectionPoint;
  145583. /**
  145584. * Gets the world position input component
  145585. */
  145586. get worldPosition(): NodeMaterialConnectionPoint;
  145587. /**
  145588. * Gets the world normal input component
  145589. */
  145590. get worldNormal(): NodeMaterialConnectionPoint;
  145591. /**
  145592. * Gets the world input component
  145593. */
  145594. get world(): NodeMaterialConnectionPoint;
  145595. /**
  145596. * Gets the camera (or eye) position component
  145597. */
  145598. get cameraPosition(): NodeMaterialConnectionPoint;
  145599. /**
  145600. * Gets the view input component
  145601. */
  145602. get view(): NodeMaterialConnectionPoint;
  145603. /**
  145604. * Gets the color input component
  145605. */
  145606. get color(): NodeMaterialConnectionPoint;
  145607. /**
  145608. * Gets the reflection object output component
  145609. */
  145610. get reflection(): NodeMaterialConnectionPoint;
  145611. /**
  145612. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145613. */
  145614. get hasTexture(): boolean;
  145615. /**
  145616. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145617. */
  145618. get reflectionColor(): string;
  145619. protected _getTexture(): Nullable<BaseTexture>;
  145620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145622. /**
  145623. * Gets the code to inject in the vertex shader
  145624. * @param state current state of the node material building
  145625. * @returns the shader code
  145626. */
  145627. handleVertexSide(state: NodeMaterialBuildState): string;
  145628. /**
  145629. * Gets the main code of the block (fragment side)
  145630. * @param state current state of the node material building
  145631. * @param normalVarName name of the existing variable corresponding to the normal
  145632. * @returns the shader code
  145633. */
  145634. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145635. protected _buildBlock(state: NodeMaterialBuildState): this;
  145636. protected _dumpPropertiesCode(): string;
  145637. serialize(): any;
  145638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145639. }
  145640. }
  145641. declare module BABYLON {
  145642. /**
  145643. * Block used to implement the sheen module of the PBR material
  145644. */
  145645. export class SheenBlock extends NodeMaterialBlock {
  145646. /**
  145647. * Create a new SheenBlock
  145648. * @param name defines the block name
  145649. */
  145650. constructor(name: string);
  145651. /**
  145652. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145653. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145654. * making it easier to setup and tweak the effect
  145655. */
  145656. albedoScaling: boolean;
  145657. /**
  145658. * Defines if the sheen is linked to the sheen color.
  145659. */
  145660. linkSheenWithAlbedo: boolean;
  145661. /**
  145662. * Initialize the block and prepare the context for build
  145663. * @param state defines the state that will be used for the build
  145664. */
  145665. initialize(state: NodeMaterialBuildState): void;
  145666. /**
  145667. * Gets the current class name
  145668. * @returns the class name
  145669. */
  145670. getClassName(): string;
  145671. /**
  145672. * Gets the intensity input component
  145673. */
  145674. get intensity(): NodeMaterialConnectionPoint;
  145675. /**
  145676. * Gets the color input component
  145677. */
  145678. get color(): NodeMaterialConnectionPoint;
  145679. /**
  145680. * Gets the roughness input component
  145681. */
  145682. get roughness(): NodeMaterialConnectionPoint;
  145683. /**
  145684. * Gets the sheen object output component
  145685. */
  145686. get sheen(): NodeMaterialConnectionPoint;
  145687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145688. /**
  145689. * Gets the main code of the block (fragment side)
  145690. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145691. * @returns the shader code
  145692. */
  145693. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145694. protected _buildBlock(state: NodeMaterialBuildState): this;
  145695. protected _dumpPropertiesCode(): string;
  145696. serialize(): any;
  145697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145698. }
  145699. }
  145700. declare module BABYLON {
  145701. /**
  145702. * Block used to implement the reflectivity module of the PBR material
  145703. */
  145704. export class ReflectivityBlock extends NodeMaterialBlock {
  145705. private _metallicReflectanceColor;
  145706. private _metallicF0Factor;
  145707. /** @hidden */
  145708. _vMetallicReflectanceFactorsName: string;
  145709. /**
  145710. * The property below is set by the main PBR block prior to calling methods of this class.
  145711. */
  145712. /** @hidden */
  145713. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145714. /**
  145715. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145716. */
  145717. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145718. /**
  145719. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145720. */
  145721. useMetallnessFromMetallicTextureBlue: boolean;
  145722. /**
  145723. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145724. */
  145725. useRoughnessFromMetallicTextureAlpha: boolean;
  145726. /**
  145727. * Specifies if the metallic texture contains the roughness information in its green channel.
  145728. */
  145729. useRoughnessFromMetallicTextureGreen: boolean;
  145730. /**
  145731. * Create a new ReflectivityBlock
  145732. * @param name defines the block name
  145733. */
  145734. constructor(name: string);
  145735. /**
  145736. * Initialize the block and prepare the context for build
  145737. * @param state defines the state that will be used for the build
  145738. */
  145739. initialize(state: NodeMaterialBuildState): void;
  145740. /**
  145741. * Gets the current class name
  145742. * @returns the class name
  145743. */
  145744. getClassName(): string;
  145745. /**
  145746. * Gets the metallic input component
  145747. */
  145748. get metallic(): NodeMaterialConnectionPoint;
  145749. /**
  145750. * Gets the roughness input component
  145751. */
  145752. get roughness(): NodeMaterialConnectionPoint;
  145753. /**
  145754. * Gets the texture input component
  145755. */
  145756. get texture(): NodeMaterialConnectionPoint;
  145757. /**
  145758. * Gets the reflectivity object output component
  145759. */
  145760. get reflectivity(): NodeMaterialConnectionPoint;
  145761. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145762. /**
  145763. * Gets the main code of the block (fragment side)
  145764. * @param state current state of the node material building
  145765. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145766. * @returns the shader code
  145767. */
  145768. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145770. protected _buildBlock(state: NodeMaterialBuildState): this;
  145771. protected _dumpPropertiesCode(): string;
  145772. serialize(): any;
  145773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145774. }
  145775. }
  145776. declare module BABYLON {
  145777. /**
  145778. * Block used to implement the anisotropy module of the PBR material
  145779. */
  145780. export class AnisotropyBlock extends NodeMaterialBlock {
  145781. /**
  145782. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145783. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145784. * It's less burden on the user side in the editor part.
  145785. */
  145786. /** @hidden */
  145787. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145788. /** @hidden */
  145789. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145790. /**
  145791. * Create a new AnisotropyBlock
  145792. * @param name defines the block name
  145793. */
  145794. constructor(name: string);
  145795. /**
  145796. * Initialize the block and prepare the context for build
  145797. * @param state defines the state that will be used for the build
  145798. */
  145799. initialize(state: NodeMaterialBuildState): void;
  145800. /**
  145801. * Gets the current class name
  145802. * @returns the class name
  145803. */
  145804. getClassName(): string;
  145805. /**
  145806. * Gets the intensity input component
  145807. */
  145808. get intensity(): NodeMaterialConnectionPoint;
  145809. /**
  145810. * Gets the direction input component
  145811. */
  145812. get direction(): NodeMaterialConnectionPoint;
  145813. /**
  145814. * Gets the texture input component
  145815. */
  145816. get texture(): NodeMaterialConnectionPoint;
  145817. /**
  145818. * Gets the uv input component
  145819. */
  145820. get uv(): NodeMaterialConnectionPoint;
  145821. /**
  145822. * Gets the worldTangent input component
  145823. */
  145824. get worldTangent(): NodeMaterialConnectionPoint;
  145825. /**
  145826. * Gets the anisotropy object output component
  145827. */
  145828. get anisotropy(): NodeMaterialConnectionPoint;
  145829. private _generateTBNSpace;
  145830. /**
  145831. * Gets the main code of the block (fragment side)
  145832. * @param state current state of the node material building
  145833. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145834. * @returns the shader code
  145835. */
  145836. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145838. protected _buildBlock(state: NodeMaterialBuildState): this;
  145839. }
  145840. }
  145841. declare module BABYLON {
  145842. /**
  145843. * Block used to implement the clear coat module of the PBR material
  145844. */
  145845. export class ClearCoatBlock extends NodeMaterialBlock {
  145846. private _scene;
  145847. /**
  145848. * Create a new ClearCoatBlock
  145849. * @param name defines the block name
  145850. */
  145851. constructor(name: string);
  145852. /**
  145853. * Initialize the block and prepare the context for build
  145854. * @param state defines the state that will be used for the build
  145855. */
  145856. initialize(state: NodeMaterialBuildState): void;
  145857. /**
  145858. * Gets the current class name
  145859. * @returns the class name
  145860. */
  145861. getClassName(): string;
  145862. /**
  145863. * Gets the intensity input component
  145864. */
  145865. get intensity(): NodeMaterialConnectionPoint;
  145866. /**
  145867. * Gets the roughness input component
  145868. */
  145869. get roughness(): NodeMaterialConnectionPoint;
  145870. /**
  145871. * Gets the ior input component
  145872. */
  145873. get ior(): NodeMaterialConnectionPoint;
  145874. /**
  145875. * Gets the texture input component
  145876. */
  145877. get texture(): NodeMaterialConnectionPoint;
  145878. /**
  145879. * Gets the bump texture input component
  145880. */
  145881. get bumpTexture(): NodeMaterialConnectionPoint;
  145882. /**
  145883. * Gets the uv input component
  145884. */
  145885. get uv(): NodeMaterialConnectionPoint;
  145886. /**
  145887. * Gets the tint color input component
  145888. */
  145889. get tintColor(): NodeMaterialConnectionPoint;
  145890. /**
  145891. * Gets the tint "at distance" input component
  145892. */
  145893. get tintAtDistance(): NodeMaterialConnectionPoint;
  145894. /**
  145895. * Gets the tint thickness input component
  145896. */
  145897. get tintThickness(): NodeMaterialConnectionPoint;
  145898. /**
  145899. * Gets the world tangent input component
  145900. */
  145901. get worldTangent(): NodeMaterialConnectionPoint;
  145902. /**
  145903. * Gets the clear coat object output component
  145904. */
  145905. get clearcoat(): NodeMaterialConnectionPoint;
  145906. autoConfigure(material: NodeMaterial): void;
  145907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145909. private _generateTBNSpace;
  145910. /**
  145911. * Gets the main code of the block (fragment side)
  145912. * @param state current state of the node material building
  145913. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145914. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145915. * @param worldPosVarName name of the variable holding the world position
  145916. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145917. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145918. * @param worldNormalVarName name of the variable holding the world normal
  145919. * @returns the shader code
  145920. */
  145921. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145922. protected _buildBlock(state: NodeMaterialBuildState): this;
  145923. }
  145924. }
  145925. declare module BABYLON {
  145926. /**
  145927. * Block used to implement the sub surface module of the PBR material
  145928. */
  145929. export class SubSurfaceBlock extends NodeMaterialBlock {
  145930. /**
  145931. * Create a new SubSurfaceBlock
  145932. * @param name defines the block name
  145933. */
  145934. constructor(name: string);
  145935. /**
  145936. * Stores the intensity of the different subsurface effects in the thickness texture.
  145937. * * the green channel is the translucency intensity.
  145938. * * the blue channel is the scattering intensity.
  145939. * * the alpha channel is the refraction intensity.
  145940. */
  145941. useMaskFromThicknessTexture: boolean;
  145942. /**
  145943. * Initialize the block and prepare the context for build
  145944. * @param state defines the state that will be used for the build
  145945. */
  145946. initialize(state: NodeMaterialBuildState): void;
  145947. /**
  145948. * Gets the current class name
  145949. * @returns the class name
  145950. */
  145951. getClassName(): string;
  145952. /**
  145953. * Gets the min thickness input component
  145954. */
  145955. get minThickness(): NodeMaterialConnectionPoint;
  145956. /**
  145957. * Gets the max thickness input component
  145958. */
  145959. get maxThickness(): NodeMaterialConnectionPoint;
  145960. /**
  145961. * Gets the thickness texture component
  145962. */
  145963. get thicknessTexture(): NodeMaterialConnectionPoint;
  145964. /**
  145965. * Gets the tint color input component
  145966. */
  145967. get tintColor(): NodeMaterialConnectionPoint;
  145968. /**
  145969. * Gets the translucency intensity input component
  145970. */
  145971. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145972. /**
  145973. * Gets the translucency diffusion distance input component
  145974. */
  145975. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145976. /**
  145977. * Gets the refraction object parameters
  145978. */
  145979. get refraction(): NodeMaterialConnectionPoint;
  145980. /**
  145981. * Gets the sub surface object output component
  145982. */
  145983. get subsurface(): NodeMaterialConnectionPoint;
  145984. autoConfigure(material: NodeMaterial): void;
  145985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145986. /**
  145987. * Gets the main code of the block (fragment side)
  145988. * @param state current state of the node material building
  145989. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145990. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145991. * @param worldPosVarName name of the variable holding the world position
  145992. * @returns the shader code
  145993. */
  145994. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145995. protected _buildBlock(state: NodeMaterialBuildState): this;
  145996. }
  145997. }
  145998. declare module BABYLON {
  145999. /**
  146000. * Block used to implement the PBR metallic/roughness model
  146001. */
  146002. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146003. /**
  146004. * Gets or sets the light associated with this block
  146005. */
  146006. light: Nullable<Light>;
  146007. private _lightId;
  146008. private _scene;
  146009. private _environmentBRDFTexture;
  146010. private _environmentBrdfSamplerName;
  146011. private _vNormalWName;
  146012. private _invertNormalName;
  146013. /**
  146014. * Create a new ReflectionBlock
  146015. * @param name defines the block name
  146016. */
  146017. constructor(name: string);
  146018. /**
  146019. * Intensity of the direct lights e.g. the four lights available in your scene.
  146020. * This impacts both the direct diffuse and specular highlights.
  146021. */
  146022. directIntensity: number;
  146023. /**
  146024. * Intensity of the environment e.g. how much the environment will light the object
  146025. * either through harmonics for rough material or through the refelction for shiny ones.
  146026. */
  146027. environmentIntensity: number;
  146028. /**
  146029. * This is a special control allowing the reduction of the specular highlights coming from the
  146030. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146031. */
  146032. specularIntensity: number;
  146033. /**
  146034. * Defines the falloff type used in this material.
  146035. * It by default is Physical.
  146036. */
  146037. lightFalloff: number;
  146038. /**
  146039. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146040. */
  146041. useAlphaFromAlbedoTexture: boolean;
  146042. /**
  146043. * Specifies that alpha test should be used
  146044. */
  146045. useAlphaTest: boolean;
  146046. /**
  146047. * Defines the alpha limits in alpha test mode.
  146048. */
  146049. alphaTestCutoff: number;
  146050. /**
  146051. * Specifies that alpha blending should be used
  146052. */
  146053. useAlphaBlending: boolean;
  146054. /**
  146055. * Defines if the alpha value should be determined via the rgb values.
  146056. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146057. */
  146058. opacityRGB: boolean;
  146059. /**
  146060. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146061. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146062. */
  146063. useRadianceOverAlpha: boolean;
  146064. /**
  146065. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146066. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146067. */
  146068. useSpecularOverAlpha: boolean;
  146069. /**
  146070. * Enables specular anti aliasing in the PBR shader.
  146071. * It will both interacts on the Geometry for analytical and IBL lighting.
  146072. * It also prefilter the roughness map based on the bump values.
  146073. */
  146074. enableSpecularAntiAliasing: boolean;
  146075. /**
  146076. * Enables realtime filtering on the texture.
  146077. */
  146078. realTimeFiltering: boolean;
  146079. /**
  146080. * Quality switch for realtime filtering
  146081. */
  146082. realTimeFilteringQuality: number;
  146083. /**
  146084. * Defines if the material uses energy conservation.
  146085. */
  146086. useEnergyConservation: boolean;
  146087. /**
  146088. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146089. * too much the area relying on ambient texture to define their ambient occlusion.
  146090. */
  146091. useRadianceOcclusion: boolean;
  146092. /**
  146093. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146094. * makes the reflect vector face the model (under horizon).
  146095. */
  146096. useHorizonOcclusion: boolean;
  146097. /**
  146098. * If set to true, no lighting calculations will be applied.
  146099. */
  146100. unlit: boolean;
  146101. /**
  146102. * Force normal to face away from face.
  146103. */
  146104. forceNormalForward: boolean;
  146105. /**
  146106. * Defines the material debug mode.
  146107. * It helps seeing only some components of the material while troubleshooting.
  146108. */
  146109. debugMode: number;
  146110. /**
  146111. * Specify from where on screen the debug mode should start.
  146112. * The value goes from -1 (full screen) to 1 (not visible)
  146113. * It helps with side by side comparison against the final render
  146114. * This defaults to 0
  146115. */
  146116. debugLimit: number;
  146117. /**
  146118. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146119. * You can use the factor to better multiply the final value.
  146120. */
  146121. debugFactor: number;
  146122. /**
  146123. * Initialize the block and prepare the context for build
  146124. * @param state defines the state that will be used for the build
  146125. */
  146126. initialize(state: NodeMaterialBuildState): void;
  146127. /**
  146128. * Gets the current class name
  146129. * @returns the class name
  146130. */
  146131. getClassName(): string;
  146132. /**
  146133. * Gets the world position input component
  146134. */
  146135. get worldPosition(): NodeMaterialConnectionPoint;
  146136. /**
  146137. * Gets the world normal input component
  146138. */
  146139. get worldNormal(): NodeMaterialConnectionPoint;
  146140. /**
  146141. * Gets the perturbed normal input component
  146142. */
  146143. get perturbedNormal(): NodeMaterialConnectionPoint;
  146144. /**
  146145. * Gets the camera position input component
  146146. */
  146147. get cameraPosition(): NodeMaterialConnectionPoint;
  146148. /**
  146149. * Gets the base color input component
  146150. */
  146151. get baseColor(): NodeMaterialConnectionPoint;
  146152. /**
  146153. * Gets the opacity texture input component
  146154. */
  146155. get opacityTexture(): NodeMaterialConnectionPoint;
  146156. /**
  146157. * Gets the ambient color input component
  146158. */
  146159. get ambientColor(): NodeMaterialConnectionPoint;
  146160. /**
  146161. * Gets the reflectivity object parameters
  146162. */
  146163. get reflectivity(): NodeMaterialConnectionPoint;
  146164. /**
  146165. * Gets the ambient occlusion object parameters
  146166. */
  146167. get ambientOcc(): NodeMaterialConnectionPoint;
  146168. /**
  146169. * Gets the reflection object parameters
  146170. */
  146171. get reflection(): NodeMaterialConnectionPoint;
  146172. /**
  146173. * Gets the sheen object parameters
  146174. */
  146175. get sheen(): NodeMaterialConnectionPoint;
  146176. /**
  146177. * Gets the clear coat object parameters
  146178. */
  146179. get clearcoat(): NodeMaterialConnectionPoint;
  146180. /**
  146181. * Gets the sub surface object parameters
  146182. */
  146183. get subsurface(): NodeMaterialConnectionPoint;
  146184. /**
  146185. * Gets the anisotropy object parameters
  146186. */
  146187. get anisotropy(): NodeMaterialConnectionPoint;
  146188. /**
  146189. * Gets the ambient output component
  146190. */
  146191. get ambient(): NodeMaterialConnectionPoint;
  146192. /**
  146193. * Gets the diffuse output component
  146194. */
  146195. get diffuse(): NodeMaterialConnectionPoint;
  146196. /**
  146197. * Gets the specular output component
  146198. */
  146199. get specular(): NodeMaterialConnectionPoint;
  146200. /**
  146201. * Gets the sheen output component
  146202. */
  146203. get sheenDir(): NodeMaterialConnectionPoint;
  146204. /**
  146205. * Gets the clear coat output component
  146206. */
  146207. get clearcoatDir(): NodeMaterialConnectionPoint;
  146208. /**
  146209. * Gets the indirect diffuse output component
  146210. */
  146211. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146212. /**
  146213. * Gets the indirect specular output component
  146214. */
  146215. get specularIndirect(): NodeMaterialConnectionPoint;
  146216. /**
  146217. * Gets the indirect sheen output component
  146218. */
  146219. get sheenIndirect(): NodeMaterialConnectionPoint;
  146220. /**
  146221. * Gets the indirect clear coat output component
  146222. */
  146223. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146224. /**
  146225. * Gets the refraction output component
  146226. */
  146227. get refraction(): NodeMaterialConnectionPoint;
  146228. /**
  146229. * Gets the global lighting output component
  146230. */
  146231. get lighting(): NodeMaterialConnectionPoint;
  146232. /**
  146233. * Gets the shadow output component
  146234. */
  146235. get shadow(): NodeMaterialConnectionPoint;
  146236. /**
  146237. * Gets the alpha output component
  146238. */
  146239. get alpha(): NodeMaterialConnectionPoint;
  146240. autoConfigure(material: NodeMaterial): void;
  146241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146242. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146244. private _injectVertexCode;
  146245. /**
  146246. * Gets the code corresponding to the albedo/opacity module
  146247. * @returns the shader code
  146248. */
  146249. getAlbedoOpacityCode(): string;
  146250. protected _buildBlock(state: NodeMaterialBuildState): this;
  146251. protected _dumpPropertiesCode(): string;
  146252. serialize(): any;
  146253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146254. }
  146255. }
  146256. declare module BABYLON {
  146257. /**
  146258. * Block used to compute value of one parameter modulo another
  146259. */
  146260. export class ModBlock extends NodeMaterialBlock {
  146261. /**
  146262. * Creates a new ModBlock
  146263. * @param name defines the block name
  146264. */
  146265. constructor(name: string);
  146266. /**
  146267. * Gets the current class name
  146268. * @returns the class name
  146269. */
  146270. getClassName(): string;
  146271. /**
  146272. * Gets the left operand input component
  146273. */
  146274. get left(): NodeMaterialConnectionPoint;
  146275. /**
  146276. * Gets the right operand input component
  146277. */
  146278. get right(): NodeMaterialConnectionPoint;
  146279. /**
  146280. * Gets the output component
  146281. */
  146282. get output(): NodeMaterialConnectionPoint;
  146283. protected _buildBlock(state: NodeMaterialBuildState): this;
  146284. }
  146285. }
  146286. declare module BABYLON {
  146287. /**
  146288. * Configuration for Draco compression
  146289. */
  146290. export interface IDracoCompressionConfiguration {
  146291. /**
  146292. * Configuration for the decoder.
  146293. */
  146294. decoder: {
  146295. /**
  146296. * The url to the WebAssembly module.
  146297. */
  146298. wasmUrl?: string;
  146299. /**
  146300. * The url to the WebAssembly binary.
  146301. */
  146302. wasmBinaryUrl?: string;
  146303. /**
  146304. * The url to the fallback JavaScript module.
  146305. */
  146306. fallbackUrl?: string;
  146307. };
  146308. }
  146309. /**
  146310. * Draco compression (https://google.github.io/draco/)
  146311. *
  146312. * This class wraps the Draco module.
  146313. *
  146314. * **Encoder**
  146315. *
  146316. * The encoder is not currently implemented.
  146317. *
  146318. * **Decoder**
  146319. *
  146320. * 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.
  146321. *
  146322. * To update the configuration, use the following code:
  146323. * ```javascript
  146324. * DracoCompression.Configuration = {
  146325. * decoder: {
  146326. * wasmUrl: "<url to the WebAssembly library>",
  146327. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146328. * fallbackUrl: "<url to the fallback JavaScript library>",
  146329. * }
  146330. * };
  146331. * ```
  146332. *
  146333. * 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.
  146334. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146335. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146336. *
  146337. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146338. * ```javascript
  146339. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146340. * ```
  146341. *
  146342. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146343. */
  146344. export class DracoCompression implements IDisposable {
  146345. private _workerPoolPromise?;
  146346. private _decoderModulePromise?;
  146347. /**
  146348. * The configuration. Defaults to the following urls:
  146349. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146350. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146351. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146352. */
  146353. static Configuration: IDracoCompressionConfiguration;
  146354. /**
  146355. * Returns true if the decoder configuration is available.
  146356. */
  146357. static get DecoderAvailable(): boolean;
  146358. /**
  146359. * Default number of workers to create when creating the draco compression object.
  146360. */
  146361. static DefaultNumWorkers: number;
  146362. private static GetDefaultNumWorkers;
  146363. private static _Default;
  146364. /**
  146365. * Default instance for the draco compression object.
  146366. */
  146367. static get Default(): DracoCompression;
  146368. /**
  146369. * Constructor
  146370. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146371. */
  146372. constructor(numWorkers?: number);
  146373. /**
  146374. * Stop all async operations and release resources.
  146375. */
  146376. dispose(): void;
  146377. /**
  146378. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146379. * @returns a promise that resolves when ready
  146380. */
  146381. whenReadyAsync(): Promise<void>;
  146382. /**
  146383. * Decode Draco compressed mesh data to vertex data.
  146384. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146385. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146386. * @returns A promise that resolves with the decoded vertex data
  146387. */
  146388. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146389. [kind: string]: number;
  146390. }): Promise<VertexData>;
  146391. }
  146392. }
  146393. declare module BABYLON {
  146394. /**
  146395. * Class for building Constructive Solid Geometry
  146396. */
  146397. export class CSG {
  146398. private polygons;
  146399. /**
  146400. * The world matrix
  146401. */
  146402. matrix: Matrix;
  146403. /**
  146404. * Stores the position
  146405. */
  146406. position: Vector3;
  146407. /**
  146408. * Stores the rotation
  146409. */
  146410. rotation: Vector3;
  146411. /**
  146412. * Stores the rotation quaternion
  146413. */
  146414. rotationQuaternion: Nullable<Quaternion>;
  146415. /**
  146416. * Stores the scaling vector
  146417. */
  146418. scaling: Vector3;
  146419. /**
  146420. * Convert the Mesh to CSG
  146421. * @param mesh The Mesh to convert to CSG
  146422. * @returns A new CSG from the Mesh
  146423. */
  146424. static FromMesh(mesh: Mesh): CSG;
  146425. /**
  146426. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146427. * @param polygons Polygons used to construct a CSG solid
  146428. */
  146429. private static FromPolygons;
  146430. /**
  146431. * Clones, or makes a deep copy, of the CSG
  146432. * @returns A new CSG
  146433. */
  146434. clone(): CSG;
  146435. /**
  146436. * Unions this CSG with another CSG
  146437. * @param csg The CSG to union against this CSG
  146438. * @returns The unioned CSG
  146439. */
  146440. union(csg: CSG): CSG;
  146441. /**
  146442. * Unions this CSG with another CSG in place
  146443. * @param csg The CSG to union against this CSG
  146444. */
  146445. unionInPlace(csg: CSG): void;
  146446. /**
  146447. * Subtracts this CSG with another CSG
  146448. * @param csg The CSG to subtract against this CSG
  146449. * @returns A new CSG
  146450. */
  146451. subtract(csg: CSG): CSG;
  146452. /**
  146453. * Subtracts this CSG with another CSG in place
  146454. * @param csg The CSG to subtact against this CSG
  146455. */
  146456. subtractInPlace(csg: CSG): void;
  146457. /**
  146458. * Intersect this CSG with another CSG
  146459. * @param csg The CSG to intersect against this CSG
  146460. * @returns A new CSG
  146461. */
  146462. intersect(csg: CSG): CSG;
  146463. /**
  146464. * Intersects this CSG with another CSG in place
  146465. * @param csg The CSG to intersect against this CSG
  146466. */
  146467. intersectInPlace(csg: CSG): void;
  146468. /**
  146469. * Return a new CSG solid with solid and empty space switched. This solid is
  146470. * not modified.
  146471. * @returns A new CSG solid with solid and empty space switched
  146472. */
  146473. inverse(): CSG;
  146474. /**
  146475. * Inverses the CSG in place
  146476. */
  146477. inverseInPlace(): void;
  146478. /**
  146479. * This is used to keep meshes transformations so they can be restored
  146480. * when we build back a Babylon Mesh
  146481. * NB : All CSG operations are performed in world coordinates
  146482. * @param csg The CSG to copy the transform attributes from
  146483. * @returns This CSG
  146484. */
  146485. copyTransformAttributes(csg: CSG): CSG;
  146486. /**
  146487. * Build Raw mesh from CSG
  146488. * Coordinates here are in world space
  146489. * @param name The name of the mesh geometry
  146490. * @param scene The Scene
  146491. * @param keepSubMeshes Specifies if the submeshes should be kept
  146492. * @returns A new Mesh
  146493. */
  146494. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146495. /**
  146496. * Build Mesh from CSG taking material and transforms into account
  146497. * @param name The name of the Mesh
  146498. * @param material The material of the Mesh
  146499. * @param scene The Scene
  146500. * @param keepSubMeshes Specifies if submeshes should be kept
  146501. * @returns The new Mesh
  146502. */
  146503. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146504. }
  146505. }
  146506. declare module BABYLON {
  146507. /**
  146508. * Class used to create a trail following a mesh
  146509. */
  146510. export class TrailMesh extends Mesh {
  146511. private _generator;
  146512. private _autoStart;
  146513. private _running;
  146514. private _diameter;
  146515. private _length;
  146516. private _sectionPolygonPointsCount;
  146517. private _sectionVectors;
  146518. private _sectionNormalVectors;
  146519. private _beforeRenderObserver;
  146520. /**
  146521. * @constructor
  146522. * @param name The value used by scene.getMeshByName() to do a lookup.
  146523. * @param generator The mesh or transform node to generate a trail.
  146524. * @param scene The scene to add this mesh to.
  146525. * @param diameter Diameter of trailing mesh. Default is 1.
  146526. * @param length Length of trailing mesh. Default is 60.
  146527. * @param autoStart Automatically start trailing mesh. Default true.
  146528. */
  146529. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146530. /**
  146531. * "TrailMesh"
  146532. * @returns "TrailMesh"
  146533. */
  146534. getClassName(): string;
  146535. private _createMesh;
  146536. /**
  146537. * Start trailing mesh.
  146538. */
  146539. start(): void;
  146540. /**
  146541. * Stop trailing mesh.
  146542. */
  146543. stop(): void;
  146544. /**
  146545. * Update trailing mesh geometry.
  146546. */
  146547. update(): void;
  146548. /**
  146549. * Returns a new TrailMesh object.
  146550. * @param name is a string, the name given to the new mesh
  146551. * @param newGenerator use new generator object for cloned trail mesh
  146552. * @returns a new mesh
  146553. */
  146554. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146555. /**
  146556. * Serializes this trail mesh
  146557. * @param serializationObject object to write serialization to
  146558. */
  146559. serialize(serializationObject: any): void;
  146560. /**
  146561. * Parses a serialized trail mesh
  146562. * @param parsedMesh the serialized mesh
  146563. * @param scene the scene to create the trail mesh in
  146564. * @returns the created trail mesh
  146565. */
  146566. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146567. }
  146568. }
  146569. declare module BABYLON {
  146570. /**
  146571. * Class containing static functions to help procedurally build meshes
  146572. */
  146573. export class TiledBoxBuilder {
  146574. /**
  146575. * Creates a box mesh
  146576. * 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)
  146577. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146581. * @param name defines the name of the mesh
  146582. * @param options defines the options used to create the mesh
  146583. * @param scene defines the hosting scene
  146584. * @returns the box mesh
  146585. */
  146586. static CreateTiledBox(name: string, options: {
  146587. pattern?: number;
  146588. width?: number;
  146589. height?: number;
  146590. depth?: number;
  146591. tileSize?: number;
  146592. tileWidth?: number;
  146593. tileHeight?: number;
  146594. alignHorizontal?: number;
  146595. alignVertical?: number;
  146596. faceUV?: Vector4[];
  146597. faceColors?: Color4[];
  146598. sideOrientation?: number;
  146599. updatable?: boolean;
  146600. }, scene?: Nullable<Scene>): Mesh;
  146601. }
  146602. }
  146603. declare module BABYLON {
  146604. /**
  146605. * Class containing static functions to help procedurally build meshes
  146606. */
  146607. export class TorusKnotBuilder {
  146608. /**
  146609. * Creates a torus knot mesh
  146610. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146611. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146612. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146613. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146617. * @param name defines the name of the mesh
  146618. * @param options defines the options used to create the mesh
  146619. * @param scene defines the hosting scene
  146620. * @returns the torus knot mesh
  146621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146622. */
  146623. static CreateTorusKnot(name: string, options: {
  146624. radius?: number;
  146625. tube?: number;
  146626. radialSegments?: number;
  146627. tubularSegments?: number;
  146628. p?: number;
  146629. q?: number;
  146630. updatable?: boolean;
  146631. sideOrientation?: number;
  146632. frontUVs?: Vector4;
  146633. backUVs?: Vector4;
  146634. }, scene: any): Mesh;
  146635. }
  146636. }
  146637. declare module BABYLON {
  146638. /**
  146639. * Polygon
  146640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146641. */
  146642. export class Polygon {
  146643. /**
  146644. * Creates a rectangle
  146645. * @param xmin bottom X coord
  146646. * @param ymin bottom Y coord
  146647. * @param xmax top X coord
  146648. * @param ymax top Y coord
  146649. * @returns points that make the resulting rectation
  146650. */
  146651. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146652. /**
  146653. * Creates a circle
  146654. * @param radius radius of circle
  146655. * @param cx scale in x
  146656. * @param cy scale in y
  146657. * @param numberOfSides number of sides that make up the circle
  146658. * @returns points that make the resulting circle
  146659. */
  146660. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146661. /**
  146662. * Creates a polygon from input string
  146663. * @param input Input polygon data
  146664. * @returns the parsed points
  146665. */
  146666. static Parse(input: string): Vector2[];
  146667. /**
  146668. * Starts building a polygon from x and y coordinates
  146669. * @param x x coordinate
  146670. * @param y y coordinate
  146671. * @returns the started path2
  146672. */
  146673. static StartingAt(x: number, y: number): Path2;
  146674. }
  146675. /**
  146676. * Builds a polygon
  146677. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146678. */
  146679. export class PolygonMeshBuilder {
  146680. private _points;
  146681. private _outlinepoints;
  146682. private _holes;
  146683. private _name;
  146684. private _scene;
  146685. private _epoints;
  146686. private _eholes;
  146687. private _addToepoint;
  146688. /**
  146689. * Babylon reference to the earcut plugin.
  146690. */
  146691. bjsEarcut: any;
  146692. /**
  146693. * Creates a PolygonMeshBuilder
  146694. * @param name name of the builder
  146695. * @param contours Path of the polygon
  146696. * @param scene scene to add to when creating the mesh
  146697. * @param earcutInjection can be used to inject your own earcut reference
  146698. */
  146699. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146700. /**
  146701. * Adds a whole within the polygon
  146702. * @param hole Array of points defining the hole
  146703. * @returns this
  146704. */
  146705. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146706. /**
  146707. * Creates the polygon
  146708. * @param updatable If the mesh should be updatable
  146709. * @param depth The depth of the mesh created
  146710. * @returns the created mesh
  146711. */
  146712. build(updatable?: boolean, depth?: number): Mesh;
  146713. /**
  146714. * Creates the polygon
  146715. * @param depth The depth of the mesh created
  146716. * @returns the created VertexData
  146717. */
  146718. buildVertexData(depth?: number): VertexData;
  146719. /**
  146720. * Adds a side to the polygon
  146721. * @param positions points that make the polygon
  146722. * @param normals normals of the polygon
  146723. * @param uvs uvs of the polygon
  146724. * @param indices indices of the polygon
  146725. * @param bounds bounds of the polygon
  146726. * @param points points of the polygon
  146727. * @param depth depth of the polygon
  146728. * @param flip flip of the polygon
  146729. */
  146730. private addSide;
  146731. }
  146732. }
  146733. declare module BABYLON {
  146734. /**
  146735. * Class containing static functions to help procedurally build meshes
  146736. */
  146737. export class PolygonBuilder {
  146738. /**
  146739. * Creates a polygon mesh
  146740. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146741. * * 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
  146742. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146745. * * Remember you can only change the shape positions, not their number when updating a polygon
  146746. * @param name defines the name of the mesh
  146747. * @param options defines the options used to create the mesh
  146748. * @param scene defines the hosting scene
  146749. * @param earcutInjection can be used to inject your own earcut reference
  146750. * @returns the polygon mesh
  146751. */
  146752. static CreatePolygon(name: string, options: {
  146753. shape: Vector3[];
  146754. holes?: Vector3[][];
  146755. depth?: number;
  146756. faceUV?: Vector4[];
  146757. faceColors?: Color4[];
  146758. updatable?: boolean;
  146759. sideOrientation?: number;
  146760. frontUVs?: Vector4;
  146761. backUVs?: Vector4;
  146762. wrap?: boolean;
  146763. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146764. /**
  146765. * Creates an extruded polygon mesh, with depth in the Y direction.
  146766. * * 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)
  146767. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146768. * @param name defines the name of the mesh
  146769. * @param options defines the options used to create the mesh
  146770. * @param scene defines the hosting scene
  146771. * @param earcutInjection can be used to inject your own earcut reference
  146772. * @returns the polygon mesh
  146773. */
  146774. static ExtrudePolygon(name: string, options: {
  146775. shape: Vector3[];
  146776. holes?: Vector3[][];
  146777. depth?: number;
  146778. faceUV?: Vector4[];
  146779. faceColors?: Color4[];
  146780. updatable?: boolean;
  146781. sideOrientation?: number;
  146782. frontUVs?: Vector4;
  146783. backUVs?: Vector4;
  146784. wrap?: boolean;
  146785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146786. }
  146787. }
  146788. declare module BABYLON {
  146789. /**
  146790. * Class containing static functions to help procedurally build meshes
  146791. */
  146792. export class LatheBuilder {
  146793. /**
  146794. * Creates lathe mesh.
  146795. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146796. * * 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
  146797. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146798. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146799. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146800. * * 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
  146801. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146802. * * 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
  146803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146805. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146807. * @param name defines the name of the mesh
  146808. * @param options defines the options used to create the mesh
  146809. * @param scene defines the hosting scene
  146810. * @returns the lathe mesh
  146811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146812. */
  146813. static CreateLathe(name: string, options: {
  146814. shape: Vector3[];
  146815. radius?: number;
  146816. tessellation?: number;
  146817. clip?: number;
  146818. arc?: number;
  146819. closed?: boolean;
  146820. updatable?: boolean;
  146821. sideOrientation?: number;
  146822. frontUVs?: Vector4;
  146823. backUVs?: Vector4;
  146824. cap?: number;
  146825. invertUV?: boolean;
  146826. }, scene?: Nullable<Scene>): Mesh;
  146827. }
  146828. }
  146829. declare module BABYLON {
  146830. /**
  146831. * Class containing static functions to help procedurally build meshes
  146832. */
  146833. export class TiledPlaneBuilder {
  146834. /**
  146835. * Creates a tiled plane mesh
  146836. * * The parameter `pattern` will, depending on value, do nothing or
  146837. * * * flip (reflect about central vertical) alternate tiles across and up
  146838. * * * flip every tile on alternate rows
  146839. * * * rotate (180 degs) alternate tiles across and up
  146840. * * * rotate every tile on alternate rows
  146841. * * * flip and rotate alternate tiles across and up
  146842. * * * flip and rotate every tile on alternate rows
  146843. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146844. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146846. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146847. * * 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)
  146848. * * 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)
  146849. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146850. * @param name defines the name of the mesh
  146851. * @param options defines the options used to create the mesh
  146852. * @param scene defines the hosting scene
  146853. * @returns the box mesh
  146854. */
  146855. static CreateTiledPlane(name: string, options: {
  146856. pattern?: number;
  146857. tileSize?: number;
  146858. tileWidth?: number;
  146859. tileHeight?: number;
  146860. size?: number;
  146861. width?: number;
  146862. height?: number;
  146863. alignHorizontal?: number;
  146864. alignVertical?: number;
  146865. sideOrientation?: number;
  146866. frontUVs?: Vector4;
  146867. backUVs?: Vector4;
  146868. updatable?: boolean;
  146869. }, scene?: Nullable<Scene>): Mesh;
  146870. }
  146871. }
  146872. declare module BABYLON {
  146873. /**
  146874. * Class containing static functions to help procedurally build meshes
  146875. */
  146876. export class TubeBuilder {
  146877. /**
  146878. * Creates a tube mesh.
  146879. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146880. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146881. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146882. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146883. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146884. * * 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)
  146885. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146886. * * 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
  146887. * * 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
  146888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146892. * @param name defines the name of the mesh
  146893. * @param options defines the options used to create the mesh
  146894. * @param scene defines the hosting scene
  146895. * @returns the tube mesh
  146896. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146897. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146898. */
  146899. static CreateTube(name: string, options: {
  146900. path: Vector3[];
  146901. radius?: number;
  146902. tessellation?: number;
  146903. radiusFunction?: {
  146904. (i: number, distance: number): number;
  146905. };
  146906. cap?: number;
  146907. arc?: number;
  146908. updatable?: boolean;
  146909. sideOrientation?: number;
  146910. frontUVs?: Vector4;
  146911. backUVs?: Vector4;
  146912. instance?: Mesh;
  146913. invertUV?: boolean;
  146914. }, scene?: Nullable<Scene>): Mesh;
  146915. }
  146916. }
  146917. declare module BABYLON {
  146918. /**
  146919. * Class containing static functions to help procedurally build meshes
  146920. */
  146921. export class IcoSphereBuilder {
  146922. /**
  146923. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146924. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146925. * * 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`)
  146926. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146927. * * 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
  146928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146931. * @param name defines the name of the mesh
  146932. * @param options defines the options used to create the mesh
  146933. * @param scene defines the hosting scene
  146934. * @returns the icosahedron mesh
  146935. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146936. */
  146937. static CreateIcoSphere(name: string, options: {
  146938. radius?: number;
  146939. radiusX?: number;
  146940. radiusY?: number;
  146941. radiusZ?: number;
  146942. flat?: boolean;
  146943. subdivisions?: number;
  146944. sideOrientation?: number;
  146945. frontUVs?: Vector4;
  146946. backUVs?: Vector4;
  146947. updatable?: boolean;
  146948. }, scene?: Nullable<Scene>): Mesh;
  146949. }
  146950. }
  146951. declare module BABYLON {
  146952. /**
  146953. * Class containing static functions to help procedurally build meshes
  146954. */
  146955. export class DecalBuilder {
  146956. /**
  146957. * Creates a decal mesh.
  146958. * 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
  146959. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146960. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146961. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146962. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146963. * @param name defines the name of the mesh
  146964. * @param sourceMesh defines the mesh where the decal must be applied
  146965. * @param options defines the options used to create the mesh
  146966. * @param scene defines the hosting scene
  146967. * @returns the decal mesh
  146968. * @see https://doc.babylonjs.com/how_to/decals
  146969. */
  146970. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146971. position?: Vector3;
  146972. normal?: Vector3;
  146973. size?: Vector3;
  146974. angle?: number;
  146975. }): Mesh;
  146976. }
  146977. }
  146978. declare module BABYLON {
  146979. /**
  146980. * Class containing static functions to help procedurally build meshes
  146981. */
  146982. export class MeshBuilder {
  146983. /**
  146984. * Creates a box mesh
  146985. * * The parameter `size` sets the size (float) of each box side (default 1)
  146986. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146987. * * 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)
  146988. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146992. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146993. * @param name defines the name of the mesh
  146994. * @param options defines the options used to create the mesh
  146995. * @param scene defines the hosting scene
  146996. * @returns the box mesh
  146997. */
  146998. static CreateBox(name: string, options: {
  146999. size?: number;
  147000. width?: number;
  147001. height?: number;
  147002. depth?: number;
  147003. faceUV?: Vector4[];
  147004. faceColors?: Color4[];
  147005. sideOrientation?: number;
  147006. frontUVs?: Vector4;
  147007. backUVs?: Vector4;
  147008. wrap?: boolean;
  147009. topBaseAt?: number;
  147010. bottomBaseAt?: number;
  147011. updatable?: boolean;
  147012. }, scene?: Nullable<Scene>): Mesh;
  147013. /**
  147014. * Creates a tiled box mesh
  147015. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147017. * @param name defines the name of the mesh
  147018. * @param options defines the options used to create the mesh
  147019. * @param scene defines the hosting scene
  147020. * @returns the tiled box mesh
  147021. */
  147022. static CreateTiledBox(name: string, options: {
  147023. pattern?: number;
  147024. size?: number;
  147025. width?: number;
  147026. height?: number;
  147027. depth: number;
  147028. tileSize?: number;
  147029. tileWidth?: number;
  147030. tileHeight?: number;
  147031. faceUV?: Vector4[];
  147032. faceColors?: Color4[];
  147033. alignHorizontal?: number;
  147034. alignVertical?: number;
  147035. sideOrientation?: number;
  147036. updatable?: boolean;
  147037. }, scene?: Nullable<Scene>): Mesh;
  147038. /**
  147039. * Creates a sphere mesh
  147040. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147041. * * 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`)
  147042. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147043. * * 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
  147044. * * 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)
  147045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147048. * @param name defines the name of the mesh
  147049. * @param options defines the options used to create the mesh
  147050. * @param scene defines the hosting scene
  147051. * @returns the sphere mesh
  147052. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147053. */
  147054. static CreateSphere(name: string, options: {
  147055. segments?: number;
  147056. diameter?: number;
  147057. diameterX?: number;
  147058. diameterY?: number;
  147059. diameterZ?: number;
  147060. arc?: number;
  147061. slice?: number;
  147062. sideOrientation?: number;
  147063. frontUVs?: Vector4;
  147064. backUVs?: Vector4;
  147065. updatable?: boolean;
  147066. }, scene?: Nullable<Scene>): Mesh;
  147067. /**
  147068. * Creates a plane polygonal mesh. By default, this is a disc
  147069. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147070. * * 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
  147071. * * 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
  147072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147075. * @param name defines the name of the mesh
  147076. * @param options defines the options used to create the mesh
  147077. * @param scene defines the hosting scene
  147078. * @returns the plane polygonal mesh
  147079. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147080. */
  147081. static CreateDisc(name: string, options: {
  147082. radius?: number;
  147083. tessellation?: number;
  147084. arc?: number;
  147085. updatable?: boolean;
  147086. sideOrientation?: number;
  147087. frontUVs?: Vector4;
  147088. backUVs?: Vector4;
  147089. }, scene?: Nullable<Scene>): Mesh;
  147090. /**
  147091. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147092. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147093. * * 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`)
  147094. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147095. * * 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
  147096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147099. * @param name defines the name of the mesh
  147100. * @param options defines the options used to create the mesh
  147101. * @param scene defines the hosting scene
  147102. * @returns the icosahedron mesh
  147103. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147104. */
  147105. static CreateIcoSphere(name: string, options: {
  147106. radius?: number;
  147107. radiusX?: number;
  147108. radiusY?: number;
  147109. radiusZ?: number;
  147110. flat?: boolean;
  147111. subdivisions?: number;
  147112. sideOrientation?: number;
  147113. frontUVs?: Vector4;
  147114. backUVs?: Vector4;
  147115. updatable?: boolean;
  147116. }, scene?: Nullable<Scene>): Mesh;
  147117. /**
  147118. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147119. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147120. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147121. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147122. * * 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
  147123. * * 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
  147124. * * 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
  147125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147128. * * 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
  147129. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147130. * * 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
  147131. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147133. * @param name defines the name of the mesh
  147134. * @param options defines the options used to create the mesh
  147135. * @param scene defines the hosting scene
  147136. * @returns the ribbon mesh
  147137. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147139. */
  147140. static CreateRibbon(name: string, options: {
  147141. pathArray: Vector3[][];
  147142. closeArray?: boolean;
  147143. closePath?: boolean;
  147144. offset?: number;
  147145. updatable?: boolean;
  147146. sideOrientation?: number;
  147147. frontUVs?: Vector4;
  147148. backUVs?: Vector4;
  147149. instance?: Mesh;
  147150. invertUV?: boolean;
  147151. uvs?: Vector2[];
  147152. colors?: Color4[];
  147153. }, scene?: Nullable<Scene>): Mesh;
  147154. /**
  147155. * Creates a cylinder or a cone mesh
  147156. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147157. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147158. * * 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.
  147159. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147160. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147161. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147162. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147163. * * 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).
  147164. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147165. * * 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).
  147166. * * 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
  147167. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147168. * * 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
  147169. * * 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.
  147170. * * If `enclose` is false, a ring surface is one element.
  147171. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147172. * * 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
  147173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147176. * @param name defines the name of the mesh
  147177. * @param options defines the options used to create the mesh
  147178. * @param scene defines the hosting scene
  147179. * @returns the cylinder mesh
  147180. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147181. */
  147182. static CreateCylinder(name: string, options: {
  147183. height?: number;
  147184. diameterTop?: number;
  147185. diameterBottom?: number;
  147186. diameter?: number;
  147187. tessellation?: number;
  147188. subdivisions?: number;
  147189. arc?: number;
  147190. faceColors?: Color4[];
  147191. faceUV?: Vector4[];
  147192. updatable?: boolean;
  147193. hasRings?: boolean;
  147194. enclose?: boolean;
  147195. cap?: number;
  147196. sideOrientation?: number;
  147197. frontUVs?: Vector4;
  147198. backUVs?: Vector4;
  147199. }, scene?: Nullable<Scene>): Mesh;
  147200. /**
  147201. * Creates a torus mesh
  147202. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147203. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147204. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147208. * @param name defines the name of the mesh
  147209. * @param options defines the options used to create the mesh
  147210. * @param scene defines the hosting scene
  147211. * @returns the torus mesh
  147212. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147213. */
  147214. static CreateTorus(name: string, options: {
  147215. diameter?: number;
  147216. thickness?: number;
  147217. tessellation?: number;
  147218. updatable?: boolean;
  147219. sideOrientation?: number;
  147220. frontUVs?: Vector4;
  147221. backUVs?: Vector4;
  147222. }, scene?: Nullable<Scene>): Mesh;
  147223. /**
  147224. * Creates a torus knot mesh
  147225. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147226. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147227. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147228. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147232. * @param name defines the name of the mesh
  147233. * @param options defines the options used to create the mesh
  147234. * @param scene defines the hosting scene
  147235. * @returns the torus knot mesh
  147236. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147237. */
  147238. static CreateTorusKnot(name: string, options: {
  147239. radius?: number;
  147240. tube?: number;
  147241. radialSegments?: number;
  147242. tubularSegments?: number;
  147243. p?: number;
  147244. q?: number;
  147245. updatable?: boolean;
  147246. sideOrientation?: number;
  147247. frontUVs?: Vector4;
  147248. backUVs?: Vector4;
  147249. }, scene?: Nullable<Scene>): Mesh;
  147250. /**
  147251. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147252. * * 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
  147253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147254. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147255. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147256. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147257. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147258. * * 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
  147259. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147262. * @param name defines the name of the new line system
  147263. * @param options defines the options used to create the line system
  147264. * @param scene defines the hosting scene
  147265. * @returns a new line system mesh
  147266. */
  147267. static CreateLineSystem(name: string, options: {
  147268. lines: Vector3[][];
  147269. updatable?: boolean;
  147270. instance?: Nullable<LinesMesh>;
  147271. colors?: Nullable<Color4[][]>;
  147272. useVertexAlpha?: boolean;
  147273. }, scene: Nullable<Scene>): LinesMesh;
  147274. /**
  147275. * Creates a line mesh
  147276. * 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
  147277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147278. * * The parameter `points` is an array successive Vector3
  147279. * * 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
  147280. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147281. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147282. * * When updating an instance, remember that only point positions can change, not the number of points
  147283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147285. * @param name defines the name of the new line system
  147286. * @param options defines the options used to create the line system
  147287. * @param scene defines the hosting scene
  147288. * @returns a new line mesh
  147289. */
  147290. static CreateLines(name: string, options: {
  147291. points: Vector3[];
  147292. updatable?: boolean;
  147293. instance?: Nullable<LinesMesh>;
  147294. colors?: Color4[];
  147295. useVertexAlpha?: boolean;
  147296. }, scene?: Nullable<Scene>): LinesMesh;
  147297. /**
  147298. * Creates a dashed line mesh
  147299. * * 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
  147300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147301. * * The parameter `points` is an array successive Vector3
  147302. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147303. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147304. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147305. * * 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
  147306. * * When updating an instance, remember that only point positions can change, not the number of points
  147307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147308. * @param name defines the name of the mesh
  147309. * @param options defines the options used to create the mesh
  147310. * @param scene defines the hosting scene
  147311. * @returns the dashed line mesh
  147312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147313. */
  147314. static CreateDashedLines(name: string, options: {
  147315. points: Vector3[];
  147316. dashSize?: number;
  147317. gapSize?: number;
  147318. dashNb?: number;
  147319. updatable?: boolean;
  147320. instance?: LinesMesh;
  147321. }, scene?: Nullable<Scene>): LinesMesh;
  147322. /**
  147323. * 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.
  147324. * * 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.
  147325. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147326. * * 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.
  147327. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147328. * * 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
  147329. * * 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
  147330. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147335. * @param name defines the name of the mesh
  147336. * @param options defines the options used to create the mesh
  147337. * @param scene defines the hosting scene
  147338. * @returns the extruded shape mesh
  147339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147341. */
  147342. static ExtrudeShape(name: string, options: {
  147343. shape: Vector3[];
  147344. path: Vector3[];
  147345. scale?: number;
  147346. rotation?: number;
  147347. cap?: number;
  147348. updatable?: boolean;
  147349. sideOrientation?: number;
  147350. frontUVs?: Vector4;
  147351. backUVs?: Vector4;
  147352. instance?: Mesh;
  147353. invertUV?: boolean;
  147354. }, scene?: Nullable<Scene>): Mesh;
  147355. /**
  147356. * Creates an custom extruded shape mesh.
  147357. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147358. * * 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.
  147359. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147360. * * 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
  147361. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147362. * * 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
  147363. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147364. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147365. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147366. * * 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
  147367. * * 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
  147368. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147373. * @param name defines the name of the mesh
  147374. * @param options defines the options used to create the mesh
  147375. * @param scene defines the hosting scene
  147376. * @returns the custom extruded shape mesh
  147377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147380. */
  147381. static ExtrudeShapeCustom(name: string, options: {
  147382. shape: Vector3[];
  147383. path: Vector3[];
  147384. scaleFunction?: any;
  147385. rotationFunction?: any;
  147386. ribbonCloseArray?: boolean;
  147387. ribbonClosePath?: boolean;
  147388. cap?: number;
  147389. updatable?: boolean;
  147390. sideOrientation?: number;
  147391. frontUVs?: Vector4;
  147392. backUVs?: Vector4;
  147393. instance?: Mesh;
  147394. invertUV?: boolean;
  147395. }, scene?: Nullable<Scene>): Mesh;
  147396. /**
  147397. * Creates lathe mesh.
  147398. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147399. * * 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
  147400. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147401. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147402. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147403. * * 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
  147404. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147405. * * 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
  147406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147410. * @param name defines the name of the mesh
  147411. * @param options defines the options used to create the mesh
  147412. * @param scene defines the hosting scene
  147413. * @returns the lathe mesh
  147414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147415. */
  147416. static CreateLathe(name: string, options: {
  147417. shape: Vector3[];
  147418. radius?: number;
  147419. tessellation?: number;
  147420. clip?: number;
  147421. arc?: number;
  147422. closed?: boolean;
  147423. updatable?: boolean;
  147424. sideOrientation?: number;
  147425. frontUVs?: Vector4;
  147426. backUVs?: Vector4;
  147427. cap?: number;
  147428. invertUV?: boolean;
  147429. }, scene?: Nullable<Scene>): Mesh;
  147430. /**
  147431. * Creates a tiled plane mesh
  147432. * * You can set a limited pattern arrangement with the tiles
  147433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147436. * @param name defines the name of the mesh
  147437. * @param options defines the options used to create the mesh
  147438. * @param scene defines the hosting scene
  147439. * @returns the plane mesh
  147440. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147441. */
  147442. static CreateTiledPlane(name: string, options: {
  147443. pattern?: number;
  147444. tileSize?: number;
  147445. tileWidth?: number;
  147446. tileHeight?: number;
  147447. size?: number;
  147448. width?: number;
  147449. height?: number;
  147450. alignHorizontal?: number;
  147451. alignVertical?: number;
  147452. sideOrientation?: number;
  147453. frontUVs?: Vector4;
  147454. backUVs?: Vector4;
  147455. updatable?: boolean;
  147456. }, scene?: Nullable<Scene>): Mesh;
  147457. /**
  147458. * Creates a plane mesh
  147459. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147460. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147461. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147465. * @param name defines the name of the mesh
  147466. * @param options defines the options used to create the mesh
  147467. * @param scene defines the hosting scene
  147468. * @returns the plane mesh
  147469. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147470. */
  147471. static CreatePlane(name: string, options: {
  147472. size?: number;
  147473. width?: number;
  147474. height?: number;
  147475. sideOrientation?: number;
  147476. frontUVs?: Vector4;
  147477. backUVs?: Vector4;
  147478. updatable?: boolean;
  147479. sourcePlane?: Plane;
  147480. }, scene?: Nullable<Scene>): Mesh;
  147481. /**
  147482. * Creates a ground mesh
  147483. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147484. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147486. * @param name defines the name of the mesh
  147487. * @param options defines the options used to create the mesh
  147488. * @param scene defines the hosting scene
  147489. * @returns the ground mesh
  147490. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147491. */
  147492. static CreateGround(name: string, options: {
  147493. width?: number;
  147494. height?: number;
  147495. subdivisions?: number;
  147496. subdivisionsX?: number;
  147497. subdivisionsY?: number;
  147498. updatable?: boolean;
  147499. }, scene?: Nullable<Scene>): Mesh;
  147500. /**
  147501. * Creates a tiled ground mesh
  147502. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147503. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147504. * * 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
  147505. * * 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
  147506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147507. * @param name defines the name of the mesh
  147508. * @param options defines the options used to create the mesh
  147509. * @param scene defines the hosting scene
  147510. * @returns the tiled ground mesh
  147511. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147512. */
  147513. static CreateTiledGround(name: string, options: {
  147514. xmin: number;
  147515. zmin: number;
  147516. xmax: number;
  147517. zmax: number;
  147518. subdivisions?: {
  147519. w: number;
  147520. h: number;
  147521. };
  147522. precision?: {
  147523. w: number;
  147524. h: number;
  147525. };
  147526. updatable?: boolean;
  147527. }, scene?: Nullable<Scene>): Mesh;
  147528. /**
  147529. * Creates a ground mesh from a height map
  147530. * * The parameter `url` sets the URL of the height map image resource.
  147531. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147532. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147533. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147534. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147535. * * 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.
  147536. * * 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).
  147537. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147539. * @param name defines the name of the mesh
  147540. * @param url defines the url to the height map
  147541. * @param options defines the options used to create the mesh
  147542. * @param scene defines the hosting scene
  147543. * @returns the ground mesh
  147544. * @see https://doc.babylonjs.com/babylon101/height_map
  147545. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147546. */
  147547. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147548. width?: number;
  147549. height?: number;
  147550. subdivisions?: number;
  147551. minHeight?: number;
  147552. maxHeight?: number;
  147553. colorFilter?: Color3;
  147554. alphaFilter?: number;
  147555. updatable?: boolean;
  147556. onReady?: (mesh: GroundMesh) => void;
  147557. }, scene?: Nullable<Scene>): GroundMesh;
  147558. /**
  147559. * Creates a polygon mesh
  147560. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147561. * * 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
  147562. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147565. * * Remember you can only change the shape positions, not their number when updating a polygon
  147566. * @param name defines the name of the mesh
  147567. * @param options defines the options used to create the mesh
  147568. * @param scene defines the hosting scene
  147569. * @param earcutInjection can be used to inject your own earcut reference
  147570. * @returns the polygon mesh
  147571. */
  147572. static CreatePolygon(name: string, options: {
  147573. shape: Vector3[];
  147574. holes?: Vector3[][];
  147575. depth?: number;
  147576. faceUV?: Vector4[];
  147577. faceColors?: Color4[];
  147578. updatable?: boolean;
  147579. sideOrientation?: number;
  147580. frontUVs?: Vector4;
  147581. backUVs?: Vector4;
  147582. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147583. /**
  147584. * Creates an extruded polygon mesh, with depth in the Y direction.
  147585. * * 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)
  147586. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147587. * @param name defines the name of the mesh
  147588. * @param options defines the options used to create the mesh
  147589. * @param scene defines the hosting scene
  147590. * @param earcutInjection can be used to inject your own earcut reference
  147591. * @returns the polygon mesh
  147592. */
  147593. static ExtrudePolygon(name: string, options: {
  147594. shape: Vector3[];
  147595. holes?: Vector3[][];
  147596. depth?: number;
  147597. faceUV?: Vector4[];
  147598. faceColors?: Color4[];
  147599. updatable?: boolean;
  147600. sideOrientation?: number;
  147601. frontUVs?: Vector4;
  147602. backUVs?: Vector4;
  147603. wrap?: boolean;
  147604. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147605. /**
  147606. * Creates a tube mesh.
  147607. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147608. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147609. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147610. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147611. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147612. * * 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)
  147613. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147614. * * 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
  147615. * * 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
  147616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147620. * @param name defines the name of the mesh
  147621. * @param options defines the options used to create the mesh
  147622. * @param scene defines the hosting scene
  147623. * @returns the tube mesh
  147624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147625. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147626. */
  147627. static CreateTube(name: string, options: {
  147628. path: Vector3[];
  147629. radius?: number;
  147630. tessellation?: number;
  147631. radiusFunction?: {
  147632. (i: number, distance: number): number;
  147633. };
  147634. cap?: number;
  147635. arc?: number;
  147636. updatable?: boolean;
  147637. sideOrientation?: number;
  147638. frontUVs?: Vector4;
  147639. backUVs?: Vector4;
  147640. instance?: Mesh;
  147641. invertUV?: boolean;
  147642. }, scene?: Nullable<Scene>): Mesh;
  147643. /**
  147644. * Creates a polyhedron mesh
  147645. * * 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
  147646. * * The parameter `size` (positive float, default 1) sets the polygon size
  147647. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147648. * * 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`
  147649. * * 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
  147650. * * 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)`)
  147651. * * 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
  147652. * * 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
  147653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147656. * @param name defines the name of the mesh
  147657. * @param options defines the options used to create the mesh
  147658. * @param scene defines the hosting scene
  147659. * @returns the polyhedron mesh
  147660. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147661. */
  147662. static CreatePolyhedron(name: string, options: {
  147663. type?: number;
  147664. size?: number;
  147665. sizeX?: number;
  147666. sizeY?: number;
  147667. sizeZ?: number;
  147668. custom?: any;
  147669. faceUV?: Vector4[];
  147670. faceColors?: Color4[];
  147671. flat?: boolean;
  147672. updatable?: boolean;
  147673. sideOrientation?: number;
  147674. frontUVs?: Vector4;
  147675. backUVs?: Vector4;
  147676. }, scene?: Nullable<Scene>): Mesh;
  147677. /**
  147678. * Creates a decal mesh.
  147679. * 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
  147680. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147681. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147682. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147683. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147684. * @param name defines the name of the mesh
  147685. * @param sourceMesh defines the mesh where the decal must be applied
  147686. * @param options defines the options used to create the mesh
  147687. * @param scene defines the hosting scene
  147688. * @returns the decal mesh
  147689. * @see https://doc.babylonjs.com/how_to/decals
  147690. */
  147691. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147692. position?: Vector3;
  147693. normal?: Vector3;
  147694. size?: Vector3;
  147695. angle?: number;
  147696. }): Mesh;
  147697. /**
  147698. * Creates a Capsule Mesh
  147699. * @param name defines the name of the mesh.
  147700. * @param options the constructors options used to shape the mesh.
  147701. * @param scene defines the scene the mesh is scoped to.
  147702. * @returns the capsule mesh
  147703. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147704. */
  147705. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147706. }
  147707. }
  147708. declare module BABYLON {
  147709. /**
  147710. * A simplifier interface for future simplification implementations
  147711. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147712. */
  147713. export interface ISimplifier {
  147714. /**
  147715. * Simplification of a given mesh according to the given settings.
  147716. * Since this requires computation, it is assumed that the function runs async.
  147717. * @param settings The settings of the simplification, including quality and distance
  147718. * @param successCallback A callback that will be called after the mesh was simplified.
  147719. * @param errorCallback in case of an error, this callback will be called. optional.
  147720. */
  147721. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147722. }
  147723. /**
  147724. * Expected simplification settings.
  147725. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147726. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147727. */
  147728. export interface ISimplificationSettings {
  147729. /**
  147730. * Gets or sets the expected quality
  147731. */
  147732. quality: number;
  147733. /**
  147734. * Gets or sets the distance when this optimized version should be used
  147735. */
  147736. distance: number;
  147737. /**
  147738. * Gets an already optimized mesh
  147739. */
  147740. optimizeMesh?: boolean;
  147741. }
  147742. /**
  147743. * Class used to specify simplification options
  147744. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147745. */
  147746. export class SimplificationSettings implements ISimplificationSettings {
  147747. /** expected quality */
  147748. quality: number;
  147749. /** distance when this optimized version should be used */
  147750. distance: number;
  147751. /** already optimized mesh */
  147752. optimizeMesh?: boolean | undefined;
  147753. /**
  147754. * Creates a SimplificationSettings
  147755. * @param quality expected quality
  147756. * @param distance distance when this optimized version should be used
  147757. * @param optimizeMesh already optimized mesh
  147758. */
  147759. constructor(
  147760. /** expected quality */
  147761. quality: number,
  147762. /** distance when this optimized version should be used */
  147763. distance: number,
  147764. /** already optimized mesh */
  147765. optimizeMesh?: boolean | undefined);
  147766. }
  147767. /**
  147768. * Interface used to define a simplification task
  147769. */
  147770. export interface ISimplificationTask {
  147771. /**
  147772. * Array of settings
  147773. */
  147774. settings: Array<ISimplificationSettings>;
  147775. /**
  147776. * Simplification type
  147777. */
  147778. simplificationType: SimplificationType;
  147779. /**
  147780. * Mesh to simplify
  147781. */
  147782. mesh: Mesh;
  147783. /**
  147784. * Callback called on success
  147785. */
  147786. successCallback?: () => void;
  147787. /**
  147788. * Defines if parallel processing can be used
  147789. */
  147790. parallelProcessing: boolean;
  147791. }
  147792. /**
  147793. * Queue used to order the simplification tasks
  147794. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147795. */
  147796. export class SimplificationQueue {
  147797. private _simplificationArray;
  147798. /**
  147799. * Gets a boolean indicating that the process is still running
  147800. */
  147801. running: boolean;
  147802. /**
  147803. * Creates a new queue
  147804. */
  147805. constructor();
  147806. /**
  147807. * Adds a new simplification task
  147808. * @param task defines a task to add
  147809. */
  147810. addTask(task: ISimplificationTask): void;
  147811. /**
  147812. * Execute next task
  147813. */
  147814. executeNext(): void;
  147815. /**
  147816. * Execute a simplification task
  147817. * @param task defines the task to run
  147818. */
  147819. runSimplification(task: ISimplificationTask): void;
  147820. private getSimplifier;
  147821. }
  147822. /**
  147823. * The implemented types of simplification
  147824. * At the moment only Quadratic Error Decimation is implemented
  147825. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147826. */
  147827. export enum SimplificationType {
  147828. /** Quadratic error decimation */
  147829. QUADRATIC = 0
  147830. }
  147831. /**
  147832. * An implementation of the Quadratic Error simplification algorithm.
  147833. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147834. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147835. * @author RaananW
  147836. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147837. */
  147838. export class QuadraticErrorSimplification implements ISimplifier {
  147839. private _mesh;
  147840. private triangles;
  147841. private vertices;
  147842. private references;
  147843. private _reconstructedMesh;
  147844. /** Gets or sets the number pf sync interations */
  147845. syncIterations: number;
  147846. /** Gets or sets the aggressiveness of the simplifier */
  147847. aggressiveness: number;
  147848. /** Gets or sets the number of allowed iterations for decimation */
  147849. decimationIterations: number;
  147850. /** Gets or sets the espilon to use for bounding box computation */
  147851. boundingBoxEpsilon: number;
  147852. /**
  147853. * Creates a new QuadraticErrorSimplification
  147854. * @param _mesh defines the target mesh
  147855. */
  147856. constructor(_mesh: Mesh);
  147857. /**
  147858. * Simplification of a given mesh according to the given settings.
  147859. * Since this requires computation, it is assumed that the function runs async.
  147860. * @param settings The settings of the simplification, including quality and distance
  147861. * @param successCallback A callback that will be called after the mesh was simplified.
  147862. */
  147863. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147864. private runDecimation;
  147865. private initWithMesh;
  147866. private init;
  147867. private reconstructMesh;
  147868. private initDecimatedMesh;
  147869. private isFlipped;
  147870. private updateTriangles;
  147871. private identifyBorder;
  147872. private updateMesh;
  147873. private vertexError;
  147874. private calculateError;
  147875. }
  147876. }
  147877. declare module BABYLON {
  147878. interface Scene {
  147879. /** @hidden (Backing field) */
  147880. _simplificationQueue: SimplificationQueue;
  147881. /**
  147882. * Gets or sets the simplification queue attached to the scene
  147883. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147884. */
  147885. simplificationQueue: SimplificationQueue;
  147886. }
  147887. interface Mesh {
  147888. /**
  147889. * Simplify the mesh according to the given array of settings.
  147890. * Function will return immediately and will simplify async
  147891. * @param settings a collection of simplification settings
  147892. * @param parallelProcessing should all levels calculate parallel or one after the other
  147893. * @param simplificationType the type of simplification to run
  147894. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147895. * @returns the current mesh
  147896. */
  147897. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147898. }
  147899. /**
  147900. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147901. * created in a scene
  147902. */
  147903. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147904. /**
  147905. * The component name helpfull to identify the component in the list of scene components.
  147906. */
  147907. readonly name: string;
  147908. /**
  147909. * The scene the component belongs to.
  147910. */
  147911. scene: Scene;
  147912. /**
  147913. * Creates a new instance of the component for the given scene
  147914. * @param scene Defines the scene to register the component in
  147915. */
  147916. constructor(scene: Scene);
  147917. /**
  147918. * Registers the component in a given scene
  147919. */
  147920. register(): void;
  147921. /**
  147922. * Rebuilds the elements related to this component in case of
  147923. * context lost for instance.
  147924. */
  147925. rebuild(): void;
  147926. /**
  147927. * Disposes the component and the associated ressources
  147928. */
  147929. dispose(): void;
  147930. private _beforeCameraUpdate;
  147931. }
  147932. }
  147933. declare module BABYLON {
  147934. interface Mesh {
  147935. /**
  147936. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147937. */
  147938. thinInstanceEnablePicking: boolean;
  147939. /**
  147940. * Creates a new thin instance
  147941. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147942. * @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
  147943. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147944. */
  147945. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147946. /**
  147947. * Adds the transformation (matrix) of the current mesh as a thin instance
  147948. * @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
  147949. * @returns the thin instance index number
  147950. */
  147951. thinInstanceAddSelf(refresh: boolean): number;
  147952. /**
  147953. * Registers a custom attribute to be used with thin instances
  147954. * @param kind name of the attribute
  147955. * @param stride size in floats of the attribute
  147956. */
  147957. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147958. /**
  147959. * Sets the matrix of a thin instance
  147960. * @param index index of the thin instance
  147961. * @param matrix matrix to set
  147962. * @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
  147963. */
  147964. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147965. /**
  147966. * Sets the value of a custom attribute for a thin instance
  147967. * @param kind name of the attribute
  147968. * @param index index of the thin instance
  147969. * @param value value to set
  147970. * @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
  147971. */
  147972. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147973. /**
  147974. * 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.
  147975. */
  147976. thinInstanceCount: number;
  147977. /**
  147978. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147979. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147980. * @param buffer buffer to set
  147981. * @param stride size in floats of each value of the buffer
  147982. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147983. */
  147984. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147985. /**
  147986. * Gets the list of world matrices
  147987. * @return an array containing all the world matrices from the thin instances
  147988. */
  147989. thinInstanceGetWorldMatrices(): Matrix[];
  147990. /**
  147991. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147992. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147993. */
  147994. thinInstanceBufferUpdated(kind: string): void;
  147995. /**
  147996. * Applies a partial update to a buffer directly on the GPU
  147997. * 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
  147998. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147999. * @param data the data to set in the GPU buffer
  148000. * @param offset the offset in the GPU buffer where to update the data
  148001. */
  148002. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148003. /**
  148004. * Refreshes the bounding info, taking into account all the thin instances defined
  148005. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148006. */
  148007. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148008. /** @hidden */
  148009. _thinInstanceInitializeUserStorage(): void;
  148010. /** @hidden */
  148011. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148012. /** @hidden */
  148013. _userThinInstanceBuffersStorage: {
  148014. data: {
  148015. [key: string]: Float32Array;
  148016. };
  148017. sizes: {
  148018. [key: string]: number;
  148019. };
  148020. vertexBuffers: {
  148021. [key: string]: Nullable<VertexBuffer>;
  148022. };
  148023. strides: {
  148024. [key: string]: number;
  148025. };
  148026. };
  148027. }
  148028. }
  148029. declare module BABYLON {
  148030. /**
  148031. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148032. */
  148033. export interface INavigationEnginePlugin {
  148034. /**
  148035. * plugin name
  148036. */
  148037. name: string;
  148038. /**
  148039. * Creates a navigation mesh
  148040. * @param meshes array of all the geometry used to compute the navigatio mesh
  148041. * @param parameters bunch of parameters used to filter geometry
  148042. */
  148043. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148044. /**
  148045. * Create a navigation mesh debug mesh
  148046. * @param scene is where the mesh will be added
  148047. * @returns debug display mesh
  148048. */
  148049. createDebugNavMesh(scene: Scene): Mesh;
  148050. /**
  148051. * Get a navigation mesh constrained position, closest to the parameter position
  148052. * @param position world position
  148053. * @returns the closest point to position constrained by the navigation mesh
  148054. */
  148055. getClosestPoint(position: Vector3): Vector3;
  148056. /**
  148057. * Get a navigation mesh constrained position, closest to the parameter position
  148058. * @param position world position
  148059. * @param result output the closest point to position constrained by the navigation mesh
  148060. */
  148061. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148062. /**
  148063. * Get a navigation mesh constrained position, within a particular radius
  148064. * @param position world position
  148065. * @param maxRadius the maximum distance to the constrained world position
  148066. * @returns the closest point to position constrained by the navigation mesh
  148067. */
  148068. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148069. /**
  148070. * Get a navigation mesh constrained position, within a particular radius
  148071. * @param position world position
  148072. * @param maxRadius the maximum distance to the constrained world position
  148073. * @param result output the closest point to position constrained by the navigation mesh
  148074. */
  148075. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148076. /**
  148077. * Compute the final position from a segment made of destination-position
  148078. * @param position world position
  148079. * @param destination world position
  148080. * @returns the resulting point along the navmesh
  148081. */
  148082. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148083. /**
  148084. * Compute the final position from a segment made of destination-position
  148085. * @param position world position
  148086. * @param destination world position
  148087. * @param result output the resulting point along the navmesh
  148088. */
  148089. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148090. /**
  148091. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148092. * @param start world position
  148093. * @param end world position
  148094. * @returns array containing world position composing the path
  148095. */
  148096. computePath(start: Vector3, end: Vector3): Vector3[];
  148097. /**
  148098. * If this plugin is supported
  148099. * @returns true if plugin is supported
  148100. */
  148101. isSupported(): boolean;
  148102. /**
  148103. * Create a new Crowd so you can add agents
  148104. * @param maxAgents the maximum agent count in the crowd
  148105. * @param maxAgentRadius the maximum radius an agent can have
  148106. * @param scene to attach the crowd to
  148107. * @returns the crowd you can add agents to
  148108. */
  148109. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148110. /**
  148111. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148112. * The queries will try to find a solution within those bounds
  148113. * default is (1,1,1)
  148114. * @param extent x,y,z value that define the extent around the queries point of reference
  148115. */
  148116. setDefaultQueryExtent(extent: Vector3): void;
  148117. /**
  148118. * Get the Bounding box extent specified by setDefaultQueryExtent
  148119. * @returns the box extent values
  148120. */
  148121. getDefaultQueryExtent(): Vector3;
  148122. /**
  148123. * build the navmesh from a previously saved state using getNavmeshData
  148124. * @param data the Uint8Array returned by getNavmeshData
  148125. */
  148126. buildFromNavmeshData(data: Uint8Array): void;
  148127. /**
  148128. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148129. * @returns data the Uint8Array that can be saved and reused
  148130. */
  148131. getNavmeshData(): Uint8Array;
  148132. /**
  148133. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148134. * @param result output the box extent values
  148135. */
  148136. getDefaultQueryExtentToRef(result: Vector3): void;
  148137. /**
  148138. * Release all resources
  148139. */
  148140. dispose(): void;
  148141. }
  148142. /**
  148143. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148144. */
  148145. export interface ICrowd {
  148146. /**
  148147. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148148. * You can attach anything to that node. The node position is updated in the scene update tick.
  148149. * @param pos world position that will be constrained by the navigation mesh
  148150. * @param parameters agent parameters
  148151. * @param transform hooked to the agent that will be update by the scene
  148152. * @returns agent index
  148153. */
  148154. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148155. /**
  148156. * Returns the agent position in world space
  148157. * @param index agent index returned by addAgent
  148158. * @returns world space position
  148159. */
  148160. getAgentPosition(index: number): Vector3;
  148161. /**
  148162. * Gets the agent position result in world space
  148163. * @param index agent index returned by addAgent
  148164. * @param result output world space position
  148165. */
  148166. getAgentPositionToRef(index: number, result: Vector3): void;
  148167. /**
  148168. * Gets the agent velocity in world space
  148169. * @param index agent index returned by addAgent
  148170. * @returns world space velocity
  148171. */
  148172. getAgentVelocity(index: number): Vector3;
  148173. /**
  148174. * Gets the agent velocity result in world space
  148175. * @param index agent index returned by addAgent
  148176. * @param result output world space velocity
  148177. */
  148178. getAgentVelocityToRef(index: number, result: Vector3): void;
  148179. /**
  148180. * remove a particular agent previously created
  148181. * @param index agent index returned by addAgent
  148182. */
  148183. removeAgent(index: number): void;
  148184. /**
  148185. * get the list of all agents attached to this crowd
  148186. * @returns list of agent indices
  148187. */
  148188. getAgents(): number[];
  148189. /**
  148190. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148191. * @param deltaTime in seconds
  148192. */
  148193. update(deltaTime: number): void;
  148194. /**
  148195. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148196. * @param index agent index returned by addAgent
  148197. * @param destination targeted world position
  148198. */
  148199. agentGoto(index: number, destination: Vector3): void;
  148200. /**
  148201. * Teleport the agent to a new position
  148202. * @param index agent index returned by addAgent
  148203. * @param destination targeted world position
  148204. */
  148205. agentTeleport(index: number, destination: Vector3): void;
  148206. /**
  148207. * Update agent parameters
  148208. * @param index agent index returned by addAgent
  148209. * @param parameters agent parameters
  148210. */
  148211. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148212. /**
  148213. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148214. * The queries will try to find a solution within those bounds
  148215. * default is (1,1,1)
  148216. * @param extent x,y,z value that define the extent around the queries point of reference
  148217. */
  148218. setDefaultQueryExtent(extent: Vector3): void;
  148219. /**
  148220. * Get the Bounding box extent specified by setDefaultQueryExtent
  148221. * @returns the box extent values
  148222. */
  148223. getDefaultQueryExtent(): Vector3;
  148224. /**
  148225. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148226. * @param result output the box extent values
  148227. */
  148228. getDefaultQueryExtentToRef(result: Vector3): void;
  148229. /**
  148230. * Release all resources
  148231. */
  148232. dispose(): void;
  148233. }
  148234. /**
  148235. * Configures an agent
  148236. */
  148237. export interface IAgentParameters {
  148238. /**
  148239. * Agent radius. [Limit: >= 0]
  148240. */
  148241. radius: number;
  148242. /**
  148243. * Agent height. [Limit: > 0]
  148244. */
  148245. height: number;
  148246. /**
  148247. * Maximum allowed acceleration. [Limit: >= 0]
  148248. */
  148249. maxAcceleration: number;
  148250. /**
  148251. * Maximum allowed speed. [Limit: >= 0]
  148252. */
  148253. maxSpeed: number;
  148254. /**
  148255. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148256. */
  148257. collisionQueryRange: number;
  148258. /**
  148259. * The path visibility optimization range. [Limit: > 0]
  148260. */
  148261. pathOptimizationRange: number;
  148262. /**
  148263. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148264. */
  148265. separationWeight: number;
  148266. }
  148267. /**
  148268. * Configures the navigation mesh creation
  148269. */
  148270. export interface INavMeshParameters {
  148271. /**
  148272. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148273. */
  148274. cs: number;
  148275. /**
  148276. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148277. */
  148278. ch: number;
  148279. /**
  148280. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148281. */
  148282. walkableSlopeAngle: number;
  148283. /**
  148284. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148285. * be considered walkable. [Limit: >= 3] [Units: vx]
  148286. */
  148287. walkableHeight: number;
  148288. /**
  148289. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148290. */
  148291. walkableClimb: number;
  148292. /**
  148293. * The distance to erode/shrink the walkable area of the heightfield away from
  148294. * obstructions. [Limit: >=0] [Units: vx]
  148295. */
  148296. walkableRadius: number;
  148297. /**
  148298. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148299. */
  148300. maxEdgeLen: number;
  148301. /**
  148302. * The maximum distance a simplfied contour's border edges should deviate
  148303. * the original raw contour. [Limit: >=0] [Units: vx]
  148304. */
  148305. maxSimplificationError: number;
  148306. /**
  148307. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148308. */
  148309. minRegionArea: number;
  148310. /**
  148311. * Any regions with a span count smaller than this value will, if possible,
  148312. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148313. */
  148314. mergeRegionArea: number;
  148315. /**
  148316. * The maximum number of vertices allowed for polygons generated during the
  148317. * contour to polygon conversion process. [Limit: >= 3]
  148318. */
  148319. maxVertsPerPoly: number;
  148320. /**
  148321. * Sets the sampling distance to use when generating the detail mesh.
  148322. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148323. */
  148324. detailSampleDist: number;
  148325. /**
  148326. * The maximum distance the detail mesh surface should deviate from heightfield
  148327. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148328. */
  148329. detailSampleMaxError: number;
  148330. }
  148331. }
  148332. declare module BABYLON {
  148333. /**
  148334. * RecastJS navigation plugin
  148335. */
  148336. export class RecastJSPlugin implements INavigationEnginePlugin {
  148337. /**
  148338. * Reference to the Recast library
  148339. */
  148340. bjsRECAST: any;
  148341. /**
  148342. * plugin name
  148343. */
  148344. name: string;
  148345. /**
  148346. * the first navmesh created. We might extend this to support multiple navmeshes
  148347. */
  148348. navMesh: any;
  148349. /**
  148350. * Initializes the recastJS plugin
  148351. * @param recastInjection can be used to inject your own recast reference
  148352. */
  148353. constructor(recastInjection?: any);
  148354. /**
  148355. * Creates a navigation mesh
  148356. * @param meshes array of all the geometry used to compute the navigatio mesh
  148357. * @param parameters bunch of parameters used to filter geometry
  148358. */
  148359. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148360. /**
  148361. * Create a navigation mesh debug mesh
  148362. * @param scene is where the mesh will be added
  148363. * @returns debug display mesh
  148364. */
  148365. createDebugNavMesh(scene: Scene): Mesh;
  148366. /**
  148367. * Get a navigation mesh constrained position, closest to the parameter position
  148368. * @param position world position
  148369. * @returns the closest point to position constrained by the navigation mesh
  148370. */
  148371. getClosestPoint(position: Vector3): Vector3;
  148372. /**
  148373. * Get a navigation mesh constrained position, closest to the parameter position
  148374. * @param position world position
  148375. * @param result output the closest point to position constrained by the navigation mesh
  148376. */
  148377. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148378. /**
  148379. * Get a navigation mesh constrained position, within a particular radius
  148380. * @param position world position
  148381. * @param maxRadius the maximum distance to the constrained world position
  148382. * @returns the closest point to position constrained by the navigation mesh
  148383. */
  148384. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148385. /**
  148386. * Get a navigation mesh constrained position, within a particular radius
  148387. * @param position world position
  148388. * @param maxRadius the maximum distance to the constrained world position
  148389. * @param result output the closest point to position constrained by the navigation mesh
  148390. */
  148391. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148392. /**
  148393. * Compute the final position from a segment made of destination-position
  148394. * @param position world position
  148395. * @param destination world position
  148396. * @returns the resulting point along the navmesh
  148397. */
  148398. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148399. /**
  148400. * Compute the final position from a segment made of destination-position
  148401. * @param position world position
  148402. * @param destination world position
  148403. * @param result output the resulting point along the navmesh
  148404. */
  148405. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148406. /**
  148407. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148408. * @param start world position
  148409. * @param end world position
  148410. * @returns array containing world position composing the path
  148411. */
  148412. computePath(start: Vector3, end: Vector3): Vector3[];
  148413. /**
  148414. * Create a new Crowd so you can add agents
  148415. * @param maxAgents the maximum agent count in the crowd
  148416. * @param maxAgentRadius the maximum radius an agent can have
  148417. * @param scene to attach the crowd to
  148418. * @returns the crowd you can add agents to
  148419. */
  148420. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148421. /**
  148422. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148423. * The queries will try to find a solution within those bounds
  148424. * default is (1,1,1)
  148425. * @param extent x,y,z value that define the extent around the queries point of reference
  148426. */
  148427. setDefaultQueryExtent(extent: Vector3): void;
  148428. /**
  148429. * Get the Bounding box extent specified by setDefaultQueryExtent
  148430. * @returns the box extent values
  148431. */
  148432. getDefaultQueryExtent(): Vector3;
  148433. /**
  148434. * build the navmesh from a previously saved state using getNavmeshData
  148435. * @param data the Uint8Array returned by getNavmeshData
  148436. */
  148437. buildFromNavmeshData(data: Uint8Array): void;
  148438. /**
  148439. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148440. * @returns data the Uint8Array that can be saved and reused
  148441. */
  148442. getNavmeshData(): Uint8Array;
  148443. /**
  148444. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148445. * @param result output the box extent values
  148446. */
  148447. getDefaultQueryExtentToRef(result: Vector3): void;
  148448. /**
  148449. * Disposes
  148450. */
  148451. dispose(): void;
  148452. /**
  148453. * If this plugin is supported
  148454. * @returns true if plugin is supported
  148455. */
  148456. isSupported(): boolean;
  148457. }
  148458. /**
  148459. * Recast detour crowd implementation
  148460. */
  148461. export class RecastJSCrowd implements ICrowd {
  148462. /**
  148463. * Recast/detour plugin
  148464. */
  148465. bjsRECASTPlugin: RecastJSPlugin;
  148466. /**
  148467. * Link to the detour crowd
  148468. */
  148469. recastCrowd: any;
  148470. /**
  148471. * One transform per agent
  148472. */
  148473. transforms: TransformNode[];
  148474. /**
  148475. * All agents created
  148476. */
  148477. agents: number[];
  148478. /**
  148479. * Link to the scene is kept to unregister the crowd from the scene
  148480. */
  148481. private _scene;
  148482. /**
  148483. * Observer for crowd updates
  148484. */
  148485. private _onBeforeAnimationsObserver;
  148486. /**
  148487. * Constructor
  148488. * @param plugin recastJS plugin
  148489. * @param maxAgents the maximum agent count in the crowd
  148490. * @param maxAgentRadius the maximum radius an agent can have
  148491. * @param scene to attach the crowd to
  148492. * @returns the crowd you can add agents to
  148493. */
  148494. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148495. /**
  148496. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148497. * You can attach anything to that node. The node position is updated in the scene update tick.
  148498. * @param pos world position that will be constrained by the navigation mesh
  148499. * @param parameters agent parameters
  148500. * @param transform hooked to the agent that will be update by the scene
  148501. * @returns agent index
  148502. */
  148503. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148504. /**
  148505. * Returns the agent position in world space
  148506. * @param index agent index returned by addAgent
  148507. * @returns world space position
  148508. */
  148509. getAgentPosition(index: number): Vector3;
  148510. /**
  148511. * Returns the agent position result in world space
  148512. * @param index agent index returned by addAgent
  148513. * @param result output world space position
  148514. */
  148515. getAgentPositionToRef(index: number, result: Vector3): void;
  148516. /**
  148517. * Returns the agent velocity in world space
  148518. * @param index agent index returned by addAgent
  148519. * @returns world space velocity
  148520. */
  148521. getAgentVelocity(index: number): Vector3;
  148522. /**
  148523. * Returns the agent velocity result in world space
  148524. * @param index agent index returned by addAgent
  148525. * @param result output world space velocity
  148526. */
  148527. getAgentVelocityToRef(index: number, result: Vector3): void;
  148528. /**
  148529. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148530. * @param index agent index returned by addAgent
  148531. * @param destination targeted world position
  148532. */
  148533. agentGoto(index: number, destination: Vector3): void;
  148534. /**
  148535. * Teleport the agent to a new position
  148536. * @param index agent index returned by addAgent
  148537. * @param destination targeted world position
  148538. */
  148539. agentTeleport(index: number, destination: Vector3): void;
  148540. /**
  148541. * Update agent parameters
  148542. * @param index agent index returned by addAgent
  148543. * @param parameters agent parameters
  148544. */
  148545. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148546. /**
  148547. * remove a particular agent previously created
  148548. * @param index agent index returned by addAgent
  148549. */
  148550. removeAgent(index: number): void;
  148551. /**
  148552. * get the list of all agents attached to this crowd
  148553. * @returns list of agent indices
  148554. */
  148555. getAgents(): number[];
  148556. /**
  148557. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148558. * @param deltaTime in seconds
  148559. */
  148560. update(deltaTime: number): void;
  148561. /**
  148562. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148563. * The queries will try to find a solution within those bounds
  148564. * default is (1,1,1)
  148565. * @param extent x,y,z value that define the extent around the queries point of reference
  148566. */
  148567. setDefaultQueryExtent(extent: Vector3): void;
  148568. /**
  148569. * Get the Bounding box extent specified by setDefaultQueryExtent
  148570. * @returns the box extent values
  148571. */
  148572. getDefaultQueryExtent(): Vector3;
  148573. /**
  148574. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148575. * @param result output the box extent values
  148576. */
  148577. getDefaultQueryExtentToRef(result: Vector3): void;
  148578. /**
  148579. * Release all resources
  148580. */
  148581. dispose(): void;
  148582. }
  148583. }
  148584. declare module BABYLON {
  148585. /**
  148586. * Class used to enable access to IndexedDB
  148587. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148588. */
  148589. export class Database implements IOfflineProvider {
  148590. private _callbackManifestChecked;
  148591. private _currentSceneUrl;
  148592. private _db;
  148593. private _enableSceneOffline;
  148594. private _enableTexturesOffline;
  148595. private _manifestVersionFound;
  148596. private _mustUpdateRessources;
  148597. private _hasReachedQuota;
  148598. private _isSupported;
  148599. private _idbFactory;
  148600. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148601. private static IsUASupportingBlobStorage;
  148602. /**
  148603. * Gets a boolean indicating if Database storate is enabled (off by default)
  148604. */
  148605. static IDBStorageEnabled: boolean;
  148606. /**
  148607. * Gets a boolean indicating if scene must be saved in the database
  148608. */
  148609. get enableSceneOffline(): boolean;
  148610. /**
  148611. * Gets a boolean indicating if textures must be saved in the database
  148612. */
  148613. get enableTexturesOffline(): boolean;
  148614. /**
  148615. * Creates a new Database
  148616. * @param urlToScene defines the url to load the scene
  148617. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148618. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148619. */
  148620. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148621. private static _ParseURL;
  148622. private static _ReturnFullUrlLocation;
  148623. private _checkManifestFile;
  148624. /**
  148625. * Open the database and make it available
  148626. * @param successCallback defines the callback to call on success
  148627. * @param errorCallback defines the callback to call on error
  148628. */
  148629. open(successCallback: () => void, errorCallback: () => void): void;
  148630. /**
  148631. * Loads an image from the database
  148632. * @param url defines the url to load from
  148633. * @param image defines the target DOM image
  148634. */
  148635. loadImage(url: string, image: HTMLImageElement): void;
  148636. private _loadImageFromDBAsync;
  148637. private _saveImageIntoDBAsync;
  148638. private _checkVersionFromDB;
  148639. private _loadVersionFromDBAsync;
  148640. private _saveVersionIntoDBAsync;
  148641. /**
  148642. * Loads a file from database
  148643. * @param url defines the URL to load from
  148644. * @param sceneLoaded defines a callback to call on success
  148645. * @param progressCallBack defines a callback to call when progress changed
  148646. * @param errorCallback defines a callback to call on error
  148647. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148648. */
  148649. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148650. private _loadFileAsync;
  148651. private _saveFileAsync;
  148652. /**
  148653. * Validates if xhr data is correct
  148654. * @param xhr defines the request to validate
  148655. * @param dataType defines the expected data type
  148656. * @returns true if data is correct
  148657. */
  148658. private static _ValidateXHRData;
  148659. }
  148660. }
  148661. declare module BABYLON {
  148662. /** @hidden */
  148663. export var gpuUpdateParticlesPixelShader: {
  148664. name: string;
  148665. shader: string;
  148666. };
  148667. }
  148668. declare module BABYLON {
  148669. /** @hidden */
  148670. export var gpuUpdateParticlesVertexShader: {
  148671. name: string;
  148672. shader: string;
  148673. };
  148674. }
  148675. declare module BABYLON {
  148676. /** @hidden */
  148677. export var clipPlaneFragmentDeclaration2: {
  148678. name: string;
  148679. shader: string;
  148680. };
  148681. }
  148682. declare module BABYLON {
  148683. /** @hidden */
  148684. export var gpuRenderParticlesPixelShader: {
  148685. name: string;
  148686. shader: string;
  148687. };
  148688. }
  148689. declare module BABYLON {
  148690. /** @hidden */
  148691. export var clipPlaneVertexDeclaration2: {
  148692. name: string;
  148693. shader: string;
  148694. };
  148695. }
  148696. declare module BABYLON {
  148697. /** @hidden */
  148698. export var gpuRenderParticlesVertexShader: {
  148699. name: string;
  148700. shader: string;
  148701. };
  148702. }
  148703. declare module BABYLON {
  148704. /**
  148705. * This represents a GPU particle system in Babylon
  148706. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148707. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148708. */
  148709. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148710. /**
  148711. * The layer mask we are rendering the particles through.
  148712. */
  148713. layerMask: number;
  148714. private _capacity;
  148715. private _activeCount;
  148716. private _currentActiveCount;
  148717. private _accumulatedCount;
  148718. private _renderEffect;
  148719. private _updateEffect;
  148720. private _buffer0;
  148721. private _buffer1;
  148722. private _spriteBuffer;
  148723. private _updateVAO;
  148724. private _renderVAO;
  148725. private _targetIndex;
  148726. private _sourceBuffer;
  148727. private _targetBuffer;
  148728. private _currentRenderId;
  148729. private _started;
  148730. private _stopped;
  148731. private _timeDelta;
  148732. private _randomTexture;
  148733. private _randomTexture2;
  148734. private _attributesStrideSize;
  148735. private _updateEffectOptions;
  148736. private _randomTextureSize;
  148737. private _actualFrame;
  148738. private _customEffect;
  148739. private readonly _rawTextureWidth;
  148740. /**
  148741. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148742. */
  148743. static get IsSupported(): boolean;
  148744. /**
  148745. * An event triggered when the system is disposed.
  148746. */
  148747. onDisposeObservable: Observable<IParticleSystem>;
  148748. /**
  148749. * An event triggered when the system is stopped
  148750. */
  148751. onStoppedObservable: Observable<IParticleSystem>;
  148752. /**
  148753. * Gets the maximum number of particles active at the same time.
  148754. * @returns The max number of active particles.
  148755. */
  148756. getCapacity(): number;
  148757. /**
  148758. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148759. * to override the particles.
  148760. */
  148761. forceDepthWrite: boolean;
  148762. /**
  148763. * Gets or set the number of active particles
  148764. */
  148765. get activeParticleCount(): number;
  148766. set activeParticleCount(value: number);
  148767. private _preWarmDone;
  148768. /**
  148769. * Specifies if the particles are updated in emitter local space or world space.
  148770. */
  148771. isLocal: boolean;
  148772. /** Gets or sets a matrix to use to compute projection */
  148773. defaultProjectionMatrix: Matrix;
  148774. /**
  148775. * Is this system ready to be used/rendered
  148776. * @return true if the system is ready
  148777. */
  148778. isReady(): boolean;
  148779. /**
  148780. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148781. * @returns True if it has been started, otherwise false.
  148782. */
  148783. isStarted(): boolean;
  148784. /**
  148785. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148786. * @returns True if it has been stopped, otherwise false.
  148787. */
  148788. isStopped(): boolean;
  148789. /**
  148790. * Gets a boolean indicating that the system is stopping
  148791. * @returns true if the system is currently stopping
  148792. */
  148793. isStopping(): boolean;
  148794. /**
  148795. * Gets the number of particles active at the same time.
  148796. * @returns The number of active particles.
  148797. */
  148798. getActiveCount(): number;
  148799. /**
  148800. * Starts the particle system and begins to emit
  148801. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148802. */
  148803. start(delay?: number): void;
  148804. /**
  148805. * Stops the particle system.
  148806. */
  148807. stop(): void;
  148808. /**
  148809. * Remove all active particles
  148810. */
  148811. reset(): void;
  148812. /**
  148813. * Returns the string "GPUParticleSystem"
  148814. * @returns a string containing the class name
  148815. */
  148816. getClassName(): string;
  148817. /**
  148818. * Gets the custom effect used to render the particles
  148819. * @param blendMode Blend mode for which the effect should be retrieved
  148820. * @returns The effect
  148821. */
  148822. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148823. /**
  148824. * Sets the custom effect used to render the particles
  148825. * @param effect The effect to set
  148826. * @param blendMode Blend mode for which the effect should be set
  148827. */
  148828. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148829. /** @hidden */
  148830. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148831. /**
  148832. * Observable that will be called just before the particles are drawn
  148833. */
  148834. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148835. /**
  148836. * Gets the name of the particle vertex shader
  148837. */
  148838. get vertexShaderName(): string;
  148839. private _colorGradientsTexture;
  148840. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148841. /**
  148842. * Adds a new color gradient
  148843. * @param gradient defines the gradient to use (between 0 and 1)
  148844. * @param color1 defines the color to affect to the specified gradient
  148845. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148846. * @returns the current particle system
  148847. */
  148848. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148849. private _refreshColorGradient;
  148850. /** Force the system to rebuild all gradients that need to be resync */
  148851. forceRefreshGradients(): void;
  148852. /**
  148853. * Remove a specific color gradient
  148854. * @param gradient defines the gradient to remove
  148855. * @returns the current particle system
  148856. */
  148857. removeColorGradient(gradient: number): GPUParticleSystem;
  148858. private _angularSpeedGradientsTexture;
  148859. private _sizeGradientsTexture;
  148860. private _velocityGradientsTexture;
  148861. private _limitVelocityGradientsTexture;
  148862. private _dragGradientsTexture;
  148863. private _addFactorGradient;
  148864. /**
  148865. * Adds a new size gradient
  148866. * @param gradient defines the gradient to use (between 0 and 1)
  148867. * @param factor defines the size factor to affect to the specified gradient
  148868. * @returns the current particle system
  148869. */
  148870. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148871. /**
  148872. * Remove a specific size gradient
  148873. * @param gradient defines the gradient to remove
  148874. * @returns the current particle system
  148875. */
  148876. removeSizeGradient(gradient: number): GPUParticleSystem;
  148877. private _refreshFactorGradient;
  148878. /**
  148879. * Adds a new angular speed gradient
  148880. * @param gradient defines the gradient to use (between 0 and 1)
  148881. * @param factor defines the angular speed to affect to the specified gradient
  148882. * @returns the current particle system
  148883. */
  148884. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148885. /**
  148886. * Remove a specific angular speed gradient
  148887. * @param gradient defines the gradient to remove
  148888. * @returns the current particle system
  148889. */
  148890. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148891. /**
  148892. * Adds a new velocity gradient
  148893. * @param gradient defines the gradient to use (between 0 and 1)
  148894. * @param factor defines the velocity to affect to the specified gradient
  148895. * @returns the current particle system
  148896. */
  148897. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148898. /**
  148899. * Remove a specific velocity gradient
  148900. * @param gradient defines the gradient to remove
  148901. * @returns the current particle system
  148902. */
  148903. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148904. /**
  148905. * Adds a new limit velocity gradient
  148906. * @param gradient defines the gradient to use (between 0 and 1)
  148907. * @param factor defines the limit velocity value to affect to the specified gradient
  148908. * @returns the current particle system
  148909. */
  148910. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148911. /**
  148912. * Remove a specific limit velocity gradient
  148913. * @param gradient defines the gradient to remove
  148914. * @returns the current particle system
  148915. */
  148916. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148917. /**
  148918. * Adds a new drag gradient
  148919. * @param gradient defines the gradient to use (between 0 and 1)
  148920. * @param factor defines the drag value to affect to the specified gradient
  148921. * @returns the current particle system
  148922. */
  148923. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148924. /**
  148925. * Remove a specific drag gradient
  148926. * @param gradient defines the gradient to remove
  148927. * @returns the current particle system
  148928. */
  148929. removeDragGradient(gradient: number): GPUParticleSystem;
  148930. /**
  148931. * Not supported by GPUParticleSystem
  148932. * @param gradient defines the gradient to use (between 0 and 1)
  148933. * @param factor defines the emit rate value to affect to the specified gradient
  148934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148935. * @returns the current particle system
  148936. */
  148937. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148938. /**
  148939. * Not supported by GPUParticleSystem
  148940. * @param gradient defines the gradient to remove
  148941. * @returns the current particle system
  148942. */
  148943. removeEmitRateGradient(gradient: number): IParticleSystem;
  148944. /**
  148945. * Not supported by GPUParticleSystem
  148946. * @param gradient defines the gradient to use (between 0 and 1)
  148947. * @param factor defines the start size value to affect to the specified gradient
  148948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148949. * @returns the current particle system
  148950. */
  148951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148952. /**
  148953. * Not supported by GPUParticleSystem
  148954. * @param gradient defines the gradient to remove
  148955. * @returns the current particle system
  148956. */
  148957. removeStartSizeGradient(gradient: number): IParticleSystem;
  148958. /**
  148959. * Not supported by GPUParticleSystem
  148960. * @param gradient defines the gradient to use (between 0 and 1)
  148961. * @param min defines the color remap minimal range
  148962. * @param max defines the color remap maximal range
  148963. * @returns the current particle system
  148964. */
  148965. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148966. /**
  148967. * Not supported by GPUParticleSystem
  148968. * @param gradient defines the gradient to remove
  148969. * @returns the current particle system
  148970. */
  148971. removeColorRemapGradient(): IParticleSystem;
  148972. /**
  148973. * Not supported by GPUParticleSystem
  148974. * @param gradient defines the gradient to use (between 0 and 1)
  148975. * @param min defines the alpha remap minimal range
  148976. * @param max defines the alpha remap maximal range
  148977. * @returns the current particle system
  148978. */
  148979. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148980. /**
  148981. * Not supported by GPUParticleSystem
  148982. * @param gradient defines the gradient to remove
  148983. * @returns the current particle system
  148984. */
  148985. removeAlphaRemapGradient(): IParticleSystem;
  148986. /**
  148987. * Not supported by GPUParticleSystem
  148988. * @param gradient defines the gradient to use (between 0 and 1)
  148989. * @param color defines the color to affect to the specified gradient
  148990. * @returns the current particle system
  148991. */
  148992. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148993. /**
  148994. * Not supported by GPUParticleSystem
  148995. * @param gradient defines the gradient to remove
  148996. * @returns the current particle system
  148997. */
  148998. removeRampGradient(): IParticleSystem;
  148999. /**
  149000. * Not supported by GPUParticleSystem
  149001. * @returns the list of ramp gradients
  149002. */
  149003. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149004. /**
  149005. * Not supported by GPUParticleSystem
  149006. * Gets or sets a boolean indicating that ramp gradients must be used
  149007. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149008. */
  149009. get useRampGradients(): boolean;
  149010. set useRampGradients(value: boolean);
  149011. /**
  149012. * Not supported by GPUParticleSystem
  149013. * @param gradient defines the gradient to use (between 0 and 1)
  149014. * @param factor defines the life time factor to affect to the specified gradient
  149015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149016. * @returns the current particle system
  149017. */
  149018. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149019. /**
  149020. * Not supported by GPUParticleSystem
  149021. * @param gradient defines the gradient to remove
  149022. * @returns the current particle system
  149023. */
  149024. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149025. /**
  149026. * Instantiates a GPU particle system.
  149027. * 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.
  149028. * @param name The name of the particle system
  149029. * @param options The options used to create the system
  149030. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149031. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149032. * @param customEffect a custom effect used to change the way particles are rendered by default
  149033. */
  149034. constructor(name: string, options: Partial<{
  149035. capacity: number;
  149036. randomTextureSize: number;
  149037. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149038. protected _reset(): void;
  149039. private _createUpdateVAO;
  149040. private _createRenderVAO;
  149041. private _initialize;
  149042. /** @hidden */
  149043. _recreateUpdateEffect(): void;
  149044. private _getEffect;
  149045. /**
  149046. * Fill the defines array according to the current settings of the particle system
  149047. * @param defines Array to be updated
  149048. * @param blendMode blend mode to take into account when updating the array
  149049. */
  149050. fillDefines(defines: Array<string>, blendMode?: number): void;
  149051. /**
  149052. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149053. * @param uniforms Uniforms array to fill
  149054. * @param attributes Attributes array to fill
  149055. * @param samplers Samplers array to fill
  149056. */
  149057. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149058. /** @hidden */
  149059. _recreateRenderEffect(): Effect;
  149060. /**
  149061. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149062. * @param preWarm defines if we are in the pre-warmimg phase
  149063. */
  149064. animate(preWarm?: boolean): void;
  149065. private _createFactorGradientTexture;
  149066. private _createSizeGradientTexture;
  149067. private _createAngularSpeedGradientTexture;
  149068. private _createVelocityGradientTexture;
  149069. private _createLimitVelocityGradientTexture;
  149070. private _createDragGradientTexture;
  149071. private _createColorGradientTexture;
  149072. /**
  149073. * Renders the particle system in its current state
  149074. * @param preWarm defines if the system should only update the particles but not render them
  149075. * @returns the current number of particles
  149076. */
  149077. render(preWarm?: boolean): number;
  149078. /**
  149079. * Rebuilds the particle system
  149080. */
  149081. rebuild(): void;
  149082. private _releaseBuffers;
  149083. private _releaseVAOs;
  149084. /**
  149085. * Disposes the particle system and free the associated resources
  149086. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149087. */
  149088. dispose(disposeTexture?: boolean): void;
  149089. /**
  149090. * Clones the particle system.
  149091. * @param name The name of the cloned object
  149092. * @param newEmitter The new emitter to use
  149093. * @returns the cloned particle system
  149094. */
  149095. clone(name: string, newEmitter: any): GPUParticleSystem;
  149096. /**
  149097. * Serializes the particle system to a JSON object
  149098. * @param serializeTexture defines if the texture must be serialized as well
  149099. * @returns the JSON object
  149100. */
  149101. serialize(serializeTexture?: boolean): any;
  149102. /**
  149103. * Parses a JSON object to create a GPU particle system.
  149104. * @param parsedParticleSystem The JSON object to parse
  149105. * @param sceneOrEngine The scene or the engine to create the particle system in
  149106. * @param rootUrl The root url to use to load external dependencies like texture
  149107. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149108. * @returns the parsed GPU particle system
  149109. */
  149110. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149111. }
  149112. }
  149113. declare module BABYLON {
  149114. /**
  149115. * Represents a set of particle systems working together to create a specific effect
  149116. */
  149117. export class ParticleSystemSet implements IDisposable {
  149118. /**
  149119. * Gets or sets base Assets URL
  149120. */
  149121. static BaseAssetsUrl: string;
  149122. private _emitterCreationOptions;
  149123. private _emitterNode;
  149124. /**
  149125. * Gets the particle system list
  149126. */
  149127. systems: IParticleSystem[];
  149128. /**
  149129. * Gets the emitter node used with this set
  149130. */
  149131. get emitterNode(): Nullable<TransformNode>;
  149132. /**
  149133. * Creates a new emitter mesh as a sphere
  149134. * @param options defines the options used to create the sphere
  149135. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149136. * @param scene defines the hosting scene
  149137. */
  149138. setEmitterAsSphere(options: {
  149139. diameter: number;
  149140. segments: number;
  149141. color: Color3;
  149142. }, renderingGroupId: number, scene: Scene): void;
  149143. /**
  149144. * Starts all particle systems of the set
  149145. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149146. */
  149147. start(emitter?: AbstractMesh): void;
  149148. /**
  149149. * Release all associated resources
  149150. */
  149151. dispose(): void;
  149152. /**
  149153. * Serialize the set into a JSON compatible object
  149154. * @param serializeTexture defines if the texture must be serialized as well
  149155. * @returns a JSON compatible representation of the set
  149156. */
  149157. serialize(serializeTexture?: boolean): any;
  149158. /**
  149159. * Parse a new ParticleSystemSet from a serialized source
  149160. * @param data defines a JSON compatible representation of the set
  149161. * @param scene defines the hosting scene
  149162. * @param gpu defines if we want GPU particles or CPU particles
  149163. * @returns a new ParticleSystemSet
  149164. */
  149165. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149166. }
  149167. }
  149168. declare module BABYLON {
  149169. /**
  149170. * This class is made for on one-liner static method to help creating particle system set.
  149171. */
  149172. export class ParticleHelper {
  149173. /**
  149174. * Gets or sets base Assets URL
  149175. */
  149176. static BaseAssetsUrl: string;
  149177. /** Define the Url to load snippets */
  149178. static SnippetUrl: string;
  149179. /**
  149180. * Create a default particle system that you can tweak
  149181. * @param emitter defines the emitter to use
  149182. * @param capacity defines the system capacity (default is 500 particles)
  149183. * @param scene defines the hosting scene
  149184. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149185. * @returns the new Particle system
  149186. */
  149187. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149188. /**
  149189. * This is the main static method (one-liner) of this helper to create different particle systems
  149190. * @param type This string represents the type to the particle system to create
  149191. * @param scene The scene where the particle system should live
  149192. * @param gpu If the system will use gpu
  149193. * @returns the ParticleSystemSet created
  149194. */
  149195. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149196. /**
  149197. * Static function used to export a particle system to a ParticleSystemSet variable.
  149198. * Please note that the emitter shape is not exported
  149199. * @param systems defines the particle systems to export
  149200. * @returns the created particle system set
  149201. */
  149202. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149203. /**
  149204. * Creates a particle system from a snippet saved in a remote file
  149205. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149206. * @param url defines the url to load from
  149207. * @param scene defines the hosting scene
  149208. * @param gpu If the system will use gpu
  149209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149210. * @returns a promise that will resolve to the new particle system
  149211. */
  149212. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149213. /**
  149214. * Creates a particle system from a snippet saved by the particle system editor
  149215. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149216. * @param scene defines the hosting scene
  149217. * @param gpu If the system will use gpu
  149218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149219. * @returns a promise that will resolve to the new particle system
  149220. */
  149221. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149222. }
  149223. }
  149224. declare module BABYLON {
  149225. interface Engine {
  149226. /**
  149227. * Create an effect to use with particle systems.
  149228. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149229. * the particle system for which you want to create a custom effect in the last parameter
  149230. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149231. * @param uniformsNames defines a list of attribute names
  149232. * @param samplers defines an array of string used to represent textures
  149233. * @param defines defines the string containing the defines to use to compile the shaders
  149234. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149235. * @param onCompiled defines a function to call when the effect creation is successful
  149236. * @param onError defines a function to call when the effect creation has failed
  149237. * @param particleSystem the particle system you want to create the effect for
  149238. * @returns the new Effect
  149239. */
  149240. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149241. }
  149242. interface Mesh {
  149243. /**
  149244. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149245. * @returns an array of IParticleSystem
  149246. */
  149247. getEmittedParticleSystems(): IParticleSystem[];
  149248. /**
  149249. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149250. * @returns an array of IParticleSystem
  149251. */
  149252. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149253. }
  149254. }
  149255. declare module BABYLON {
  149256. /** Defines the 4 color options */
  149257. export enum PointColor {
  149258. /** color value */
  149259. Color = 2,
  149260. /** uv value */
  149261. UV = 1,
  149262. /** random value */
  149263. Random = 0,
  149264. /** stated value */
  149265. Stated = 3
  149266. }
  149267. /**
  149268. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149269. * 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.
  149270. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149271. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149272. *
  149273. * Full documentation here : TO BE ENTERED
  149274. */
  149275. export class PointsCloudSystem implements IDisposable {
  149276. /**
  149277. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149278. * Example : var p = SPS.particles[i];
  149279. */
  149280. particles: CloudPoint[];
  149281. /**
  149282. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149283. */
  149284. nbParticles: number;
  149285. /**
  149286. * This a counter for your own usage. It's not set by any SPS functions.
  149287. */
  149288. counter: number;
  149289. /**
  149290. * The PCS name. This name is also given to the underlying mesh.
  149291. */
  149292. name: string;
  149293. /**
  149294. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149295. */
  149296. mesh: Mesh;
  149297. /**
  149298. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149299. * Please read :
  149300. */
  149301. vars: any;
  149302. /**
  149303. * @hidden
  149304. */
  149305. _size: number;
  149306. private _scene;
  149307. private _promises;
  149308. private _positions;
  149309. private _indices;
  149310. private _normals;
  149311. private _colors;
  149312. private _uvs;
  149313. private _indices32;
  149314. private _positions32;
  149315. private _colors32;
  149316. private _uvs32;
  149317. private _updatable;
  149318. private _isVisibilityBoxLocked;
  149319. private _alwaysVisible;
  149320. private _groups;
  149321. private _groupCounter;
  149322. private _computeParticleColor;
  149323. private _computeParticleTexture;
  149324. private _computeParticleRotation;
  149325. private _computeBoundingBox;
  149326. private _isReady;
  149327. /**
  149328. * Creates a PCS (Points Cloud System) object
  149329. * @param name (String) is the PCS name, this will be the underlying mesh name
  149330. * @param pointSize (number) is the size for each point
  149331. * @param scene (Scene) is the scene in which the PCS is added
  149332. * @param options defines the options of the PCS e.g.
  149333. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149334. */
  149335. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149336. updatable?: boolean;
  149337. });
  149338. /**
  149339. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149340. * If no points were added to the PCS, the returned mesh is just a single point.
  149341. * @returns a promise for the created mesh
  149342. */
  149343. buildMeshAsync(): Promise<Mesh>;
  149344. /**
  149345. * @hidden
  149346. */
  149347. private _buildMesh;
  149348. private _addParticle;
  149349. private _randomUnitVector;
  149350. private _getColorIndicesForCoord;
  149351. private _setPointsColorOrUV;
  149352. private _colorFromTexture;
  149353. private _calculateDensity;
  149354. /**
  149355. * Adds points to the PCS in random positions within a unit sphere
  149356. * @param nb (positive integer) the number of particles to be created from this model
  149357. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149358. * @returns the number of groups in the system
  149359. */
  149360. addPoints(nb: number, pointFunction?: any): number;
  149361. /**
  149362. * Adds points to the PCS from the surface of the model shape
  149363. * @param mesh is any Mesh object that will be used as a surface model for the points
  149364. * @param nb (positive integer) the number of particles to be created from this model
  149365. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149366. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149367. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149368. * @returns the number of groups in the system
  149369. */
  149370. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149371. /**
  149372. * Adds points to the PCS inside the model shape
  149373. * @param mesh is any Mesh object that will be used as a surface model for the points
  149374. * @param nb (positive integer) the number of particles to be created from this model
  149375. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149376. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149377. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149378. * @returns the number of groups in the system
  149379. */
  149380. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149381. /**
  149382. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149383. * This method calls `updateParticle()` for each particle of the SPS.
  149384. * For an animated SPS, it is usually called within the render loop.
  149385. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149386. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149387. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149388. * @returns the PCS.
  149389. */
  149390. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149391. /**
  149392. * Disposes the PCS.
  149393. */
  149394. dispose(): void;
  149395. /**
  149396. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149397. * doc :
  149398. * @returns the PCS.
  149399. */
  149400. refreshVisibleSize(): PointsCloudSystem;
  149401. /**
  149402. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149403. * @param size the size (float) of the visibility box
  149404. * note : this doesn't lock the PCS mesh bounding box.
  149405. * doc :
  149406. */
  149407. setVisibilityBox(size: number): void;
  149408. /**
  149409. * Gets whether the PCS is always visible or not
  149410. * doc :
  149411. */
  149412. get isAlwaysVisible(): boolean;
  149413. /**
  149414. * Sets the PCS as always visible or not
  149415. * doc :
  149416. */
  149417. set isAlwaysVisible(val: boolean);
  149418. /**
  149419. * Tells to `setParticles()` to compute the particle rotations or not
  149420. * Default value : false. The PCS is faster when it's set to false
  149421. * Note : particle rotations are only applied to parent particles
  149422. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149423. */
  149424. set computeParticleRotation(val: boolean);
  149425. /**
  149426. * Tells to `setParticles()` to compute the particle colors or not.
  149427. * Default value : true. The PCS is faster when it's set to false.
  149428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149429. */
  149430. set computeParticleColor(val: boolean);
  149431. set computeParticleTexture(val: boolean);
  149432. /**
  149433. * Gets if `setParticles()` computes the particle colors or not.
  149434. * Default value : false. The PCS is faster when it's set to false.
  149435. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149436. */
  149437. get computeParticleColor(): boolean;
  149438. /**
  149439. * Gets if `setParticles()` computes the particle textures or not.
  149440. * Default value : false. The PCS is faster when it's set to false.
  149441. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149442. */
  149443. get computeParticleTexture(): boolean;
  149444. /**
  149445. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149446. */
  149447. set computeBoundingBox(val: boolean);
  149448. /**
  149449. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149450. */
  149451. get computeBoundingBox(): boolean;
  149452. /**
  149453. * This function does nothing. It may be overwritten to set all the particle first values.
  149454. * The PCS doesn't call this function, you may have to call it by your own.
  149455. * doc :
  149456. */
  149457. initParticles(): void;
  149458. /**
  149459. * This function does nothing. It may be overwritten to recycle a particle
  149460. * The PCS doesn't call this function, you can to call it
  149461. * doc :
  149462. * @param particle The particle to recycle
  149463. * @returns the recycled particle
  149464. */
  149465. recycleParticle(particle: CloudPoint): CloudPoint;
  149466. /**
  149467. * Updates a particle : this function should be overwritten by the user.
  149468. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149469. * doc :
  149470. * @example : just set a particle position or velocity and recycle conditions
  149471. * @param particle The particle to update
  149472. * @returns the updated particle
  149473. */
  149474. updateParticle(particle: CloudPoint): CloudPoint;
  149475. /**
  149476. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149477. * This does nothing and may be overwritten by the user.
  149478. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149479. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149480. * @param update the boolean update value actually passed to setParticles()
  149481. */
  149482. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149483. /**
  149484. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149485. * This will be passed three parameters.
  149486. * This does nothing and may be overwritten by the user.
  149487. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149488. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149489. * @param update the boolean update value actually passed to setParticles()
  149490. */
  149491. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149492. }
  149493. }
  149494. declare module BABYLON {
  149495. /**
  149496. * Represents one particle of a points cloud system.
  149497. */
  149498. export class CloudPoint {
  149499. /**
  149500. * particle global index
  149501. */
  149502. idx: number;
  149503. /**
  149504. * The color of the particle
  149505. */
  149506. color: Nullable<Color4>;
  149507. /**
  149508. * The world space position of the particle.
  149509. */
  149510. position: Vector3;
  149511. /**
  149512. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149513. */
  149514. rotation: Vector3;
  149515. /**
  149516. * The world space rotation quaternion of the particle.
  149517. */
  149518. rotationQuaternion: Nullable<Quaternion>;
  149519. /**
  149520. * The uv of the particle.
  149521. */
  149522. uv: Nullable<Vector2>;
  149523. /**
  149524. * The current speed of the particle.
  149525. */
  149526. velocity: Vector3;
  149527. /**
  149528. * The pivot point in the particle local space.
  149529. */
  149530. pivot: Vector3;
  149531. /**
  149532. * Must the particle be translated from its pivot point in its local space ?
  149533. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149534. * Default : false
  149535. */
  149536. translateFromPivot: boolean;
  149537. /**
  149538. * Index of this particle in the global "positions" array (Internal use)
  149539. * @hidden
  149540. */
  149541. _pos: number;
  149542. /**
  149543. * @hidden Index of this particle in the global "indices" array (Internal use)
  149544. */
  149545. _ind: number;
  149546. /**
  149547. * Group this particle belongs to
  149548. */
  149549. _group: PointsGroup;
  149550. /**
  149551. * Group id of this particle
  149552. */
  149553. groupId: number;
  149554. /**
  149555. * Index of the particle in its group id (Internal use)
  149556. */
  149557. idxInGroup: number;
  149558. /**
  149559. * @hidden Particle BoundingInfo object (Internal use)
  149560. */
  149561. _boundingInfo: BoundingInfo;
  149562. /**
  149563. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149564. */
  149565. _pcs: PointsCloudSystem;
  149566. /**
  149567. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149568. */
  149569. _stillInvisible: boolean;
  149570. /**
  149571. * @hidden Last computed particle rotation matrix
  149572. */
  149573. _rotationMatrix: number[];
  149574. /**
  149575. * Parent particle Id, if any.
  149576. * Default null.
  149577. */
  149578. parentId: Nullable<number>;
  149579. /**
  149580. * @hidden Internal global position in the PCS.
  149581. */
  149582. _globalPosition: Vector3;
  149583. /**
  149584. * Creates a Point Cloud object.
  149585. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149586. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149587. * @param group (PointsGroup) is the group the particle belongs to
  149588. * @param groupId (integer) is the group identifier in the PCS.
  149589. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149590. * @param pcs defines the PCS it is associated to
  149591. */
  149592. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149593. /**
  149594. * get point size
  149595. */
  149596. get size(): Vector3;
  149597. /**
  149598. * Set point size
  149599. */
  149600. set size(scale: Vector3);
  149601. /**
  149602. * Legacy support, changed quaternion to rotationQuaternion
  149603. */
  149604. get quaternion(): Nullable<Quaternion>;
  149605. /**
  149606. * Legacy support, changed quaternion to rotationQuaternion
  149607. */
  149608. set quaternion(q: Nullable<Quaternion>);
  149609. /**
  149610. * Returns a boolean. True if the particle intersects a mesh, else false
  149611. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149612. * @param target is the object (point or mesh) what the intersection is computed against
  149613. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149614. * @returns true if it intersects
  149615. */
  149616. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149617. /**
  149618. * get the rotation matrix of the particle
  149619. * @hidden
  149620. */
  149621. getRotationMatrix(m: Matrix): void;
  149622. }
  149623. /**
  149624. * Represents a group of points in a points cloud system
  149625. * * PCS internal tool, don't use it manually.
  149626. */
  149627. export class PointsGroup {
  149628. /**
  149629. * The group id
  149630. * @hidden
  149631. */
  149632. groupID: number;
  149633. /**
  149634. * image data for group (internal use)
  149635. * @hidden
  149636. */
  149637. _groupImageData: Nullable<ArrayBufferView>;
  149638. /**
  149639. * Image Width (internal use)
  149640. * @hidden
  149641. */
  149642. _groupImgWidth: number;
  149643. /**
  149644. * Image Height (internal use)
  149645. * @hidden
  149646. */
  149647. _groupImgHeight: number;
  149648. /**
  149649. * Custom position function (internal use)
  149650. * @hidden
  149651. */
  149652. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149653. /**
  149654. * density per facet for surface points
  149655. * @hidden
  149656. */
  149657. _groupDensity: number[];
  149658. /**
  149659. * Only when points are colored by texture carries pointer to texture list array
  149660. * @hidden
  149661. */
  149662. _textureNb: number;
  149663. /**
  149664. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149665. * PCS internal tool, don't use it manually.
  149666. * @hidden
  149667. */
  149668. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149669. }
  149670. }
  149671. declare module BABYLON {
  149672. interface Scene {
  149673. /** @hidden (Backing field) */
  149674. _physicsEngine: Nullable<IPhysicsEngine>;
  149675. /** @hidden */
  149676. _physicsTimeAccumulator: number;
  149677. /**
  149678. * Gets the current physics engine
  149679. * @returns a IPhysicsEngine or null if none attached
  149680. */
  149681. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149682. /**
  149683. * Enables physics to the current scene
  149684. * @param gravity defines the scene's gravity for the physics engine
  149685. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149686. * @return a boolean indicating if the physics engine was initialized
  149687. */
  149688. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149689. /**
  149690. * Disables and disposes the physics engine associated with the scene
  149691. */
  149692. disablePhysicsEngine(): void;
  149693. /**
  149694. * Gets a boolean indicating if there is an active physics engine
  149695. * @returns a boolean indicating if there is an active physics engine
  149696. */
  149697. isPhysicsEnabled(): boolean;
  149698. /**
  149699. * Deletes a physics compound impostor
  149700. * @param compound defines the compound to delete
  149701. */
  149702. deleteCompoundImpostor(compound: any): void;
  149703. /**
  149704. * An event triggered when physic simulation is about to be run
  149705. */
  149706. onBeforePhysicsObservable: Observable<Scene>;
  149707. /**
  149708. * An event triggered when physic simulation has been done
  149709. */
  149710. onAfterPhysicsObservable: Observable<Scene>;
  149711. }
  149712. interface AbstractMesh {
  149713. /** @hidden */
  149714. _physicsImpostor: Nullable<PhysicsImpostor>;
  149715. /**
  149716. * Gets or sets impostor used for physic simulation
  149717. * @see https://doc.babylonjs.com/features/physics_engine
  149718. */
  149719. physicsImpostor: Nullable<PhysicsImpostor>;
  149720. /**
  149721. * Gets the current physics impostor
  149722. * @see https://doc.babylonjs.com/features/physics_engine
  149723. * @returns a physics impostor or null
  149724. */
  149725. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149726. /** Apply a physic impulse to the mesh
  149727. * @param force defines the force to apply
  149728. * @param contactPoint defines where to apply the force
  149729. * @returns the current mesh
  149730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149731. */
  149732. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149733. /**
  149734. * Creates a physic joint between two meshes
  149735. * @param otherMesh defines the other mesh to use
  149736. * @param pivot1 defines the pivot to use on this mesh
  149737. * @param pivot2 defines the pivot to use on the other mesh
  149738. * @param options defines additional options (can be plugin dependent)
  149739. * @returns the current mesh
  149740. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149741. */
  149742. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149743. /** @hidden */
  149744. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149745. }
  149746. /**
  149747. * Defines the physics engine scene component responsible to manage a physics engine
  149748. */
  149749. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149750. /**
  149751. * The component name helpful to identify the component in the list of scene components.
  149752. */
  149753. readonly name: string;
  149754. /**
  149755. * The scene the component belongs to.
  149756. */
  149757. scene: Scene;
  149758. /**
  149759. * Creates a new instance of the component for the given scene
  149760. * @param scene Defines the scene to register the component in
  149761. */
  149762. constructor(scene: Scene);
  149763. /**
  149764. * Registers the component in a given scene
  149765. */
  149766. register(): void;
  149767. /**
  149768. * Rebuilds the elements related to this component in case of
  149769. * context lost for instance.
  149770. */
  149771. rebuild(): void;
  149772. /**
  149773. * Disposes the component and the associated ressources
  149774. */
  149775. dispose(): void;
  149776. }
  149777. }
  149778. declare module BABYLON {
  149779. /**
  149780. * A helper for physics simulations
  149781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149782. */
  149783. export class PhysicsHelper {
  149784. private _scene;
  149785. private _physicsEngine;
  149786. /**
  149787. * Initializes the Physics helper
  149788. * @param scene Babylon.js scene
  149789. */
  149790. constructor(scene: Scene);
  149791. /**
  149792. * Applies a radial explosion impulse
  149793. * @param origin the origin of the explosion
  149794. * @param radiusOrEventOptions the radius or the options of radial explosion
  149795. * @param strength the explosion strength
  149796. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149797. * @returns A physics radial explosion event, or null
  149798. */
  149799. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149800. /**
  149801. * Applies a radial explosion force
  149802. * @param origin the origin of the explosion
  149803. * @param radiusOrEventOptions the radius or the options of radial explosion
  149804. * @param strength the explosion strength
  149805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149806. * @returns A physics radial explosion event, or null
  149807. */
  149808. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149809. /**
  149810. * Creates a gravitational field
  149811. * @param origin the origin of the explosion
  149812. * @param radiusOrEventOptions the radius or the options of radial explosion
  149813. * @param strength the explosion strength
  149814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149815. * @returns A physics gravitational field event, or null
  149816. */
  149817. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149818. /**
  149819. * Creates a physics updraft event
  149820. * @param origin the origin of the updraft
  149821. * @param radiusOrEventOptions the radius or the options of the updraft
  149822. * @param strength the strength of the updraft
  149823. * @param height the height of the updraft
  149824. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149825. * @returns A physics updraft event, or null
  149826. */
  149827. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149828. /**
  149829. * Creates a physics vortex event
  149830. * @param origin the of the vortex
  149831. * @param radiusOrEventOptions the radius or the options of the vortex
  149832. * @param strength the strength of the vortex
  149833. * @param height the height of the vortex
  149834. * @returns a Physics vortex event, or null
  149835. * A physics vortex event or null
  149836. */
  149837. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149838. }
  149839. /**
  149840. * Represents a physics radial explosion event
  149841. */
  149842. class PhysicsRadialExplosionEvent {
  149843. private _scene;
  149844. private _options;
  149845. private _sphere;
  149846. private _dataFetched;
  149847. /**
  149848. * Initializes a radial explosioin event
  149849. * @param _scene BabylonJS scene
  149850. * @param _options The options for the vortex event
  149851. */
  149852. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149853. /**
  149854. * Returns the data related to the radial explosion event (sphere).
  149855. * @returns The radial explosion event data
  149856. */
  149857. getData(): PhysicsRadialExplosionEventData;
  149858. /**
  149859. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149860. * @param impostor A physics imposter
  149861. * @param origin the origin of the explosion
  149862. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149863. */
  149864. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149865. /**
  149866. * Triggers affecterd impostors callbacks
  149867. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149868. */
  149869. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149870. /**
  149871. * Disposes the sphere.
  149872. * @param force Specifies if the sphere should be disposed by force
  149873. */
  149874. dispose(force?: boolean): void;
  149875. /*** Helpers ***/
  149876. private _prepareSphere;
  149877. private _intersectsWithSphere;
  149878. }
  149879. /**
  149880. * Represents a gravitational field event
  149881. */
  149882. class PhysicsGravitationalFieldEvent {
  149883. private _physicsHelper;
  149884. private _scene;
  149885. private _origin;
  149886. private _options;
  149887. private _tickCallback;
  149888. private _sphere;
  149889. private _dataFetched;
  149890. /**
  149891. * Initializes the physics gravitational field event
  149892. * @param _physicsHelper A physics helper
  149893. * @param _scene BabylonJS scene
  149894. * @param _origin The origin position of the gravitational field event
  149895. * @param _options The options for the vortex event
  149896. */
  149897. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149898. /**
  149899. * Returns the data related to the gravitational field event (sphere).
  149900. * @returns A gravitational field event
  149901. */
  149902. getData(): PhysicsGravitationalFieldEventData;
  149903. /**
  149904. * Enables the gravitational field.
  149905. */
  149906. enable(): void;
  149907. /**
  149908. * Disables the gravitational field.
  149909. */
  149910. disable(): void;
  149911. /**
  149912. * Disposes the sphere.
  149913. * @param force The force to dispose from the gravitational field event
  149914. */
  149915. dispose(force?: boolean): void;
  149916. private _tick;
  149917. }
  149918. /**
  149919. * Represents a physics updraft event
  149920. */
  149921. class PhysicsUpdraftEvent {
  149922. private _scene;
  149923. private _origin;
  149924. private _options;
  149925. private _physicsEngine;
  149926. private _originTop;
  149927. private _originDirection;
  149928. private _tickCallback;
  149929. private _cylinder;
  149930. private _cylinderPosition;
  149931. private _dataFetched;
  149932. /**
  149933. * Initializes the physics updraft event
  149934. * @param _scene BabylonJS scene
  149935. * @param _origin The origin position of the updraft
  149936. * @param _options The options for the updraft event
  149937. */
  149938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149939. /**
  149940. * Returns the data related to the updraft event (cylinder).
  149941. * @returns A physics updraft event
  149942. */
  149943. getData(): PhysicsUpdraftEventData;
  149944. /**
  149945. * Enables the updraft.
  149946. */
  149947. enable(): void;
  149948. /**
  149949. * Disables the updraft.
  149950. */
  149951. disable(): void;
  149952. /**
  149953. * Disposes the cylinder.
  149954. * @param force Specifies if the updraft should be disposed by force
  149955. */
  149956. dispose(force?: boolean): void;
  149957. private getImpostorHitData;
  149958. private _tick;
  149959. /*** Helpers ***/
  149960. private _prepareCylinder;
  149961. private _intersectsWithCylinder;
  149962. }
  149963. /**
  149964. * Represents a physics vortex event
  149965. */
  149966. class PhysicsVortexEvent {
  149967. private _scene;
  149968. private _origin;
  149969. private _options;
  149970. private _physicsEngine;
  149971. private _originTop;
  149972. private _tickCallback;
  149973. private _cylinder;
  149974. private _cylinderPosition;
  149975. private _dataFetched;
  149976. /**
  149977. * Initializes the physics vortex event
  149978. * @param _scene The BabylonJS scene
  149979. * @param _origin The origin position of the vortex
  149980. * @param _options The options for the vortex event
  149981. */
  149982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149983. /**
  149984. * Returns the data related to the vortex event (cylinder).
  149985. * @returns The physics vortex event data
  149986. */
  149987. getData(): PhysicsVortexEventData;
  149988. /**
  149989. * Enables the vortex.
  149990. */
  149991. enable(): void;
  149992. /**
  149993. * Disables the cortex.
  149994. */
  149995. disable(): void;
  149996. /**
  149997. * Disposes the sphere.
  149998. * @param force
  149999. */
  150000. dispose(force?: boolean): void;
  150001. private getImpostorHitData;
  150002. private _tick;
  150003. /*** Helpers ***/
  150004. private _prepareCylinder;
  150005. private _intersectsWithCylinder;
  150006. }
  150007. /**
  150008. * Options fot the radial explosion event
  150009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150010. */
  150011. export class PhysicsRadialExplosionEventOptions {
  150012. /**
  150013. * The radius of the sphere for the radial explosion.
  150014. */
  150015. radius: number;
  150016. /**
  150017. * The strenth of the explosion.
  150018. */
  150019. strength: number;
  150020. /**
  150021. * The strenght of the force in correspondence to the distance of the affected object
  150022. */
  150023. falloff: PhysicsRadialImpulseFalloff;
  150024. /**
  150025. * Sphere options for the radial explosion.
  150026. */
  150027. sphere: {
  150028. segments: number;
  150029. diameter: number;
  150030. };
  150031. /**
  150032. * Sphere options for the radial explosion.
  150033. */
  150034. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150035. }
  150036. /**
  150037. * Options fot the updraft event
  150038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150039. */
  150040. export class PhysicsUpdraftEventOptions {
  150041. /**
  150042. * The radius of the cylinder for the vortex
  150043. */
  150044. radius: number;
  150045. /**
  150046. * The strenth of the updraft.
  150047. */
  150048. strength: number;
  150049. /**
  150050. * The height of the cylinder for the updraft.
  150051. */
  150052. height: number;
  150053. /**
  150054. * The mode for the the updraft.
  150055. */
  150056. updraftMode: PhysicsUpdraftMode;
  150057. }
  150058. /**
  150059. * Options fot the vortex event
  150060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150061. */
  150062. export class PhysicsVortexEventOptions {
  150063. /**
  150064. * The radius of the cylinder for the vortex
  150065. */
  150066. radius: number;
  150067. /**
  150068. * The strenth of the vortex.
  150069. */
  150070. strength: number;
  150071. /**
  150072. * The height of the cylinder for the vortex.
  150073. */
  150074. height: number;
  150075. /**
  150076. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150077. */
  150078. centripetalForceThreshold: number;
  150079. /**
  150080. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150081. */
  150082. centripetalForceMultiplier: number;
  150083. /**
  150084. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150085. */
  150086. centrifugalForceMultiplier: number;
  150087. /**
  150088. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150089. */
  150090. updraftForceMultiplier: number;
  150091. }
  150092. /**
  150093. * The strenght of the force in correspondence to the distance of the affected object
  150094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150095. */
  150096. export enum PhysicsRadialImpulseFalloff {
  150097. /** Defines that impulse is constant in strength across it's whole radius */
  150098. Constant = 0,
  150099. /** Defines that impulse gets weaker if it's further from the origin */
  150100. Linear = 1
  150101. }
  150102. /**
  150103. * The strength of the force in correspondence to the distance of the affected object
  150104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150105. */
  150106. export enum PhysicsUpdraftMode {
  150107. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150108. Center = 0,
  150109. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150110. Perpendicular = 1
  150111. }
  150112. /**
  150113. * Interface for a physics hit data
  150114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150115. */
  150116. export interface PhysicsHitData {
  150117. /**
  150118. * The force applied at the contact point
  150119. */
  150120. force: Vector3;
  150121. /**
  150122. * The contact point
  150123. */
  150124. contactPoint: Vector3;
  150125. /**
  150126. * The distance from the origin to the contact point
  150127. */
  150128. distanceFromOrigin: number;
  150129. }
  150130. /**
  150131. * Interface for radial explosion event data
  150132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150133. */
  150134. export interface PhysicsRadialExplosionEventData {
  150135. /**
  150136. * A sphere used for the radial explosion event
  150137. */
  150138. sphere: Mesh;
  150139. }
  150140. /**
  150141. * Interface for gravitational field event data
  150142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150143. */
  150144. export interface PhysicsGravitationalFieldEventData {
  150145. /**
  150146. * A sphere mesh used for the gravitational field event
  150147. */
  150148. sphere: Mesh;
  150149. }
  150150. /**
  150151. * Interface for updraft event data
  150152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150153. */
  150154. export interface PhysicsUpdraftEventData {
  150155. /**
  150156. * A cylinder used for the updraft event
  150157. */
  150158. cylinder: Mesh;
  150159. }
  150160. /**
  150161. * Interface for vortex event data
  150162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150163. */
  150164. export interface PhysicsVortexEventData {
  150165. /**
  150166. * A cylinder used for the vortex event
  150167. */
  150168. cylinder: Mesh;
  150169. }
  150170. /**
  150171. * Interface for an affected physics impostor
  150172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150173. */
  150174. export interface PhysicsAffectedImpostorWithData {
  150175. /**
  150176. * The impostor affected by the effect
  150177. */
  150178. impostor: PhysicsImpostor;
  150179. /**
  150180. * The data about the hit/horce from the explosion
  150181. */
  150182. hitData: PhysicsHitData;
  150183. }
  150184. }
  150185. declare module BABYLON {
  150186. /** @hidden */
  150187. export var blackAndWhitePixelShader: {
  150188. name: string;
  150189. shader: string;
  150190. };
  150191. }
  150192. declare module BABYLON {
  150193. /**
  150194. * Post process used to render in black and white
  150195. */
  150196. export class BlackAndWhitePostProcess extends PostProcess {
  150197. /**
  150198. * Linear about to convert he result to black and white (default: 1)
  150199. */
  150200. degree: number;
  150201. /**
  150202. * Gets a string identifying the name of the class
  150203. * @returns "BlackAndWhitePostProcess" string
  150204. */
  150205. getClassName(): string;
  150206. /**
  150207. * Creates a black and white post process
  150208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150209. * @param name The name of the effect.
  150210. * @param options The required width/height ratio to downsize to before computing the render pass.
  150211. * @param camera The camera to apply the render pass to.
  150212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150213. * @param engine The engine which the post process will be applied. (default: current engine)
  150214. * @param reusable If the post process can be reused on the same frame. (default: false)
  150215. */
  150216. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150217. /** @hidden */
  150218. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150219. }
  150220. }
  150221. declare module BABYLON {
  150222. /**
  150223. * This represents a set of one or more post processes in Babylon.
  150224. * A post process can be used to apply a shader to a texture after it is rendered.
  150225. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150226. */
  150227. export class PostProcessRenderEffect {
  150228. private _postProcesses;
  150229. private _getPostProcesses;
  150230. private _singleInstance;
  150231. private _cameras;
  150232. private _indicesForCamera;
  150233. /**
  150234. * Name of the effect
  150235. * @hidden
  150236. */
  150237. _name: string;
  150238. /**
  150239. * Instantiates a post process render effect.
  150240. * A post process can be used to apply a shader to a texture after it is rendered.
  150241. * @param engine The engine the effect is tied to
  150242. * @param name The name of the effect
  150243. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150244. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150245. */
  150246. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150247. /**
  150248. * Checks if all the post processes in the effect are supported.
  150249. */
  150250. get isSupported(): boolean;
  150251. /**
  150252. * Updates the current state of the effect
  150253. * @hidden
  150254. */
  150255. _update(): void;
  150256. /**
  150257. * Attaches the effect on cameras
  150258. * @param cameras The camera to attach to.
  150259. * @hidden
  150260. */
  150261. _attachCameras(cameras: Camera): void;
  150262. /**
  150263. * Attaches the effect on cameras
  150264. * @param cameras The camera to attach to.
  150265. * @hidden
  150266. */
  150267. _attachCameras(cameras: Camera[]): void;
  150268. /**
  150269. * Detaches the effect on cameras
  150270. * @param cameras The camera to detatch from.
  150271. * @hidden
  150272. */
  150273. _detachCameras(cameras: Camera): void;
  150274. /**
  150275. * Detatches the effect on cameras
  150276. * @param cameras The camera to detatch from.
  150277. * @hidden
  150278. */
  150279. _detachCameras(cameras: Camera[]): void;
  150280. /**
  150281. * Enables the effect on given cameras
  150282. * @param cameras The camera to enable.
  150283. * @hidden
  150284. */
  150285. _enable(cameras: Camera): void;
  150286. /**
  150287. * Enables the effect on given cameras
  150288. * @param cameras The camera to enable.
  150289. * @hidden
  150290. */
  150291. _enable(cameras: Nullable<Camera[]>): void;
  150292. /**
  150293. * Disables the effect on the given cameras
  150294. * @param cameras The camera to disable.
  150295. * @hidden
  150296. */
  150297. _disable(cameras: Camera): void;
  150298. /**
  150299. * Disables the effect on the given cameras
  150300. * @param cameras The camera to disable.
  150301. * @hidden
  150302. */
  150303. _disable(cameras: Nullable<Camera[]>): void;
  150304. /**
  150305. * Gets a list of the post processes contained in the effect.
  150306. * @param camera The camera to get the post processes on.
  150307. * @returns The list of the post processes in the effect.
  150308. */
  150309. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150310. }
  150311. }
  150312. declare module BABYLON {
  150313. /** @hidden */
  150314. export var extractHighlightsPixelShader: {
  150315. name: string;
  150316. shader: string;
  150317. };
  150318. }
  150319. declare module BABYLON {
  150320. /**
  150321. * 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.
  150322. */
  150323. export class ExtractHighlightsPostProcess extends PostProcess {
  150324. /**
  150325. * The luminance threshold, pixels below this value will be set to black.
  150326. */
  150327. threshold: number;
  150328. /** @hidden */
  150329. _exposure: number;
  150330. /**
  150331. * Post process which has the input texture to be used when performing highlight extraction
  150332. * @hidden
  150333. */
  150334. _inputPostProcess: Nullable<PostProcess>;
  150335. /**
  150336. * Gets a string identifying the name of the class
  150337. * @returns "ExtractHighlightsPostProcess" string
  150338. */
  150339. getClassName(): string;
  150340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150341. }
  150342. }
  150343. declare module BABYLON {
  150344. /** @hidden */
  150345. export var bloomMergePixelShader: {
  150346. name: string;
  150347. shader: string;
  150348. };
  150349. }
  150350. declare module BABYLON {
  150351. /**
  150352. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150353. */
  150354. export class BloomMergePostProcess extends PostProcess {
  150355. /** Weight of the bloom to be added to the original input. */
  150356. weight: number;
  150357. /**
  150358. * Gets a string identifying the name of the class
  150359. * @returns "BloomMergePostProcess" string
  150360. */
  150361. getClassName(): string;
  150362. /**
  150363. * Creates a new instance of @see BloomMergePostProcess
  150364. * @param name The name of the effect.
  150365. * @param originalFromInput Post process which's input will be used for the merge.
  150366. * @param blurred Blurred highlights post process which's output will be used.
  150367. * @param weight Weight of the bloom to be added to the original input.
  150368. * @param options The required width/height ratio to downsize to before computing the render pass.
  150369. * @param camera The camera to apply the render pass to.
  150370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150371. * @param engine The engine which the post process will be applied. (default: current engine)
  150372. * @param reusable If the post process can be reused on the same frame. (default: false)
  150373. * @param textureType Type of textures used when performing the post process. (default: 0)
  150374. * @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)
  150375. */
  150376. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150377. /** Weight of the bloom to be added to the original input. */
  150378. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150379. }
  150380. }
  150381. declare module BABYLON {
  150382. /**
  150383. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150384. */
  150385. export class BloomEffect extends PostProcessRenderEffect {
  150386. private bloomScale;
  150387. /**
  150388. * @hidden Internal
  150389. */
  150390. _effects: Array<PostProcess>;
  150391. /**
  150392. * @hidden Internal
  150393. */
  150394. _downscale: ExtractHighlightsPostProcess;
  150395. private _blurX;
  150396. private _blurY;
  150397. private _merge;
  150398. /**
  150399. * The luminance threshold to find bright areas of the image to bloom.
  150400. */
  150401. get threshold(): number;
  150402. set threshold(value: number);
  150403. /**
  150404. * The strength of the bloom.
  150405. */
  150406. get weight(): number;
  150407. set weight(value: number);
  150408. /**
  150409. * Specifies the size of the bloom blur kernel, relative to the final output size
  150410. */
  150411. get kernel(): number;
  150412. set kernel(value: number);
  150413. /**
  150414. * Creates a new instance of @see BloomEffect
  150415. * @param scene The scene the effect belongs to.
  150416. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150417. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150418. * @param bloomWeight The the strength of bloom.
  150419. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150420. * @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)
  150421. */
  150422. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150423. /**
  150424. * Disposes each of the internal effects for a given camera.
  150425. * @param camera The camera to dispose the effect on.
  150426. */
  150427. disposeEffects(camera: Camera): void;
  150428. /**
  150429. * @hidden Internal
  150430. */
  150431. _updateEffects(): void;
  150432. /**
  150433. * Internal
  150434. * @returns if all the contained post processes are ready.
  150435. * @hidden
  150436. */
  150437. _isReady(): boolean;
  150438. }
  150439. }
  150440. declare module BABYLON {
  150441. /** @hidden */
  150442. export var chromaticAberrationPixelShader: {
  150443. name: string;
  150444. shader: string;
  150445. };
  150446. }
  150447. declare module BABYLON {
  150448. /**
  150449. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150450. */
  150451. export class ChromaticAberrationPostProcess extends PostProcess {
  150452. /**
  150453. * The amount of seperation of rgb channels (default: 30)
  150454. */
  150455. aberrationAmount: number;
  150456. /**
  150457. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150458. */
  150459. radialIntensity: number;
  150460. /**
  150461. * 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))
  150462. */
  150463. direction: Vector2;
  150464. /**
  150465. * 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))
  150466. */
  150467. centerPosition: Vector2;
  150468. /** The width of the screen to apply the effect on */
  150469. screenWidth: number;
  150470. /** The height of the screen to apply the effect on */
  150471. screenHeight: number;
  150472. /**
  150473. * Gets a string identifying the name of the class
  150474. * @returns "ChromaticAberrationPostProcess" string
  150475. */
  150476. getClassName(): string;
  150477. /**
  150478. * Creates a new instance ChromaticAberrationPostProcess
  150479. * @param name The name of the effect.
  150480. * @param screenWidth The width of the screen to apply the effect on.
  150481. * @param screenHeight The height of the screen to apply the effect on.
  150482. * @param options The required width/height ratio to downsize to before computing the render pass.
  150483. * @param camera The camera to apply the render pass to.
  150484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150485. * @param engine The engine which the post process will be applied. (default: current engine)
  150486. * @param reusable If the post process can be reused on the same frame. (default: false)
  150487. * @param textureType Type of textures used when performing the post process. (default: 0)
  150488. * @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)
  150489. */
  150490. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150491. /** @hidden */
  150492. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150493. }
  150494. }
  150495. declare module BABYLON {
  150496. /** @hidden */
  150497. export var circleOfConfusionPixelShader: {
  150498. name: string;
  150499. shader: string;
  150500. };
  150501. }
  150502. declare module BABYLON {
  150503. /**
  150504. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150505. */
  150506. export class CircleOfConfusionPostProcess extends PostProcess {
  150507. /**
  150508. * 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.
  150509. */
  150510. lensSize: number;
  150511. /**
  150512. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150513. */
  150514. fStop: number;
  150515. /**
  150516. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150517. */
  150518. focusDistance: number;
  150519. /**
  150520. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150521. */
  150522. focalLength: number;
  150523. /**
  150524. * Gets a string identifying the name of the class
  150525. * @returns "CircleOfConfusionPostProcess" string
  150526. */
  150527. getClassName(): string;
  150528. private _depthTexture;
  150529. /**
  150530. * Creates a new instance CircleOfConfusionPostProcess
  150531. * @param name The name of the effect.
  150532. * @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.
  150533. * @param options The required width/height ratio to downsize to before computing the render pass.
  150534. * @param camera The camera to apply the render pass to.
  150535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150536. * @param engine The engine which the post process will be applied. (default: current engine)
  150537. * @param reusable If the post process can be reused on the same frame. (default: false)
  150538. * @param textureType Type of textures used when performing the post process. (default: 0)
  150539. * @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)
  150540. */
  150541. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150542. /**
  150543. * 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.
  150544. */
  150545. set depthTexture(value: RenderTargetTexture);
  150546. }
  150547. }
  150548. declare module BABYLON {
  150549. /** @hidden */
  150550. export var colorCorrectionPixelShader: {
  150551. name: string;
  150552. shader: string;
  150553. };
  150554. }
  150555. declare module BABYLON {
  150556. /**
  150557. *
  150558. * This post-process allows the modification of rendered colors by using
  150559. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150560. *
  150561. * The object needs to be provided an url to a texture containing the color
  150562. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150563. * Use an image editing software to tweak the LUT to match your needs.
  150564. *
  150565. * For an example of a color LUT, see here:
  150566. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150567. * For explanations on color grading, see here:
  150568. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150569. *
  150570. */
  150571. export class ColorCorrectionPostProcess extends PostProcess {
  150572. private _colorTableTexture;
  150573. /**
  150574. * Gets the color table url used to create the LUT texture
  150575. */
  150576. colorTableUrl: string;
  150577. /**
  150578. * Gets a string identifying the name of the class
  150579. * @returns "ColorCorrectionPostProcess" string
  150580. */
  150581. getClassName(): string;
  150582. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150583. /** @hidden */
  150584. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150585. }
  150586. }
  150587. declare module BABYLON {
  150588. /** @hidden */
  150589. export var convolutionPixelShader: {
  150590. name: string;
  150591. shader: string;
  150592. };
  150593. }
  150594. declare module BABYLON {
  150595. /**
  150596. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150597. * input texture to perform effects such as edge detection or sharpening
  150598. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150599. */
  150600. export class ConvolutionPostProcess extends PostProcess {
  150601. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150602. kernel: number[];
  150603. /**
  150604. * Gets a string identifying the name of the class
  150605. * @returns "ConvolutionPostProcess" string
  150606. */
  150607. getClassName(): string;
  150608. /**
  150609. * Creates a new instance ConvolutionPostProcess
  150610. * @param name The name of the effect.
  150611. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150612. * @param options The required width/height ratio to downsize to before computing the render pass.
  150613. * @param camera The camera to apply the render pass to.
  150614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150615. * @param engine The engine which the post process will be applied. (default: current engine)
  150616. * @param reusable If the post process can be reused on the same frame. (default: false)
  150617. * @param textureType Type of textures used when performing the post process. (default: 0)
  150618. */
  150619. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150620. /** @hidden */
  150621. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150622. /**
  150623. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150624. */
  150625. static EdgeDetect0Kernel: number[];
  150626. /**
  150627. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150628. */
  150629. static EdgeDetect1Kernel: number[];
  150630. /**
  150631. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150632. */
  150633. static EdgeDetect2Kernel: number[];
  150634. /**
  150635. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150636. */
  150637. static SharpenKernel: number[];
  150638. /**
  150639. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150640. */
  150641. static EmbossKernel: number[];
  150642. /**
  150643. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150644. */
  150645. static GaussianKernel: number[];
  150646. }
  150647. }
  150648. declare module BABYLON {
  150649. /**
  150650. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150651. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150652. * based on samples that have a large difference in distance than the center pixel.
  150653. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150654. */
  150655. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150656. /**
  150657. * The direction the blur should be applied
  150658. */
  150659. direction: Vector2;
  150660. /**
  150661. * Gets a string identifying the name of the class
  150662. * @returns "DepthOfFieldBlurPostProcess" string
  150663. */
  150664. getClassName(): string;
  150665. /**
  150666. * Creates a new instance CircleOfConfusionPostProcess
  150667. * @param name The name of the effect.
  150668. * @param scene The scene the effect belongs to.
  150669. * @param direction The direction the blur should be applied.
  150670. * @param kernel The size of the kernel used to blur.
  150671. * @param options The required width/height ratio to downsize to before computing the render pass.
  150672. * @param camera The camera to apply the render pass to.
  150673. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150674. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150676. * @param engine The engine which the post process will be applied. (default: current engine)
  150677. * @param reusable If the post process can be reused on the same frame. (default: false)
  150678. * @param textureType Type of textures used when performing the post process. (default: 0)
  150679. * @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)
  150680. */
  150681. 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);
  150682. }
  150683. }
  150684. declare module BABYLON {
  150685. /** @hidden */
  150686. export var depthOfFieldMergePixelShader: {
  150687. name: string;
  150688. shader: string;
  150689. };
  150690. }
  150691. declare module BABYLON {
  150692. /**
  150693. * Options to be set when merging outputs from the default pipeline.
  150694. */
  150695. export class DepthOfFieldMergePostProcessOptions {
  150696. /**
  150697. * The original image to merge on top of
  150698. */
  150699. originalFromInput: PostProcess;
  150700. /**
  150701. * Parameters to perform the merge of the depth of field effect
  150702. */
  150703. depthOfField?: {
  150704. circleOfConfusion: PostProcess;
  150705. blurSteps: Array<PostProcess>;
  150706. };
  150707. /**
  150708. * Parameters to perform the merge of bloom effect
  150709. */
  150710. bloom?: {
  150711. blurred: PostProcess;
  150712. weight: number;
  150713. };
  150714. }
  150715. /**
  150716. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150717. */
  150718. export class DepthOfFieldMergePostProcess extends PostProcess {
  150719. private blurSteps;
  150720. /**
  150721. * Gets a string identifying the name of the class
  150722. * @returns "DepthOfFieldMergePostProcess" string
  150723. */
  150724. getClassName(): string;
  150725. /**
  150726. * Creates a new instance of DepthOfFieldMergePostProcess
  150727. * @param name The name of the effect.
  150728. * @param originalFromInput Post process which's input will be used for the merge.
  150729. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150730. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150731. * @param options The required width/height ratio to downsize to before computing the render pass.
  150732. * @param camera The camera to apply the render pass to.
  150733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150734. * @param engine The engine which the post process will be applied. (default: current engine)
  150735. * @param reusable If the post process can be reused on the same frame. (default: false)
  150736. * @param textureType Type of textures used when performing the post process. (default: 0)
  150737. * @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)
  150738. */
  150739. 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);
  150740. /**
  150741. * Updates the effect with the current post process compile time values and recompiles the shader.
  150742. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150743. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150744. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150745. * @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
  150746. * @param onCompiled Called when the shader has been compiled.
  150747. * @param onError Called if there is an error when compiling a shader.
  150748. */
  150749. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150750. }
  150751. }
  150752. declare module BABYLON {
  150753. /**
  150754. * Specifies the level of max blur that should be applied when using the depth of field effect
  150755. */
  150756. export enum DepthOfFieldEffectBlurLevel {
  150757. /**
  150758. * Subtle blur
  150759. */
  150760. Low = 0,
  150761. /**
  150762. * Medium blur
  150763. */
  150764. Medium = 1,
  150765. /**
  150766. * Large blur
  150767. */
  150768. High = 2
  150769. }
  150770. /**
  150771. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150772. */
  150773. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150774. private _circleOfConfusion;
  150775. /**
  150776. * @hidden Internal, blurs from high to low
  150777. */
  150778. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150779. private _depthOfFieldBlurY;
  150780. private _dofMerge;
  150781. /**
  150782. * @hidden Internal post processes in depth of field effect
  150783. */
  150784. _effects: Array<PostProcess>;
  150785. /**
  150786. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150787. */
  150788. set focalLength(value: number);
  150789. get focalLength(): number;
  150790. /**
  150791. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150792. */
  150793. set fStop(value: number);
  150794. get fStop(): number;
  150795. /**
  150796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150797. */
  150798. set focusDistance(value: number);
  150799. get focusDistance(): number;
  150800. /**
  150801. * 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.
  150802. */
  150803. set lensSize(value: number);
  150804. get lensSize(): number;
  150805. /**
  150806. * Creates a new instance DepthOfFieldEffect
  150807. * @param scene The scene the effect belongs to.
  150808. * @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.
  150809. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150810. * @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)
  150811. */
  150812. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150813. /**
  150814. * Get the current class name of the current effet
  150815. * @returns "DepthOfFieldEffect"
  150816. */
  150817. getClassName(): string;
  150818. /**
  150819. * 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.
  150820. */
  150821. set depthTexture(value: RenderTargetTexture);
  150822. /**
  150823. * Disposes each of the internal effects for a given camera.
  150824. * @param camera The camera to dispose the effect on.
  150825. */
  150826. disposeEffects(camera: Camera): void;
  150827. /**
  150828. * @hidden Internal
  150829. */
  150830. _updateEffects(): void;
  150831. /**
  150832. * Internal
  150833. * @returns if all the contained post processes are ready.
  150834. * @hidden
  150835. */
  150836. _isReady(): boolean;
  150837. }
  150838. }
  150839. declare module BABYLON {
  150840. /** @hidden */
  150841. export var displayPassPixelShader: {
  150842. name: string;
  150843. shader: string;
  150844. };
  150845. }
  150846. declare module BABYLON {
  150847. /**
  150848. * DisplayPassPostProcess which produces an output the same as it's input
  150849. */
  150850. export class DisplayPassPostProcess extends PostProcess {
  150851. /**
  150852. * Gets a string identifying the name of the class
  150853. * @returns "DisplayPassPostProcess" string
  150854. */
  150855. getClassName(): string;
  150856. /**
  150857. * Creates the DisplayPassPostProcess
  150858. * @param name The name of the effect.
  150859. * @param options The required width/height ratio to downsize to before computing the render pass.
  150860. * @param camera The camera to apply the render pass to.
  150861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150862. * @param engine The engine which the post process will be applied. (default: current engine)
  150863. * @param reusable If the post process can be reused on the same frame. (default: false)
  150864. */
  150865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150866. /** @hidden */
  150867. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150868. }
  150869. }
  150870. declare module BABYLON {
  150871. /** @hidden */
  150872. export var filterPixelShader: {
  150873. name: string;
  150874. shader: string;
  150875. };
  150876. }
  150877. declare module BABYLON {
  150878. /**
  150879. * Applies a kernel filter to the image
  150880. */
  150881. export class FilterPostProcess extends PostProcess {
  150882. /** The matrix to be applied to the image */
  150883. kernelMatrix: Matrix;
  150884. /**
  150885. * Gets a string identifying the name of the class
  150886. * @returns "FilterPostProcess" string
  150887. */
  150888. getClassName(): string;
  150889. /**
  150890. *
  150891. * @param name The name of the effect.
  150892. * @param kernelMatrix The matrix to be applied to the image
  150893. * @param options The required width/height ratio to downsize to before computing the render pass.
  150894. * @param camera The camera to apply the render pass to.
  150895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150896. * @param engine The engine which the post process will be applied. (default: current engine)
  150897. * @param reusable If the post process can be reused on the same frame. (default: false)
  150898. */
  150899. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150900. /** @hidden */
  150901. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150902. }
  150903. }
  150904. declare module BABYLON {
  150905. /** @hidden */
  150906. export var fxaaPixelShader: {
  150907. name: string;
  150908. shader: string;
  150909. };
  150910. }
  150911. declare module BABYLON {
  150912. /** @hidden */
  150913. export var fxaaVertexShader: {
  150914. name: string;
  150915. shader: string;
  150916. };
  150917. }
  150918. declare module BABYLON {
  150919. /**
  150920. * Fxaa post process
  150921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150922. */
  150923. export class FxaaPostProcess extends PostProcess {
  150924. /**
  150925. * Gets a string identifying the name of the class
  150926. * @returns "FxaaPostProcess" string
  150927. */
  150928. getClassName(): string;
  150929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150930. private _getDefines;
  150931. /** @hidden */
  150932. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150933. }
  150934. }
  150935. declare module BABYLON {
  150936. /** @hidden */
  150937. export var grainPixelShader: {
  150938. name: string;
  150939. shader: string;
  150940. };
  150941. }
  150942. declare module BABYLON {
  150943. /**
  150944. * The GrainPostProcess adds noise to the image at mid luminance levels
  150945. */
  150946. export class GrainPostProcess extends PostProcess {
  150947. /**
  150948. * The intensity of the grain added (default: 30)
  150949. */
  150950. intensity: number;
  150951. /**
  150952. * If the grain should be randomized on every frame
  150953. */
  150954. animated: boolean;
  150955. /**
  150956. * Gets a string identifying the name of the class
  150957. * @returns "GrainPostProcess" string
  150958. */
  150959. getClassName(): string;
  150960. /**
  150961. * Creates a new instance of @see GrainPostProcess
  150962. * @param name The name of the effect.
  150963. * @param options The required width/height ratio to downsize to before computing the render pass.
  150964. * @param camera The camera to apply the render pass to.
  150965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150966. * @param engine The engine which the post process will be applied. (default: current engine)
  150967. * @param reusable If the post process can be reused on the same frame. (default: false)
  150968. * @param textureType Type of textures used when performing the post process. (default: 0)
  150969. * @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)
  150970. */
  150971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150972. /** @hidden */
  150973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150974. }
  150975. }
  150976. declare module BABYLON {
  150977. /** @hidden */
  150978. export var highlightsPixelShader: {
  150979. name: string;
  150980. shader: string;
  150981. };
  150982. }
  150983. declare module BABYLON {
  150984. /**
  150985. * Extracts highlights from the image
  150986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150987. */
  150988. export class HighlightsPostProcess extends PostProcess {
  150989. /**
  150990. * Gets a string identifying the name of the class
  150991. * @returns "HighlightsPostProcess" string
  150992. */
  150993. getClassName(): string;
  150994. /**
  150995. * Extracts highlights from the image
  150996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150997. * @param name The name of the effect.
  150998. * @param options The required width/height ratio to downsize to before computing the render pass.
  150999. * @param camera The camera to apply the render pass to.
  151000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151001. * @param engine The engine which the post process will be applied. (default: current engine)
  151002. * @param reusable If the post process can be reused on the same frame. (default: false)
  151003. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151004. */
  151005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151006. }
  151007. }
  151008. declare module BABYLON {
  151009. /**
  151010. * Contains all parameters needed for the prepass to perform
  151011. * motion blur
  151012. */
  151013. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151014. /**
  151015. * Is motion blur enabled
  151016. */
  151017. enabled: boolean;
  151018. /**
  151019. * Name of the configuration
  151020. */
  151021. name: string;
  151022. /**
  151023. * Textures that should be present in the MRT for this effect to work
  151024. */
  151025. readonly texturesRequired: number[];
  151026. }
  151027. }
  151028. declare module BABYLON {
  151029. interface Scene {
  151030. /** @hidden (Backing field) */
  151031. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151032. /**
  151033. * Gets or Sets the current geometry buffer associated to the scene.
  151034. */
  151035. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151036. /**
  151037. * Enables a GeometryBufferRender and associates it with the scene
  151038. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151039. * @returns the GeometryBufferRenderer
  151040. */
  151041. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151042. /**
  151043. * Disables the GeometryBufferRender associated with the scene
  151044. */
  151045. disableGeometryBufferRenderer(): void;
  151046. }
  151047. /**
  151048. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151049. * in several rendering techniques.
  151050. */
  151051. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151052. /**
  151053. * The component name helpful to identify the component in the list of scene components.
  151054. */
  151055. readonly name: string;
  151056. /**
  151057. * The scene the component belongs to.
  151058. */
  151059. scene: Scene;
  151060. /**
  151061. * Creates a new instance of the component for the given scene
  151062. * @param scene Defines the scene to register the component in
  151063. */
  151064. constructor(scene: Scene);
  151065. /**
  151066. * Registers the component in a given scene
  151067. */
  151068. register(): void;
  151069. /**
  151070. * Rebuilds the elements related to this component in case of
  151071. * context lost for instance.
  151072. */
  151073. rebuild(): void;
  151074. /**
  151075. * Disposes the component and the associated ressources
  151076. */
  151077. dispose(): void;
  151078. private _gatherRenderTargets;
  151079. }
  151080. }
  151081. declare module BABYLON {
  151082. /** @hidden */
  151083. export var motionBlurPixelShader: {
  151084. name: string;
  151085. shader: string;
  151086. };
  151087. }
  151088. declare module BABYLON {
  151089. /**
  151090. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151091. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151092. * As an example, all you have to do is to create the post-process:
  151093. * var mb = new BABYLON.MotionBlurPostProcess(
  151094. * 'mb', // The name of the effect.
  151095. * scene, // The scene containing the objects to blur according to their velocity.
  151096. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151097. * camera // The camera to apply the render pass to.
  151098. * );
  151099. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151100. */
  151101. export class MotionBlurPostProcess extends PostProcess {
  151102. /**
  151103. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151104. */
  151105. motionStrength: number;
  151106. /**
  151107. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151108. */
  151109. get motionBlurSamples(): number;
  151110. /**
  151111. * Sets the number of iterations to be used for motion blur quality
  151112. */
  151113. set motionBlurSamples(samples: number);
  151114. private _motionBlurSamples;
  151115. private _forceGeometryBuffer;
  151116. private _geometryBufferRenderer;
  151117. private _prePassRenderer;
  151118. /**
  151119. * Gets a string identifying the name of the class
  151120. * @returns "MotionBlurPostProcess" string
  151121. */
  151122. getClassName(): string;
  151123. /**
  151124. * Creates a new instance MotionBlurPostProcess
  151125. * @param name The name of the effect.
  151126. * @param scene The scene containing the objects to blur according to their velocity.
  151127. * @param options The required width/height ratio to downsize to before computing the render pass.
  151128. * @param camera The camera to apply the render pass to.
  151129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151130. * @param engine The engine which the post process will be applied. (default: current engine)
  151131. * @param reusable If the post process can be reused on the same frame. (default: false)
  151132. * @param textureType Type of textures used when performing the post process. (default: 0)
  151133. * @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)
  151134. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151135. */
  151136. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151137. /**
  151138. * Excludes the given skinned mesh from computing bones velocities.
  151139. * 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.
  151140. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151141. */
  151142. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151143. /**
  151144. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151145. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151146. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151147. */
  151148. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151149. /**
  151150. * Disposes the post process.
  151151. * @param camera The camera to dispose the post process on.
  151152. */
  151153. dispose(camera?: Camera): void;
  151154. /** @hidden */
  151155. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151156. }
  151157. }
  151158. declare module BABYLON {
  151159. /** @hidden */
  151160. export var refractionPixelShader: {
  151161. name: string;
  151162. shader: string;
  151163. };
  151164. }
  151165. declare module BABYLON {
  151166. /**
  151167. * Post process which applies a refractin texture
  151168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151169. */
  151170. export class RefractionPostProcess extends PostProcess {
  151171. private _refTexture;
  151172. private _ownRefractionTexture;
  151173. /** the base color of the refraction (used to taint the rendering) */
  151174. color: Color3;
  151175. /** simulated refraction depth */
  151176. depth: number;
  151177. /** the coefficient of the base color (0 to remove base color tainting) */
  151178. colorLevel: number;
  151179. /** Gets the url used to load the refraction texture */
  151180. refractionTextureUrl: string;
  151181. /**
  151182. * Gets or sets the refraction texture
  151183. * Please note that you are responsible for disposing the texture if you set it manually
  151184. */
  151185. get refractionTexture(): Texture;
  151186. set refractionTexture(value: Texture);
  151187. /**
  151188. * Gets a string identifying the name of the class
  151189. * @returns "RefractionPostProcess" string
  151190. */
  151191. getClassName(): string;
  151192. /**
  151193. * Initializes the RefractionPostProcess
  151194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151195. * @param name The name of the effect.
  151196. * @param refractionTextureUrl Url of the refraction texture to use
  151197. * @param color the base color of the refraction (used to taint the rendering)
  151198. * @param depth simulated refraction depth
  151199. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151200. * @param camera The camera to apply the render pass to.
  151201. * @param options The required width/height ratio to downsize to before computing the render pass.
  151202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151203. * @param engine The engine which the post process will be applied. (default: current engine)
  151204. * @param reusable If the post process can be reused on the same frame. (default: false)
  151205. */
  151206. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151207. /**
  151208. * Disposes of the post process
  151209. * @param camera Camera to dispose post process on
  151210. */
  151211. dispose(camera: Camera): void;
  151212. /** @hidden */
  151213. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151214. }
  151215. }
  151216. declare module BABYLON {
  151217. /** @hidden */
  151218. export var sharpenPixelShader: {
  151219. name: string;
  151220. shader: string;
  151221. };
  151222. }
  151223. declare module BABYLON {
  151224. /**
  151225. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151226. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151227. */
  151228. export class SharpenPostProcess extends PostProcess {
  151229. /**
  151230. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151231. */
  151232. colorAmount: number;
  151233. /**
  151234. * How much sharpness should be applied (default: 0.3)
  151235. */
  151236. edgeAmount: number;
  151237. /**
  151238. * Gets a string identifying the name of the class
  151239. * @returns "SharpenPostProcess" string
  151240. */
  151241. getClassName(): string;
  151242. /**
  151243. * Creates a new instance ConvolutionPostProcess
  151244. * @param name The name of the effect.
  151245. * @param options The required width/height ratio to downsize to before computing the render pass.
  151246. * @param camera The camera to apply the render pass to.
  151247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151248. * @param engine The engine which the post process will be applied. (default: current engine)
  151249. * @param reusable If the post process can be reused on the same frame. (default: false)
  151250. * @param textureType Type of textures used when performing the post process. (default: 0)
  151251. * @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)
  151252. */
  151253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151254. /** @hidden */
  151255. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151256. }
  151257. }
  151258. declare module BABYLON {
  151259. /**
  151260. * PostProcessRenderPipeline
  151261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151262. */
  151263. export class PostProcessRenderPipeline {
  151264. private engine;
  151265. private _renderEffects;
  151266. private _renderEffectsForIsolatedPass;
  151267. /**
  151268. * List of inspectable custom properties (used by the Inspector)
  151269. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151270. */
  151271. inspectableCustomProperties: IInspectable[];
  151272. /**
  151273. * @hidden
  151274. */
  151275. protected _cameras: Camera[];
  151276. /** @hidden */
  151277. _name: string;
  151278. /**
  151279. * Gets pipeline name
  151280. */
  151281. get name(): string;
  151282. /** Gets the list of attached cameras */
  151283. get cameras(): Camera[];
  151284. /**
  151285. * Initializes a PostProcessRenderPipeline
  151286. * @param engine engine to add the pipeline to
  151287. * @param name name of the pipeline
  151288. */
  151289. constructor(engine: Engine, name: string);
  151290. /**
  151291. * Gets the class name
  151292. * @returns "PostProcessRenderPipeline"
  151293. */
  151294. getClassName(): string;
  151295. /**
  151296. * If all the render effects in the pipeline are supported
  151297. */
  151298. get isSupported(): boolean;
  151299. /**
  151300. * Adds an effect to the pipeline
  151301. * @param renderEffect the effect to add
  151302. */
  151303. addEffect(renderEffect: PostProcessRenderEffect): void;
  151304. /** @hidden */
  151305. _rebuild(): void;
  151306. /** @hidden */
  151307. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151308. /** @hidden */
  151309. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151310. /** @hidden */
  151311. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151312. /** @hidden */
  151313. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151314. /** @hidden */
  151315. _attachCameras(cameras: Camera, unique: boolean): void;
  151316. /** @hidden */
  151317. _attachCameras(cameras: Camera[], unique: boolean): void;
  151318. /** @hidden */
  151319. _detachCameras(cameras: Camera): void;
  151320. /** @hidden */
  151321. _detachCameras(cameras: Nullable<Camera[]>): void;
  151322. /** @hidden */
  151323. _update(): void;
  151324. /** @hidden */
  151325. _reset(): void;
  151326. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151327. /**
  151328. * Sets the required values to the prepass renderer.
  151329. * @param prePassRenderer defines the prepass renderer to setup.
  151330. * @returns true if the pre pass is needed.
  151331. */
  151332. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151333. /**
  151334. * Disposes of the pipeline
  151335. */
  151336. dispose(): void;
  151337. }
  151338. }
  151339. declare module BABYLON {
  151340. /**
  151341. * PostProcessRenderPipelineManager class
  151342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151343. */
  151344. export class PostProcessRenderPipelineManager {
  151345. private _renderPipelines;
  151346. /**
  151347. * Initializes a PostProcessRenderPipelineManager
  151348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151349. */
  151350. constructor();
  151351. /**
  151352. * Gets the list of supported render pipelines
  151353. */
  151354. get supportedPipelines(): PostProcessRenderPipeline[];
  151355. /**
  151356. * Adds a pipeline to the manager
  151357. * @param renderPipeline The pipeline to add
  151358. */
  151359. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151360. /**
  151361. * Attaches a camera to the pipeline
  151362. * @param renderPipelineName The name of the pipeline to attach to
  151363. * @param cameras the camera to attach
  151364. * @param unique if the camera can be attached multiple times to the pipeline
  151365. */
  151366. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151367. /**
  151368. * Detaches a camera from the pipeline
  151369. * @param renderPipelineName The name of the pipeline to detach from
  151370. * @param cameras the camera to detach
  151371. */
  151372. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151373. /**
  151374. * Enables an effect by name on a pipeline
  151375. * @param renderPipelineName the name of the pipeline to enable the effect in
  151376. * @param renderEffectName the name of the effect to enable
  151377. * @param cameras the cameras that the effect should be enabled on
  151378. */
  151379. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151380. /**
  151381. * Disables an effect by name on a pipeline
  151382. * @param renderPipelineName the name of the pipeline to disable the effect in
  151383. * @param renderEffectName the name of the effect to disable
  151384. * @param cameras the cameras that the effect should be disabled on
  151385. */
  151386. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151387. /**
  151388. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151389. */
  151390. update(): void;
  151391. /** @hidden */
  151392. _rebuild(): void;
  151393. /**
  151394. * Disposes of the manager and pipelines
  151395. */
  151396. dispose(): void;
  151397. }
  151398. }
  151399. declare module BABYLON {
  151400. interface Scene {
  151401. /** @hidden (Backing field) */
  151402. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151403. /**
  151404. * Gets the postprocess render pipeline manager
  151405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151406. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151407. */
  151408. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151409. }
  151410. /**
  151411. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151412. */
  151413. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151414. /**
  151415. * The component name helpfull to identify the component in the list of scene components.
  151416. */
  151417. readonly name: string;
  151418. /**
  151419. * The scene the component belongs to.
  151420. */
  151421. scene: Scene;
  151422. /**
  151423. * Creates a new instance of the component for the given scene
  151424. * @param scene Defines the scene to register the component in
  151425. */
  151426. constructor(scene: Scene);
  151427. /**
  151428. * Registers the component in a given scene
  151429. */
  151430. register(): void;
  151431. /**
  151432. * Rebuilds the elements related to this component in case of
  151433. * context lost for instance.
  151434. */
  151435. rebuild(): void;
  151436. /**
  151437. * Disposes the component and the associated ressources
  151438. */
  151439. dispose(): void;
  151440. private _gatherRenderTargets;
  151441. }
  151442. }
  151443. declare module BABYLON {
  151444. /**
  151445. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151446. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151447. */
  151448. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151449. private _scene;
  151450. private _camerasToBeAttached;
  151451. /**
  151452. * ID of the sharpen post process,
  151453. */
  151454. private readonly SharpenPostProcessId;
  151455. /**
  151456. * @ignore
  151457. * ID of the image processing post process;
  151458. */
  151459. readonly ImageProcessingPostProcessId: string;
  151460. /**
  151461. * @ignore
  151462. * ID of the Fast Approximate Anti-Aliasing post process;
  151463. */
  151464. readonly FxaaPostProcessId: string;
  151465. /**
  151466. * ID of the chromatic aberration post process,
  151467. */
  151468. private readonly ChromaticAberrationPostProcessId;
  151469. /**
  151470. * ID of the grain post process
  151471. */
  151472. private readonly GrainPostProcessId;
  151473. /**
  151474. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151475. */
  151476. sharpen: SharpenPostProcess;
  151477. private _sharpenEffect;
  151478. private bloom;
  151479. /**
  151480. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151481. */
  151482. depthOfField: DepthOfFieldEffect;
  151483. /**
  151484. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151485. */
  151486. fxaa: FxaaPostProcess;
  151487. /**
  151488. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151489. */
  151490. imageProcessing: ImageProcessingPostProcess;
  151491. /**
  151492. * Chromatic aberration post process which will shift rgb colors in the image
  151493. */
  151494. chromaticAberration: ChromaticAberrationPostProcess;
  151495. private _chromaticAberrationEffect;
  151496. /**
  151497. * Grain post process which add noise to the image
  151498. */
  151499. grain: GrainPostProcess;
  151500. private _grainEffect;
  151501. /**
  151502. * Glow post process which adds a glow to emissive areas of the image
  151503. */
  151504. private _glowLayer;
  151505. /**
  151506. * Animations which can be used to tweak settings over a period of time
  151507. */
  151508. animations: Animation[];
  151509. private _imageProcessingConfigurationObserver;
  151510. private _sharpenEnabled;
  151511. private _bloomEnabled;
  151512. private _depthOfFieldEnabled;
  151513. private _depthOfFieldBlurLevel;
  151514. private _fxaaEnabled;
  151515. private _imageProcessingEnabled;
  151516. private _defaultPipelineTextureType;
  151517. private _bloomScale;
  151518. private _chromaticAberrationEnabled;
  151519. private _grainEnabled;
  151520. private _buildAllowed;
  151521. /**
  151522. * Gets active scene
  151523. */
  151524. get scene(): Scene;
  151525. /**
  151526. * Enable or disable the sharpen process from the pipeline
  151527. */
  151528. set sharpenEnabled(enabled: boolean);
  151529. get sharpenEnabled(): boolean;
  151530. private _resizeObserver;
  151531. private _hardwareScaleLevel;
  151532. private _bloomKernel;
  151533. /**
  151534. * Specifies the size of the bloom blur kernel, relative to the final output size
  151535. */
  151536. get bloomKernel(): number;
  151537. set bloomKernel(value: number);
  151538. /**
  151539. * Specifies the weight of the bloom in the final rendering
  151540. */
  151541. private _bloomWeight;
  151542. /**
  151543. * Specifies the luma threshold for the area that will be blurred by the bloom
  151544. */
  151545. private _bloomThreshold;
  151546. private _hdr;
  151547. /**
  151548. * The strength of the bloom.
  151549. */
  151550. set bloomWeight(value: number);
  151551. get bloomWeight(): number;
  151552. /**
  151553. * The strength of the bloom.
  151554. */
  151555. set bloomThreshold(value: number);
  151556. get bloomThreshold(): number;
  151557. /**
  151558. * The scale of the bloom, lower value will provide better performance.
  151559. */
  151560. set bloomScale(value: number);
  151561. get bloomScale(): number;
  151562. /**
  151563. * Enable or disable the bloom from the pipeline
  151564. */
  151565. set bloomEnabled(enabled: boolean);
  151566. get bloomEnabled(): boolean;
  151567. private _rebuildBloom;
  151568. /**
  151569. * If the depth of field is enabled.
  151570. */
  151571. get depthOfFieldEnabled(): boolean;
  151572. set depthOfFieldEnabled(enabled: boolean);
  151573. /**
  151574. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151575. */
  151576. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151577. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151578. /**
  151579. * If the anti aliasing is enabled.
  151580. */
  151581. set fxaaEnabled(enabled: boolean);
  151582. get fxaaEnabled(): boolean;
  151583. private _samples;
  151584. /**
  151585. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151586. */
  151587. set samples(sampleCount: number);
  151588. get samples(): number;
  151589. /**
  151590. * If image processing is enabled.
  151591. */
  151592. set imageProcessingEnabled(enabled: boolean);
  151593. get imageProcessingEnabled(): boolean;
  151594. /**
  151595. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151596. */
  151597. set glowLayerEnabled(enabled: boolean);
  151598. get glowLayerEnabled(): boolean;
  151599. /**
  151600. * Gets the glow layer (or null if not defined)
  151601. */
  151602. get glowLayer(): Nullable<GlowLayer>;
  151603. /**
  151604. * Enable or disable the chromaticAberration process from the pipeline
  151605. */
  151606. set chromaticAberrationEnabled(enabled: boolean);
  151607. get chromaticAberrationEnabled(): boolean;
  151608. /**
  151609. * Enable or disable the grain process from the pipeline
  151610. */
  151611. set grainEnabled(enabled: boolean);
  151612. get grainEnabled(): boolean;
  151613. /**
  151614. * @constructor
  151615. * @param name - The rendering pipeline name (default: "")
  151616. * @param hdr - If high dynamic range textures should be used (default: true)
  151617. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151618. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151619. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151620. */
  151621. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151622. /**
  151623. * Get the class name
  151624. * @returns "DefaultRenderingPipeline"
  151625. */
  151626. getClassName(): string;
  151627. /**
  151628. * Force the compilation of the entire pipeline.
  151629. */
  151630. prepare(): void;
  151631. private _hasCleared;
  151632. private _prevPostProcess;
  151633. private _prevPrevPostProcess;
  151634. private _setAutoClearAndTextureSharing;
  151635. private _depthOfFieldSceneObserver;
  151636. private _buildPipeline;
  151637. private _disposePostProcesses;
  151638. /**
  151639. * Adds a camera to the pipeline
  151640. * @param camera the camera to be added
  151641. */
  151642. addCamera(camera: Camera): void;
  151643. /**
  151644. * Removes a camera from the pipeline
  151645. * @param camera the camera to remove
  151646. */
  151647. removeCamera(camera: Camera): void;
  151648. /**
  151649. * Dispose of the pipeline and stop all post processes
  151650. */
  151651. dispose(): void;
  151652. /**
  151653. * Serialize the rendering pipeline (Used when exporting)
  151654. * @returns the serialized object
  151655. */
  151656. serialize(): any;
  151657. /**
  151658. * Parse the serialized pipeline
  151659. * @param source Source pipeline.
  151660. * @param scene The scene to load the pipeline to.
  151661. * @param rootUrl The URL of the serialized pipeline.
  151662. * @returns An instantiated pipeline from the serialized object.
  151663. */
  151664. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151665. }
  151666. }
  151667. declare module BABYLON {
  151668. /** @hidden */
  151669. export var lensHighlightsPixelShader: {
  151670. name: string;
  151671. shader: string;
  151672. };
  151673. }
  151674. declare module BABYLON {
  151675. /** @hidden */
  151676. export var depthOfFieldPixelShader: {
  151677. name: string;
  151678. shader: string;
  151679. };
  151680. }
  151681. declare module BABYLON {
  151682. /**
  151683. * BABYLON.JS Chromatic Aberration GLSL Shader
  151684. * Author: Olivier Guyot
  151685. * Separates very slightly R, G and B colors on the edges of the screen
  151686. * Inspired by Francois Tarlier & Martins Upitis
  151687. */
  151688. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151689. /**
  151690. * @ignore
  151691. * The chromatic aberration PostProcess id in the pipeline
  151692. */
  151693. LensChromaticAberrationEffect: string;
  151694. /**
  151695. * @ignore
  151696. * The highlights enhancing PostProcess id in the pipeline
  151697. */
  151698. HighlightsEnhancingEffect: string;
  151699. /**
  151700. * @ignore
  151701. * The depth-of-field PostProcess id in the pipeline
  151702. */
  151703. LensDepthOfFieldEffect: string;
  151704. private _scene;
  151705. private _depthTexture;
  151706. private _grainTexture;
  151707. private _chromaticAberrationPostProcess;
  151708. private _highlightsPostProcess;
  151709. private _depthOfFieldPostProcess;
  151710. private _edgeBlur;
  151711. private _grainAmount;
  151712. private _chromaticAberration;
  151713. private _distortion;
  151714. private _highlightsGain;
  151715. private _highlightsThreshold;
  151716. private _dofDistance;
  151717. private _dofAperture;
  151718. private _dofDarken;
  151719. private _dofPentagon;
  151720. private _blurNoise;
  151721. /**
  151722. * @constructor
  151723. *
  151724. * Effect parameters are as follow:
  151725. * {
  151726. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151727. * edge_blur: number; // from 0 to x (1 for realism)
  151728. * distortion: number; // from 0 to x (1 for realism)
  151729. * grain_amount: number; // from 0 to 1
  151730. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151731. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151732. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151733. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151734. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151735. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151736. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151737. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151738. * }
  151739. * Note: if an effect parameter is unset, effect is disabled
  151740. *
  151741. * @param name The rendering pipeline name
  151742. * @param parameters - An object containing all parameters (see above)
  151743. * @param scene The scene linked to this pipeline
  151744. * @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)
  151745. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151746. */
  151747. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151748. /**
  151749. * Get the class name
  151750. * @returns "LensRenderingPipeline"
  151751. */
  151752. getClassName(): string;
  151753. /**
  151754. * Gets associated scene
  151755. */
  151756. get scene(): Scene;
  151757. /**
  151758. * Gets or sets the edge blur
  151759. */
  151760. get edgeBlur(): number;
  151761. set edgeBlur(value: number);
  151762. /**
  151763. * Gets or sets the grain amount
  151764. */
  151765. get grainAmount(): number;
  151766. set grainAmount(value: number);
  151767. /**
  151768. * Gets or sets the chromatic aberration amount
  151769. */
  151770. get chromaticAberration(): number;
  151771. set chromaticAberration(value: number);
  151772. /**
  151773. * Gets or sets the depth of field aperture
  151774. */
  151775. get dofAperture(): number;
  151776. set dofAperture(value: number);
  151777. /**
  151778. * Gets or sets the edge distortion
  151779. */
  151780. get edgeDistortion(): number;
  151781. set edgeDistortion(value: number);
  151782. /**
  151783. * Gets or sets the depth of field distortion
  151784. */
  151785. get dofDistortion(): number;
  151786. set dofDistortion(value: number);
  151787. /**
  151788. * Gets or sets the darken out of focus amount
  151789. */
  151790. get darkenOutOfFocus(): number;
  151791. set darkenOutOfFocus(value: number);
  151792. /**
  151793. * Gets or sets a boolean indicating if blur noise is enabled
  151794. */
  151795. get blurNoise(): boolean;
  151796. set blurNoise(value: boolean);
  151797. /**
  151798. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151799. */
  151800. get pentagonBokeh(): boolean;
  151801. set pentagonBokeh(value: boolean);
  151802. /**
  151803. * Gets or sets the highlight grain amount
  151804. */
  151805. get highlightsGain(): number;
  151806. set highlightsGain(value: number);
  151807. /**
  151808. * Gets or sets the highlight threshold
  151809. */
  151810. get highlightsThreshold(): number;
  151811. set highlightsThreshold(value: number);
  151812. /**
  151813. * Sets the amount of blur at the edges
  151814. * @param amount blur amount
  151815. */
  151816. setEdgeBlur(amount: number): void;
  151817. /**
  151818. * Sets edge blur to 0
  151819. */
  151820. disableEdgeBlur(): void;
  151821. /**
  151822. * Sets the amout of grain
  151823. * @param amount Amount of grain
  151824. */
  151825. setGrainAmount(amount: number): void;
  151826. /**
  151827. * Set grain amount to 0
  151828. */
  151829. disableGrain(): void;
  151830. /**
  151831. * Sets the chromatic aberration amount
  151832. * @param amount amount of chromatic aberration
  151833. */
  151834. setChromaticAberration(amount: number): void;
  151835. /**
  151836. * Sets chromatic aberration amount to 0
  151837. */
  151838. disableChromaticAberration(): void;
  151839. /**
  151840. * Sets the EdgeDistortion amount
  151841. * @param amount amount of EdgeDistortion
  151842. */
  151843. setEdgeDistortion(amount: number): void;
  151844. /**
  151845. * Sets edge distortion to 0
  151846. */
  151847. disableEdgeDistortion(): void;
  151848. /**
  151849. * Sets the FocusDistance amount
  151850. * @param amount amount of FocusDistance
  151851. */
  151852. setFocusDistance(amount: number): void;
  151853. /**
  151854. * Disables depth of field
  151855. */
  151856. disableDepthOfField(): void;
  151857. /**
  151858. * Sets the Aperture amount
  151859. * @param amount amount of Aperture
  151860. */
  151861. setAperture(amount: number): void;
  151862. /**
  151863. * Sets the DarkenOutOfFocus amount
  151864. * @param amount amount of DarkenOutOfFocus
  151865. */
  151866. setDarkenOutOfFocus(amount: number): void;
  151867. private _pentagonBokehIsEnabled;
  151868. /**
  151869. * Creates a pentagon bokeh effect
  151870. */
  151871. enablePentagonBokeh(): void;
  151872. /**
  151873. * Disables the pentagon bokeh effect
  151874. */
  151875. disablePentagonBokeh(): void;
  151876. /**
  151877. * Enables noise blur
  151878. */
  151879. enableNoiseBlur(): void;
  151880. /**
  151881. * Disables noise blur
  151882. */
  151883. disableNoiseBlur(): void;
  151884. /**
  151885. * Sets the HighlightsGain amount
  151886. * @param amount amount of HighlightsGain
  151887. */
  151888. setHighlightsGain(amount: number): void;
  151889. /**
  151890. * Sets the HighlightsThreshold amount
  151891. * @param amount amount of HighlightsThreshold
  151892. */
  151893. setHighlightsThreshold(amount: number): void;
  151894. /**
  151895. * Disables highlights
  151896. */
  151897. disableHighlights(): void;
  151898. /**
  151899. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151900. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151901. */
  151902. dispose(disableDepthRender?: boolean): void;
  151903. private _createChromaticAberrationPostProcess;
  151904. private _createHighlightsPostProcess;
  151905. private _createDepthOfFieldPostProcess;
  151906. private _createGrainTexture;
  151907. }
  151908. }
  151909. declare module BABYLON {
  151910. /**
  151911. * Contains all parameters needed for the prepass to perform
  151912. * screen space subsurface scattering
  151913. */
  151914. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151915. /**
  151916. * Is subsurface enabled
  151917. */
  151918. enabled: boolean;
  151919. /**
  151920. * Name of the configuration
  151921. */
  151922. name: string;
  151923. /**
  151924. * Textures that should be present in the MRT for this effect to work
  151925. */
  151926. readonly texturesRequired: number[];
  151927. }
  151928. }
  151929. declare module BABYLON {
  151930. /** @hidden */
  151931. export var ssao2PixelShader: {
  151932. name: string;
  151933. shader: string;
  151934. };
  151935. }
  151936. declare module BABYLON {
  151937. /** @hidden */
  151938. export var ssaoCombinePixelShader: {
  151939. name: string;
  151940. shader: string;
  151941. };
  151942. }
  151943. declare module BABYLON {
  151944. /**
  151945. * Render pipeline to produce ssao effect
  151946. */
  151947. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151948. /**
  151949. * @ignore
  151950. * The PassPostProcess id in the pipeline that contains the original scene color
  151951. */
  151952. SSAOOriginalSceneColorEffect: string;
  151953. /**
  151954. * @ignore
  151955. * The SSAO PostProcess id in the pipeline
  151956. */
  151957. SSAORenderEffect: string;
  151958. /**
  151959. * @ignore
  151960. * The horizontal blur PostProcess id in the pipeline
  151961. */
  151962. SSAOBlurHRenderEffect: string;
  151963. /**
  151964. * @ignore
  151965. * The vertical blur PostProcess id in the pipeline
  151966. */
  151967. SSAOBlurVRenderEffect: string;
  151968. /**
  151969. * @ignore
  151970. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151971. */
  151972. SSAOCombineRenderEffect: string;
  151973. /**
  151974. * The output strength of the SSAO post-process. Default value is 1.0.
  151975. */
  151976. totalStrength: number;
  151977. /**
  151978. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151979. */
  151980. maxZ: number;
  151981. /**
  151982. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151983. */
  151984. minZAspect: number;
  151985. private _samples;
  151986. /**
  151987. * Number of samples used for the SSAO calculations. Default value is 8
  151988. */
  151989. set samples(n: number);
  151990. get samples(): number;
  151991. private _textureSamples;
  151992. /**
  151993. * Number of samples to use for antialiasing
  151994. */
  151995. set textureSamples(n: number);
  151996. get textureSamples(): number;
  151997. /**
  151998. * Force rendering the geometry through geometry buffer
  151999. */
  152000. private _forceGeometryBuffer;
  152001. /**
  152002. * Ratio object used for SSAO ratio and blur ratio
  152003. */
  152004. private _ratio;
  152005. /**
  152006. * Dynamically generated sphere sampler.
  152007. */
  152008. private _sampleSphere;
  152009. /**
  152010. * Blur filter offsets
  152011. */
  152012. private _samplerOffsets;
  152013. private _expensiveBlur;
  152014. /**
  152015. * If bilateral blur should be used
  152016. */
  152017. set expensiveBlur(b: boolean);
  152018. get expensiveBlur(): boolean;
  152019. /**
  152020. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152021. */
  152022. radius: number;
  152023. /**
  152024. * The base color of the SSAO post-process
  152025. * The final result is "base + ssao" between [0, 1]
  152026. */
  152027. base: number;
  152028. /**
  152029. * Support test.
  152030. */
  152031. static get IsSupported(): boolean;
  152032. private _scene;
  152033. private _randomTexture;
  152034. private _originalColorPostProcess;
  152035. private _ssaoPostProcess;
  152036. private _blurHPostProcess;
  152037. private _blurVPostProcess;
  152038. private _ssaoCombinePostProcess;
  152039. private _prePassRenderer;
  152040. /**
  152041. * Gets active scene
  152042. */
  152043. get scene(): Scene;
  152044. /**
  152045. * @constructor
  152046. * @param name The rendering pipeline name
  152047. * @param scene The scene linked to this pipeline
  152048. * @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 }
  152049. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152050. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152051. */
  152052. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152053. /**
  152054. * Get the class name
  152055. * @returns "SSAO2RenderingPipeline"
  152056. */
  152057. getClassName(): string;
  152058. /**
  152059. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152060. */
  152061. dispose(disableGeometryBufferRenderer?: boolean): void;
  152062. private _createBlurPostProcess;
  152063. /** @hidden */
  152064. _rebuild(): void;
  152065. private _bits;
  152066. private _radicalInverse_VdC;
  152067. private _hammersley;
  152068. private _hemisphereSample_uniform;
  152069. private _generateHemisphere;
  152070. private _getDefinesForSSAO;
  152071. private _createSSAOPostProcess;
  152072. private _createSSAOCombinePostProcess;
  152073. private _createRandomTexture;
  152074. /**
  152075. * Serialize the rendering pipeline (Used when exporting)
  152076. * @returns the serialized object
  152077. */
  152078. serialize(): any;
  152079. /**
  152080. * Parse the serialized pipeline
  152081. * @param source Source pipeline.
  152082. * @param scene The scene to load the pipeline to.
  152083. * @param rootUrl The URL of the serialized pipeline.
  152084. * @returns An instantiated pipeline from the serialized object.
  152085. */
  152086. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152087. }
  152088. }
  152089. declare module BABYLON {
  152090. /** @hidden */
  152091. export var ssaoPixelShader: {
  152092. name: string;
  152093. shader: string;
  152094. };
  152095. }
  152096. declare module BABYLON {
  152097. /**
  152098. * Render pipeline to produce ssao effect
  152099. */
  152100. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152101. /**
  152102. * @ignore
  152103. * The PassPostProcess id in the pipeline that contains the original scene color
  152104. */
  152105. SSAOOriginalSceneColorEffect: string;
  152106. /**
  152107. * @ignore
  152108. * The SSAO PostProcess id in the pipeline
  152109. */
  152110. SSAORenderEffect: string;
  152111. /**
  152112. * @ignore
  152113. * The horizontal blur PostProcess id in the pipeline
  152114. */
  152115. SSAOBlurHRenderEffect: string;
  152116. /**
  152117. * @ignore
  152118. * The vertical blur PostProcess id in the pipeline
  152119. */
  152120. SSAOBlurVRenderEffect: string;
  152121. /**
  152122. * @ignore
  152123. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152124. */
  152125. SSAOCombineRenderEffect: string;
  152126. /**
  152127. * The output strength of the SSAO post-process. Default value is 1.0.
  152128. */
  152129. totalStrength: number;
  152130. /**
  152131. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152132. */
  152133. radius: number;
  152134. /**
  152135. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152136. * Must not be equal to fallOff and superior to fallOff.
  152137. * Default value is 0.0075
  152138. */
  152139. area: number;
  152140. /**
  152141. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152142. * Must not be equal to area and inferior to area.
  152143. * Default value is 0.000001
  152144. */
  152145. fallOff: number;
  152146. /**
  152147. * The base color of the SSAO post-process
  152148. * The final result is "base + ssao" between [0, 1]
  152149. */
  152150. base: number;
  152151. private _scene;
  152152. private _depthTexture;
  152153. private _randomTexture;
  152154. private _originalColorPostProcess;
  152155. private _ssaoPostProcess;
  152156. private _blurHPostProcess;
  152157. private _blurVPostProcess;
  152158. private _ssaoCombinePostProcess;
  152159. private _firstUpdate;
  152160. /**
  152161. * Gets active scene
  152162. */
  152163. get scene(): Scene;
  152164. /**
  152165. * @constructor
  152166. * @param name - The rendering pipeline name
  152167. * @param scene - The scene linked to this pipeline
  152168. * @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 }
  152169. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152170. */
  152171. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152172. /**
  152173. * Get the class name
  152174. * @returns "SSAORenderingPipeline"
  152175. */
  152176. getClassName(): string;
  152177. /**
  152178. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152179. */
  152180. dispose(disableDepthRender?: boolean): void;
  152181. private _createBlurPostProcess;
  152182. /** @hidden */
  152183. _rebuild(): void;
  152184. private _createSSAOPostProcess;
  152185. private _createSSAOCombinePostProcess;
  152186. private _createRandomTexture;
  152187. }
  152188. }
  152189. declare module BABYLON {
  152190. /**
  152191. * Contains all parameters needed for the prepass to perform
  152192. * screen space reflections
  152193. */
  152194. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152195. /**
  152196. * Is ssr enabled
  152197. */
  152198. enabled: boolean;
  152199. /**
  152200. * Name of the configuration
  152201. */
  152202. name: string;
  152203. /**
  152204. * Textures that should be present in the MRT for this effect to work
  152205. */
  152206. readonly texturesRequired: number[];
  152207. }
  152208. }
  152209. declare module BABYLON {
  152210. /** @hidden */
  152211. export var screenSpaceReflectionPixelShader: {
  152212. name: string;
  152213. shader: string;
  152214. };
  152215. }
  152216. declare module BABYLON {
  152217. /**
  152218. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152219. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152220. */
  152221. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152222. /**
  152223. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152224. */
  152225. threshold: number;
  152226. /**
  152227. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152228. */
  152229. strength: number;
  152230. /**
  152231. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152232. */
  152233. reflectionSpecularFalloffExponent: number;
  152234. /**
  152235. * 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]
  152236. */
  152237. step: number;
  152238. /**
  152239. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152240. */
  152241. roughnessFactor: number;
  152242. private _forceGeometryBuffer;
  152243. private _geometryBufferRenderer;
  152244. private _prePassRenderer;
  152245. private _enableSmoothReflections;
  152246. private _reflectionSamples;
  152247. private _smoothSteps;
  152248. /**
  152249. * Gets a string identifying the name of the class
  152250. * @returns "ScreenSpaceReflectionPostProcess" string
  152251. */
  152252. getClassName(): string;
  152253. /**
  152254. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152255. * @param name The name of the effect.
  152256. * @param scene The scene containing the objects to calculate reflections.
  152257. * @param options The required width/height ratio to downsize to before computing the render pass.
  152258. * @param camera The camera to apply the render pass to.
  152259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152260. * @param engine The engine which the post process will be applied. (default: current engine)
  152261. * @param reusable If the post process can be reused on the same frame. (default: false)
  152262. * @param textureType Type of textures used when performing the post process. (default: 0)
  152263. * @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)
  152264. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152265. */
  152266. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152267. /**
  152268. * Gets wether or not smoothing reflections is enabled.
  152269. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152270. */
  152271. get enableSmoothReflections(): boolean;
  152272. /**
  152273. * Sets wether or not smoothing reflections is enabled.
  152274. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152275. */
  152276. set enableSmoothReflections(enabled: boolean);
  152277. /**
  152278. * Gets the number of samples taken while computing reflections. More samples count is high,
  152279. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152280. */
  152281. get reflectionSamples(): number;
  152282. /**
  152283. * Sets the number of samples taken while computing reflections. More samples count is high,
  152284. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152285. */
  152286. set reflectionSamples(samples: number);
  152287. /**
  152288. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152289. * more the post-process will require GPU power and can generate a drop in FPS.
  152290. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152291. */
  152292. get smoothSteps(): number;
  152293. set smoothSteps(steps: number);
  152294. private _updateEffectDefines;
  152295. /** @hidden */
  152296. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152297. }
  152298. }
  152299. declare module BABYLON {
  152300. /** @hidden */
  152301. export var standardPixelShader: {
  152302. name: string;
  152303. shader: string;
  152304. };
  152305. }
  152306. declare module BABYLON {
  152307. /**
  152308. * Standard rendering pipeline
  152309. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152310. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152311. */
  152312. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152313. /**
  152314. * Public members
  152315. */
  152316. /**
  152317. * Post-process which contains the original scene color before the pipeline applies all the effects
  152318. */
  152319. originalPostProcess: Nullable<PostProcess>;
  152320. /**
  152321. * Post-process used to down scale an image x4
  152322. */
  152323. downSampleX4PostProcess: Nullable<PostProcess>;
  152324. /**
  152325. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152326. */
  152327. brightPassPostProcess: Nullable<PostProcess>;
  152328. /**
  152329. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152330. */
  152331. blurHPostProcesses: PostProcess[];
  152332. /**
  152333. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152334. */
  152335. blurVPostProcesses: PostProcess[];
  152336. /**
  152337. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152338. */
  152339. textureAdderPostProcess: Nullable<PostProcess>;
  152340. /**
  152341. * Post-process used to create volumetric lighting effect
  152342. */
  152343. volumetricLightPostProcess: Nullable<PostProcess>;
  152344. /**
  152345. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152346. */
  152347. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152348. /**
  152349. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152350. */
  152351. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152352. /**
  152353. * Post-process used to merge the volumetric light effect and the real scene color
  152354. */
  152355. volumetricLightMergePostProces: Nullable<PostProcess>;
  152356. /**
  152357. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152358. */
  152359. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152360. /**
  152361. * Base post-process used to calculate the average luminance of the final image for HDR
  152362. */
  152363. luminancePostProcess: Nullable<PostProcess>;
  152364. /**
  152365. * Post-processes used to create down sample post-processes in order to get
  152366. * the average luminance of the final image for HDR
  152367. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152368. */
  152369. luminanceDownSamplePostProcesses: PostProcess[];
  152370. /**
  152371. * Post-process used to create a HDR effect (light adaptation)
  152372. */
  152373. hdrPostProcess: Nullable<PostProcess>;
  152374. /**
  152375. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152376. */
  152377. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152378. /**
  152379. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152380. */
  152381. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152382. /**
  152383. * Post-process used to merge the final HDR post-process and the real scene color
  152384. */
  152385. hdrFinalPostProcess: Nullable<PostProcess>;
  152386. /**
  152387. * Post-process used to create a lens flare effect
  152388. */
  152389. lensFlarePostProcess: Nullable<PostProcess>;
  152390. /**
  152391. * Post-process that merges the result of the lens flare post-process and the real scene color
  152392. */
  152393. lensFlareComposePostProcess: Nullable<PostProcess>;
  152394. /**
  152395. * Post-process used to create a motion blur effect
  152396. */
  152397. motionBlurPostProcess: Nullable<PostProcess>;
  152398. /**
  152399. * Post-process used to create a depth of field effect
  152400. */
  152401. depthOfFieldPostProcess: Nullable<PostProcess>;
  152402. /**
  152403. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152404. */
  152405. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152406. /**
  152407. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152408. */
  152409. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152410. /**
  152411. * Represents the brightness threshold in order to configure the illuminated surfaces
  152412. */
  152413. brightThreshold: number;
  152414. /**
  152415. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152416. */
  152417. blurWidth: number;
  152418. /**
  152419. * Sets if the blur for highlighted surfaces must be only horizontal
  152420. */
  152421. horizontalBlur: boolean;
  152422. /**
  152423. * Gets the overall exposure used by the pipeline
  152424. */
  152425. get exposure(): number;
  152426. /**
  152427. * Sets the overall exposure used by the pipeline
  152428. */
  152429. set exposure(value: number);
  152430. /**
  152431. * Texture used typically to simulate "dirty" on camera lens
  152432. */
  152433. lensTexture: Nullable<Texture>;
  152434. /**
  152435. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152436. */
  152437. volumetricLightCoefficient: number;
  152438. /**
  152439. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152440. */
  152441. volumetricLightPower: number;
  152442. /**
  152443. * Used the set the blur intensity to smooth the volumetric lights
  152444. */
  152445. volumetricLightBlurScale: number;
  152446. /**
  152447. * Light (spot or directional) used to generate the volumetric lights rays
  152448. * The source light must have a shadow generate so the pipeline can get its
  152449. * depth map
  152450. */
  152451. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152452. /**
  152453. * For eye adaptation, represents the minimum luminance the eye can see
  152454. */
  152455. hdrMinimumLuminance: number;
  152456. /**
  152457. * For eye adaptation, represents the decrease luminance speed
  152458. */
  152459. hdrDecreaseRate: number;
  152460. /**
  152461. * For eye adaptation, represents the increase luminance speed
  152462. */
  152463. hdrIncreaseRate: number;
  152464. /**
  152465. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152466. */
  152467. get hdrAutoExposure(): boolean;
  152468. /**
  152469. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152470. */
  152471. set hdrAutoExposure(value: boolean);
  152472. /**
  152473. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152474. */
  152475. lensColorTexture: Nullable<Texture>;
  152476. /**
  152477. * The overall strengh for the lens flare effect
  152478. */
  152479. lensFlareStrength: number;
  152480. /**
  152481. * Dispersion coefficient for lens flare ghosts
  152482. */
  152483. lensFlareGhostDispersal: number;
  152484. /**
  152485. * Main lens flare halo width
  152486. */
  152487. lensFlareHaloWidth: number;
  152488. /**
  152489. * Based on the lens distortion effect, defines how much the lens flare result
  152490. * is distorted
  152491. */
  152492. lensFlareDistortionStrength: number;
  152493. /**
  152494. * Configures the blur intensity used for for lens flare (halo)
  152495. */
  152496. lensFlareBlurWidth: number;
  152497. /**
  152498. * Lens star texture must be used to simulate rays on the flares and is available
  152499. * in the documentation
  152500. */
  152501. lensStarTexture: Nullable<Texture>;
  152502. /**
  152503. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152504. * flare effect by taking account of the dirt texture
  152505. */
  152506. lensFlareDirtTexture: Nullable<Texture>;
  152507. /**
  152508. * Represents the focal length for the depth of field effect
  152509. */
  152510. depthOfFieldDistance: number;
  152511. /**
  152512. * Represents the blur intensity for the blurred part of the depth of field effect
  152513. */
  152514. depthOfFieldBlurWidth: number;
  152515. /**
  152516. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152517. */
  152518. get motionStrength(): number;
  152519. /**
  152520. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152521. */
  152522. set motionStrength(strength: number);
  152523. /**
  152524. * Gets wether or not the motion blur post-process is object based or screen based.
  152525. */
  152526. get objectBasedMotionBlur(): boolean;
  152527. /**
  152528. * Sets wether or not the motion blur post-process should be object based or screen based
  152529. */
  152530. set objectBasedMotionBlur(value: boolean);
  152531. /**
  152532. * List of animations for the pipeline (IAnimatable implementation)
  152533. */
  152534. animations: Animation[];
  152535. /**
  152536. * Private members
  152537. */
  152538. private _scene;
  152539. private _currentDepthOfFieldSource;
  152540. private _basePostProcess;
  152541. private _fixedExposure;
  152542. private _currentExposure;
  152543. private _hdrAutoExposure;
  152544. private _hdrCurrentLuminance;
  152545. private _motionStrength;
  152546. private _isObjectBasedMotionBlur;
  152547. private _floatTextureType;
  152548. private _camerasToBeAttached;
  152549. private _ratio;
  152550. private _bloomEnabled;
  152551. private _depthOfFieldEnabled;
  152552. private _vlsEnabled;
  152553. private _lensFlareEnabled;
  152554. private _hdrEnabled;
  152555. private _motionBlurEnabled;
  152556. private _fxaaEnabled;
  152557. private _screenSpaceReflectionsEnabled;
  152558. private _motionBlurSamples;
  152559. private _volumetricLightStepsCount;
  152560. private _samples;
  152561. /**
  152562. * @ignore
  152563. * Specifies if the bloom pipeline is enabled
  152564. */
  152565. get BloomEnabled(): boolean;
  152566. set BloomEnabled(enabled: boolean);
  152567. /**
  152568. * @ignore
  152569. * Specifies if the depth of field pipeline is enabed
  152570. */
  152571. get DepthOfFieldEnabled(): boolean;
  152572. set DepthOfFieldEnabled(enabled: boolean);
  152573. /**
  152574. * @ignore
  152575. * Specifies if the lens flare pipeline is enabed
  152576. */
  152577. get LensFlareEnabled(): boolean;
  152578. set LensFlareEnabled(enabled: boolean);
  152579. /**
  152580. * @ignore
  152581. * Specifies if the HDR pipeline is enabled
  152582. */
  152583. get HDREnabled(): boolean;
  152584. set HDREnabled(enabled: boolean);
  152585. /**
  152586. * @ignore
  152587. * Specifies if the volumetric lights scattering effect is enabled
  152588. */
  152589. get VLSEnabled(): boolean;
  152590. set VLSEnabled(enabled: boolean);
  152591. /**
  152592. * @ignore
  152593. * Specifies if the motion blur effect is enabled
  152594. */
  152595. get MotionBlurEnabled(): boolean;
  152596. set MotionBlurEnabled(enabled: boolean);
  152597. /**
  152598. * Specifies if anti-aliasing is enabled
  152599. */
  152600. get fxaaEnabled(): boolean;
  152601. set fxaaEnabled(enabled: boolean);
  152602. /**
  152603. * Specifies if screen space reflections are enabled.
  152604. */
  152605. get screenSpaceReflectionsEnabled(): boolean;
  152606. set screenSpaceReflectionsEnabled(enabled: boolean);
  152607. /**
  152608. * Specifies the number of steps used to calculate the volumetric lights
  152609. * Typically in interval [50, 200]
  152610. */
  152611. get volumetricLightStepsCount(): number;
  152612. set volumetricLightStepsCount(count: number);
  152613. /**
  152614. * Specifies the number of samples used for the motion blur effect
  152615. * Typically in interval [16, 64]
  152616. */
  152617. get motionBlurSamples(): number;
  152618. set motionBlurSamples(samples: number);
  152619. /**
  152620. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152621. */
  152622. get samples(): number;
  152623. set samples(sampleCount: number);
  152624. /**
  152625. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152626. * @constructor
  152627. * @param name The rendering pipeline name
  152628. * @param scene The scene linked to this pipeline
  152629. * @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)
  152630. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152632. */
  152633. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152634. private _buildPipeline;
  152635. private _createDownSampleX4PostProcess;
  152636. private _createBrightPassPostProcess;
  152637. private _createBlurPostProcesses;
  152638. private _createTextureAdderPostProcess;
  152639. private _createVolumetricLightPostProcess;
  152640. private _createLuminancePostProcesses;
  152641. private _createHdrPostProcess;
  152642. private _createLensFlarePostProcess;
  152643. private _createDepthOfFieldPostProcess;
  152644. private _createMotionBlurPostProcess;
  152645. private _getDepthTexture;
  152646. private _disposePostProcesses;
  152647. /**
  152648. * Dispose of the pipeline and stop all post processes
  152649. */
  152650. dispose(): void;
  152651. /**
  152652. * Serialize the rendering pipeline (Used when exporting)
  152653. * @returns the serialized object
  152654. */
  152655. serialize(): any;
  152656. /**
  152657. * Parse the serialized pipeline
  152658. * @param source Source pipeline.
  152659. * @param scene The scene to load the pipeline to.
  152660. * @param rootUrl The URL of the serialized pipeline.
  152661. * @returns An instantiated pipeline from the serialized object.
  152662. */
  152663. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152664. /**
  152665. * Luminance steps
  152666. */
  152667. static LuminanceSteps: number;
  152668. }
  152669. }
  152670. declare module BABYLON {
  152671. /** @hidden */
  152672. export var stereoscopicInterlacePixelShader: {
  152673. name: string;
  152674. shader: string;
  152675. };
  152676. }
  152677. declare module BABYLON {
  152678. /**
  152679. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152680. */
  152681. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152682. private _stepSize;
  152683. private _passedProcess;
  152684. /**
  152685. * Gets a string identifying the name of the class
  152686. * @returns "StereoscopicInterlacePostProcessI" string
  152687. */
  152688. getClassName(): string;
  152689. /**
  152690. * Initializes a StereoscopicInterlacePostProcessI
  152691. * @param name The name of the effect.
  152692. * @param rigCameras The rig cameras to be appled to the post process
  152693. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152694. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152696. * @param engine The engine which the post process will be applied. (default: current engine)
  152697. * @param reusable If the post process can be reused on the same frame. (default: false)
  152698. */
  152699. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152700. }
  152701. /**
  152702. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152703. */
  152704. export class StereoscopicInterlacePostProcess extends PostProcess {
  152705. private _stepSize;
  152706. private _passedProcess;
  152707. /**
  152708. * Gets a string identifying the name of the class
  152709. * @returns "StereoscopicInterlacePostProcess" string
  152710. */
  152711. getClassName(): string;
  152712. /**
  152713. * Initializes a StereoscopicInterlacePostProcess
  152714. * @param name The name of the effect.
  152715. * @param rigCameras The rig cameras to be appled to the post process
  152716. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152718. * @param engine The engine which the post process will be applied. (default: current engine)
  152719. * @param reusable If the post process can be reused on the same frame. (default: false)
  152720. */
  152721. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152722. }
  152723. }
  152724. declare module BABYLON {
  152725. /** @hidden */
  152726. export var tonemapPixelShader: {
  152727. name: string;
  152728. shader: string;
  152729. };
  152730. }
  152731. declare module BABYLON {
  152732. /** Defines operator used for tonemapping */
  152733. export enum TonemappingOperator {
  152734. /** Hable */
  152735. Hable = 0,
  152736. /** Reinhard */
  152737. Reinhard = 1,
  152738. /** HejiDawson */
  152739. HejiDawson = 2,
  152740. /** Photographic */
  152741. Photographic = 3
  152742. }
  152743. /**
  152744. * Defines a post process to apply tone mapping
  152745. */
  152746. export class TonemapPostProcess extends PostProcess {
  152747. private _operator;
  152748. /** Defines the required exposure adjustement */
  152749. exposureAdjustment: number;
  152750. /**
  152751. * Gets a string identifying the name of the class
  152752. * @returns "TonemapPostProcess" string
  152753. */
  152754. getClassName(): string;
  152755. /**
  152756. * Creates a new TonemapPostProcess
  152757. * @param name defines the name of the postprocess
  152758. * @param _operator defines the operator to use
  152759. * @param exposureAdjustment defines the required exposure adjustement
  152760. * @param camera defines the camera to use (can be null)
  152761. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152762. * @param engine defines the hosting engine (can be ignore if camera is set)
  152763. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152764. */
  152765. constructor(name: string, _operator: TonemappingOperator,
  152766. /** Defines the required exposure adjustement */
  152767. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152768. }
  152769. }
  152770. declare module BABYLON {
  152771. /** @hidden */
  152772. export var volumetricLightScatteringPixelShader: {
  152773. name: string;
  152774. shader: string;
  152775. };
  152776. }
  152777. declare module BABYLON {
  152778. /** @hidden */
  152779. export var volumetricLightScatteringPassVertexShader: {
  152780. name: string;
  152781. shader: string;
  152782. };
  152783. }
  152784. declare module BABYLON {
  152785. /** @hidden */
  152786. export var volumetricLightScatteringPassPixelShader: {
  152787. name: string;
  152788. shader: string;
  152789. };
  152790. }
  152791. declare module BABYLON {
  152792. /**
  152793. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152794. */
  152795. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152796. private _volumetricLightScatteringPass;
  152797. private _volumetricLightScatteringRTT;
  152798. private _viewPort;
  152799. private _screenCoordinates;
  152800. private _cachedDefines;
  152801. /**
  152802. * If not undefined, the mesh position is computed from the attached node position
  152803. */
  152804. attachedNode: {
  152805. position: Vector3;
  152806. };
  152807. /**
  152808. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152809. */
  152810. customMeshPosition: Vector3;
  152811. /**
  152812. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152813. */
  152814. useCustomMeshPosition: boolean;
  152815. /**
  152816. * If the post-process should inverse the light scattering direction
  152817. */
  152818. invert: boolean;
  152819. /**
  152820. * The internal mesh used by the post-process
  152821. */
  152822. mesh: Mesh;
  152823. /**
  152824. * @hidden
  152825. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152826. */
  152827. get useDiffuseColor(): boolean;
  152828. set useDiffuseColor(useDiffuseColor: boolean);
  152829. /**
  152830. * Array containing the excluded meshes not rendered in the internal pass
  152831. */
  152832. excludedMeshes: AbstractMesh[];
  152833. /**
  152834. * Controls the overall intensity of the post-process
  152835. */
  152836. exposure: number;
  152837. /**
  152838. * Dissipates each sample's contribution in range [0, 1]
  152839. */
  152840. decay: number;
  152841. /**
  152842. * Controls the overall intensity of each sample
  152843. */
  152844. weight: number;
  152845. /**
  152846. * Controls the density of each sample
  152847. */
  152848. density: number;
  152849. /**
  152850. * @constructor
  152851. * @param name The post-process name
  152852. * @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)
  152853. * @param camera The camera that the post-process will be attached to
  152854. * @param mesh The mesh used to create the light scattering
  152855. * @param samples The post-process quality, default 100
  152856. * @param samplingModeThe post-process filtering mode
  152857. * @param engine The babylon engine
  152858. * @param reusable If the post-process is reusable
  152859. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152860. */
  152861. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152862. /**
  152863. * Returns the string "VolumetricLightScatteringPostProcess"
  152864. * @returns "VolumetricLightScatteringPostProcess"
  152865. */
  152866. getClassName(): string;
  152867. private _isReady;
  152868. /**
  152869. * Sets the new light position for light scattering effect
  152870. * @param position The new custom light position
  152871. */
  152872. setCustomMeshPosition(position: Vector3): void;
  152873. /**
  152874. * Returns the light position for light scattering effect
  152875. * @return Vector3 The custom light position
  152876. */
  152877. getCustomMeshPosition(): Vector3;
  152878. /**
  152879. * Disposes the internal assets and detaches the post-process from the camera
  152880. */
  152881. dispose(camera: Camera): void;
  152882. /**
  152883. * Returns the render target texture used by the post-process
  152884. * @return the render target texture used by the post-process
  152885. */
  152886. getPass(): RenderTargetTexture;
  152887. private _meshExcluded;
  152888. private _createPass;
  152889. private _updateMeshScreenCoordinates;
  152890. /**
  152891. * Creates a default mesh for the Volumeric Light Scattering post-process
  152892. * @param name The mesh name
  152893. * @param scene The scene where to create the mesh
  152894. * @return the default mesh
  152895. */
  152896. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152897. }
  152898. }
  152899. declare module BABYLON {
  152900. /** @hidden */
  152901. export var screenSpaceCurvaturePixelShader: {
  152902. name: string;
  152903. shader: string;
  152904. };
  152905. }
  152906. declare module BABYLON {
  152907. /**
  152908. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152909. */
  152910. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152911. /**
  152912. * Defines how much ridge the curvature effect displays.
  152913. */
  152914. ridge: number;
  152915. /**
  152916. * Defines how much valley the curvature effect displays.
  152917. */
  152918. valley: number;
  152919. private _geometryBufferRenderer;
  152920. /**
  152921. * Gets a string identifying the name of the class
  152922. * @returns "ScreenSpaceCurvaturePostProcess" string
  152923. */
  152924. getClassName(): string;
  152925. /**
  152926. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152927. * @param name The name of the effect.
  152928. * @param scene The scene containing the objects to blur according to their velocity.
  152929. * @param options The required width/height ratio to downsize to before computing the render pass.
  152930. * @param camera The camera to apply the render pass to.
  152931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152932. * @param engine The engine which the post process will be applied. (default: current engine)
  152933. * @param reusable If the post process can be reused on the same frame. (default: false)
  152934. * @param textureType Type of textures used when performing the post process. (default: 0)
  152935. * @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)
  152936. */
  152937. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152938. /**
  152939. * Support test.
  152940. */
  152941. static get IsSupported(): boolean;
  152942. /** @hidden */
  152943. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152944. }
  152945. }
  152946. declare module BABYLON {
  152947. interface Scene {
  152948. /** @hidden (Backing field) */
  152949. _boundingBoxRenderer: BoundingBoxRenderer;
  152950. /** @hidden (Backing field) */
  152951. _forceShowBoundingBoxes: boolean;
  152952. /**
  152953. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152954. */
  152955. forceShowBoundingBoxes: boolean;
  152956. /**
  152957. * Gets the bounding box renderer associated with the scene
  152958. * @returns a BoundingBoxRenderer
  152959. */
  152960. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152961. }
  152962. interface AbstractMesh {
  152963. /** @hidden (Backing field) */
  152964. _showBoundingBox: boolean;
  152965. /**
  152966. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152967. */
  152968. showBoundingBox: boolean;
  152969. }
  152970. /**
  152971. * Component responsible of rendering the bounding box of the meshes in a scene.
  152972. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152973. */
  152974. export class BoundingBoxRenderer implements ISceneComponent {
  152975. /**
  152976. * The component name helpfull to identify the component in the list of scene components.
  152977. */
  152978. readonly name: string;
  152979. /**
  152980. * The scene the component belongs to.
  152981. */
  152982. scene: Scene;
  152983. /**
  152984. * Color of the bounding box lines placed in front of an object
  152985. */
  152986. frontColor: Color3;
  152987. /**
  152988. * Color of the bounding box lines placed behind an object
  152989. */
  152990. backColor: Color3;
  152991. /**
  152992. * Defines if the renderer should show the back lines or not
  152993. */
  152994. showBackLines: boolean;
  152995. /**
  152996. * Observable raised before rendering a bounding box
  152997. */
  152998. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152999. /**
  153000. * Observable raised after rendering a bounding box
  153001. */
  153002. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153003. /**
  153004. * @hidden
  153005. */
  153006. renderList: SmartArray<BoundingBox>;
  153007. private _colorShader;
  153008. private _vertexBuffers;
  153009. private _indexBuffer;
  153010. private _fillIndexBuffer;
  153011. private _fillIndexData;
  153012. /**
  153013. * Instantiates a new bounding box renderer in a scene.
  153014. * @param scene the scene the renderer renders in
  153015. */
  153016. constructor(scene: Scene);
  153017. /**
  153018. * Registers the component in a given scene
  153019. */
  153020. register(): void;
  153021. private _evaluateSubMesh;
  153022. private _activeMesh;
  153023. private _prepareRessources;
  153024. private _createIndexBuffer;
  153025. /**
  153026. * Rebuilds the elements related to this component in case of
  153027. * context lost for instance.
  153028. */
  153029. rebuild(): void;
  153030. /**
  153031. * @hidden
  153032. */
  153033. reset(): void;
  153034. /**
  153035. * Render the bounding boxes of a specific rendering group
  153036. * @param renderingGroupId defines the rendering group to render
  153037. */
  153038. render(renderingGroupId: number): void;
  153039. /**
  153040. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153041. * @param mesh Define the mesh to render the occlusion bounding box for
  153042. */
  153043. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153044. /**
  153045. * Dispose and release the resources attached to this renderer.
  153046. */
  153047. dispose(): void;
  153048. }
  153049. }
  153050. declare module BABYLON {
  153051. interface Scene {
  153052. /** @hidden (Backing field) */
  153053. _depthRenderer: {
  153054. [id: string]: DepthRenderer;
  153055. };
  153056. /**
  153057. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153058. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153059. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153060. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153061. * @returns the created depth renderer
  153062. */
  153063. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153064. /**
  153065. * Disables a depth renderer for a given camera
  153066. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153067. */
  153068. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153069. }
  153070. /**
  153071. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153072. * in several rendering techniques.
  153073. */
  153074. export class DepthRendererSceneComponent implements ISceneComponent {
  153075. /**
  153076. * The component name helpfull to identify the component in the list of scene components.
  153077. */
  153078. readonly name: string;
  153079. /**
  153080. * The scene the component belongs to.
  153081. */
  153082. scene: Scene;
  153083. /**
  153084. * Creates a new instance of the component for the given scene
  153085. * @param scene Defines the scene to register the component in
  153086. */
  153087. constructor(scene: Scene);
  153088. /**
  153089. * Registers the component in a given scene
  153090. */
  153091. register(): void;
  153092. /**
  153093. * Rebuilds the elements related to this component in case of
  153094. * context lost for instance.
  153095. */
  153096. rebuild(): void;
  153097. /**
  153098. * Disposes the component and the associated ressources
  153099. */
  153100. dispose(): void;
  153101. private _gatherRenderTargets;
  153102. private _gatherActiveCameraRenderTargets;
  153103. }
  153104. }
  153105. declare module BABYLON {
  153106. interface AbstractScene {
  153107. /** @hidden (Backing field) */
  153108. _prePassRenderer: Nullable<PrePassRenderer>;
  153109. /**
  153110. * Gets or Sets the current prepass renderer associated to the scene.
  153111. */
  153112. prePassRenderer: Nullable<PrePassRenderer>;
  153113. /**
  153114. * Enables the prepass and associates it with the scene
  153115. * @returns the PrePassRenderer
  153116. */
  153117. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153118. /**
  153119. * Disables the prepass associated with the scene
  153120. */
  153121. disablePrePassRenderer(): void;
  153122. }
  153123. /**
  153124. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153125. * in several rendering techniques.
  153126. */
  153127. export class PrePassRendererSceneComponent implements ISceneComponent {
  153128. /**
  153129. * The component name helpful to identify the component in the list of scene components.
  153130. */
  153131. readonly name: string;
  153132. /**
  153133. * The scene the component belongs to.
  153134. */
  153135. scene: Scene;
  153136. /**
  153137. * Creates a new instance of the component for the given scene
  153138. * @param scene Defines the scene to register the component in
  153139. */
  153140. constructor(scene: Scene);
  153141. /**
  153142. * Registers the component in a given scene
  153143. */
  153144. register(): void;
  153145. private _beforeCameraDraw;
  153146. private _afterCameraDraw;
  153147. private _beforeClearStage;
  153148. /**
  153149. * Rebuilds the elements related to this component in case of
  153150. * context lost for instance.
  153151. */
  153152. rebuild(): void;
  153153. /**
  153154. * Disposes the component and the associated ressources
  153155. */
  153156. dispose(): void;
  153157. }
  153158. }
  153159. declare module BABYLON {
  153160. /** @hidden */
  153161. export var fibonacci: {
  153162. name: string;
  153163. shader: string;
  153164. };
  153165. }
  153166. declare module BABYLON {
  153167. /** @hidden */
  153168. export var diffusionProfile: {
  153169. name: string;
  153170. shader: string;
  153171. };
  153172. }
  153173. declare module BABYLON {
  153174. /** @hidden */
  153175. export var subSurfaceScatteringPixelShader: {
  153176. name: string;
  153177. shader: string;
  153178. };
  153179. }
  153180. declare module BABYLON {
  153181. /**
  153182. * Sub surface scattering post process
  153183. */
  153184. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153185. /**
  153186. * Gets a string identifying the name of the class
  153187. * @returns "SubSurfaceScatteringPostProcess" string
  153188. */
  153189. getClassName(): string;
  153190. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153191. }
  153192. }
  153193. declare module BABYLON {
  153194. /**
  153195. * Contains all parameters needed for the prepass to perform
  153196. * screen space subsurface scattering
  153197. */
  153198. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153199. /** @hidden */
  153200. static _SceneComponentInitialization: (scene: Scene) => void;
  153201. private _ssDiffusionS;
  153202. private _ssFilterRadii;
  153203. private _ssDiffusionD;
  153204. /**
  153205. * Post process to attach for screen space subsurface scattering
  153206. */
  153207. postProcess: SubSurfaceScatteringPostProcess;
  153208. /**
  153209. * Diffusion profile color for subsurface scattering
  153210. */
  153211. get ssDiffusionS(): number[];
  153212. /**
  153213. * Diffusion profile max color channel value for subsurface scattering
  153214. */
  153215. get ssDiffusionD(): number[];
  153216. /**
  153217. * Diffusion profile filter radius for subsurface scattering
  153218. */
  153219. get ssFilterRadii(): number[];
  153220. /**
  153221. * Is subsurface enabled
  153222. */
  153223. enabled: boolean;
  153224. /**
  153225. * Name of the configuration
  153226. */
  153227. name: string;
  153228. /**
  153229. * Diffusion profile colors for subsurface scattering
  153230. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153231. * See ...
  153232. * Note that you can only store up to 5 of them
  153233. */
  153234. ssDiffusionProfileColors: Color3[];
  153235. /**
  153236. * Defines the ratio real world => scene units.
  153237. * Used for subsurface scattering
  153238. */
  153239. metersPerUnit: number;
  153240. /**
  153241. * Textures that should be present in the MRT for this effect to work
  153242. */
  153243. readonly texturesRequired: number[];
  153244. private _scene;
  153245. /**
  153246. * Builds a subsurface configuration object
  153247. * @param scene The scene
  153248. */
  153249. constructor(scene: Scene);
  153250. /**
  153251. * Adds a new diffusion profile.
  153252. * Useful for more realistic subsurface scattering on diverse materials.
  153253. * @param color The color of the diffusion profile. Should be the average color of the material.
  153254. * @return The index of the diffusion profile for the material subsurface configuration
  153255. */
  153256. addDiffusionProfile(color: Color3): number;
  153257. /**
  153258. * Creates the sss post process
  153259. * @return The created post process
  153260. */
  153261. createPostProcess(): SubSurfaceScatteringPostProcess;
  153262. /**
  153263. * Deletes all diffusion profiles.
  153264. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153265. */
  153266. clearAllDiffusionProfiles(): void;
  153267. /**
  153268. * Disposes this object
  153269. */
  153270. dispose(): void;
  153271. /**
  153272. * @hidden
  153273. * https://zero-radiance.github.io/post/sampling-diffusion/
  153274. *
  153275. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153276. * ------------------------------------------------------------------------------------
  153277. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153278. * PDF[r, phi, s] = r * R[r, phi, s]
  153279. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153280. * ------------------------------------------------------------------------------------
  153281. * We importance sample the color channel with the widest scattering distance.
  153282. */
  153283. getDiffusionProfileParameters(color: Color3): number;
  153284. /**
  153285. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153286. * 'u' is the random number (the value of the CDF): [0, 1).
  153287. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153288. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153289. */
  153290. private _sampleBurleyDiffusionProfile;
  153291. }
  153292. }
  153293. declare module BABYLON {
  153294. interface AbstractScene {
  153295. /** @hidden (Backing field) */
  153296. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153297. /**
  153298. * Gets or Sets the current prepass renderer associated to the scene.
  153299. */
  153300. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153301. /**
  153302. * Enables the subsurface effect for prepass
  153303. * @returns the SubSurfaceConfiguration
  153304. */
  153305. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153306. /**
  153307. * Disables the subsurface effect for prepass
  153308. */
  153309. disableSubSurfaceForPrePass(): void;
  153310. }
  153311. /**
  153312. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153313. * in several rendering techniques.
  153314. */
  153315. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153316. /**
  153317. * The component name helpful to identify the component in the list of scene components.
  153318. */
  153319. readonly name: string;
  153320. /**
  153321. * The scene the component belongs to.
  153322. */
  153323. scene: Scene;
  153324. /**
  153325. * Creates a new instance of the component for the given scene
  153326. * @param scene Defines the scene to register the component in
  153327. */
  153328. constructor(scene: Scene);
  153329. /**
  153330. * Registers the component in a given scene
  153331. */
  153332. register(): void;
  153333. /**
  153334. * Serializes the component data to the specified json object
  153335. * @param serializationObject The object to serialize to
  153336. */
  153337. serialize(serializationObject: any): void;
  153338. /**
  153339. * Adds all the elements from the container to the scene
  153340. * @param container the container holding the elements
  153341. */
  153342. addFromContainer(container: AbstractScene): void;
  153343. /**
  153344. * Removes all the elements in the container from the scene
  153345. * @param container contains the elements to remove
  153346. * @param dispose if the removed element should be disposed (default: false)
  153347. */
  153348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153349. /**
  153350. * Rebuilds the elements related to this component in case of
  153351. * context lost for instance.
  153352. */
  153353. rebuild(): void;
  153354. /**
  153355. * Disposes the component and the associated ressources
  153356. */
  153357. dispose(): void;
  153358. }
  153359. }
  153360. declare module BABYLON {
  153361. /** @hidden */
  153362. export var outlinePixelShader: {
  153363. name: string;
  153364. shader: string;
  153365. };
  153366. }
  153367. declare module BABYLON {
  153368. /** @hidden */
  153369. export var outlineVertexShader: {
  153370. name: string;
  153371. shader: string;
  153372. };
  153373. }
  153374. declare module BABYLON {
  153375. interface Scene {
  153376. /** @hidden */
  153377. _outlineRenderer: OutlineRenderer;
  153378. /**
  153379. * Gets the outline renderer associated with the scene
  153380. * @returns a OutlineRenderer
  153381. */
  153382. getOutlineRenderer(): OutlineRenderer;
  153383. }
  153384. interface AbstractMesh {
  153385. /** @hidden (Backing field) */
  153386. _renderOutline: boolean;
  153387. /**
  153388. * Gets or sets a boolean indicating if the outline must be rendered as well
  153389. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153390. */
  153391. renderOutline: boolean;
  153392. /** @hidden (Backing field) */
  153393. _renderOverlay: boolean;
  153394. /**
  153395. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153396. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153397. */
  153398. renderOverlay: boolean;
  153399. }
  153400. /**
  153401. * This class is responsible to draw bothe outline/overlay of meshes.
  153402. * It should not be used directly but through the available method on mesh.
  153403. */
  153404. export class OutlineRenderer implements ISceneComponent {
  153405. /**
  153406. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153407. */
  153408. private static _StencilReference;
  153409. /**
  153410. * The name of the component. Each component must have a unique name.
  153411. */
  153412. name: string;
  153413. /**
  153414. * The scene the component belongs to.
  153415. */
  153416. scene: Scene;
  153417. /**
  153418. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153419. */
  153420. zOffset: number;
  153421. private _engine;
  153422. private _effect;
  153423. private _cachedDefines;
  153424. private _savedDepthWrite;
  153425. /**
  153426. * Instantiates a new outline renderer. (There could be only one per scene).
  153427. * @param scene Defines the scene it belongs to
  153428. */
  153429. constructor(scene: Scene);
  153430. /**
  153431. * Register the component to one instance of a scene.
  153432. */
  153433. register(): void;
  153434. /**
  153435. * Rebuilds the elements related to this component in case of
  153436. * context lost for instance.
  153437. */
  153438. rebuild(): void;
  153439. /**
  153440. * Disposes the component and the associated ressources.
  153441. */
  153442. dispose(): void;
  153443. /**
  153444. * Renders the outline in the canvas.
  153445. * @param subMesh Defines the sumesh to render
  153446. * @param batch Defines the batch of meshes in case of instances
  153447. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153448. */
  153449. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153450. /**
  153451. * Returns whether or not the outline renderer is ready for a given submesh.
  153452. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153453. * @param subMesh Defines the submesh to check readyness for
  153454. * @param useInstances Defines wheter wee are trying to render instances or not
  153455. * @returns true if ready otherwise false
  153456. */
  153457. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153458. private _beforeRenderingMesh;
  153459. private _afterRenderingMesh;
  153460. }
  153461. }
  153462. declare module BABYLON {
  153463. /**
  153464. * Defines the basic options interface of a Sprite Frame Source Size.
  153465. */
  153466. export interface ISpriteJSONSpriteSourceSize {
  153467. /**
  153468. * number of the original width of the Frame
  153469. */
  153470. w: number;
  153471. /**
  153472. * number of the original height of the Frame
  153473. */
  153474. h: number;
  153475. }
  153476. /**
  153477. * Defines the basic options interface of a Sprite Frame Data.
  153478. */
  153479. export interface ISpriteJSONSpriteFrameData {
  153480. /**
  153481. * number of the x offset of the Frame
  153482. */
  153483. x: number;
  153484. /**
  153485. * number of the y offset of the Frame
  153486. */
  153487. y: number;
  153488. /**
  153489. * number of the width of the Frame
  153490. */
  153491. w: number;
  153492. /**
  153493. * number of the height of the Frame
  153494. */
  153495. h: number;
  153496. }
  153497. /**
  153498. * Defines the basic options interface of a JSON Sprite.
  153499. */
  153500. export interface ISpriteJSONSprite {
  153501. /**
  153502. * string name of the Frame
  153503. */
  153504. filename: string;
  153505. /**
  153506. * ISpriteJSONSpriteFrame basic object of the frame data
  153507. */
  153508. frame: ISpriteJSONSpriteFrameData;
  153509. /**
  153510. * boolean to flag is the frame was rotated.
  153511. */
  153512. rotated: boolean;
  153513. /**
  153514. * boolean to flag is the frame was trimmed.
  153515. */
  153516. trimmed: boolean;
  153517. /**
  153518. * ISpriteJSONSpriteFrame basic object of the source data
  153519. */
  153520. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153521. /**
  153522. * ISpriteJSONSpriteFrame basic object of the source data
  153523. */
  153524. sourceSize: ISpriteJSONSpriteSourceSize;
  153525. }
  153526. /**
  153527. * Defines the basic options interface of a JSON atlas.
  153528. */
  153529. export interface ISpriteJSONAtlas {
  153530. /**
  153531. * Array of objects that contain the frame data.
  153532. */
  153533. frames: Array<ISpriteJSONSprite>;
  153534. /**
  153535. * object basic object containing the sprite meta data.
  153536. */
  153537. meta?: object;
  153538. }
  153539. }
  153540. declare module BABYLON {
  153541. /** @hidden */
  153542. export var spriteMapPixelShader: {
  153543. name: string;
  153544. shader: string;
  153545. };
  153546. }
  153547. declare module BABYLON {
  153548. /** @hidden */
  153549. export var spriteMapVertexShader: {
  153550. name: string;
  153551. shader: string;
  153552. };
  153553. }
  153554. declare module BABYLON {
  153555. /**
  153556. * Defines the basic options interface of a SpriteMap
  153557. */
  153558. export interface ISpriteMapOptions {
  153559. /**
  153560. * Vector2 of the number of cells in the grid.
  153561. */
  153562. stageSize?: Vector2;
  153563. /**
  153564. * Vector2 of the size of the output plane in World Units.
  153565. */
  153566. outputSize?: Vector2;
  153567. /**
  153568. * Vector3 of the position of the output plane in World Units.
  153569. */
  153570. outputPosition?: Vector3;
  153571. /**
  153572. * Vector3 of the rotation of the output plane.
  153573. */
  153574. outputRotation?: Vector3;
  153575. /**
  153576. * number of layers that the system will reserve in resources.
  153577. */
  153578. layerCount?: number;
  153579. /**
  153580. * number of max animation frames a single cell will reserve in resources.
  153581. */
  153582. maxAnimationFrames?: number;
  153583. /**
  153584. * number cell index of the base tile when the system compiles.
  153585. */
  153586. baseTile?: number;
  153587. /**
  153588. * boolean flip the sprite after its been repositioned by the framing data.
  153589. */
  153590. flipU?: boolean;
  153591. /**
  153592. * Vector3 scalar of the global RGB values of the SpriteMap.
  153593. */
  153594. colorMultiply?: Vector3;
  153595. }
  153596. /**
  153597. * Defines the IDisposable interface in order to be cleanable from resources.
  153598. */
  153599. export interface ISpriteMap extends IDisposable {
  153600. /**
  153601. * String name of the SpriteMap.
  153602. */
  153603. name: string;
  153604. /**
  153605. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153606. */
  153607. atlasJSON: ISpriteJSONAtlas;
  153608. /**
  153609. * Texture of the SpriteMap.
  153610. */
  153611. spriteSheet: Texture;
  153612. /**
  153613. * The parameters to initialize the SpriteMap with.
  153614. */
  153615. options: ISpriteMapOptions;
  153616. }
  153617. /**
  153618. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153619. */
  153620. export class SpriteMap implements ISpriteMap {
  153621. /** The Name of the spriteMap */
  153622. name: string;
  153623. /** The JSON file with the frame and meta data */
  153624. atlasJSON: ISpriteJSONAtlas;
  153625. /** The systems Sprite Sheet Texture */
  153626. spriteSheet: Texture;
  153627. /** Arguments passed with the Constructor */
  153628. options: ISpriteMapOptions;
  153629. /** Public Sprite Storage array, parsed from atlasJSON */
  153630. sprites: Array<ISpriteJSONSprite>;
  153631. /** Returns the Number of Sprites in the System */
  153632. get spriteCount(): number;
  153633. /** Returns the Position of Output Plane*/
  153634. get position(): Vector3;
  153635. /** Returns the Position of Output Plane*/
  153636. set position(v: Vector3);
  153637. /** Returns the Rotation of Output Plane*/
  153638. get rotation(): Vector3;
  153639. /** Returns the Rotation of Output Plane*/
  153640. set rotation(v: Vector3);
  153641. /** Sets the AnimationMap*/
  153642. get animationMap(): RawTexture;
  153643. /** Sets the AnimationMap*/
  153644. set animationMap(v: RawTexture);
  153645. /** Scene that the SpriteMap was created in */
  153646. private _scene;
  153647. /** Texture Buffer of Float32 that holds tile frame data*/
  153648. private _frameMap;
  153649. /** Texture Buffers of Float32 that holds tileMap data*/
  153650. private _tileMaps;
  153651. /** Texture Buffer of Float32 that holds Animation Data*/
  153652. private _animationMap;
  153653. /** Custom ShaderMaterial Central to the System*/
  153654. private _material;
  153655. /** Custom ShaderMaterial Central to the System*/
  153656. private _output;
  153657. /** Systems Time Ticker*/
  153658. private _time;
  153659. /**
  153660. * Creates a new SpriteMap
  153661. * @param name defines the SpriteMaps Name
  153662. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153663. * @param spriteSheet is the Texture that the Sprites are on.
  153664. * @param options a basic deployment configuration
  153665. * @param scene The Scene that the map is deployed on
  153666. */
  153667. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153668. /**
  153669. * Returns tileID location
  153670. * @returns Vector2 the cell position ID
  153671. */
  153672. getTileID(): Vector2;
  153673. /**
  153674. * Gets the UV location of the mouse over the SpriteMap.
  153675. * @returns Vector2 the UV position of the mouse interaction
  153676. */
  153677. getMousePosition(): Vector2;
  153678. /**
  153679. * Creates the "frame" texture Buffer
  153680. * -------------------------------------
  153681. * Structure of frames
  153682. * "filename": "Falling-Water-2.png",
  153683. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153684. * "rotated": true,
  153685. * "trimmed": true,
  153686. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153687. * "sourceSize": {"w":32,"h":32}
  153688. * @returns RawTexture of the frameMap
  153689. */
  153690. private _createFrameBuffer;
  153691. /**
  153692. * Creates the tileMap texture Buffer
  153693. * @param buffer normally and array of numbers, or a false to generate from scratch
  153694. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153695. * @returns RawTexture of the tileMap
  153696. */
  153697. private _createTileBuffer;
  153698. /**
  153699. * Modifies the data of the tileMaps
  153700. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153701. * @param pos is the iVector2 Coordinates of the Tile
  153702. * @param tile The SpriteIndex of the new Tile
  153703. */
  153704. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153705. /**
  153706. * Creates the animationMap texture Buffer
  153707. * @param buffer normally and array of numbers, or a false to generate from scratch
  153708. * @returns RawTexture of the animationMap
  153709. */
  153710. private _createTileAnimationBuffer;
  153711. /**
  153712. * Modifies the data of the animationMap
  153713. * @param cellID is the Index of the Sprite
  153714. * @param _frame is the target Animation frame
  153715. * @param toCell is the Target Index of the next frame of the animation
  153716. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153717. * @param speed is a global scalar of the time variable on the map.
  153718. */
  153719. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153720. /**
  153721. * Exports the .tilemaps file
  153722. */
  153723. saveTileMaps(): void;
  153724. /**
  153725. * Imports the .tilemaps file
  153726. * @param url of the .tilemaps file
  153727. */
  153728. loadTileMaps(url: string): void;
  153729. /**
  153730. * Release associated resources
  153731. */
  153732. dispose(): void;
  153733. }
  153734. }
  153735. declare module BABYLON {
  153736. /**
  153737. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153738. * @see https://doc.babylonjs.com/babylon101/sprites
  153739. */
  153740. export class SpritePackedManager extends SpriteManager {
  153741. /** defines the packed manager's name */
  153742. name: string;
  153743. /**
  153744. * Creates a new sprite manager from a packed sprite sheet
  153745. * @param name defines the manager's name
  153746. * @param imgUrl defines the sprite sheet url
  153747. * @param capacity defines the maximum allowed number of sprites
  153748. * @param scene defines the hosting scene
  153749. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153750. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153751. * @param samplingMode defines the smapling mode to use with spritesheet
  153752. * @param fromPacked set to true; do not alter
  153753. */
  153754. constructor(
  153755. /** defines the packed manager's name */
  153756. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153757. }
  153758. }
  153759. declare module BABYLON {
  153760. /**
  153761. * Defines the list of states available for a task inside a AssetsManager
  153762. */
  153763. export enum AssetTaskState {
  153764. /**
  153765. * Initialization
  153766. */
  153767. INIT = 0,
  153768. /**
  153769. * Running
  153770. */
  153771. RUNNING = 1,
  153772. /**
  153773. * Done
  153774. */
  153775. DONE = 2,
  153776. /**
  153777. * Error
  153778. */
  153779. ERROR = 3
  153780. }
  153781. /**
  153782. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153783. */
  153784. export abstract class AbstractAssetTask {
  153785. /**
  153786. * Task name
  153787. */ name: string;
  153788. /**
  153789. * Callback called when the task is successful
  153790. */
  153791. onSuccess: (task: any) => void;
  153792. /**
  153793. * Callback called when the task is not successful
  153794. */
  153795. onError: (task: any, message?: string, exception?: any) => void;
  153796. /**
  153797. * Creates a new AssetsManager
  153798. * @param name defines the name of the task
  153799. */
  153800. constructor(
  153801. /**
  153802. * Task name
  153803. */ name: string);
  153804. private _isCompleted;
  153805. private _taskState;
  153806. private _errorObject;
  153807. /**
  153808. * Get if the task is completed
  153809. */
  153810. get isCompleted(): boolean;
  153811. /**
  153812. * Gets the current state of the task
  153813. */
  153814. get taskState(): AssetTaskState;
  153815. /**
  153816. * Gets the current error object (if task is in error)
  153817. */
  153818. get errorObject(): {
  153819. message?: string;
  153820. exception?: any;
  153821. };
  153822. /**
  153823. * Internal only
  153824. * @hidden
  153825. */
  153826. _setErrorObject(message?: string, exception?: any): void;
  153827. /**
  153828. * Execute the current task
  153829. * @param scene defines the scene where you want your assets to be loaded
  153830. * @param onSuccess is a callback called when the task is successfully executed
  153831. * @param onError is a callback called if an error occurs
  153832. */
  153833. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153834. /**
  153835. * Execute the current task
  153836. * @param scene defines the scene where you want your assets to be loaded
  153837. * @param onSuccess is a callback called when the task is successfully executed
  153838. * @param onError is a callback called if an error occurs
  153839. */
  153840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153841. /**
  153842. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153843. * This can be used with failed tasks that have the reason for failure fixed.
  153844. */
  153845. reset(): void;
  153846. private onErrorCallback;
  153847. private onDoneCallback;
  153848. }
  153849. /**
  153850. * Define the interface used by progress events raised during assets loading
  153851. */
  153852. export interface IAssetsProgressEvent {
  153853. /**
  153854. * Defines the number of remaining tasks to process
  153855. */
  153856. remainingCount: number;
  153857. /**
  153858. * Defines the total number of tasks
  153859. */
  153860. totalCount: number;
  153861. /**
  153862. * Defines the task that was just processed
  153863. */
  153864. task: AbstractAssetTask;
  153865. }
  153866. /**
  153867. * Class used to share progress information about assets loading
  153868. */
  153869. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153870. /**
  153871. * Defines the number of remaining tasks to process
  153872. */
  153873. remainingCount: number;
  153874. /**
  153875. * Defines the total number of tasks
  153876. */
  153877. totalCount: number;
  153878. /**
  153879. * Defines the task that was just processed
  153880. */
  153881. task: AbstractAssetTask;
  153882. /**
  153883. * Creates a AssetsProgressEvent
  153884. * @param remainingCount defines the number of remaining tasks to process
  153885. * @param totalCount defines the total number of tasks
  153886. * @param task defines the task that was just processed
  153887. */
  153888. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153889. }
  153890. /**
  153891. * Define a task used by AssetsManager to load assets into a container
  153892. */
  153893. export class ContainerAssetTask extends AbstractAssetTask {
  153894. /**
  153895. * Defines the name of the task
  153896. */
  153897. name: string;
  153898. /**
  153899. * Defines the list of mesh's names you want to load
  153900. */
  153901. meshesNames: any;
  153902. /**
  153903. * Defines the root url to use as a base to load your meshes and associated resources
  153904. */
  153905. rootUrl: string;
  153906. /**
  153907. * Defines the filename or File of the scene to load from
  153908. */
  153909. sceneFilename: string | File;
  153910. /**
  153911. * Get the loaded asset container
  153912. */
  153913. loadedContainer: AssetContainer;
  153914. /**
  153915. * Gets the list of loaded meshes
  153916. */
  153917. loadedMeshes: Array<AbstractMesh>;
  153918. /**
  153919. * Gets the list of loaded particle systems
  153920. */
  153921. loadedParticleSystems: Array<IParticleSystem>;
  153922. /**
  153923. * Gets the list of loaded skeletons
  153924. */
  153925. loadedSkeletons: Array<Skeleton>;
  153926. /**
  153927. * Gets the list of loaded animation groups
  153928. */
  153929. loadedAnimationGroups: Array<AnimationGroup>;
  153930. /**
  153931. * Callback called when the task is successful
  153932. */
  153933. onSuccess: (task: ContainerAssetTask) => void;
  153934. /**
  153935. * Callback called when the task is successful
  153936. */
  153937. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153938. /**
  153939. * Creates a new ContainerAssetTask
  153940. * @param name defines the name of the task
  153941. * @param meshesNames defines the list of mesh's names you want to load
  153942. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153943. * @param sceneFilename defines the filename or File of the scene to load from
  153944. */
  153945. constructor(
  153946. /**
  153947. * Defines the name of the task
  153948. */
  153949. name: string,
  153950. /**
  153951. * Defines the list of mesh's names you want to load
  153952. */
  153953. meshesNames: any,
  153954. /**
  153955. * Defines the root url to use as a base to load your meshes and associated resources
  153956. */
  153957. rootUrl: string,
  153958. /**
  153959. * Defines the filename or File of the scene to load from
  153960. */
  153961. sceneFilename: string | File);
  153962. /**
  153963. * Execute the current task
  153964. * @param scene defines the scene where you want your assets to be loaded
  153965. * @param onSuccess is a callback called when the task is successfully executed
  153966. * @param onError is a callback called if an error occurs
  153967. */
  153968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153969. }
  153970. /**
  153971. * Define a task used by AssetsManager to load meshes
  153972. */
  153973. export class MeshAssetTask extends AbstractAssetTask {
  153974. /**
  153975. * Defines the name of the task
  153976. */
  153977. name: string;
  153978. /**
  153979. * Defines the list of mesh's names you want to load
  153980. */
  153981. meshesNames: any;
  153982. /**
  153983. * Defines the root url to use as a base to load your meshes and associated resources
  153984. */
  153985. rootUrl: string;
  153986. /**
  153987. * Defines the filename or File of the scene to load from
  153988. */
  153989. sceneFilename: string | File;
  153990. /**
  153991. * Gets the list of loaded meshes
  153992. */
  153993. loadedMeshes: Array<AbstractMesh>;
  153994. /**
  153995. * Gets the list of loaded particle systems
  153996. */
  153997. loadedParticleSystems: Array<IParticleSystem>;
  153998. /**
  153999. * Gets the list of loaded skeletons
  154000. */
  154001. loadedSkeletons: Array<Skeleton>;
  154002. /**
  154003. * Gets the list of loaded animation groups
  154004. */
  154005. loadedAnimationGroups: Array<AnimationGroup>;
  154006. /**
  154007. * Callback called when the task is successful
  154008. */
  154009. onSuccess: (task: MeshAssetTask) => void;
  154010. /**
  154011. * Callback called when the task is successful
  154012. */
  154013. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154014. /**
  154015. * Creates a new MeshAssetTask
  154016. * @param name defines the name of the task
  154017. * @param meshesNames defines the list of mesh's names you want to load
  154018. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154019. * @param sceneFilename defines the filename or File of the scene to load from
  154020. */
  154021. constructor(
  154022. /**
  154023. * Defines the name of the task
  154024. */
  154025. name: string,
  154026. /**
  154027. * Defines the list of mesh's names you want to load
  154028. */
  154029. meshesNames: any,
  154030. /**
  154031. * Defines the root url to use as a base to load your meshes and associated resources
  154032. */
  154033. rootUrl: string,
  154034. /**
  154035. * Defines the filename or File of the scene to load from
  154036. */
  154037. sceneFilename: string | File);
  154038. /**
  154039. * Execute the current task
  154040. * @param scene defines the scene where you want your assets to be loaded
  154041. * @param onSuccess is a callback called when the task is successfully executed
  154042. * @param onError is a callback called if an error occurs
  154043. */
  154044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154045. }
  154046. /**
  154047. * Define a task used by AssetsManager to load text content
  154048. */
  154049. export class TextFileAssetTask extends AbstractAssetTask {
  154050. /**
  154051. * Defines the name of the task
  154052. */
  154053. name: string;
  154054. /**
  154055. * Defines the location of the file to load
  154056. */
  154057. url: string;
  154058. /**
  154059. * Gets the loaded text string
  154060. */
  154061. text: string;
  154062. /**
  154063. * Callback called when the task is successful
  154064. */
  154065. onSuccess: (task: TextFileAssetTask) => void;
  154066. /**
  154067. * Callback called when the task is successful
  154068. */
  154069. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154070. /**
  154071. * Creates a new TextFileAssetTask object
  154072. * @param name defines the name of the task
  154073. * @param url defines the location of the file to load
  154074. */
  154075. constructor(
  154076. /**
  154077. * Defines the name of the task
  154078. */
  154079. name: string,
  154080. /**
  154081. * Defines the location of the file to load
  154082. */
  154083. url: string);
  154084. /**
  154085. * Execute the current task
  154086. * @param scene defines the scene where you want your assets to be loaded
  154087. * @param onSuccess is a callback called when the task is successfully executed
  154088. * @param onError is a callback called if an error occurs
  154089. */
  154090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154091. }
  154092. /**
  154093. * Define a task used by AssetsManager to load binary data
  154094. */
  154095. export class BinaryFileAssetTask extends AbstractAssetTask {
  154096. /**
  154097. * Defines the name of the task
  154098. */
  154099. name: string;
  154100. /**
  154101. * Defines the location of the file to load
  154102. */
  154103. url: string;
  154104. /**
  154105. * Gets the lodaded data (as an array buffer)
  154106. */
  154107. data: ArrayBuffer;
  154108. /**
  154109. * Callback called when the task is successful
  154110. */
  154111. onSuccess: (task: BinaryFileAssetTask) => void;
  154112. /**
  154113. * Callback called when the task is successful
  154114. */
  154115. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154116. /**
  154117. * Creates a new BinaryFileAssetTask object
  154118. * @param name defines the name of the new task
  154119. * @param url defines the location of the file to load
  154120. */
  154121. constructor(
  154122. /**
  154123. * Defines the name of the task
  154124. */
  154125. name: string,
  154126. /**
  154127. * Defines the location of the file to load
  154128. */
  154129. url: string);
  154130. /**
  154131. * Execute the current task
  154132. * @param scene defines the scene where you want your assets to be loaded
  154133. * @param onSuccess is a callback called when the task is successfully executed
  154134. * @param onError is a callback called if an error occurs
  154135. */
  154136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154137. }
  154138. /**
  154139. * Define a task used by AssetsManager to load images
  154140. */
  154141. export class ImageAssetTask extends AbstractAssetTask {
  154142. /**
  154143. * Defines the name of the task
  154144. */
  154145. name: string;
  154146. /**
  154147. * Defines the location of the image to load
  154148. */
  154149. url: string;
  154150. /**
  154151. * Gets the loaded images
  154152. */
  154153. image: HTMLImageElement;
  154154. /**
  154155. * Callback called when the task is successful
  154156. */
  154157. onSuccess: (task: ImageAssetTask) => void;
  154158. /**
  154159. * Callback called when the task is successful
  154160. */
  154161. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154162. /**
  154163. * Creates a new ImageAssetTask
  154164. * @param name defines the name of the task
  154165. * @param url defines the location of the image to load
  154166. */
  154167. constructor(
  154168. /**
  154169. * Defines the name of the task
  154170. */
  154171. name: string,
  154172. /**
  154173. * Defines the location of the image to load
  154174. */
  154175. url: string);
  154176. /**
  154177. * Execute the current task
  154178. * @param scene defines the scene where you want your assets to be loaded
  154179. * @param onSuccess is a callback called when the task is successfully executed
  154180. * @param onError is a callback called if an error occurs
  154181. */
  154182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154183. }
  154184. /**
  154185. * Defines the interface used by texture loading tasks
  154186. */
  154187. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154188. /**
  154189. * Gets the loaded texture
  154190. */
  154191. texture: TEX;
  154192. }
  154193. /**
  154194. * Define a task used by AssetsManager to load 2D textures
  154195. */
  154196. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154197. /**
  154198. * Defines the name of the task
  154199. */
  154200. name: string;
  154201. /**
  154202. * Defines the location of the file to load
  154203. */
  154204. url: string;
  154205. /**
  154206. * Defines if mipmap should not be generated (default is false)
  154207. */
  154208. noMipmap?: boolean | undefined;
  154209. /**
  154210. * Defines if texture must be inverted on Y axis (default is true)
  154211. */
  154212. invertY: boolean;
  154213. /**
  154214. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154215. */
  154216. samplingMode: number;
  154217. /**
  154218. * Gets the loaded texture
  154219. */
  154220. texture: Texture;
  154221. /**
  154222. * Callback called when the task is successful
  154223. */
  154224. onSuccess: (task: TextureAssetTask) => void;
  154225. /**
  154226. * Callback called when the task is successful
  154227. */
  154228. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154229. /**
  154230. * Creates a new TextureAssetTask object
  154231. * @param name defines the name of the task
  154232. * @param url defines the location of the file to load
  154233. * @param noMipmap defines if mipmap should not be generated (default is false)
  154234. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154235. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154236. */
  154237. constructor(
  154238. /**
  154239. * Defines the name of the task
  154240. */
  154241. name: string,
  154242. /**
  154243. * Defines the location of the file to load
  154244. */
  154245. url: string,
  154246. /**
  154247. * Defines if mipmap should not be generated (default is false)
  154248. */
  154249. noMipmap?: boolean | undefined,
  154250. /**
  154251. * Defines if texture must be inverted on Y axis (default is true)
  154252. */
  154253. invertY?: boolean,
  154254. /**
  154255. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154256. */
  154257. samplingMode?: number);
  154258. /**
  154259. * Execute the current task
  154260. * @param scene defines the scene where you want your assets to be loaded
  154261. * @param onSuccess is a callback called when the task is successfully executed
  154262. * @param onError is a callback called if an error occurs
  154263. */
  154264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154265. }
  154266. /**
  154267. * Define a task used by AssetsManager to load cube textures
  154268. */
  154269. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154270. /**
  154271. * Defines the name of the task
  154272. */
  154273. name: string;
  154274. /**
  154275. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154276. */
  154277. url: string;
  154278. /**
  154279. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154280. */
  154281. extensions?: string[] | undefined;
  154282. /**
  154283. * Defines if mipmaps should not be generated (default is false)
  154284. */
  154285. noMipmap?: boolean | undefined;
  154286. /**
  154287. * Defines the explicit list of files (undefined by default)
  154288. */
  154289. files?: string[] | undefined;
  154290. /**
  154291. * Gets the loaded texture
  154292. */
  154293. texture: CubeTexture;
  154294. /**
  154295. * Callback called when the task is successful
  154296. */
  154297. onSuccess: (task: CubeTextureAssetTask) => void;
  154298. /**
  154299. * Callback called when the task is successful
  154300. */
  154301. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154302. /**
  154303. * Creates a new CubeTextureAssetTask
  154304. * @param name defines the name of the task
  154305. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154306. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154308. * @param files defines the explicit list of files (undefined by default)
  154309. */
  154310. constructor(
  154311. /**
  154312. * Defines the name of the task
  154313. */
  154314. name: string,
  154315. /**
  154316. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154317. */
  154318. url: string,
  154319. /**
  154320. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154321. */
  154322. extensions?: string[] | undefined,
  154323. /**
  154324. * Defines if mipmaps should not be generated (default is false)
  154325. */
  154326. noMipmap?: boolean | undefined,
  154327. /**
  154328. * Defines the explicit list of files (undefined by default)
  154329. */
  154330. files?: string[] | undefined);
  154331. /**
  154332. * Execute the current task
  154333. * @param scene defines the scene where you want your assets to be loaded
  154334. * @param onSuccess is a callback called when the task is successfully executed
  154335. * @param onError is a callback called if an error occurs
  154336. */
  154337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154338. }
  154339. /**
  154340. * Define a task used by AssetsManager to load HDR cube textures
  154341. */
  154342. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154343. /**
  154344. * Defines the name of the task
  154345. */
  154346. name: string;
  154347. /**
  154348. * Defines the location of the file to load
  154349. */
  154350. url: string;
  154351. /**
  154352. * Defines the desired size (the more it increases the longer the generation will be)
  154353. */
  154354. size: number;
  154355. /**
  154356. * Defines if mipmaps should not be generated (default is false)
  154357. */
  154358. noMipmap: boolean;
  154359. /**
  154360. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154361. */
  154362. generateHarmonics: boolean;
  154363. /**
  154364. * 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)
  154365. */
  154366. gammaSpace: boolean;
  154367. /**
  154368. * Internal Use Only
  154369. */
  154370. reserved: boolean;
  154371. /**
  154372. * Gets the loaded texture
  154373. */
  154374. texture: HDRCubeTexture;
  154375. /**
  154376. * Callback called when the task is successful
  154377. */
  154378. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154379. /**
  154380. * Callback called when the task is successful
  154381. */
  154382. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154383. /**
  154384. * Creates a new HDRCubeTextureAssetTask object
  154385. * @param name defines the name of the task
  154386. * @param url defines the location of the file to load
  154387. * @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.
  154388. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154389. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154390. * @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)
  154391. * @param reserved Internal use only
  154392. */
  154393. constructor(
  154394. /**
  154395. * Defines the name of the task
  154396. */
  154397. name: string,
  154398. /**
  154399. * Defines the location of the file to load
  154400. */
  154401. url: string,
  154402. /**
  154403. * Defines the desired size (the more it increases the longer the generation will be)
  154404. */
  154405. size: number,
  154406. /**
  154407. * Defines if mipmaps should not be generated (default is false)
  154408. */
  154409. noMipmap?: boolean,
  154410. /**
  154411. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154412. */
  154413. generateHarmonics?: boolean,
  154414. /**
  154415. * 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)
  154416. */
  154417. gammaSpace?: boolean,
  154418. /**
  154419. * Internal Use Only
  154420. */
  154421. reserved?: boolean);
  154422. /**
  154423. * Execute the current task
  154424. * @param scene defines the scene where you want your assets to be loaded
  154425. * @param onSuccess is a callback called when the task is successfully executed
  154426. * @param onError is a callback called if an error occurs
  154427. */
  154428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154429. }
  154430. /**
  154431. * Define a task used by AssetsManager to load Equirectangular cube textures
  154432. */
  154433. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154434. /**
  154435. * Defines the name of the task
  154436. */
  154437. name: string;
  154438. /**
  154439. * Defines the location of the file to load
  154440. */
  154441. url: string;
  154442. /**
  154443. * Defines the desired size (the more it increases the longer the generation will be)
  154444. */
  154445. size: number;
  154446. /**
  154447. * Defines if mipmaps should not be generated (default is false)
  154448. */
  154449. noMipmap: boolean;
  154450. /**
  154451. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154452. * but the standard material would require them in Gamma space) (default is true)
  154453. */
  154454. gammaSpace: boolean;
  154455. /**
  154456. * Gets the loaded texture
  154457. */
  154458. texture: EquiRectangularCubeTexture;
  154459. /**
  154460. * Callback called when the task is successful
  154461. */
  154462. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154463. /**
  154464. * Callback called when the task is successful
  154465. */
  154466. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154467. /**
  154468. * Creates a new EquiRectangularCubeTextureAssetTask object
  154469. * @param name defines the name of the task
  154470. * @param url defines the location of the file to load
  154471. * @param size defines the desired size (the more it increases the longer the generation will be)
  154472. * If the size is omitted this implies you are using a preprocessed cubemap.
  154473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154474. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154475. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154476. * (default is true)
  154477. */
  154478. constructor(
  154479. /**
  154480. * Defines the name of the task
  154481. */
  154482. name: string,
  154483. /**
  154484. * Defines the location of the file to load
  154485. */
  154486. url: string,
  154487. /**
  154488. * Defines the desired size (the more it increases the longer the generation will be)
  154489. */
  154490. size: number,
  154491. /**
  154492. * Defines if mipmaps should not be generated (default is false)
  154493. */
  154494. noMipmap?: boolean,
  154495. /**
  154496. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154497. * but the standard material would require them in Gamma space) (default is true)
  154498. */
  154499. gammaSpace?: boolean);
  154500. /**
  154501. * Execute the current task
  154502. * @param scene defines the scene where you want your assets to be loaded
  154503. * @param onSuccess is a callback called when the task is successfully executed
  154504. * @param onError is a callback called if an error occurs
  154505. */
  154506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154507. }
  154508. /**
  154509. * This class can be used to easily import assets into a scene
  154510. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154511. */
  154512. export class AssetsManager {
  154513. private _scene;
  154514. private _isLoading;
  154515. protected _tasks: AbstractAssetTask[];
  154516. protected _waitingTasksCount: number;
  154517. protected _totalTasksCount: number;
  154518. /**
  154519. * Callback called when all tasks are processed
  154520. */
  154521. onFinish: (tasks: AbstractAssetTask[]) => void;
  154522. /**
  154523. * Callback called when a task is successful
  154524. */
  154525. onTaskSuccess: (task: AbstractAssetTask) => void;
  154526. /**
  154527. * Callback called when a task had an error
  154528. */
  154529. onTaskError: (task: AbstractAssetTask) => void;
  154530. /**
  154531. * Callback called when a task is done (whatever the result is)
  154532. */
  154533. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154534. /**
  154535. * Observable called when all tasks are processed
  154536. */
  154537. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154538. /**
  154539. * Observable called when a task had an error
  154540. */
  154541. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154542. /**
  154543. * Observable called when all tasks were executed
  154544. */
  154545. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154546. /**
  154547. * Observable called when a task is done (whatever the result is)
  154548. */
  154549. onProgressObservable: Observable<IAssetsProgressEvent>;
  154550. /**
  154551. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154552. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154553. */
  154554. useDefaultLoadingScreen: boolean;
  154555. /**
  154556. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154557. * when all assets have been downloaded.
  154558. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154559. */
  154560. autoHideLoadingUI: boolean;
  154561. /**
  154562. * Creates a new AssetsManager
  154563. * @param scene defines the scene to work on
  154564. */
  154565. constructor(scene: Scene);
  154566. /**
  154567. * Add a ContainerAssetTask to the list of active tasks
  154568. * @param taskName defines the name of the new task
  154569. * @param meshesNames defines the name of meshes to load
  154570. * @param rootUrl defines the root url to use to locate files
  154571. * @param sceneFilename defines the filename of the scene file
  154572. * @returns a new ContainerAssetTask object
  154573. */
  154574. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154575. /**
  154576. * Add a MeshAssetTask to the list of active tasks
  154577. * @param taskName defines the name of the new task
  154578. * @param meshesNames defines the name of meshes to load
  154579. * @param rootUrl defines the root url to use to locate files
  154580. * @param sceneFilename defines the filename of the scene file
  154581. * @returns a new MeshAssetTask object
  154582. */
  154583. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154584. /**
  154585. * Add a TextFileAssetTask to the list of active tasks
  154586. * @param taskName defines the name of the new task
  154587. * @param url defines the url of the file to load
  154588. * @returns a new TextFileAssetTask object
  154589. */
  154590. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154591. /**
  154592. * Add a BinaryFileAssetTask to the list of active tasks
  154593. * @param taskName defines the name of the new task
  154594. * @param url defines the url of the file to load
  154595. * @returns a new BinaryFileAssetTask object
  154596. */
  154597. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154598. /**
  154599. * Add a ImageAssetTask to the list of active tasks
  154600. * @param taskName defines the name of the new task
  154601. * @param url defines the url of the file to load
  154602. * @returns a new ImageAssetTask object
  154603. */
  154604. addImageTask(taskName: string, url: string): ImageAssetTask;
  154605. /**
  154606. * Add a TextureAssetTask to the list of active tasks
  154607. * @param taskName defines the name of the new task
  154608. * @param url defines the url of the file to load
  154609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154610. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154611. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154612. * @returns a new TextureAssetTask object
  154613. */
  154614. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154615. /**
  154616. * Add a CubeTextureAssetTask to the list of active tasks
  154617. * @param taskName defines the name of the new task
  154618. * @param url defines the url of the file to load
  154619. * @param extensions defines the extension to use to load the cube map (can be null)
  154620. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154621. * @param files defines the list of files to load (can be null)
  154622. * @returns a new CubeTextureAssetTask object
  154623. */
  154624. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154625. /**
  154626. *
  154627. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154628. * @param taskName defines the name of the new task
  154629. * @param url defines the url of the file to load
  154630. * @param size defines the size you want for the cubemap (can be null)
  154631. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154632. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154633. * @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)
  154634. * @param reserved Internal use only
  154635. * @returns a new HDRCubeTextureAssetTask object
  154636. */
  154637. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154638. /**
  154639. *
  154640. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154641. * @param taskName defines the name of the new task
  154642. * @param url defines the url of the file to load
  154643. * @param size defines the size you want for the cubemap (can be null)
  154644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154645. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154646. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154647. * @returns a new EquiRectangularCubeTextureAssetTask object
  154648. */
  154649. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154650. /**
  154651. * Remove a task from the assets manager.
  154652. * @param task the task to remove
  154653. */
  154654. removeTask(task: AbstractAssetTask): void;
  154655. private _decreaseWaitingTasksCount;
  154656. private _runTask;
  154657. /**
  154658. * Reset the AssetsManager and remove all tasks
  154659. * @return the current instance of the AssetsManager
  154660. */
  154661. reset(): AssetsManager;
  154662. /**
  154663. * Start the loading process
  154664. * @return the current instance of the AssetsManager
  154665. */
  154666. load(): AssetsManager;
  154667. /**
  154668. * Start the loading process as an async operation
  154669. * @return a promise returning the list of failed tasks
  154670. */
  154671. loadAsync(): Promise<void>;
  154672. }
  154673. }
  154674. declare module BABYLON {
  154675. /**
  154676. * Wrapper class for promise with external resolve and reject.
  154677. */
  154678. export class Deferred<T> {
  154679. /**
  154680. * The promise associated with this deferred object.
  154681. */
  154682. readonly promise: Promise<T>;
  154683. private _resolve;
  154684. private _reject;
  154685. /**
  154686. * The resolve method of the promise associated with this deferred object.
  154687. */
  154688. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154689. /**
  154690. * The reject method of the promise associated with this deferred object.
  154691. */
  154692. get reject(): (reason?: any) => void;
  154693. /**
  154694. * Constructor for this deferred object.
  154695. */
  154696. constructor();
  154697. }
  154698. }
  154699. declare module BABYLON {
  154700. /**
  154701. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154702. */
  154703. export class MeshExploder {
  154704. private _centerMesh;
  154705. private _meshes;
  154706. private _meshesOrigins;
  154707. private _toCenterVectors;
  154708. private _scaledDirection;
  154709. private _newPosition;
  154710. private _centerPosition;
  154711. /**
  154712. * Explodes meshes from a center mesh.
  154713. * @param meshes The meshes to explode.
  154714. * @param centerMesh The mesh to be center of explosion.
  154715. */
  154716. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154717. private _setCenterMesh;
  154718. /**
  154719. * Get class name
  154720. * @returns "MeshExploder"
  154721. */
  154722. getClassName(): string;
  154723. /**
  154724. * "Exploded meshes"
  154725. * @returns Array of meshes with the centerMesh at index 0.
  154726. */
  154727. getMeshes(): Array<Mesh>;
  154728. /**
  154729. * Explodes meshes giving a specific direction
  154730. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154731. */
  154732. explode(direction?: number): void;
  154733. }
  154734. }
  154735. declare module BABYLON {
  154736. /**
  154737. * Class used to help managing file picking and drag'n'drop
  154738. */
  154739. export class FilesInput {
  154740. /**
  154741. * List of files ready to be loaded
  154742. */
  154743. static get FilesToLoad(): {
  154744. [key: string]: File;
  154745. };
  154746. /**
  154747. * Callback called when a file is processed
  154748. */
  154749. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154750. private _engine;
  154751. private _currentScene;
  154752. private _sceneLoadedCallback;
  154753. private _progressCallback;
  154754. private _additionalRenderLoopLogicCallback;
  154755. private _textureLoadingCallback;
  154756. private _startingProcessingFilesCallback;
  154757. private _onReloadCallback;
  154758. private _errorCallback;
  154759. private _elementToMonitor;
  154760. private _sceneFileToLoad;
  154761. private _filesToLoad;
  154762. /**
  154763. * Creates a new FilesInput
  154764. * @param engine defines the rendering engine
  154765. * @param scene defines the hosting scene
  154766. * @param sceneLoadedCallback callback called when scene is loaded
  154767. * @param progressCallback callback called to track progress
  154768. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154769. * @param textureLoadingCallback callback called when a texture is loading
  154770. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154771. * @param onReloadCallback callback called when a reload is requested
  154772. * @param errorCallback callback call if an error occurs
  154773. */
  154774. 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>);
  154775. private _dragEnterHandler;
  154776. private _dragOverHandler;
  154777. private _dropHandler;
  154778. /**
  154779. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154780. * @param elementToMonitor defines the DOM element to track
  154781. */
  154782. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154783. /** Gets the current list of files to load */
  154784. get filesToLoad(): File[];
  154785. /**
  154786. * Release all associated resources
  154787. */
  154788. dispose(): void;
  154789. private renderFunction;
  154790. private drag;
  154791. private drop;
  154792. private _traverseFolder;
  154793. private _processFiles;
  154794. /**
  154795. * Load files from a drop event
  154796. * @param event defines the drop event to use as source
  154797. */
  154798. loadFiles(event: any): void;
  154799. private _processReload;
  154800. /**
  154801. * Reload the current scene from the loaded files
  154802. */
  154803. reload(): void;
  154804. }
  154805. }
  154806. declare module BABYLON {
  154807. /**
  154808. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154810. */
  154811. export class SceneOptimization {
  154812. /**
  154813. * Defines the priority of this optimization (0 by default which means first in the list)
  154814. */
  154815. priority: number;
  154816. /**
  154817. * Gets a string describing the action executed by the current optimization
  154818. * @returns description string
  154819. */
  154820. getDescription(): string;
  154821. /**
  154822. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154823. * @param scene defines the current scene where to apply this optimization
  154824. * @param optimizer defines the current optimizer
  154825. * @returns true if everything that can be done was applied
  154826. */
  154827. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154828. /**
  154829. * Creates the SceneOptimization object
  154830. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154831. * @param desc defines the description associated with the optimization
  154832. */
  154833. constructor(
  154834. /**
  154835. * Defines the priority of this optimization (0 by default which means first in the list)
  154836. */
  154837. priority?: number);
  154838. }
  154839. /**
  154840. * Defines an optimization used to reduce the size of render target textures
  154841. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154842. */
  154843. export class TextureOptimization extends SceneOptimization {
  154844. /**
  154845. * Defines the priority of this optimization (0 by default which means first in the list)
  154846. */
  154847. priority: number;
  154848. /**
  154849. * 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
  154850. */
  154851. maximumSize: number;
  154852. /**
  154853. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154854. */
  154855. step: number;
  154856. /**
  154857. * Gets a string describing the action executed by the current optimization
  154858. * @returns description string
  154859. */
  154860. getDescription(): string;
  154861. /**
  154862. * Creates the TextureOptimization object
  154863. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154864. * @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
  154865. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154866. */
  154867. constructor(
  154868. /**
  154869. * Defines the priority of this optimization (0 by default which means first in the list)
  154870. */
  154871. priority?: number,
  154872. /**
  154873. * 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
  154874. */
  154875. maximumSize?: number,
  154876. /**
  154877. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154878. */
  154879. step?: number);
  154880. /**
  154881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154882. * @param scene defines the current scene where to apply this optimization
  154883. * @param optimizer defines the current optimizer
  154884. * @returns true if everything that can be done was applied
  154885. */
  154886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154887. }
  154888. /**
  154889. * Defines an optimization used to increase or decrease the rendering resolution
  154890. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154891. */
  154892. export class HardwareScalingOptimization extends SceneOptimization {
  154893. /**
  154894. * Defines the priority of this optimization (0 by default which means first in the list)
  154895. */
  154896. priority: number;
  154897. /**
  154898. * Defines the maximum scale to use (2 by default)
  154899. */
  154900. maximumScale: number;
  154901. /**
  154902. * Defines the step to use between two passes (0.5 by default)
  154903. */
  154904. step: number;
  154905. private _currentScale;
  154906. private _directionOffset;
  154907. /**
  154908. * Gets a string describing the action executed by the current optimization
  154909. * @return description string
  154910. */
  154911. getDescription(): string;
  154912. /**
  154913. * Creates the HardwareScalingOptimization object
  154914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154915. * @param maximumScale defines the maximum scale to use (2 by default)
  154916. * @param step defines the step to use between two passes (0.5 by default)
  154917. */
  154918. constructor(
  154919. /**
  154920. * Defines the priority of this optimization (0 by default which means first in the list)
  154921. */
  154922. priority?: number,
  154923. /**
  154924. * Defines the maximum scale to use (2 by default)
  154925. */
  154926. maximumScale?: number,
  154927. /**
  154928. * Defines the step to use between two passes (0.5 by default)
  154929. */
  154930. step?: number);
  154931. /**
  154932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154933. * @param scene defines the current scene where to apply this optimization
  154934. * @param optimizer defines the current optimizer
  154935. * @returns true if everything that can be done was applied
  154936. */
  154937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154938. }
  154939. /**
  154940. * Defines an optimization used to remove shadows
  154941. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154942. */
  154943. export class ShadowsOptimization extends SceneOptimization {
  154944. /**
  154945. * Gets a string describing the action executed by the current optimization
  154946. * @return description string
  154947. */
  154948. getDescription(): string;
  154949. /**
  154950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154951. * @param scene defines the current scene where to apply this optimization
  154952. * @param optimizer defines the current optimizer
  154953. * @returns true if everything that can be done was applied
  154954. */
  154955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154956. }
  154957. /**
  154958. * Defines an optimization used to turn post-processes off
  154959. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154960. */
  154961. export class PostProcessesOptimization extends SceneOptimization {
  154962. /**
  154963. * Gets a string describing the action executed by the current optimization
  154964. * @return description string
  154965. */
  154966. getDescription(): string;
  154967. /**
  154968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154969. * @param scene defines the current scene where to apply this optimization
  154970. * @param optimizer defines the current optimizer
  154971. * @returns true if everything that can be done was applied
  154972. */
  154973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154974. }
  154975. /**
  154976. * Defines an optimization used to turn lens flares off
  154977. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154978. */
  154979. export class LensFlaresOptimization extends SceneOptimization {
  154980. /**
  154981. * Gets a string describing the action executed by the current optimization
  154982. * @return description string
  154983. */
  154984. getDescription(): string;
  154985. /**
  154986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154987. * @param scene defines the current scene where to apply this optimization
  154988. * @param optimizer defines the current optimizer
  154989. * @returns true if everything that can be done was applied
  154990. */
  154991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154992. }
  154993. /**
  154994. * Defines an optimization based on user defined callback.
  154995. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154996. */
  154997. export class CustomOptimization extends SceneOptimization {
  154998. /**
  154999. * Callback called to apply the custom optimization.
  155000. */
  155001. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155002. /**
  155003. * Callback called to get custom description
  155004. */
  155005. onGetDescription: () => string;
  155006. /**
  155007. * Gets a string describing the action executed by the current optimization
  155008. * @returns description string
  155009. */
  155010. getDescription(): string;
  155011. /**
  155012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155013. * @param scene defines the current scene where to apply this optimization
  155014. * @param optimizer defines the current optimizer
  155015. * @returns true if everything that can be done was applied
  155016. */
  155017. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155018. }
  155019. /**
  155020. * Defines an optimization used to turn particles off
  155021. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155022. */
  155023. export class ParticlesOptimization extends SceneOptimization {
  155024. /**
  155025. * Gets a string describing the action executed by the current optimization
  155026. * @return description string
  155027. */
  155028. getDescription(): string;
  155029. /**
  155030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155031. * @param scene defines the current scene where to apply this optimization
  155032. * @param optimizer defines the current optimizer
  155033. * @returns true if everything that can be done was applied
  155034. */
  155035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155036. }
  155037. /**
  155038. * Defines an optimization used to turn render targets off
  155039. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155040. */
  155041. export class RenderTargetsOptimization extends SceneOptimization {
  155042. /**
  155043. * Gets a string describing the action executed by the current optimization
  155044. * @return description string
  155045. */
  155046. getDescription(): string;
  155047. /**
  155048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155049. * @param scene defines the current scene where to apply this optimization
  155050. * @param optimizer defines the current optimizer
  155051. * @returns true if everything that can be done was applied
  155052. */
  155053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155054. }
  155055. /**
  155056. * Defines an optimization used to merge meshes with compatible materials
  155057. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155058. */
  155059. export class MergeMeshesOptimization extends SceneOptimization {
  155060. private static _UpdateSelectionTree;
  155061. /**
  155062. * Gets or sets a boolean which defines if optimization octree has to be updated
  155063. */
  155064. static get UpdateSelectionTree(): boolean;
  155065. /**
  155066. * Gets or sets a boolean which defines if optimization octree has to be updated
  155067. */
  155068. static set UpdateSelectionTree(value: boolean);
  155069. /**
  155070. * Gets a string describing the action executed by the current optimization
  155071. * @return description string
  155072. */
  155073. getDescription(): string;
  155074. private _canBeMerged;
  155075. /**
  155076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155077. * @param scene defines the current scene where to apply this optimization
  155078. * @param optimizer defines the current optimizer
  155079. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155080. * @returns true if everything that can be done was applied
  155081. */
  155082. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155083. }
  155084. /**
  155085. * Defines a list of options used by SceneOptimizer
  155086. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155087. */
  155088. export class SceneOptimizerOptions {
  155089. /**
  155090. * Defines the target frame rate to reach (60 by default)
  155091. */
  155092. targetFrameRate: number;
  155093. /**
  155094. * Defines the interval between two checkes (2000ms by default)
  155095. */
  155096. trackerDuration: number;
  155097. /**
  155098. * Gets the list of optimizations to apply
  155099. */
  155100. optimizations: SceneOptimization[];
  155101. /**
  155102. * Creates a new list of options used by SceneOptimizer
  155103. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155104. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155105. */
  155106. constructor(
  155107. /**
  155108. * Defines the target frame rate to reach (60 by default)
  155109. */
  155110. targetFrameRate?: number,
  155111. /**
  155112. * Defines the interval between two checkes (2000ms by default)
  155113. */
  155114. trackerDuration?: number);
  155115. /**
  155116. * Add a new optimization
  155117. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155118. * @returns the current SceneOptimizerOptions
  155119. */
  155120. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155121. /**
  155122. * Add a new custom optimization
  155123. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155124. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155125. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155126. * @returns the current SceneOptimizerOptions
  155127. */
  155128. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155129. /**
  155130. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155131. * @param targetFrameRate defines the target frame rate (60 by default)
  155132. * @returns a SceneOptimizerOptions object
  155133. */
  155134. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155135. /**
  155136. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155137. * @param targetFrameRate defines the target frame rate (60 by default)
  155138. * @returns a SceneOptimizerOptions object
  155139. */
  155140. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155141. /**
  155142. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155143. * @param targetFrameRate defines the target frame rate (60 by default)
  155144. * @returns a SceneOptimizerOptions object
  155145. */
  155146. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155147. }
  155148. /**
  155149. * Class used to run optimizations in order to reach a target frame rate
  155150. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155151. */
  155152. export class SceneOptimizer implements IDisposable {
  155153. private _isRunning;
  155154. private _options;
  155155. private _scene;
  155156. private _currentPriorityLevel;
  155157. private _targetFrameRate;
  155158. private _trackerDuration;
  155159. private _currentFrameRate;
  155160. private _sceneDisposeObserver;
  155161. private _improvementMode;
  155162. /**
  155163. * Defines an observable called when the optimizer reaches the target frame rate
  155164. */
  155165. onSuccessObservable: Observable<SceneOptimizer>;
  155166. /**
  155167. * Defines an observable called when the optimizer enables an optimization
  155168. */
  155169. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155170. /**
  155171. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155172. */
  155173. onFailureObservable: Observable<SceneOptimizer>;
  155174. /**
  155175. * Gets a boolean indicating if the optimizer is in improvement mode
  155176. */
  155177. get isInImprovementMode(): boolean;
  155178. /**
  155179. * Gets the current priority level (0 at start)
  155180. */
  155181. get currentPriorityLevel(): number;
  155182. /**
  155183. * Gets the current frame rate checked by the SceneOptimizer
  155184. */
  155185. get currentFrameRate(): number;
  155186. /**
  155187. * Gets or sets the current target frame rate (60 by default)
  155188. */
  155189. get targetFrameRate(): number;
  155190. /**
  155191. * Gets or sets the current target frame rate (60 by default)
  155192. */
  155193. set targetFrameRate(value: number);
  155194. /**
  155195. * Gets or sets the current interval between two checks (every 2000ms by default)
  155196. */
  155197. get trackerDuration(): number;
  155198. /**
  155199. * Gets or sets the current interval between two checks (every 2000ms by default)
  155200. */
  155201. set trackerDuration(value: number);
  155202. /**
  155203. * Gets the list of active optimizations
  155204. */
  155205. get optimizations(): SceneOptimization[];
  155206. /**
  155207. * Creates a new SceneOptimizer
  155208. * @param scene defines the scene to work on
  155209. * @param options defines the options to use with the SceneOptimizer
  155210. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155211. * @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)
  155212. */
  155213. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155214. /**
  155215. * Stops the current optimizer
  155216. */
  155217. stop(): void;
  155218. /**
  155219. * Reset the optimizer to initial step (current priority level = 0)
  155220. */
  155221. reset(): void;
  155222. /**
  155223. * Start the optimizer. By default it will try to reach a specific framerate
  155224. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155225. */
  155226. start(): void;
  155227. private _checkCurrentState;
  155228. /**
  155229. * Release all resources
  155230. */
  155231. dispose(): void;
  155232. /**
  155233. * Helper function to create a SceneOptimizer with one single line of code
  155234. * @param scene defines the scene to work on
  155235. * @param options defines the options to use with the SceneOptimizer
  155236. * @param onSuccess defines a callback to call on success
  155237. * @param onFailure defines a callback to call on failure
  155238. * @returns the new SceneOptimizer object
  155239. */
  155240. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155241. }
  155242. }
  155243. declare module BABYLON {
  155244. /**
  155245. * Class used to serialize a scene into a string
  155246. */
  155247. export class SceneSerializer {
  155248. /**
  155249. * Clear cache used by a previous serialization
  155250. */
  155251. static ClearCache(): void;
  155252. /**
  155253. * Serialize a scene into a JSON compatible object
  155254. * @param scene defines the scene to serialize
  155255. * @returns a JSON compatible object
  155256. */
  155257. static Serialize(scene: Scene): any;
  155258. /**
  155259. * Serialize a mesh into a JSON compatible object
  155260. * @param toSerialize defines the mesh to serialize
  155261. * @param withParents defines if parents must be serialized as well
  155262. * @param withChildren defines if children must be serialized as well
  155263. * @returns a JSON compatible object
  155264. */
  155265. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155266. }
  155267. }
  155268. declare module BABYLON {
  155269. /**
  155270. * Class used to host texture specific utilities
  155271. */
  155272. export class TextureTools {
  155273. /**
  155274. * Uses the GPU to create a copy texture rescaled at a given size
  155275. * @param texture Texture to copy from
  155276. * @param width defines the desired width
  155277. * @param height defines the desired height
  155278. * @param useBilinearMode defines if bilinear mode has to be used
  155279. * @return the generated texture
  155280. */
  155281. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155282. }
  155283. }
  155284. declare module BABYLON {
  155285. /**
  155286. * This represents the different options available for the video capture.
  155287. */
  155288. export interface VideoRecorderOptions {
  155289. /** Defines the mime type of the video. */
  155290. mimeType: string;
  155291. /** Defines the FPS the video should be recorded at. */
  155292. fps: number;
  155293. /** Defines the chunk size for the recording data. */
  155294. recordChunckSize: number;
  155295. /** The audio tracks to attach to the recording. */
  155296. audioTracks?: MediaStreamTrack[];
  155297. }
  155298. /**
  155299. * This can help with recording videos from BabylonJS.
  155300. * This is based on the available WebRTC functionalities of the browser.
  155301. *
  155302. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155303. */
  155304. export class VideoRecorder {
  155305. private static readonly _defaultOptions;
  155306. /**
  155307. * Returns whether or not the VideoRecorder is available in your browser.
  155308. * @param engine Defines the Babylon Engine.
  155309. * @returns true if supported otherwise false.
  155310. */
  155311. static IsSupported(engine: Engine): boolean;
  155312. private readonly _options;
  155313. private _canvas;
  155314. private _mediaRecorder;
  155315. private _recordedChunks;
  155316. private _fileName;
  155317. private _resolve;
  155318. private _reject;
  155319. /**
  155320. * True when a recording is already in progress.
  155321. */
  155322. get isRecording(): boolean;
  155323. /**
  155324. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155325. * @param engine Defines the BabylonJS Engine you wish to record.
  155326. * @param options Defines options that can be used to customize the capture.
  155327. */
  155328. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155329. /**
  155330. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155331. */
  155332. stopRecording(): void;
  155333. /**
  155334. * Starts recording the canvas for a max duration specified in parameters.
  155335. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155336. * If null no automatic download will start and you can rely on the promise to get the data back.
  155337. * @param maxDuration Defines the maximum recording time in seconds.
  155338. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155339. * @return A promise callback at the end of the recording with the video data in Blob.
  155340. */
  155341. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155342. /**
  155343. * Releases internal resources used during the recording.
  155344. */
  155345. dispose(): void;
  155346. private _handleDataAvailable;
  155347. private _handleError;
  155348. private _handleStop;
  155349. }
  155350. }
  155351. declare module BABYLON {
  155352. /**
  155353. * Class containing a set of static utilities functions for screenshots
  155354. */
  155355. export class ScreenshotTools {
  155356. /**
  155357. * Captures a screenshot of the current rendering
  155358. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155359. * @param engine defines the rendering engine
  155360. * @param camera defines the source camera
  155361. * @param size This parameter can be set to a single number or to an object with the
  155362. * following (optional) properties: precision, width, height. If a single number is passed,
  155363. * it will be used for both width and height. If an object is passed, the screenshot size
  155364. * will be derived from the parameters. The precision property is a multiplier allowing
  155365. * rendering at a higher or lower resolution
  155366. * @param successCallback defines the callback receives a single parameter which contains the
  155367. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155368. * src parameter of an <img> to display it
  155369. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155370. * Check your browser for supported MIME types
  155371. */
  155372. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155373. /**
  155374. * Captures a screenshot of the current rendering
  155375. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155376. * @param engine defines the rendering engine
  155377. * @param camera defines the source camera
  155378. * @param size This parameter can be set to a single number or to an object with the
  155379. * following (optional) properties: precision, width, height. If a single number is passed,
  155380. * it will be used for both width and height. If an object is passed, the screenshot size
  155381. * will be derived from the parameters. The precision property is a multiplier allowing
  155382. * rendering at a higher or lower resolution
  155383. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155384. * Check your browser for supported MIME types
  155385. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155386. * to the src parameter of an <img> to display it
  155387. */
  155388. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155389. /**
  155390. * Generates an image screenshot from the specified camera.
  155391. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155392. * @param engine The engine to use for rendering
  155393. * @param camera The camera to use for rendering
  155394. * @param size This parameter can be set to a single number or to an object with the
  155395. * following (optional) properties: precision, width, height. If a single number is passed,
  155396. * it will be used for both width and height. If an object is passed, the screenshot size
  155397. * will be derived from the parameters. The precision property is a multiplier allowing
  155398. * rendering at a higher or lower resolution
  155399. * @param successCallback The callback receives a single parameter which contains the
  155400. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155401. * src parameter of an <img> to display it
  155402. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155403. * Check your browser for supported MIME types
  155404. * @param samples Texture samples (default: 1)
  155405. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155406. * @param fileName A name for for the downloaded file.
  155407. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155408. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155409. */
  155410. 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;
  155411. /**
  155412. * Generates an image screenshot from the specified camera.
  155413. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155414. * @param engine The engine to use for rendering
  155415. * @param camera The camera to use for rendering
  155416. * @param size This parameter can be set to a single number or to an object with the
  155417. * following (optional) properties: precision, width, height. If a single number is passed,
  155418. * it will be used for both width and height. If an object is passed, the screenshot size
  155419. * will be derived from the parameters. The precision property is a multiplier allowing
  155420. * rendering at a higher or lower resolution
  155421. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155422. * Check your browser for supported MIME types
  155423. * @param samples Texture samples (default: 1)
  155424. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155425. * @param fileName A name for for the downloaded file.
  155426. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155427. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155428. * to the src parameter of an <img> to display it
  155429. */
  155430. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155431. /**
  155432. * Gets height and width for screenshot size
  155433. * @private
  155434. */
  155435. private static _getScreenshotSize;
  155436. }
  155437. }
  155438. declare module BABYLON {
  155439. /**
  155440. * Interface for a data buffer
  155441. */
  155442. export interface IDataBuffer {
  155443. /**
  155444. * Reads bytes from the data buffer.
  155445. * @param byteOffset The byte offset to read
  155446. * @param byteLength The byte length to read
  155447. * @returns A promise that resolves when the bytes are read
  155448. */
  155449. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155450. /**
  155451. * The byte length of the buffer.
  155452. */
  155453. readonly byteLength: number;
  155454. }
  155455. /**
  155456. * Utility class for reading from a data buffer
  155457. */
  155458. export class DataReader {
  155459. /**
  155460. * The data buffer associated with this data reader.
  155461. */
  155462. readonly buffer: IDataBuffer;
  155463. /**
  155464. * The current byte offset from the beginning of the data buffer.
  155465. */
  155466. byteOffset: number;
  155467. private _dataView;
  155468. private _dataByteOffset;
  155469. /**
  155470. * Constructor
  155471. * @param buffer The buffer to read
  155472. */
  155473. constructor(buffer: IDataBuffer);
  155474. /**
  155475. * Loads the given byte length.
  155476. * @param byteLength The byte length to load
  155477. * @returns A promise that resolves when the load is complete
  155478. */
  155479. loadAsync(byteLength: number): Promise<void>;
  155480. /**
  155481. * Read a unsigned 32-bit integer from the currently loaded data range.
  155482. * @returns The 32-bit integer read
  155483. */
  155484. readUint32(): number;
  155485. /**
  155486. * Read a byte array from the currently loaded data range.
  155487. * @param byteLength The byte length to read
  155488. * @returns The byte array read
  155489. */
  155490. readUint8Array(byteLength: number): Uint8Array;
  155491. /**
  155492. * Read a string from the currently loaded data range.
  155493. * @param byteLength The byte length to read
  155494. * @returns The string read
  155495. */
  155496. readString(byteLength: number): string;
  155497. /**
  155498. * Skips the given byte length the currently loaded data range.
  155499. * @param byteLength The byte length to skip
  155500. */
  155501. skipBytes(byteLength: number): void;
  155502. }
  155503. }
  155504. declare module BABYLON {
  155505. /**
  155506. * Class for storing data to local storage if available or in-memory storage otherwise
  155507. */
  155508. export class DataStorage {
  155509. private static _Storage;
  155510. private static _GetStorage;
  155511. /**
  155512. * Reads a string from the data storage
  155513. * @param key The key to read
  155514. * @param defaultValue The value if the key doesn't exist
  155515. * @returns The string value
  155516. */
  155517. static ReadString(key: string, defaultValue: string): string;
  155518. /**
  155519. * Writes a string to the data storage
  155520. * @param key The key to write
  155521. * @param value The value to write
  155522. */
  155523. static WriteString(key: string, value: string): void;
  155524. /**
  155525. * Reads a boolean from the data storage
  155526. * @param key The key to read
  155527. * @param defaultValue The value if the key doesn't exist
  155528. * @returns The boolean value
  155529. */
  155530. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155531. /**
  155532. * Writes a boolean to the data storage
  155533. * @param key The key to write
  155534. * @param value The value to write
  155535. */
  155536. static WriteBoolean(key: string, value: boolean): void;
  155537. /**
  155538. * Reads a number from the data storage
  155539. * @param key The key to read
  155540. * @param defaultValue The value if the key doesn't exist
  155541. * @returns The number value
  155542. */
  155543. static ReadNumber(key: string, defaultValue: number): number;
  155544. /**
  155545. * Writes a number to the data storage
  155546. * @param key The key to write
  155547. * @param value The value to write
  155548. */
  155549. static WriteNumber(key: string, value: number): void;
  155550. }
  155551. }
  155552. declare module BABYLON {
  155553. /**
  155554. * Class used to record delta files between 2 scene states
  155555. */
  155556. export class SceneRecorder {
  155557. private _trackedScene;
  155558. private _savedJSON;
  155559. /**
  155560. * Track a given scene. This means the current scene state will be considered the original state
  155561. * @param scene defines the scene to track
  155562. */
  155563. track(scene: Scene): void;
  155564. /**
  155565. * Get the delta between current state and original state
  155566. * @returns a string containing the delta
  155567. */
  155568. getDelta(): any;
  155569. private _compareArray;
  155570. private _compareObjects;
  155571. private _compareCollections;
  155572. private static GetShadowGeneratorById;
  155573. /**
  155574. * Apply a given delta to a given scene
  155575. * @param deltaJSON defines the JSON containing the delta
  155576. * @param scene defines the scene to apply the delta to
  155577. */
  155578. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155579. private static _ApplyPropertiesToEntity;
  155580. private static _ApplyDeltaForEntity;
  155581. }
  155582. }
  155583. declare module BABYLON {
  155584. /**
  155585. * A 3D trajectory consisting of an order list of vectors describing a
  155586. * path of motion through 3D space.
  155587. */
  155588. export class Trajectory {
  155589. private _points;
  155590. private readonly _segmentLength;
  155591. /**
  155592. * Serialize to JSON.
  155593. * @returns serialized JSON string
  155594. */
  155595. serialize(): string;
  155596. /**
  155597. * Deserialize from JSON.
  155598. * @param json serialized JSON string
  155599. * @returns deserialized Trajectory
  155600. */
  155601. static Deserialize(json: string): Trajectory;
  155602. /**
  155603. * Create a new empty Trajectory.
  155604. * @param segmentLength radius of discretization for Trajectory points
  155605. */
  155606. constructor(segmentLength?: number);
  155607. /**
  155608. * Get the length of the Trajectory.
  155609. * @returns length of the Trajectory
  155610. */
  155611. getLength(): number;
  155612. /**
  155613. * Append a new point to the Trajectory.
  155614. * NOTE: This implementation has many allocations.
  155615. * @param point point to append to the Trajectory
  155616. */
  155617. add(point: DeepImmutable<Vector3>): void;
  155618. /**
  155619. * Create a new Trajectory with a segment length chosen to make it
  155620. * probable that the new Trajectory will have a specified number of
  155621. * segments. This operation is imprecise.
  155622. * @param targetResolution number of segments desired
  155623. * @returns new Trajectory with approximately the requested number of segments
  155624. */
  155625. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155626. /**
  155627. * Convert Trajectory segments into tokenized representation. This
  155628. * representation is an array of numbers where each nth number is the
  155629. * index of the token which is most similar to the nth segment of the
  155630. * Trajectory.
  155631. * @param tokens list of vectors which serve as discrete tokens
  155632. * @returns list of indices of most similar token per segment
  155633. */
  155634. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155635. private static _forwardDir;
  155636. private static _inverseFromVec;
  155637. private static _upDir;
  155638. private static _fromToVec;
  155639. private static _lookMatrix;
  155640. /**
  155641. * Transform the rotation (i.e., direction) of a segment to isolate
  155642. * the relative transformation represented by the segment. This operation
  155643. * may or may not succeed due to singularities in the equations that define
  155644. * motion relativity in this context.
  155645. * @param priorVec the origin of the prior segment
  155646. * @param fromVec the origin of the current segment
  155647. * @param toVec the destination of the current segment
  155648. * @param result reference to output variable
  155649. * @returns whether or not transformation was successful
  155650. */
  155651. private static _transformSegmentDirToRef;
  155652. private static _bestMatch;
  155653. private static _score;
  155654. private static _bestScore;
  155655. /**
  155656. * Determine which token vector is most similar to the
  155657. * segment vector.
  155658. * @param segment segment vector
  155659. * @param tokens token vector list
  155660. * @returns index of the most similar token to the segment
  155661. */
  155662. private static _tokenizeSegment;
  155663. }
  155664. /**
  155665. * Class representing a set of known, named trajectories to which Trajectories can be
  155666. * added and using which Trajectories can be recognized.
  155667. */
  155668. export class TrajectoryClassifier {
  155669. private _maximumAllowableMatchCost;
  155670. private _vector3Alphabet;
  155671. private _levenshteinAlphabet;
  155672. private _nameToDescribedTrajectory;
  155673. /**
  155674. * Serialize to JSON.
  155675. * @returns JSON serialization
  155676. */
  155677. serialize(): string;
  155678. /**
  155679. * Deserialize from JSON.
  155680. * @param json JSON serialization
  155681. * @returns deserialized TrajectorySet
  155682. */
  155683. static Deserialize(json: string): TrajectoryClassifier;
  155684. /**
  155685. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155686. * VERY naive, need to be generating these things from known
  155687. * sets. Better version later, probably eliminating this one.
  155688. * @returns auto-generated TrajectorySet
  155689. */
  155690. static Generate(): TrajectoryClassifier;
  155691. private constructor();
  155692. /**
  155693. * Add a new Trajectory to the set with a given name.
  155694. * @param trajectory new Trajectory to be added
  155695. * @param classification name to which to add the Trajectory
  155696. */
  155697. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155698. /**
  155699. * Remove a known named trajectory and all Trajectories associated with it.
  155700. * @param classification name to remove
  155701. * @returns whether anything was removed
  155702. */
  155703. deleteClassification(classification: string): boolean;
  155704. /**
  155705. * Attempt to recognize a Trajectory from among all the classifications
  155706. * already known to the classifier.
  155707. * @param trajectory Trajectory to be recognized
  155708. * @returns classification of Trajectory if recognized, null otherwise
  155709. */
  155710. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155711. }
  155712. }
  155713. declare module BABYLON {
  155714. /**
  155715. * An interface for all Hit test features
  155716. */
  155717. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155718. /**
  155719. * Triggered when new babylon (transformed) hit test results are available
  155720. */
  155721. onHitTestResultObservable: Observable<T[]>;
  155722. }
  155723. /**
  155724. * Options used for hit testing
  155725. */
  155726. export interface IWebXRLegacyHitTestOptions {
  155727. /**
  155728. * Only test when user interacted with the scene. Default - hit test every frame
  155729. */
  155730. testOnPointerDownOnly?: boolean;
  155731. /**
  155732. * The node to use to transform the local results to world coordinates
  155733. */
  155734. worldParentNode?: TransformNode;
  155735. }
  155736. /**
  155737. * Interface defining the babylon result of raycasting/hit-test
  155738. */
  155739. export interface IWebXRLegacyHitResult {
  155740. /**
  155741. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155742. */
  155743. transformationMatrix: Matrix;
  155744. /**
  155745. * The native hit test result
  155746. */
  155747. xrHitResult: XRHitResult | XRHitTestResult;
  155748. }
  155749. /**
  155750. * The currently-working hit-test module.
  155751. * Hit test (or Ray-casting) is used to interact with the real world.
  155752. * For further information read here - https://github.com/immersive-web/hit-test
  155753. */
  155754. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155755. /**
  155756. * options to use when constructing this feature
  155757. */
  155758. readonly options: IWebXRLegacyHitTestOptions;
  155759. private _direction;
  155760. private _mat;
  155761. private _onSelectEnabled;
  155762. private _origin;
  155763. /**
  155764. * The module's name
  155765. */
  155766. static readonly Name: string;
  155767. /**
  155768. * The (Babylon) version of this module.
  155769. * This is an integer representing the implementation version.
  155770. * This number does not correspond to the WebXR specs version
  155771. */
  155772. static readonly Version: number;
  155773. /**
  155774. * Populated with the last native XR Hit Results
  155775. */
  155776. lastNativeXRHitResults: XRHitResult[];
  155777. /**
  155778. * Triggered when new babylon (transformed) hit test results are available
  155779. */
  155780. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155781. /**
  155782. * Creates a new instance of the (legacy version) hit test feature
  155783. * @param _xrSessionManager an instance of WebXRSessionManager
  155784. * @param options options to use when constructing this feature
  155785. */
  155786. constructor(_xrSessionManager: WebXRSessionManager,
  155787. /**
  155788. * options to use when constructing this feature
  155789. */
  155790. options?: IWebXRLegacyHitTestOptions);
  155791. /**
  155792. * execute a hit test with an XR Ray
  155793. *
  155794. * @param xrSession a native xrSession that will execute this hit test
  155795. * @param xrRay the ray (position and direction) to use for ray-casting
  155796. * @param referenceSpace native XR reference space to use for the hit-test
  155797. * @param filter filter function that will filter the results
  155798. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155799. */
  155800. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155801. /**
  155802. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155803. * @param event the (select) event to use to select with
  155804. * @param referenceSpace the reference space to use for this hit test
  155805. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155806. */
  155807. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155808. /**
  155809. * attach this feature
  155810. * Will usually be called by the features manager
  155811. *
  155812. * @returns true if successful.
  155813. */
  155814. attach(): boolean;
  155815. /**
  155816. * detach this feature.
  155817. * Will usually be called by the features manager
  155818. *
  155819. * @returns true if successful.
  155820. */
  155821. detach(): boolean;
  155822. /**
  155823. * Dispose this feature and all of the resources attached
  155824. */
  155825. dispose(): void;
  155826. protected _onXRFrame(frame: XRFrame): void;
  155827. private _onHitTestResults;
  155828. private _onSelect;
  155829. }
  155830. }
  155831. declare module BABYLON {
  155832. /**
  155833. * Options used for hit testing (version 2)
  155834. */
  155835. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155836. /**
  155837. * Do not create a permanent hit test. Will usually be used when only
  155838. * transient inputs are needed.
  155839. */
  155840. disablePermanentHitTest?: boolean;
  155841. /**
  155842. * Enable transient (for example touch-based) hit test inspections
  155843. */
  155844. enableTransientHitTest?: boolean;
  155845. /**
  155846. * Offset ray for the permanent hit test
  155847. */
  155848. offsetRay?: Vector3;
  155849. /**
  155850. * Offset ray for the transient hit test
  155851. */
  155852. transientOffsetRay?: Vector3;
  155853. /**
  155854. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155855. */
  155856. useReferenceSpace?: boolean;
  155857. /**
  155858. * Override the default entity type(s) of the hit-test result
  155859. */
  155860. entityTypes?: XRHitTestTrackableType[];
  155861. }
  155862. /**
  155863. * Interface defining the babylon result of hit-test
  155864. */
  155865. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155866. /**
  155867. * The input source that generated this hit test (if transient)
  155868. */
  155869. inputSource?: XRInputSource;
  155870. /**
  155871. * Is this a transient hit test
  155872. */
  155873. isTransient?: boolean;
  155874. /**
  155875. * Position of the hit test result
  155876. */
  155877. position: Vector3;
  155878. /**
  155879. * Rotation of the hit test result
  155880. */
  155881. rotationQuaternion: Quaternion;
  155882. /**
  155883. * The native hit test result
  155884. */
  155885. xrHitResult: XRHitTestResult;
  155886. }
  155887. /**
  155888. * The currently-working hit-test module.
  155889. * Hit test (or Ray-casting) is used to interact with the real world.
  155890. * For further information read here - https://github.com/immersive-web/hit-test
  155891. *
  155892. * Tested on chrome (mobile) 80.
  155893. */
  155894. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155895. /**
  155896. * options to use when constructing this feature
  155897. */
  155898. readonly options: IWebXRHitTestOptions;
  155899. private _tmpMat;
  155900. private _tmpPos;
  155901. private _tmpQuat;
  155902. private _transientXrHitTestSource;
  155903. private _xrHitTestSource;
  155904. private initHitTestSource;
  155905. /**
  155906. * The module's name
  155907. */
  155908. static readonly Name: string;
  155909. /**
  155910. * The (Babylon) version of this module.
  155911. * This is an integer representing the implementation version.
  155912. * This number does not correspond to the WebXR specs version
  155913. */
  155914. static readonly Version: number;
  155915. /**
  155916. * When set to true, each hit test will have its own position/rotation objects
  155917. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155918. * the developers will clone them or copy them as they see fit.
  155919. */
  155920. autoCloneTransformation: boolean;
  155921. /**
  155922. * Triggered when new babylon (transformed) hit test results are available
  155923. * Note - this will be called when results come back from the device. It can be an empty array!!
  155924. */
  155925. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155926. /**
  155927. * Use this to temporarily pause hit test checks.
  155928. */
  155929. paused: boolean;
  155930. /**
  155931. * Creates a new instance of the hit test feature
  155932. * @param _xrSessionManager an instance of WebXRSessionManager
  155933. * @param options options to use when constructing this feature
  155934. */
  155935. constructor(_xrSessionManager: WebXRSessionManager,
  155936. /**
  155937. * options to use when constructing this feature
  155938. */
  155939. options?: IWebXRHitTestOptions);
  155940. /**
  155941. * attach this feature
  155942. * Will usually be called by the features manager
  155943. *
  155944. * @returns true if successful.
  155945. */
  155946. attach(): boolean;
  155947. /**
  155948. * detach this feature.
  155949. * Will usually be called by the features manager
  155950. *
  155951. * @returns true if successful.
  155952. */
  155953. detach(): boolean;
  155954. /**
  155955. * Dispose this feature and all of the resources attached
  155956. */
  155957. dispose(): void;
  155958. protected _onXRFrame(frame: XRFrame): void;
  155959. private _processWebXRHitTestResult;
  155960. }
  155961. }
  155962. declare module BABYLON {
  155963. /**
  155964. * Configuration options of the anchor system
  155965. */
  155966. export interface IWebXRAnchorSystemOptions {
  155967. /**
  155968. * a node that will be used to convert local to world coordinates
  155969. */
  155970. worldParentNode?: TransformNode;
  155971. /**
  155972. * If set to true a reference of the created anchors will be kept until the next session starts
  155973. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155974. */
  155975. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155976. }
  155977. /**
  155978. * A babylon container for an XR Anchor
  155979. */
  155980. export interface IWebXRAnchor {
  155981. /**
  155982. * A babylon-assigned ID for this anchor
  155983. */
  155984. id: number;
  155985. /**
  155986. * Transformation matrix to apply to an object attached to this anchor
  155987. */
  155988. transformationMatrix: Matrix;
  155989. /**
  155990. * The native anchor object
  155991. */
  155992. xrAnchor: XRAnchor;
  155993. /**
  155994. * if defined, this object will be constantly updated by the anchor's position and rotation
  155995. */
  155996. attachedNode?: TransformNode;
  155997. }
  155998. /**
  155999. * An implementation of the anchor system for WebXR.
  156000. * For further information see https://github.com/immersive-web/anchors/
  156001. */
  156002. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156003. private _options;
  156004. private _lastFrameDetected;
  156005. private _trackedAnchors;
  156006. private _referenceSpaceForFrameAnchors;
  156007. private _futureAnchors;
  156008. /**
  156009. * The module's name
  156010. */
  156011. static readonly Name: string;
  156012. /**
  156013. * The (Babylon) version of this module.
  156014. * This is an integer representing the implementation version.
  156015. * This number does not correspond to the WebXR specs version
  156016. */
  156017. static readonly Version: number;
  156018. /**
  156019. * Observers registered here will be executed when a new anchor was added to the session
  156020. */
  156021. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156022. /**
  156023. * Observers registered here will be executed when an anchor was removed from the session
  156024. */
  156025. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156026. /**
  156027. * Observers registered here will be executed when an existing anchor updates
  156028. * This can execute N times every frame
  156029. */
  156030. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156031. /**
  156032. * Set the reference space to use for anchor creation, when not using a hit test.
  156033. * Will default to the session's reference space if not defined
  156034. */
  156035. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156036. /**
  156037. * constructs a new anchor system
  156038. * @param _xrSessionManager an instance of WebXRSessionManager
  156039. * @param _options configuration object for this feature
  156040. */
  156041. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156042. private _tmpVector;
  156043. private _tmpQuaternion;
  156044. private _populateTmpTransformation;
  156045. /**
  156046. * Create a new anchor point using a hit test result at a specific point in the scene
  156047. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156048. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156049. *
  156050. * @param hitTestResult The hit test result to use for this anchor creation
  156051. * @param position an optional position offset for this anchor
  156052. * @param rotationQuaternion an optional rotation offset for this anchor
  156053. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156054. */
  156055. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156056. /**
  156057. * Add a new anchor at a specific position and rotation
  156058. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156059. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156060. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156061. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156062. *
  156063. * @param position the position in which to add an anchor
  156064. * @param rotationQuaternion an optional rotation for the anchor transformation
  156065. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156066. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156067. */
  156068. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156069. /**
  156070. * detach this feature.
  156071. * Will usually be called by the features manager
  156072. *
  156073. * @returns true if successful.
  156074. */
  156075. detach(): boolean;
  156076. /**
  156077. * Dispose this feature and all of the resources attached
  156078. */
  156079. dispose(): void;
  156080. protected _onXRFrame(frame: XRFrame): void;
  156081. /**
  156082. * avoiding using Array.find for global support.
  156083. * @param xrAnchor the plane to find in the array
  156084. */
  156085. private _findIndexInAnchorArray;
  156086. private _updateAnchorWithXRFrame;
  156087. private _createAnchorAtTransformation;
  156088. }
  156089. }
  156090. declare module BABYLON {
  156091. /**
  156092. * Options used in the plane detector module
  156093. */
  156094. export interface IWebXRPlaneDetectorOptions {
  156095. /**
  156096. * The node to use to transform the local results to world coordinates
  156097. */
  156098. worldParentNode?: TransformNode;
  156099. /**
  156100. * If set to true a reference of the created planes will be kept until the next session starts
  156101. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156102. */
  156103. doNotRemovePlanesOnSessionEnded?: boolean;
  156104. }
  156105. /**
  156106. * A babylon interface for a WebXR plane.
  156107. * A Plane is actually a polygon, built from N points in space
  156108. *
  156109. * Supported in chrome 79, not supported in canary 81 ATM
  156110. */
  156111. export interface IWebXRPlane {
  156112. /**
  156113. * a babylon-assigned ID for this polygon
  156114. */
  156115. id: number;
  156116. /**
  156117. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156118. */
  156119. polygonDefinition: Array<Vector3>;
  156120. /**
  156121. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156122. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156123. */
  156124. transformationMatrix: Matrix;
  156125. /**
  156126. * the native xr-plane object
  156127. */
  156128. xrPlane: XRPlane;
  156129. }
  156130. /**
  156131. * The plane detector is used to detect planes in the real world when in AR
  156132. * For more information see https://github.com/immersive-web/real-world-geometry/
  156133. */
  156134. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156135. private _options;
  156136. private _detectedPlanes;
  156137. private _enabled;
  156138. private _lastFrameDetected;
  156139. /**
  156140. * The module's name
  156141. */
  156142. static readonly Name: string;
  156143. /**
  156144. * The (Babylon) version of this module.
  156145. * This is an integer representing the implementation version.
  156146. * This number does not correspond to the WebXR specs version
  156147. */
  156148. static readonly Version: number;
  156149. /**
  156150. * Observers registered here will be executed when a new plane was added to the session
  156151. */
  156152. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156153. /**
  156154. * Observers registered here will be executed when a plane is no longer detected in the session
  156155. */
  156156. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156157. /**
  156158. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156159. * This can execute N times every frame
  156160. */
  156161. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156162. /**
  156163. * construct a new Plane Detector
  156164. * @param _xrSessionManager an instance of xr Session manager
  156165. * @param _options configuration to use when constructing this feature
  156166. */
  156167. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156168. /**
  156169. * detach this feature.
  156170. * Will usually be called by the features manager
  156171. *
  156172. * @returns true if successful.
  156173. */
  156174. detach(): boolean;
  156175. /**
  156176. * Dispose this feature and all of the resources attached
  156177. */
  156178. dispose(): void;
  156179. protected _onXRFrame(frame: XRFrame): void;
  156180. private _init;
  156181. private _updatePlaneWithXRPlane;
  156182. /**
  156183. * avoiding using Array.find for global support.
  156184. * @param xrPlane the plane to find in the array
  156185. */
  156186. private findIndexInPlaneArray;
  156187. }
  156188. }
  156189. declare module BABYLON {
  156190. /**
  156191. * Options interface for the background remover plugin
  156192. */
  156193. export interface IWebXRBackgroundRemoverOptions {
  156194. /**
  156195. * Further background meshes to disable when entering AR
  156196. */
  156197. backgroundMeshes?: AbstractMesh[];
  156198. /**
  156199. * flags to configure the removal of the environment helper.
  156200. * If not set, the entire background will be removed. If set, flags should be set as well.
  156201. */
  156202. environmentHelperRemovalFlags?: {
  156203. /**
  156204. * Should the skybox be removed (default false)
  156205. */
  156206. skyBox?: boolean;
  156207. /**
  156208. * Should the ground be removed (default false)
  156209. */
  156210. ground?: boolean;
  156211. };
  156212. /**
  156213. * don't disable the environment helper
  156214. */
  156215. ignoreEnvironmentHelper?: boolean;
  156216. }
  156217. /**
  156218. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156219. */
  156220. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156221. /**
  156222. * read-only options to be used in this module
  156223. */
  156224. readonly options: IWebXRBackgroundRemoverOptions;
  156225. /**
  156226. * The module's name
  156227. */
  156228. static readonly Name: string;
  156229. /**
  156230. * The (Babylon) version of this module.
  156231. * This is an integer representing the implementation version.
  156232. * This number does not correspond to the WebXR specs version
  156233. */
  156234. static readonly Version: number;
  156235. /**
  156236. * registered observers will be triggered when the background state changes
  156237. */
  156238. onBackgroundStateChangedObservable: Observable<boolean>;
  156239. /**
  156240. * constructs a new background remover module
  156241. * @param _xrSessionManager the session manager for this module
  156242. * @param options read-only options to be used in this module
  156243. */
  156244. constructor(_xrSessionManager: WebXRSessionManager,
  156245. /**
  156246. * read-only options to be used in this module
  156247. */
  156248. options?: IWebXRBackgroundRemoverOptions);
  156249. /**
  156250. * attach this feature
  156251. * Will usually be called by the features manager
  156252. *
  156253. * @returns true if successful.
  156254. */
  156255. attach(): boolean;
  156256. /**
  156257. * detach this feature.
  156258. * Will usually be called by the features manager
  156259. *
  156260. * @returns true if successful.
  156261. */
  156262. detach(): boolean;
  156263. /**
  156264. * Dispose this feature and all of the resources attached
  156265. */
  156266. dispose(): void;
  156267. protected _onXRFrame(_xrFrame: XRFrame): void;
  156268. private _setBackgroundState;
  156269. }
  156270. }
  156271. declare module BABYLON {
  156272. /**
  156273. * Options for the controller physics feature
  156274. */
  156275. export class IWebXRControllerPhysicsOptions {
  156276. /**
  156277. * Should the headset get its own impostor
  156278. */
  156279. enableHeadsetImpostor?: boolean;
  156280. /**
  156281. * Optional parameters for the headset impostor
  156282. */
  156283. headsetImpostorParams?: {
  156284. /**
  156285. * The type of impostor to create. Default is sphere
  156286. */
  156287. impostorType: number;
  156288. /**
  156289. * the size of the impostor. Defaults to 10cm
  156290. */
  156291. impostorSize?: number | {
  156292. width: number;
  156293. height: number;
  156294. depth: number;
  156295. };
  156296. /**
  156297. * Friction definitions
  156298. */
  156299. friction?: number;
  156300. /**
  156301. * Restitution
  156302. */
  156303. restitution?: number;
  156304. };
  156305. /**
  156306. * The physics properties of the future impostors
  156307. */
  156308. physicsProperties?: {
  156309. /**
  156310. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156311. * Note that this requires a physics engine that supports mesh impostors!
  156312. */
  156313. useControllerMesh?: boolean;
  156314. /**
  156315. * The type of impostor to create. Default is sphere
  156316. */
  156317. impostorType?: number;
  156318. /**
  156319. * the size of the impostor. Defaults to 10cm
  156320. */
  156321. impostorSize?: number | {
  156322. width: number;
  156323. height: number;
  156324. depth: number;
  156325. };
  156326. /**
  156327. * Friction definitions
  156328. */
  156329. friction?: number;
  156330. /**
  156331. * Restitution
  156332. */
  156333. restitution?: number;
  156334. };
  156335. /**
  156336. * the xr input to use with this pointer selection
  156337. */
  156338. xrInput: WebXRInput;
  156339. }
  156340. /**
  156341. * Add physics impostor to your webxr controllers,
  156342. * including naive calculation of their linear and angular velocity
  156343. */
  156344. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156345. private readonly _options;
  156346. private _attachController;
  156347. private _controllers;
  156348. private _debugMode;
  156349. private _delta;
  156350. private _headsetImpostor?;
  156351. private _headsetMesh?;
  156352. private _lastTimestamp;
  156353. private _tmpQuaternion;
  156354. private _tmpVector;
  156355. /**
  156356. * The module's name
  156357. */
  156358. static readonly Name: string;
  156359. /**
  156360. * The (Babylon) version of this module.
  156361. * This is an integer representing the implementation version.
  156362. * This number does not correspond to the webxr specs version
  156363. */
  156364. static readonly Version: number;
  156365. /**
  156366. * Construct a new Controller Physics Feature
  156367. * @param _xrSessionManager the corresponding xr session manager
  156368. * @param _options options to create this feature with
  156369. */
  156370. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156371. /**
  156372. * @hidden
  156373. * enable debugging - will show console outputs and the impostor mesh
  156374. */
  156375. _enablePhysicsDebug(): void;
  156376. /**
  156377. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156378. * @param xrController the controller to add
  156379. */
  156380. addController(xrController: WebXRInputSource): void;
  156381. /**
  156382. * attach this feature
  156383. * Will usually be called by the features manager
  156384. *
  156385. * @returns true if successful.
  156386. */
  156387. attach(): boolean;
  156388. /**
  156389. * detach this feature.
  156390. * Will usually be called by the features manager
  156391. *
  156392. * @returns true if successful.
  156393. */
  156394. detach(): boolean;
  156395. /**
  156396. * Get the headset impostor, if enabled
  156397. * @returns the impostor
  156398. */
  156399. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156400. /**
  156401. * Get the physics impostor of a specific controller.
  156402. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156403. * @param controller the controller or the controller id of which to get the impostor
  156404. * @returns the impostor or null
  156405. */
  156406. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156407. /**
  156408. * Update the physics properties provided in the constructor
  156409. * @param newProperties the new properties object
  156410. */
  156411. setPhysicsProperties(newProperties: {
  156412. impostorType?: number;
  156413. impostorSize?: number | {
  156414. width: number;
  156415. height: number;
  156416. depth: number;
  156417. };
  156418. friction?: number;
  156419. restitution?: number;
  156420. }): void;
  156421. protected _onXRFrame(_xrFrame: any): void;
  156422. private _detachController;
  156423. }
  156424. }
  156425. declare module BABYLON {
  156426. /**
  156427. * A babylon interface for a "WebXR" feature point.
  156428. * Represents the position and confidence value of a given feature point.
  156429. */
  156430. export interface IWebXRFeaturePoint {
  156431. /**
  156432. * Represents the position of the feature point in world space.
  156433. */
  156434. position: Vector3;
  156435. /**
  156436. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156437. */
  156438. confidenceValue: number;
  156439. }
  156440. /**
  156441. * The feature point system is used to detect feature points from real world geometry.
  156442. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156443. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156444. */
  156445. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156446. private _enabled;
  156447. private _featurePointCloud;
  156448. /**
  156449. * The module's name
  156450. */
  156451. static readonly Name: string;
  156452. /**
  156453. * The (Babylon) version of this module.
  156454. * This is an integer representing the implementation version.
  156455. * This number does not correspond to the WebXR specs version
  156456. */
  156457. static readonly Version: number;
  156458. /**
  156459. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156460. * Will notify the observers about which feature points have been added.
  156461. */
  156462. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156463. /**
  156464. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156465. * Will notify the observers about which feature points have been updated.
  156466. */
  156467. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156468. /**
  156469. * The current feature point cloud maintained across frames.
  156470. */
  156471. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156472. /**
  156473. * construct the feature point system
  156474. * @param _xrSessionManager an instance of xr Session manager
  156475. */
  156476. constructor(_xrSessionManager: WebXRSessionManager);
  156477. /**
  156478. * Detach this feature.
  156479. * Will usually be called by the features manager
  156480. *
  156481. * @returns true if successful.
  156482. */
  156483. detach(): boolean;
  156484. /**
  156485. * Dispose this feature and all of the resources attached
  156486. */
  156487. dispose(): void;
  156488. /**
  156489. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156490. */
  156491. protected _onXRFrame(frame: XRFrame): void;
  156492. /**
  156493. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156494. */
  156495. private _init;
  156496. }
  156497. }
  156498. declare module BABYLON {
  156499. /**
  156500. * Configuration interface for the hand tracking feature
  156501. */
  156502. export interface IWebXRHandTrackingOptions {
  156503. /**
  156504. * The xrInput that will be used as source for new hands
  156505. */
  156506. xrInput: WebXRInput;
  156507. /**
  156508. * Configuration object for the joint meshes
  156509. */
  156510. jointMeshes?: {
  156511. /**
  156512. * Should the meshes created be invisible (defaults to false)
  156513. */
  156514. invisible?: boolean;
  156515. /**
  156516. * A source mesh to be used to create instances. Defaults to a sphere.
  156517. * This mesh will be the source for all other (25) meshes.
  156518. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156519. */
  156520. sourceMesh?: Mesh;
  156521. /**
  156522. * This function will be called after a mesh was created for a specific joint.
  156523. * Using this function you can either manipulate the instance or return a new mesh.
  156524. * When returning a new mesh the instance created before will be disposed
  156525. */
  156526. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156527. /**
  156528. * Should the source mesh stay visible. Defaults to false
  156529. */
  156530. keepOriginalVisible?: boolean;
  156531. /**
  156532. * Scale factor for all instances (defaults to 2)
  156533. */
  156534. scaleFactor?: number;
  156535. /**
  156536. * Should each instance have its own physics impostor
  156537. */
  156538. enablePhysics?: boolean;
  156539. /**
  156540. * If enabled, override default physics properties
  156541. */
  156542. physicsProps?: {
  156543. friction?: number;
  156544. restitution?: number;
  156545. impostorType?: number;
  156546. };
  156547. /**
  156548. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156549. */
  156550. handMesh?: AbstractMesh;
  156551. };
  156552. }
  156553. /**
  156554. * Parts of the hands divided to writs and finger names
  156555. */
  156556. export const enum HandPart {
  156557. /**
  156558. * HandPart - Wrist
  156559. */
  156560. WRIST = "wrist",
  156561. /**
  156562. * HandPart - The THumb
  156563. */
  156564. THUMB = "thumb",
  156565. /**
  156566. * HandPart - Index finger
  156567. */
  156568. INDEX = "index",
  156569. /**
  156570. * HandPart - Middle finger
  156571. */
  156572. MIDDLE = "middle",
  156573. /**
  156574. * HandPart - Ring finger
  156575. */
  156576. RING = "ring",
  156577. /**
  156578. * HandPart - Little finger
  156579. */
  156580. LITTLE = "little"
  156581. }
  156582. /**
  156583. * Representing a single hand (with its corresponding native XRHand object)
  156584. */
  156585. export class WebXRHand implements IDisposable {
  156586. /** the controller to which the hand correlates */
  156587. readonly xrController: WebXRInputSource;
  156588. /** the meshes to be used to track the hand joints */
  156589. readonly trackedMeshes: AbstractMesh[];
  156590. /**
  156591. * Hand-parts definition (key is HandPart)
  156592. */
  156593. handPartsDefinition: {
  156594. [key: string]: number[];
  156595. };
  156596. /**
  156597. * Populate the HandPartsDefinition object.
  156598. * This is called as a side effect since certain browsers don't have XRHand defined.
  156599. */
  156600. private generateHandPartsDefinition;
  156601. /**
  156602. * Construct a new hand object
  156603. * @param xrController the controller to which the hand correlates
  156604. * @param trackedMeshes the meshes to be used to track the hand joints
  156605. */
  156606. constructor(
  156607. /** the controller to which the hand correlates */
  156608. xrController: WebXRInputSource,
  156609. /** the meshes to be used to track the hand joints */
  156610. trackedMeshes: AbstractMesh[]);
  156611. /**
  156612. * Update this hand from the latest xr frame
  156613. * @param xrFrame xrFrame to update from
  156614. * @param referenceSpace The current viewer reference space
  156615. * @param scaleFactor optional scale factor for the meshes
  156616. */
  156617. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156618. /**
  156619. * Get meshes of part of the hand
  156620. * @param part the part of hand to get
  156621. * @returns An array of meshes that correlate to the hand part requested
  156622. */
  156623. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156624. /**
  156625. * Dispose this Hand object
  156626. */
  156627. dispose(): void;
  156628. }
  156629. /**
  156630. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156631. */
  156632. export class WebXRHandTracking extends WebXRAbstractFeature {
  156633. /**
  156634. * options to use when constructing this feature
  156635. */
  156636. readonly options: IWebXRHandTrackingOptions;
  156637. private static _idCounter;
  156638. /**
  156639. * The module's name
  156640. */
  156641. static readonly Name: string;
  156642. /**
  156643. * The (Babylon) version of this module.
  156644. * This is an integer representing the implementation version.
  156645. * This number does not correspond to the WebXR specs version
  156646. */
  156647. static readonly Version: number;
  156648. /**
  156649. * This observable will notify registered observers when a new hand object was added and initialized
  156650. */
  156651. onHandAddedObservable: Observable<WebXRHand>;
  156652. /**
  156653. * This observable will notify its observers right before the hand object is disposed
  156654. */
  156655. onHandRemovedObservable: Observable<WebXRHand>;
  156656. private _hands;
  156657. /**
  156658. * Creates a new instance of the hit test feature
  156659. * @param _xrSessionManager an instance of WebXRSessionManager
  156660. * @param options options to use when constructing this feature
  156661. */
  156662. constructor(_xrSessionManager: WebXRSessionManager,
  156663. /**
  156664. * options to use when constructing this feature
  156665. */
  156666. options: IWebXRHandTrackingOptions);
  156667. /**
  156668. * Check if the needed objects are defined.
  156669. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156670. */
  156671. isCompatible(): boolean;
  156672. /**
  156673. * attach this feature
  156674. * Will usually be called by the features manager
  156675. *
  156676. * @returns true if successful.
  156677. */
  156678. attach(): boolean;
  156679. /**
  156680. * detach this feature.
  156681. * Will usually be called by the features manager
  156682. *
  156683. * @returns true if successful.
  156684. */
  156685. detach(): boolean;
  156686. /**
  156687. * Dispose this feature and all of the resources attached
  156688. */
  156689. dispose(): void;
  156690. /**
  156691. * Get the hand object according to the controller id
  156692. * @param controllerId the controller id to which we want to get the hand
  156693. * @returns null if not found or the WebXRHand object if found
  156694. */
  156695. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156696. /**
  156697. * Get a hand object according to the requested handedness
  156698. * @param handedness the handedness to request
  156699. * @returns null if not found or the WebXRHand object if found
  156700. */
  156701. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156702. protected _onXRFrame(_xrFrame: XRFrame): void;
  156703. private _attachHand;
  156704. private _detachHand;
  156705. }
  156706. }
  156707. declare module BABYLON {
  156708. /**
  156709. * The motion controller class for all microsoft mixed reality controllers
  156710. */
  156711. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156712. protected readonly _mapping: {
  156713. defaultButton: {
  156714. valueNodeName: string;
  156715. unpressedNodeName: string;
  156716. pressedNodeName: string;
  156717. };
  156718. defaultAxis: {
  156719. valueNodeName: string;
  156720. minNodeName: string;
  156721. maxNodeName: string;
  156722. };
  156723. buttons: {
  156724. "xr-standard-trigger": {
  156725. rootNodeName: string;
  156726. componentProperty: string;
  156727. states: string[];
  156728. };
  156729. "xr-standard-squeeze": {
  156730. rootNodeName: string;
  156731. componentProperty: string;
  156732. states: string[];
  156733. };
  156734. "xr-standard-touchpad": {
  156735. rootNodeName: string;
  156736. labelAnchorNodeName: string;
  156737. touchPointNodeName: string;
  156738. };
  156739. "xr-standard-thumbstick": {
  156740. rootNodeName: string;
  156741. componentProperty: string;
  156742. states: string[];
  156743. };
  156744. };
  156745. axes: {
  156746. "xr-standard-touchpad": {
  156747. "x-axis": {
  156748. rootNodeName: string;
  156749. };
  156750. "y-axis": {
  156751. rootNodeName: string;
  156752. };
  156753. };
  156754. "xr-standard-thumbstick": {
  156755. "x-axis": {
  156756. rootNodeName: string;
  156757. };
  156758. "y-axis": {
  156759. rootNodeName: string;
  156760. };
  156761. };
  156762. };
  156763. };
  156764. /**
  156765. * The base url used to load the left and right controller models
  156766. */
  156767. static MODEL_BASE_URL: string;
  156768. /**
  156769. * The name of the left controller model file
  156770. */
  156771. static MODEL_LEFT_FILENAME: string;
  156772. /**
  156773. * The name of the right controller model file
  156774. */
  156775. static MODEL_RIGHT_FILENAME: string;
  156776. profileId: string;
  156777. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156778. protected _getFilenameAndPath(): {
  156779. filename: string;
  156780. path: string;
  156781. };
  156782. protected _getModelLoadingConstraints(): boolean;
  156783. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156784. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156785. protected _updateModel(): void;
  156786. }
  156787. }
  156788. declare module BABYLON {
  156789. /**
  156790. * The motion controller class for oculus touch (quest, rift).
  156791. * This class supports legacy mapping as well the standard xr mapping
  156792. */
  156793. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156794. private _forceLegacyControllers;
  156795. private _modelRootNode;
  156796. /**
  156797. * The base url used to load the left and right controller models
  156798. */
  156799. static MODEL_BASE_URL: string;
  156800. /**
  156801. * The name of the left controller model file
  156802. */
  156803. static MODEL_LEFT_FILENAME: string;
  156804. /**
  156805. * The name of the right controller model file
  156806. */
  156807. static MODEL_RIGHT_FILENAME: string;
  156808. /**
  156809. * Base Url for the Quest controller model.
  156810. */
  156811. static QUEST_MODEL_BASE_URL: string;
  156812. profileId: string;
  156813. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156814. protected _getFilenameAndPath(): {
  156815. filename: string;
  156816. path: string;
  156817. };
  156818. protected _getModelLoadingConstraints(): boolean;
  156819. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156820. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156821. protected _updateModel(): void;
  156822. /**
  156823. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156824. * between the touch and touch 2.
  156825. */
  156826. private _isQuest;
  156827. }
  156828. }
  156829. declare module BABYLON {
  156830. /**
  156831. * The motion controller class for the standard HTC-Vive controllers
  156832. */
  156833. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156834. private _modelRootNode;
  156835. /**
  156836. * The base url used to load the left and right controller models
  156837. */
  156838. static MODEL_BASE_URL: string;
  156839. /**
  156840. * File name for the controller model.
  156841. */
  156842. static MODEL_FILENAME: string;
  156843. profileId: string;
  156844. /**
  156845. * Create a new Vive motion controller object
  156846. * @param scene the scene to use to create this controller
  156847. * @param gamepadObject the corresponding gamepad object
  156848. * @param handedness the handedness of the controller
  156849. */
  156850. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156851. protected _getFilenameAndPath(): {
  156852. filename: string;
  156853. path: string;
  156854. };
  156855. protected _getModelLoadingConstraints(): boolean;
  156856. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156857. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156858. protected _updateModel(): void;
  156859. }
  156860. }
  156861. declare module BABYLON {
  156862. /**
  156863. * A cursor which tracks a point on a path
  156864. */
  156865. export class PathCursor {
  156866. private path;
  156867. /**
  156868. * Stores path cursor callbacks for when an onchange event is triggered
  156869. */
  156870. private _onchange;
  156871. /**
  156872. * The value of the path cursor
  156873. */
  156874. value: number;
  156875. /**
  156876. * The animation array of the path cursor
  156877. */
  156878. animations: Animation[];
  156879. /**
  156880. * Initializes the path cursor
  156881. * @param path The path to track
  156882. */
  156883. constructor(path: Path2);
  156884. /**
  156885. * Gets the cursor point on the path
  156886. * @returns A point on the path cursor at the cursor location
  156887. */
  156888. getPoint(): Vector3;
  156889. /**
  156890. * Moves the cursor ahead by the step amount
  156891. * @param step The amount to move the cursor forward
  156892. * @returns This path cursor
  156893. */
  156894. moveAhead(step?: number): PathCursor;
  156895. /**
  156896. * Moves the cursor behind by the step amount
  156897. * @param step The amount to move the cursor back
  156898. * @returns This path cursor
  156899. */
  156900. moveBack(step?: number): PathCursor;
  156901. /**
  156902. * Moves the cursor by the step amount
  156903. * If the step amount is greater than one, an exception is thrown
  156904. * @param step The amount to move the cursor
  156905. * @returns This path cursor
  156906. */
  156907. move(step: number): PathCursor;
  156908. /**
  156909. * Ensures that the value is limited between zero and one
  156910. * @returns This path cursor
  156911. */
  156912. private ensureLimits;
  156913. /**
  156914. * Runs onchange callbacks on change (used by the animation engine)
  156915. * @returns This path cursor
  156916. */
  156917. private raiseOnChange;
  156918. /**
  156919. * Executes a function on change
  156920. * @param f A path cursor onchange callback
  156921. * @returns This path cursor
  156922. */
  156923. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156924. }
  156925. }
  156926. declare module BABYLON {
  156927. /** @hidden */
  156928. export var blurPixelShader: {
  156929. name: string;
  156930. shader: string;
  156931. };
  156932. }
  156933. declare module BABYLON {
  156934. /** @hidden */
  156935. export var pointCloudVertexDeclaration: {
  156936. name: string;
  156937. shader: string;
  156938. };
  156939. }
  156940. // Mixins
  156941. interface Window {
  156942. mozIndexedDB: IDBFactory;
  156943. webkitIndexedDB: IDBFactory;
  156944. msIndexedDB: IDBFactory;
  156945. webkitURL: typeof URL;
  156946. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156947. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156948. WebGLRenderingContext: WebGLRenderingContext;
  156949. MSGesture: MSGesture;
  156950. CANNON: any;
  156951. AudioContext: AudioContext;
  156952. webkitAudioContext: AudioContext;
  156953. PointerEvent: any;
  156954. Math: Math;
  156955. Uint8Array: Uint8ArrayConstructor;
  156956. Float32Array: Float32ArrayConstructor;
  156957. mozURL: typeof URL;
  156958. msURL: typeof URL;
  156959. VRFrameData: any; // WebVR, from specs 1.1
  156960. DracoDecoderModule: any;
  156961. setImmediate(handler: (...args: any[]) => void): number;
  156962. }
  156963. interface HTMLCanvasElement {
  156964. requestPointerLock(): void;
  156965. msRequestPointerLock?(): void;
  156966. mozRequestPointerLock?(): void;
  156967. webkitRequestPointerLock?(): void;
  156968. /** Track wether a record is in progress */
  156969. isRecording: boolean;
  156970. /** Capture Stream method defined by some browsers */
  156971. captureStream(fps?: number): MediaStream;
  156972. }
  156973. interface CanvasRenderingContext2D {
  156974. msImageSmoothingEnabled: boolean;
  156975. }
  156976. interface MouseEvent {
  156977. mozMovementX: number;
  156978. mozMovementY: number;
  156979. webkitMovementX: number;
  156980. webkitMovementY: number;
  156981. msMovementX: number;
  156982. msMovementY: number;
  156983. }
  156984. interface Navigator {
  156985. mozGetVRDevices: (any: any) => any;
  156986. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156987. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156988. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156989. webkitGetGamepads(): Gamepad[];
  156990. msGetGamepads(): Gamepad[];
  156991. webkitGamepads(): Gamepad[];
  156992. }
  156993. interface HTMLVideoElement {
  156994. mozSrcObject: any;
  156995. }
  156996. interface Math {
  156997. fround(x: number): number;
  156998. imul(a: number, b: number): number;
  156999. }
  157000. interface WebGLRenderingContext {
  157001. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157002. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157003. vertexAttribDivisor(index: number, divisor: number): void;
  157004. createVertexArray(): any;
  157005. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157006. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157007. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157008. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157009. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157010. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157011. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157012. // Queries
  157013. createQuery(): WebGLQuery;
  157014. deleteQuery(query: WebGLQuery): void;
  157015. beginQuery(target: number, query: WebGLQuery): void;
  157016. endQuery(target: number): void;
  157017. getQueryParameter(query: WebGLQuery, pname: number): any;
  157018. getQuery(target: number, pname: number): any;
  157019. MAX_SAMPLES: number;
  157020. RGBA8: number;
  157021. READ_FRAMEBUFFER: number;
  157022. DRAW_FRAMEBUFFER: number;
  157023. UNIFORM_BUFFER: number;
  157024. HALF_FLOAT_OES: number;
  157025. RGBA16F: number;
  157026. RGBA32F: number;
  157027. R32F: number;
  157028. RG32F: number;
  157029. RGB32F: number;
  157030. R16F: number;
  157031. RG16F: number;
  157032. RGB16F: number;
  157033. RED: number;
  157034. RG: number;
  157035. R8: number;
  157036. RG8: number;
  157037. UNSIGNED_INT_24_8: number;
  157038. DEPTH24_STENCIL8: number;
  157039. MIN: number;
  157040. MAX: number;
  157041. /* Multiple Render Targets */
  157042. drawBuffers(buffers: number[]): void;
  157043. readBuffer(src: number): void;
  157044. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157045. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157046. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157047. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157048. // Occlusion Query
  157049. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157050. ANY_SAMPLES_PASSED: number;
  157051. QUERY_RESULT_AVAILABLE: number;
  157052. QUERY_RESULT: number;
  157053. }
  157054. interface WebGLProgram {
  157055. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157056. }
  157057. interface EXT_disjoint_timer_query {
  157058. QUERY_COUNTER_BITS_EXT: number;
  157059. TIME_ELAPSED_EXT: number;
  157060. TIMESTAMP_EXT: number;
  157061. GPU_DISJOINT_EXT: number;
  157062. QUERY_RESULT_EXT: number;
  157063. QUERY_RESULT_AVAILABLE_EXT: number;
  157064. queryCounterEXT(query: WebGLQuery, target: number): void;
  157065. createQueryEXT(): WebGLQuery;
  157066. beginQueryEXT(target: number, query: WebGLQuery): void;
  157067. endQueryEXT(target: number): void;
  157068. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157069. deleteQueryEXT(query: WebGLQuery): void;
  157070. }
  157071. interface WebGLUniformLocation {
  157072. _currentState: any;
  157073. }
  157074. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157075. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157076. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157077. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157078. interface WebGLRenderingContext {
  157079. readonly RASTERIZER_DISCARD: number;
  157080. readonly DEPTH_COMPONENT24: number;
  157081. readonly TEXTURE_3D: number;
  157082. readonly TEXTURE_2D_ARRAY: number;
  157083. readonly TEXTURE_COMPARE_FUNC: number;
  157084. readonly TEXTURE_COMPARE_MODE: number;
  157085. readonly COMPARE_REF_TO_TEXTURE: number;
  157086. readonly TEXTURE_WRAP_R: number;
  157087. readonly HALF_FLOAT: number;
  157088. readonly RGB8: number;
  157089. readonly RED_INTEGER: number;
  157090. readonly RG_INTEGER: number;
  157091. readonly RGB_INTEGER: number;
  157092. readonly RGBA_INTEGER: number;
  157093. readonly R8_SNORM: number;
  157094. readonly RG8_SNORM: number;
  157095. readonly RGB8_SNORM: number;
  157096. readonly RGBA8_SNORM: number;
  157097. readonly R8I: number;
  157098. readonly RG8I: number;
  157099. readonly RGB8I: number;
  157100. readonly RGBA8I: number;
  157101. readonly R8UI: number;
  157102. readonly RG8UI: number;
  157103. readonly RGB8UI: number;
  157104. readonly RGBA8UI: number;
  157105. readonly R16I: number;
  157106. readonly RG16I: number;
  157107. readonly RGB16I: number;
  157108. readonly RGBA16I: number;
  157109. readonly R16UI: number;
  157110. readonly RG16UI: number;
  157111. readonly RGB16UI: number;
  157112. readonly RGBA16UI: number;
  157113. readonly R32I: number;
  157114. readonly RG32I: number;
  157115. readonly RGB32I: number;
  157116. readonly RGBA32I: number;
  157117. readonly R32UI: number;
  157118. readonly RG32UI: number;
  157119. readonly RGB32UI: number;
  157120. readonly RGBA32UI: number;
  157121. readonly RGB10_A2UI: number;
  157122. readonly R11F_G11F_B10F: number;
  157123. readonly RGB9_E5: number;
  157124. readonly RGB10_A2: number;
  157125. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157126. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157127. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157128. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157129. readonly DEPTH_COMPONENT32F: number;
  157130. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157131. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157132. 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;
  157133. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157134. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157135. readonly TRANSFORM_FEEDBACK: number;
  157136. readonly INTERLEAVED_ATTRIBS: number;
  157137. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157138. createTransformFeedback(): WebGLTransformFeedback;
  157139. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157140. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157141. beginTransformFeedback(primitiveMode: number): void;
  157142. endTransformFeedback(): void;
  157143. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157144. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157145. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157146. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157147. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157148. }
  157149. interface ImageBitmap {
  157150. readonly width: number;
  157151. readonly height: number;
  157152. close(): void;
  157153. }
  157154. interface WebGLQuery extends WebGLObject {
  157155. }
  157156. declare var WebGLQuery: {
  157157. prototype: WebGLQuery;
  157158. new(): WebGLQuery;
  157159. };
  157160. interface WebGLSampler extends WebGLObject {
  157161. }
  157162. declare var WebGLSampler: {
  157163. prototype: WebGLSampler;
  157164. new(): WebGLSampler;
  157165. };
  157166. interface WebGLSync extends WebGLObject {
  157167. }
  157168. declare var WebGLSync: {
  157169. prototype: WebGLSync;
  157170. new(): WebGLSync;
  157171. };
  157172. interface WebGLTransformFeedback extends WebGLObject {
  157173. }
  157174. declare var WebGLTransformFeedback: {
  157175. prototype: WebGLTransformFeedback;
  157176. new(): WebGLTransformFeedback;
  157177. };
  157178. interface WebGLVertexArrayObject extends WebGLObject {
  157179. }
  157180. declare var WebGLVertexArrayObject: {
  157181. prototype: WebGLVertexArrayObject;
  157182. new(): WebGLVertexArrayObject;
  157183. };
  157184. // Type definitions for WebVR API
  157185. // Project: https://w3c.github.io/webvr/
  157186. // Definitions by: six a <https://github.com/lostfictions>
  157187. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157188. interface VRDisplay extends EventTarget {
  157189. /**
  157190. * Dictionary of capabilities describing the VRDisplay.
  157191. */
  157192. readonly capabilities: VRDisplayCapabilities;
  157193. /**
  157194. * z-depth defining the far plane of the eye view frustum
  157195. * enables mapping of values in the render target depth
  157196. * attachment to scene coordinates. Initially set to 10000.0.
  157197. */
  157198. depthFar: number;
  157199. /**
  157200. * z-depth defining the near plane of the eye view frustum
  157201. * enables mapping of values in the render target depth
  157202. * attachment to scene coordinates. Initially set to 0.01.
  157203. */
  157204. depthNear: number;
  157205. /**
  157206. * An identifier for this distinct VRDisplay. Used as an
  157207. * association point in the Gamepad API.
  157208. */
  157209. readonly displayId: number;
  157210. /**
  157211. * A display name, a user-readable name identifying it.
  157212. */
  157213. readonly displayName: string;
  157214. readonly isConnected: boolean;
  157215. readonly isPresenting: boolean;
  157216. /**
  157217. * If this VRDisplay supports room-scale experiences, the optional
  157218. * stage attribute contains details on the room-scale parameters.
  157219. */
  157220. readonly stageParameters: VRStageParameters | null;
  157221. /**
  157222. * Passing the value returned by `requestAnimationFrame` to
  157223. * `cancelAnimationFrame` will unregister the callback.
  157224. * @param handle Define the hanle of the request to cancel
  157225. */
  157226. cancelAnimationFrame(handle: number): void;
  157227. /**
  157228. * Stops presenting to the VRDisplay.
  157229. * @returns a promise to know when it stopped
  157230. */
  157231. exitPresent(): Promise<void>;
  157232. /**
  157233. * Return the current VREyeParameters for the given eye.
  157234. * @param whichEye Define the eye we want the parameter for
  157235. * @returns the eye parameters
  157236. */
  157237. getEyeParameters(whichEye: string): VREyeParameters;
  157238. /**
  157239. * Populates the passed VRFrameData with the information required to render
  157240. * the current frame.
  157241. * @param frameData Define the data structure to populate
  157242. * @returns true if ok otherwise false
  157243. */
  157244. getFrameData(frameData: VRFrameData): boolean;
  157245. /**
  157246. * Get the layers currently being presented.
  157247. * @returns the list of VR layers
  157248. */
  157249. getLayers(): VRLayer[];
  157250. /**
  157251. * Return a VRPose containing the future predicted pose of the VRDisplay
  157252. * when the current frame will be presented. The value returned will not
  157253. * change until JavaScript has returned control to the browser.
  157254. *
  157255. * The VRPose will contain the position, orientation, velocity,
  157256. * and acceleration of each of these properties.
  157257. * @returns the pose object
  157258. */
  157259. getPose(): VRPose;
  157260. /**
  157261. * Return the current instantaneous pose of the VRDisplay, with no
  157262. * prediction applied.
  157263. * @returns the current instantaneous pose
  157264. */
  157265. getImmediatePose(): VRPose;
  157266. /**
  157267. * The callback passed to `requestAnimationFrame` will be called
  157268. * any time a new frame should be rendered. When the VRDisplay is
  157269. * presenting the callback will be called at the native refresh
  157270. * rate of the HMD. When not presenting this function acts
  157271. * identically to how window.requestAnimationFrame acts. Content should
  157272. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157273. * asynchronously from other displays and at differing refresh rates.
  157274. * @param callback Define the eaction to run next frame
  157275. * @returns the request handle it
  157276. */
  157277. requestAnimationFrame(callback: FrameRequestCallback): number;
  157278. /**
  157279. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157280. * Repeat calls while already presenting will update the VRLayers being displayed.
  157281. * @param layers Define the list of layer to present
  157282. * @returns a promise to know when the request has been fulfilled
  157283. */
  157284. requestPresent(layers: VRLayer[]): Promise<void>;
  157285. /**
  157286. * Reset the pose for this display, treating its current position and
  157287. * orientation as the "origin/zero" values. VRPose.position,
  157288. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157289. * updated when calling resetPose(). This should be called in only
  157290. * sitting-space experiences.
  157291. */
  157292. resetPose(): void;
  157293. /**
  157294. * The VRLayer provided to the VRDisplay will be captured and presented
  157295. * in the HMD. Calling this function has the same effect on the source
  157296. * canvas as any other operation that uses its source image, and canvases
  157297. * created without preserveDrawingBuffer set to true will be cleared.
  157298. * @param pose Define the pose to submit
  157299. */
  157300. submitFrame(pose?: VRPose): void;
  157301. }
  157302. declare var VRDisplay: {
  157303. prototype: VRDisplay;
  157304. new(): VRDisplay;
  157305. };
  157306. interface VRLayer {
  157307. leftBounds?: number[] | Float32Array | null;
  157308. rightBounds?: number[] | Float32Array | null;
  157309. source?: HTMLCanvasElement | null;
  157310. }
  157311. interface VRDisplayCapabilities {
  157312. readonly canPresent: boolean;
  157313. readonly hasExternalDisplay: boolean;
  157314. readonly hasOrientation: boolean;
  157315. readonly hasPosition: boolean;
  157316. readonly maxLayers: number;
  157317. }
  157318. interface VREyeParameters {
  157319. /** @deprecated */
  157320. readonly fieldOfView: VRFieldOfView;
  157321. readonly offset: Float32Array;
  157322. readonly renderHeight: number;
  157323. readonly renderWidth: number;
  157324. }
  157325. interface VRFieldOfView {
  157326. readonly downDegrees: number;
  157327. readonly leftDegrees: number;
  157328. readonly rightDegrees: number;
  157329. readonly upDegrees: number;
  157330. }
  157331. interface VRFrameData {
  157332. readonly leftProjectionMatrix: Float32Array;
  157333. readonly leftViewMatrix: Float32Array;
  157334. readonly pose: VRPose;
  157335. readonly rightProjectionMatrix: Float32Array;
  157336. readonly rightViewMatrix: Float32Array;
  157337. readonly timestamp: number;
  157338. }
  157339. interface VRPose {
  157340. readonly angularAcceleration: Float32Array | null;
  157341. readonly angularVelocity: Float32Array | null;
  157342. readonly linearAcceleration: Float32Array | null;
  157343. readonly linearVelocity: Float32Array | null;
  157344. readonly orientation: Float32Array | null;
  157345. readonly position: Float32Array | null;
  157346. readonly timestamp: number;
  157347. }
  157348. interface VRStageParameters {
  157349. sittingToStandingTransform?: Float32Array;
  157350. sizeX?: number;
  157351. sizeY?: number;
  157352. }
  157353. interface Navigator {
  157354. getVRDisplays(): Promise<VRDisplay[]>;
  157355. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157356. }
  157357. interface Window {
  157358. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157359. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157360. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157361. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157362. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157363. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157364. }
  157365. interface Gamepad {
  157366. readonly displayId: number;
  157367. }
  157368. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157369. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157370. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157371. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157372. type XRHandedness = "none" | "left" | "right";
  157373. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157374. type XREye = "none" | "left" | "right";
  157375. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157376. interface XRSpace extends EventTarget {}
  157377. interface XRRenderState {
  157378. depthNear?: number;
  157379. depthFar?: number;
  157380. inlineVerticalFieldOfView?: number;
  157381. baseLayer?: XRWebGLLayer;
  157382. }
  157383. interface XRInputSource {
  157384. handedness: XRHandedness;
  157385. targetRayMode: XRTargetRayMode;
  157386. targetRaySpace: XRSpace;
  157387. gripSpace: XRSpace | undefined;
  157388. gamepad: Gamepad | undefined;
  157389. profiles: Array<string>;
  157390. hand: XRHand | undefined;
  157391. }
  157392. interface XRSessionInit {
  157393. optionalFeatures?: string[];
  157394. requiredFeatures?: string[];
  157395. }
  157396. interface XRSession {
  157397. addEventListener: Function;
  157398. removeEventListener: Function;
  157399. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157400. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157401. requestAnimationFrame: Function;
  157402. end(): Promise<void>;
  157403. renderState: XRRenderState;
  157404. inputSources: Array<XRInputSource>;
  157405. // hit test
  157406. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157407. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157408. // legacy AR hit test
  157409. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157410. // legacy plane detection
  157411. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157412. }
  157413. interface XRReferenceSpace extends XRSpace {
  157414. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157415. onreset: any;
  157416. }
  157417. type XRPlaneSet = Set<XRPlane>;
  157418. type XRAnchorSet = Set<XRAnchor>;
  157419. interface XRFrame {
  157420. session: XRSession;
  157421. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157422. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157423. // AR
  157424. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157425. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157426. // Anchors
  157427. trackedAnchors?: XRAnchorSet;
  157428. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157429. // Planes
  157430. worldInformation: {
  157431. detectedPlanes?: XRPlaneSet;
  157432. };
  157433. // Hand tracking
  157434. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157435. }
  157436. interface XRViewerPose extends XRPose {
  157437. views: Array<XRView>;
  157438. }
  157439. interface XRPose {
  157440. transform: XRRigidTransform;
  157441. emulatedPosition: boolean;
  157442. }
  157443. interface XRWebGLLayerOptions {
  157444. antialias?: boolean;
  157445. depth?: boolean;
  157446. stencil?: boolean;
  157447. alpha?: boolean;
  157448. multiview?: boolean;
  157449. framebufferScaleFactor?: number;
  157450. }
  157451. declare var XRWebGLLayer: {
  157452. prototype: XRWebGLLayer;
  157453. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157454. };
  157455. interface XRWebGLLayer {
  157456. framebuffer: WebGLFramebuffer;
  157457. framebufferWidth: number;
  157458. framebufferHeight: number;
  157459. getViewport: Function;
  157460. }
  157461. declare class XRRigidTransform {
  157462. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157463. position: DOMPointReadOnly;
  157464. orientation: DOMPointReadOnly;
  157465. matrix: Float32Array;
  157466. inverse: XRRigidTransform;
  157467. }
  157468. interface XRView {
  157469. eye: XREye;
  157470. projectionMatrix: Float32Array;
  157471. transform: XRRigidTransform;
  157472. }
  157473. interface XRInputSourceChangeEvent {
  157474. session: XRSession;
  157475. removed: Array<XRInputSource>;
  157476. added: Array<XRInputSource>;
  157477. }
  157478. interface XRInputSourceEvent extends Event {
  157479. readonly frame: XRFrame;
  157480. readonly inputSource: XRInputSource;
  157481. }
  157482. // Experimental(er) features
  157483. declare class XRRay {
  157484. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157485. origin: DOMPointReadOnly;
  157486. direction: DOMPointReadOnly;
  157487. matrix: Float32Array;
  157488. }
  157489. declare enum XRHitTestTrackableType {
  157490. "point",
  157491. "plane",
  157492. "mesh",
  157493. }
  157494. interface XRHitResult {
  157495. hitMatrix: Float32Array;
  157496. }
  157497. interface XRTransientInputHitTestResult {
  157498. readonly inputSource: XRInputSource;
  157499. readonly results: Array<XRHitTestResult>;
  157500. }
  157501. interface XRHitTestResult {
  157502. getPose(baseSpace: XRSpace): XRPose | undefined;
  157503. // When anchor system is enabled
  157504. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157505. }
  157506. interface XRHitTestSource {
  157507. cancel(): void;
  157508. }
  157509. interface XRTransientInputHitTestSource {
  157510. cancel(): void;
  157511. }
  157512. interface XRHitTestOptionsInit {
  157513. space: XRSpace;
  157514. entityTypes?: Array<XRHitTestTrackableType>;
  157515. offsetRay?: XRRay;
  157516. }
  157517. interface XRTransientInputHitTestOptionsInit {
  157518. profile: string;
  157519. entityTypes?: Array<XRHitTestTrackableType>;
  157520. offsetRay?: XRRay;
  157521. }
  157522. interface XRAnchor {
  157523. anchorSpace: XRSpace;
  157524. delete(): void;
  157525. }
  157526. interface XRPlane {
  157527. orientation: "Horizontal" | "Vertical";
  157528. planeSpace: XRSpace;
  157529. polygon: Array<DOMPointReadOnly>;
  157530. lastChangedTime: number;
  157531. }
  157532. interface XRJointSpace extends XRSpace {}
  157533. interface XRJointPose extends XRPose {
  157534. radius: number | undefined;
  157535. }
  157536. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157537. readonly length: number;
  157538. [index: number]: XRJointSpace;
  157539. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157540. readonly WRIST: number;
  157541. readonly THUMB_METACARPAL: number;
  157542. readonly THUMB_PHALANX_PROXIMAL: number;
  157543. readonly THUMB_PHALANX_DISTAL: number;
  157544. readonly THUMB_PHALANX_TIP: number;
  157545. readonly INDEX_METACARPAL: number;
  157546. readonly INDEX_PHALANX_PROXIMAL: number;
  157547. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157548. readonly INDEX_PHALANX_DISTAL: number;
  157549. readonly INDEX_PHALANX_TIP: number;
  157550. readonly MIDDLE_METACARPAL: number;
  157551. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157552. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157553. readonly MIDDLE_PHALANX_DISTAL: number;
  157554. readonly MIDDLE_PHALANX_TIP: number;
  157555. readonly RING_METACARPAL: number;
  157556. readonly RING_PHALANX_PROXIMAL: number;
  157557. readonly RING_PHALANX_INTERMEDIATE: number;
  157558. readonly RING_PHALANX_DISTAL: number;
  157559. readonly RING_PHALANX_TIP: number;
  157560. readonly LITTLE_METACARPAL: number;
  157561. readonly LITTLE_PHALANX_PROXIMAL: number;
  157562. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157563. readonly LITTLE_PHALANX_DISTAL: number;
  157564. readonly LITTLE_PHALANX_TIP: number;
  157565. }
  157566. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157567. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157568. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157569. interface XRSession {
  157570. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157571. }
  157572. interface XRFrame {
  157573. featurePointCloud? : Array<number>;
  157574. }